diff --git a/flake.nix b/flake.nix index 9b8c8f8..70b6a66 100755 --- a/flake.nix +++ b/flake.nix @@ -146,6 +146,25 @@ ]; }; + vps = nixpkgs.lib.nixosSystem { + specialArgs = {inherit inputs outputs username;}; + modules = [ + ./hosts/vps + + home-manager.nixosModules.home-manager + { + home-manager.backupFileExtension = "backup"; + home-manager.useUserPackages = true; + home-manager.extraSpecialArgs = {inherit inputs outputs username;}; + home-manager.users.${username} = { + imports = [ + ./hosts/vps/home.nix + ]; + }; + } + ]; + }; + isoImage = nixpkgs.lib.nixosSystem { specialArgs = {inherit inputs outputs username;}; modules = [ diff --git a/hosts/vps/default.nix b/hosts/vps/default.nix new file mode 100644 index 0000000..fc9fe06 --- /dev/null +++ b/hosts/vps/default.nix @@ -0,0 +1,118 @@ +{ + modulesPath, + inputs, + outputs, + pkgs, + username, + ... +}: { + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + (modulesPath + "/profiles/qemu-guest.nix") + inputs.disko.nixosModules.default + (import ./disko.nix {device = "/dev/sda";}) + ]; + + nixpkgs = { + hostPlatform = "x86_64-linux"; + + overlays = [ + outputs.overlays.additions + outputs.overlays.modifications + outputs.overlays.unstable-packages + outputs.overlays.nur + ]; + + config = { + allowUnfree = true; + joypixels.acceptLicense = true; + }; + }; + + nix = { + package = pkgs.lix; + settings = { + experimental-features = "nix-command flakes"; + auto-optimise-store = true; + trusted-users = ["${username}"]; + warn-dirty = false; + substituters = [ + "https://cache.nixos.org?priority=10" + "https://anyrun.cachix.org" + "https://fufexan.cachix.org" + "https://helix.cachix.org" + "https://hyprland.cachix.org" + "https://nix-community.cachix.org" + "https://nix-gaming.cachix.org" + "https://yazi.cachix.org" + ]; + trusted-public-keys = [ + "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" + "anyrun.cachix.org-1:pqBobmOjI7nKlsUMV25u9QHa9btJK65/C8vnO3p346s=" + "fufexan.cachix.org-1:LwCDjCJNJQf5XD2BV+yamQIMZfcKWR9ISIFy5curUsY=" + "helix.cachix.org-1:ejp9KQpR1FBI2onstMQ34yogDm4OgU2ru6lIwPvuCVs=" + "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + "nix-gaming.cachix.org-1:nbjlureqMbRAxR1gJ/f3hxemL9svXaZF/Ees8vCUUs4=" + "yazi.cachix.org-1:Dcdz63NZKfvUCbDGngQDAZq6kOroIrFoyO064uvLh8k=" + ]; + }; + }; + + boot.loader.grub = { + efiSupport = true; + efiInstallAsRemovable = true; + }; + + networking.hostName = "vps"; + + time.timeZone = "Asia/Kolkata"; + i18n = { + defaultLocale = "en_US.UTF-8"; + extraLocaleSettings = { + LC_ADDRESS = "en_IN"; + LC_IDENTIFICATION = "en_IN"; + LC_MEASUREMENT = "en_IN"; + LC_MONETARY = "en_IN"; + LC_NAME = "en_IN"; + LC_NUMERIC = "en_IN"; + LC_PAPER = "en_IN"; + LC_TELEPHONE = "en_IN"; + LC_TIME = "en_IN"; + }; + }; + + programs = { + zsh.enable = true; + nh = { + enable = true; + clean.enable = true; + clean.extraArgs = "--keep-since 5d --keep 5"; + flake = "/home/${username}/Projects/nixos-config"; + }; + }; + + services = { + openssh = { + enable = true; + settings = { + PasswordAuthentication = false; + }; + }; + }; + + users = { + mutableUsers = false; + defaultUserShell = pkgs.zsh; + users.${username} = { + password = "${username}"; + isNormalUser = true; + extraGroups = ["networkmanager" "wheel" "storage"]; + openssh.authorizedKeys.keys = [ + ''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIL+OzPUe2ECPC929DqpkM39tl/vdNAXfsRnmrGfR+X3D 0xtux@pm.me'' + ]; + }; + }; + + system.stateVersion = "24.11"; +} diff --git a/hosts/vps/disko.nix b/hosts/vps/disko.nix new file mode 100644 index 0000000..ebd5c1a --- /dev/null +++ b/hosts/vps/disko.nix @@ -0,0 +1,54 @@ +{device ? throw "Set this to the disk device, e.g. /dev/nvme0n1", ...}: { + disko.devices = { + disk.primary = { + inherit device; + type = "disk"; + content = { + type = "gpt"; + partitions = { + boot = { + name = "boot"; + size = "1M"; + type = "EF02"; + }; + esp = { + name = "ESP"; + size = "500M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + }; + }; + root = { + name = "root"; + size = "100%"; + content = { + type = "lvm_pv"; + vg = "pool"; + }; + }; + }; + }; + }; + lvm_vg = { + pool = { + type = "lvm_vg"; + lvs = { + root = { + size = "100%FREE"; + content = { + type = "filesystem"; + format = "ext4"; + mountpoint = "/"; + mountOptions = [ + "defaults" + ]; + }; + }; + }; + }; + }; + }; +} diff --git a/hosts/vps/home.nix b/hosts/vps/home.nix new file mode 100644 index 0000000..bbac4a5 --- /dev/null +++ b/hosts/vps/home.nix @@ -0,0 +1,7 @@ +{...}: { + imports = [ + ../common/home.nix + ]; + + home.stateVersion = "24.11"; +}