diff --git a/flake.nix b/flake.nix index fc18dd0..fbe1b76 100644 --- a/flake.nix +++ b/flake.nix @@ -10,16 +10,15 @@ }; outputs = { self, nixpkgs, ... }@attrs: let - user = import ./username.nix; + user = "user"; # Select user from `./users` directory in { # Debugging VM configuration nixosConfigurations.qemu-vm = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; + specialArgs = attrs; modules = [ ./users/${user}.nix - ./common.nix ./systems/qemu-vm.nix - ./systems/hardware/qemu-vm.nix ]; }; }; diff --git a/sets/meta/sysadmin.nix b/sets/meta/sysadmin.nix index 426ec2d..c9eaddd 100644 --- a/sets/meta/sysadmin.nix +++ b/sets/meta/sysadmin.nix @@ -1,10 +1,11 @@ -{ config, pkgs, ... }: +{ pkgs, ... }: { environment.systemPackages = with pkgs; [ htop wget curl + git ]; services.openssh.enable = true; diff --git a/common.nix b/systems/common.nix similarity index 94% rename from common.nix rename to systems/common.nix index 36f9179..f695755 100644 --- a/common.nix +++ b/systems/common.nix @@ -1,6 +1,6 @@ # Common configuration for all systems -{ config, pkgs, ... }: +{ ... }: { nix = { diff --git a/systems/hardware/qemu-vm.nix b/systems/hardware/qemu-vm.nix index 16ef2fe..a1ec463 100644 --- a/systems/hardware/qemu-vm.nix +++ b/systems/hardware/qemu-vm.nix @@ -1,53 +1,36 @@ -# Do not modify this file! It was generated by ‘nixos-generate-config’ -# and may be overwritten by future invocations. Please make changes -# to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: +{lib, modulesPath, ... }: { - imports = - [ (modulesPath + "/profiles/qemu-guest.nix") - ]; + imports = [ + (modulesPath + "/profiles/qemu-guest.nix") + ]; boot.initrd.availableKernelModules = [ "ahci" "xhci_pci" "virtio_pci" "sr_mod" "virtio_blk" ]; boot.initrd.kernelModules = [ ]; + + boot.initrd.postDeviceCommands = lib.mkAfter '' + zfs rollback -r local/root@blank + ''; + boot.kernelModules = [ "kvm-amd" ]; boot.extraModulePackages = [ ]; - fileSystems."/" = - { device = "/dev/disk/by-uuid/cba5b18e-14e6-479d-baf5-0827fced96e7"; - fsType = "btrfs"; - options = [ "subvol=root" ]; - }; + boot.zfs.devNodes = "/dev/disk/by-path"; - fileSystems."/home" = - { device = "/dev/disk/by-uuid/cba5b18e-14e6-479d-baf5-0827fced96e7"; - fsType = "btrfs"; - options = [ "subvol=home" ]; - }; + fileSystems."/" = { + device = "local/root"; + fsType = "zfs"; + }; - fileSystems."/nix" = - { device = "/dev/disk/by-uuid/cba5b18e-14e6-479d-baf5-0827fced96e7"; - fsType = "btrfs"; - options = [ "subvol=nix" ]; - }; - - fileSystems."/persist" = - { device = "/dev/disk/by-uuid/cba5b18e-14e6-479d-baf5-0827fced96e7"; - fsType = "btrfs"; - options = [ "subvol=persist" ]; - }; - - fileSystems."/var/log" = - { device = "/dev/disk/by-uuid/cba5b18e-14e6-479d-baf5-0827fced96e7"; - fsType = "btrfs"; - options = [ "subvol=log" ]; - neededForBoot = true; - }; - - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/5725-D092"; + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/1FD8-C4B8"; fsType = "vfat"; - }; + }; + + fileSystems."/nix" = { + device = "local/nix"; + fsType = "zfs"; + }; swapDevices = [ ]; diff --git a/systems/persist/.common.nix.un~ b/systems/persist/.common.nix.un~ new file mode 100644 index 0000000..c4f888e Binary files /dev/null and b/systems/persist/.common.nix.un~ differ diff --git a/systems/persist/common.nix b/systems/persist/common.nix new file mode 100644 index 0000000..62d5674 --- /dev/null +++ b/systems/persist/common.nix @@ -0,0 +1,19 @@ +{ impermanence, ... }: + +{ + imports = [ + impermanence.nixosModules.impermanence + ]; + + environment.persistence."/nix/persist/common" = { + directories = [ + "/etc/ssh" + "/var/lib" + ]; + + files = [ + "/etc/machine-id" + "/etc/shadow" + ]; + }; +} diff --git a/systems/persist/qemu-vm.nix b/systems/persist/qemu-vm.nix new file mode 100644 index 0000000..27f4abc --- /dev/null +++ b/systems/persist/qemu-vm.nix @@ -0,0 +1,7 @@ +{ ... }: + +{ + imports = [ + ./common.nix + ]; +} diff --git a/systems/qemu-vm.nix b/systems/qemu-vm.nix index 5fa99da..13ba35d 100644 --- a/systems/qemu-vm.nix +++ b/systems/qemu-vm.nix @@ -1,13 +1,18 @@ -{ config, pkgs, ... }: +{ ... }: { imports = [ + ./hardware/qemu-vm.nix ../sets/meta/sysadmin.nix ../packages/vim/package.nix + ./common.nix + ./persist/qemu-vm.nix ]; boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/vda"; + networking.hostId = "e78229f8"; + time.timeZone = "Europe/Berlin"; } diff --git a/username.nix b/username.nix deleted file mode 100644 index 718f367..0000000 --- a/username.nix +++ /dev/null @@ -1,2 +0,0 @@ -# Select the user from the ./users directory -"user"