diff --git a/flake.nix b/flake.nix index 4c5aad3..a7b5a3c 100644 --- a/flake.nix +++ b/flake.nix @@ -72,21 +72,21 @@ }; }; in { - # nixos-rebuild switch --flake .#hostname + # nixos-rebuild switch --flake /etc/nixos#hostname nixosConfigurations = { firefly = mkNix [ ./hosts/firefly ]; # Main Desktop - detritus = mkNix [ ./hosts/detritus/system ]; # Acer Desktop + detritus = mkNix [ ./hosts/detritus ]; # Acer Desktop - shuttle = mkNix [ ./hosts/shuttleworth/system ]; # Pinebook Pro - lacros = mkNix [ ./hosts/lacros/system ]; # Dell Chromebook + shuttle = mkNix [ ./hosts/shuttleworth ]; # Pinebook Pro + lacros = mkNix [ ./hosts/lacros ]; # Dell Chromebook redmond = mkNix [ ./hosts/redmond ]; # Lenovo Dual-Boot Laptop - treefruit = mkNix [ ./hosts/treefruit/system ]; # Macbook Pro 14,1 + treefruit = mkNix [ ./hosts/treefruit ]; # Macbook Pro 14,1 - cyberspark = mkNix [ ./hosts/cyberspark/system ]; # Dell Optiplex 7010 - bomberman = mkNix [ ./hosts/bomberman/system ]; # Oracle ARM + cyberspark = mkNix [ ./hosts/cyberspark ]; # Dell Optiplex 7010 + bomberman = mkNix [ ./hosts/bomberman ]; # Oracle ARM }; - # home-manager switch --flake .#username + # home-manager switch --flake /etc/nixos#username homeConfigurations."jimbo" = mkHome [ ./modules/home ] nixpkgs.legacyPackages.x86_64-linux; }; } diff --git a/hosts/bomberman/boot/default.nix b/hosts/bomberman/boot/default.nix new file mode 100644 index 0000000..d989cc0 --- /dev/null +++ b/hosts/bomberman/boot/default.nix @@ -0,0 +1,37 @@ +{ pkgs, ... }: +{ + boot = { + initrd = { + systemd = { + enable = true; + services.root-reset = { + description = "Reset root and snapshot last boot"; + wantedBy = [ "initrd.target" ]; + after = [ "dev-${config.networking.hostName}-root.device" ]; + before = [ "sysroot.mount" ]; + unitConfig.DefaultDependencies = "no"; + serviceConfig.Type = "oneshot"; + script = '' + mkdir -p /mnt + mount /dev/${config.networking.hostName}/root /mnt + + if [[ -e /mnt/prev ]]; then + btrfs subvolume delete /mnt/prev + fi + + btrfs subvolume snapshot /mnt/root /mnt/prev + + btrfs subvolume list -o /mnt/root | cut -f9 -d' ' | while read subvolume; do + btrfs subvolume delete "/mnt/$subvolume" + done + + btrfs subvolume delete /mnt/root + btrfs subvolume create /mnt/root + + umount /mnt + ''; + }; + }; + }; + }; +} diff --git a/hosts/bomberman/system/default.nix b/hosts/bomberman/default.nix similarity index 100% rename from hosts/bomberman/system/default.nix rename to hosts/bomberman/default.nix diff --git a/hosts/bomberman/disko/default.nix b/hosts/bomberman/disko/default.nix new file mode 100644 index 0000000..ceed70d --- /dev/null +++ b/hosts/bomberman/disko/default.nix @@ -0,0 +1,96 @@ +{ disko, config, ... }: +{ + imports = [ disko.nixosModules.disko ]; + + disko.devices = { + disk = { + "${config.networking.hostName}" = { + type = "disk"; + device = "/dev/nvme0n1"; + content = { + type = "gpt"; + partitions = { + ESP = { + size = "2G"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "umask=0077" ]; + }; + }; + luks = { + size = "100%"; + content = { + type = "luks"; + name = "${config.networking.hostName}-disk"; + settings.allowDiscards = true; + passwordFile = "/tmp/secret.key"; + content = { + type = "lvm_pv"; + vg = "${config.networking.hostName}"; + }; + }; + }; + }; + }; + }; + }; + + lvm_vg = { + "${config.networking.hostName}" = { + type = "lvm_vg"; + lvs = { + root = { + size = "100%"; + content = { + type = "btrfs"; + extraArgs = [ "-f" ]; + subvolumes = { + "/root" = { + mountpoint = "/"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/prev" = { + mountpoint = "/prev"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/nix" = { + mountpoint = "/nix"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + + # Impermanence + "/persist" = { + mountpoint = "/persist"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/persist/.snapshots" = { }; + + "/jimbo" = { + mountpoint = "/persist/home/jimbo"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/jimbo/.snapshots" = { }; + }; + }; + }; + swap = { + size = "8G"; + content = { + type = "swap"; + discardPolicy = "both"; + }; + }; + }; + }; + }; + }; + + # Needed for impermanence + fileSystems = { + "/persist".neededForBoot = true; + "/persist/home/jimbo".neededForBoot = true; + }; +} diff --git a/hosts/bomberman/system/hardware/default.nix b/hosts/bomberman/hardware/default.nix similarity index 100% rename from hosts/bomberman/system/hardware/default.nix rename to hosts/bomberman/hardware/default.nix diff --git a/hosts/bomberman/home/default.nix b/hosts/bomberman/home/default.nix deleted file mode 100644 index 179fe6b..0000000 --- a/hosts/bomberman/home/default.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ ... }: -{ - imports = [ - ../../../modules/home/users - ../../../modules/home/programs/misc/headless - ../../../modules/home/programs/terminal/fastfetch - ../../../modules/home/programs/terminal/git - ../../../modules/home/programs/terminal/neovim - ../../../modules/home/programs/terminal/ranger - ../../../modules/home/programs/terminal/tmux - ../../../modules/home/programs/terminal/zsh - ../../../variables/domains - ]; -} diff --git a/hosts/detritus/boot/default.nix b/hosts/detritus/boot/default.nix new file mode 100644 index 0000000..cc98a84 --- /dev/null +++ b/hosts/detritus/boot/default.nix @@ -0,0 +1,7 @@ +{ pkgs, ... }: +{ + boot = { + kernelPackages = pkgs.linuxPackages_latest; + kernel.sysctl."vm.max_map_count" = 2147483642; + }; +} diff --git a/hosts/detritus/default.nix b/hosts/detritus/default.nix new file mode 100644 index 0000000..97e2881 --- /dev/null +++ b/hosts/detritus/default.nix @@ -0,0 +1,14 @@ +{ ... }: +{ + imports = [ + ./boot + ./disko + ./hardware + ../../modules/system + ]; + + system.lanzaboote.enable = true; + system.wireguard.client.enable = false; + + networking.hostName = "detritus"; +} diff --git a/hosts/detritus/disko/default.nix b/hosts/detritus/disko/default.nix new file mode 100644 index 0000000..b88d6d6 --- /dev/null +++ b/hosts/detritus/disko/default.nix @@ -0,0 +1,96 @@ +{ disko, config, ... }: +{ + imports = [ disko.nixosModules.disko ]; + + disko.devices = { + disk = { + "${config.networking.hostName}" = { + type = "disk"; + device = "/dev/sda"; + content = { + type = "gpt"; + partitions = { + ESP = { + size = "2G"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "umask=0077" ]; + }; + }; + luks = { + size = "100%"; + content = { + type = "luks"; + name = "${config.networking.hostName}-disk"; + settings.allowDiscards = true; + passwordFile = "/tmp/secret.key"; + content = { + type = "lvm_pv"; + vg = "${config.networking.hostName}"; + }; + }; + }; + }; + }; + }; + }; + + lvm_vg = { + "${config.networking.hostName}" = { + type = "lvm_vg"; + lvs = { + root = { + size = "100%"; + content = { + type = "btrfs"; + extraArgs = [ "-f" ]; + subvolumes = { + "/root" = { + mountpoint = "/"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/prev" = { + mountpoint = "/prev"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/nix" = { + mountpoint = "/nix"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + + # Impermanence + "/persist" = { + mountpoint = "/persist"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/persist/.snapshots" = { }; + + "/jimbo" = { + mountpoint = "/persist/home/jimbo"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/jimbo/.snapshots" = { }; + }; + }; + }; + swap = { + size = "8G"; + content = { + type = "swap"; + discardPolicy = "both"; + }; + }; + }; + }; + }; + }; + + # Needed for impermanence + fileSystems = { + "/persist".neededForBoot = true; + "/persist/home/jimbo".neededForBoot = true; + }; +} diff --git a/hosts/detritus/hardware/default.nix b/hosts/detritus/hardware/default.nix new file mode 100644 index 0000000..91995b9 --- /dev/null +++ b/hosts/detritus/hardware/default.nix @@ -0,0 +1,14 @@ +{ config, lib, pkgs, modulesPath, ... }: +{ + boot = { + kernelModules = [ "kvm-intel" ]; + initrd = { + availableKernelModules = [ "ehci_pci" "ata_piix" "usbhid" "usb_storage" "sd_mod" "sr_mod" ]; + kernelModules = [ "dm-snapshot" ]; + }; + }; + + networking.useDHCP = lib.mkDefault true; + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/detritus/home/default.nix b/hosts/detritus/home/default.nix deleted file mode 100644 index 6a0e5c5..0000000 --- a/hosts/detritus/home/default.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ ... }: -{ - imports = [ - ../../../modules/home - ../../../modules/home/programs/misc/gaming/launchers - ]; -} diff --git a/hosts/detritus/system/boot/default.nix b/hosts/detritus/system/boot/default.nix deleted file mode 100644 index f895e04..0000000 --- a/hosts/detritus/system/boot/default.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ pkgs, ... }: -{ - boot = { - kernelPackages = pkgs.linuxPackages_latest; - kernel.sysctl."vm.max_map_count" = 2147483642; - initrd = { - systemd.enable = true; - luks.devices = { - crypt-hhd = { - device = "/dev/disk/by-uuid/0ab46868-3c54-4a19-bf30-93855eac0a86"; - preLVM = true; - allowDiscards = true; - }; - }; - }; - }; -} diff --git a/hosts/detritus/system/default.nix b/hosts/detritus/system/default.nix deleted file mode 100644 index f5cad98..0000000 --- a/hosts/detritus/system/default.nix +++ /dev/null @@ -1,26 +0,0 @@ -{ ... }: -{ - imports = [ - ./hardware - ./boot - - # Apps and programs - ../../../modules/system - ../../../modules/system/accounts - ../../../modules/system/desktop - ../../../modules/system/programs - ../../../modules/system/services - - # Devices and hardware - ../../../modules/system/devices - ../../../modules/system/devices/boot/systemd - ../../../modules/system/devices/networking/wireless - ../../../modules/system/devices/networking/firewall/pc - - # Extras - ../../../overlays - ../../../variables - ]; - - networking.hostName = "detritus"; -} diff --git a/hosts/detritus/system/hardware/default.nix b/hosts/detritus/system/hardware/default.nix deleted file mode 100644 index 991ee2b..0000000 --- a/hosts/detritus/system/hardware/default.nix +++ /dev/null @@ -1,46 +0,0 @@ -{ config, lib, pkgs, modulesPath, ... }: -{ - boot = { - kernelModules = [ "kvm-intel" ]; - initrd = { - availableKernelModules = [ "ehci_pci" "ata_piix" "usbhid" "usb_storage" "sd_mod" "sr_mod" ]; - kernelModules = [ "dm-snapshot" ]; - }; - }; - - fileSystems = { - "/" = { - device = "/dev/disk/by-uuid/dc6e2cd9-040b-4104-8138-5dfa9cb5558c"; - fsType = "btrfs"; - options = [ "subvol=@" ]; - }; - "/home" = { - device = "/dev/disk/by-uuid/dc6e2cd9-040b-4104-8138-5dfa9cb5558c"; - fsType = "btrfs"; - options = [ "subvol=@home" ]; - }; - "/nix" = { - device = "/dev/disk/by-uuid/dc6e2cd9-040b-4104-8138-5dfa9cb5558c"; - fsType = "btrfs"; - options = [ "subvol=@nix" ]; - }; - "/snapshots" = { - device = "/dev/disk/by-uuid/dc6e2cd9-040b-4104-8138-5dfa9cb5558c"; - fsType = "btrfs"; - options = [ "subvol=@snapshots" ]; - }; - "/boot" = { - device = "/dev/disk/by-uuid/C93C-885E"; - fsType = "vfat"; - options = [ "fmask=0022" "dmask=0022" ]; - }; - }; - - swapDevices = [ - { device = "/dev/disk/by-uuid/efbfa333-3971-477c-a0c3-3250a66993a0"; } - ]; - - networking.useDHCP = lib.mkDefault true; - nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; -} diff --git a/hosts/firefly/boot/default.nix b/hosts/firefly/boot/default.nix index 2aa9bea..5aef54f 100644 --- a/hosts/firefly/boot/default.nix +++ b/hosts/firefly/boot/default.nix @@ -21,48 +21,44 @@ in { boot = { # Must be unstable for newest NVIDIA drivers kernelPackages = pkgs.unstable.linuxPackages_latest; - blacklistedKernelModules = [ "pcspkr" ]; kernel.sysctl."vm.max_map_count" = 2147483642; kernelParams = commonKernelParams ++ [ "vfio-pci.ids=10de:1f82,10de:10fa" ]; + blacklistedKernelModules = [ "pcspkr" ]; - initrd = { - systemd = { - enable = true; - services.root-reset = { - description = "Reset root and snapshot last boot"; - wantedBy = [ "initrd.target" ]; - after = [ "dev-${config.networking.hostName}-root.device" ]; - before = [ "sysroot.mount" ]; - unitConfig.DefaultDependencies = "no"; - serviceConfig.Type = "oneshot"; - script = '' - mkdir -p /mnt - mount /dev/${config.networking.hostName}/root /mnt + initrd.systemd = { + enable = true; + services.root-reset = { + description = "Reset root and snapshot last boot"; + wantedBy = [ "initrd.target" ]; + after = [ "dev-${config.networking.hostName}-root.device" ]; + before = [ "sysroot.mount" ]; + unitConfig.DefaultDependencies = "no"; + serviceConfig.Type = "oneshot"; + script = '' + mkdir -p /mnt + mount /dev/${config.networking.hostName}/root /mnt - if [[ -e /mnt/prev ]]; then - btrfs subvolume delete /mnt/prev - fi + if [[ -e /mnt/prev ]]; then + btrfs subvolume delete /mnt/prev + fi - btrfs subvolume snapshot /mnt/root /mnt/prev + btrfs subvolume snapshot /mnt/root /mnt/prev - btrfs subvolume list -o /mnt/root | cut -f9 -d' ' | while read subvolume; do - btrfs subvolume delete "/mnt/$subvolume" - done + btrfs subvolume list -o /mnt/root | cut -f9 -d' ' | while read subvolume; do + btrfs subvolume delete "/mnt/$subvolume" + done - btrfs subvolume delete /mnt/root - btrfs subvolume create /mnt/root + btrfs subvolume delete /mnt/root + btrfs subvolume create /mnt/root - umount /mnt - ''; - }; + umount /mnt + ''; }; }; }; # Additional entry to boot from the second GPU - specialisation = { - gputwo.configuration = { - boot.kernelParams = commonKernelParams ++ [ "vfio-pci.ids=10de:2504,10de:228e" ]; - }; + specialisation.gputwo.configuration = { + boot.kernelParams = commonKernelParams ++ [ "vfio-pci.ids=10de:2504,10de:228e" ]; }; } diff --git a/hosts/firefly/disko/default.nix b/hosts/firefly/disko/default.nix index e52c45d..ceed70d 100644 --- a/hosts/firefly/disko/default.nix +++ b/hosts/firefly/disko/default.nix @@ -17,14 +17,14 @@ type = "filesystem"; format = "vfat"; mountpoint = "/boot"; - mountOptions = [ "fmask=0022" "dmask=0022" ]; + mountOptions = [ "umask=0077" ]; }; }; luks = { size = "100%"; content = { type = "luks"; - name = "crypt-nvme"; + name = "${config.networking.hostName}-disk"; settings.allowDiscards = true; passwordFile = "/tmp/secret.key"; content = { diff --git a/hosts/lacros/boot/default.nix b/hosts/lacros/boot/default.nix new file mode 100644 index 0000000..a838a6a --- /dev/null +++ b/hosts/lacros/boot/default.nix @@ -0,0 +1,39 @@ +{ pkgs, ... }: +{ + boot = { + kernelPackages = pkgs.linuxPackages_latest; + kernel.sysctl."vm.max_map_count" = 2147483642; + initrd = { + systemd = { + enable = true; + services.root-reset = { + description = "Reset root and snapshot last boot"; + wantedBy = [ "initrd.target" ]; + after = [ "dev-${config.networking.hostName}-root.device" ]; + before = [ "sysroot.mount" ]; + unitConfig.DefaultDependencies = "no"; + serviceConfig.Type = "oneshot"; + script = '' + mkdir -p /mnt + mount /dev/${config.networking.hostName}/root /mnt + + if [[ -e /mnt/prev ]]; then + btrfs subvolume delete /mnt/prev + fi + + btrfs subvolume snapshot /mnt/root /mnt/prev + + btrfs subvolume list -o /mnt/root | cut -f9 -d' ' | while read subvolume; do + btrfs subvolume delete "/mnt/$subvolume" + done + + btrfs subvolume delete /mnt/root + btrfs subvolume create /mnt/root + + umount /mnt + ''; + }; + }; + }; + }; +} diff --git a/hosts/lacros/system/default.nix b/hosts/lacros/default.nix similarity index 100% rename from hosts/lacros/system/default.nix rename to hosts/lacros/default.nix diff --git a/hosts/lacros/disko/default.nix b/hosts/lacros/disko/default.nix new file mode 100644 index 0000000..e52c45d --- /dev/null +++ b/hosts/lacros/disko/default.nix @@ -0,0 +1,96 @@ +{ disko, config, ... }: +{ + imports = [ disko.nixosModules.disko ]; + + disko.devices = { + disk = { + "${config.networking.hostName}" = { + type = "disk"; + device = "/dev/nvme0n1"; + content = { + type = "gpt"; + partitions = { + ESP = { + size = "2G"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ "fmask=0022" "dmask=0022" ]; + }; + }; + luks = { + size = "100%"; + content = { + type = "luks"; + name = "crypt-nvme"; + settings.allowDiscards = true; + passwordFile = "/tmp/secret.key"; + content = { + type = "lvm_pv"; + vg = "${config.networking.hostName}"; + }; + }; + }; + }; + }; + }; + }; + + lvm_vg = { + "${config.networking.hostName}" = { + type = "lvm_vg"; + lvs = { + root = { + size = "100%"; + content = { + type = "btrfs"; + extraArgs = [ "-f" ]; + subvolumes = { + "/root" = { + mountpoint = "/"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/prev" = { + mountpoint = "/prev"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/nix" = { + mountpoint = "/nix"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + + # Impermanence + "/persist" = { + mountpoint = "/persist"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/persist/.snapshots" = { }; + + "/jimbo" = { + mountpoint = "/persist/home/jimbo"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/jimbo/.snapshots" = { }; + }; + }; + }; + swap = { + size = "8G"; + content = { + type = "swap"; + discardPolicy = "both"; + }; + }; + }; + }; + }; + }; + + # Needed for impermanence + fileSystems = { + "/persist".neededForBoot = true; + "/persist/home/jimbo".neededForBoot = true; + }; +} diff --git a/hosts/lacros/hardware/default.nix b/hosts/lacros/hardware/default.nix new file mode 100644 index 0000000..08182c5 --- /dev/null +++ b/hosts/lacros/hardware/default.nix @@ -0,0 +1,24 @@ +{ config, lib, modulesPath, ... }: + +{ + boot = { + kernelModules = [ "kvm-intel" ]; + initrd = { + availableKernelModules = [ "xhci_pci" "sdhci_pci" ]; + kernelModules = [ "dm-snapshot" ]; + }; + }; + + fileSystems = { + # Remote + "/home/jimbo/JimboNFS" = { + device = "${config.ips.wgSpan}.1:/export/JimboNFS"; + fsType = "nfs4"; + options = [ "x-systemd.automount" "_netdev" "nofail" "noauto" ]; + }; + }; + + networking.useDHCP = lib.mkDefault true; + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/lacros/home/default.nix b/hosts/lacros/home/default.nix deleted file mode 100644 index 7e85b70..0000000 --- a/hosts/lacros/home/default.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ ... }: -{ - imports = [ - ../../../modules/home - ../../../modules/home/programs/misc/remote-desktop - ]; -} diff --git a/hosts/lacros/system/boot/default.nix b/hosts/lacros/system/boot/default.nix deleted file mode 100644 index 4b60e8a..0000000 --- a/hosts/lacros/system/boot/default.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ pkgs, ... }: -{ - boot = { - kernelPackages = pkgs.linuxPackages_latest; - kernel.sysctl."vm.max_map_count" = 2147483642; - initrd = { - systemd.enable = true; - luks.devices = { - crypt-mmc = { - device = "/dev/disk/by-uuid/5906e176-7ad3-41e5-bc45-ae65664eb10c"; - preLVM = true; - allowDiscards = true; - }; - }; - }; - }; -} diff --git a/hosts/lacros/system/hardware/default.nix b/hosts/lacros/system/hardware/default.nix deleted file mode 100644 index 4693d78..0000000 --- a/hosts/lacros/system/hardware/default.nix +++ /dev/null @@ -1,59 +0,0 @@ -{ config, lib, modulesPath, ... }: - -{ - boot = { - kernelModules = [ "kvm-intel" ]; - initrd = { - availableKernelModules = [ "xhci_pci" "sdhci_pci" ]; - kernelModules = [ "dm-snapshot" ]; - }; - }; - - fileSystems = { - "/" = { - device = "/dev/disk/by-uuid/e8c9c5a8-4df0-4100-8de6-f08a1a774fad"; - fsType = "btrfs"; - options = [ "subvol=@" "noatime" "nodiratime" "discard" ]; - }; - "/nix" = { - device = "/dev/disk/by-uuid/e8c9c5a8-4df0-4100-8de6-f08a1a774fad"; - fsType = "btrfs"; - options = [ "subvol=@nix" "noatime" "nodiratime" "discard" ]; - }; - "/var" = { - device = "/dev/disk/by-uuid/e8c9c5a8-4df0-4100-8de6-f08a1a774fad"; - fsType = "btrfs"; - options = [ "subvol=@var" "noatime" "nodiratime" "discard" ]; - }; - "/snapshots" = { - device = "/dev/disk/by-uuid/e8c9c5a8-4df0-4100-8de6-f08a1a774fad"; - fsType = "btrfs"; - options = [ "subvol=@snapshots" "noatime" "nodiratime" "discard" ]; - }; - "/home" = { - device = "/dev/disk/by-uuid/e8c9c5a8-4df0-4100-8de6-f08a1a774fad"; - fsType = "btrfs"; - options = [ "subvol=@home" "noatime" "nodiratime" "discard" ]; - }; - "/boot" = { - device = "/dev/disk/by-uuid/1C76-1006"; - fsType = "vfat"; - options = [ "fmask=0022" "dmask=0022" ]; - }; - - # Remote - "/home/jimbo/JimboNFS" = { - device = "${config.ips.wgSpan}.1:/export/JimboNFS"; - fsType = "nfs4"; - options = [ "x-systemd.automount" "_netdev" "nofail" "noauto" ]; - }; - }; - - swapDevices = [ - { device = "/dev/disk/by-uuid/54a9cc22-4a2c-4e04-a968-313c34481489"; } - ]; - - networking.useDHCP = lib.mkDefault true; - nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; -} diff --git a/hosts/redmond/boot/default.nix b/hosts/redmond/boot/default.nix index f34c395..3e8b22b 100644 --- a/hosts/redmond/boot/default.nix +++ b/hosts/redmond/boot/default.nix @@ -7,7 +7,7 @@ initrd = { systemd = { enable = true; - services.root-reset = { + services.root-reset = { description = "Reset BTRFS root and snapshot last boot"; wantedBy = [ "initrd.target" ]; after = [ "dev-nixos-root.device" ]; diff --git a/hosts/redmond/disko/default.nix b/hosts/redmond/disko/default.nix index 72cdd59..e52c45d 100644 --- a/hosts/redmond/disko/default.nix +++ b/hosts/redmond/disko/default.nix @@ -1,14 +1,12 @@ -{ disko, ... }: +{ disko, config, ... }: { - imports = [ - disko.nixosModules.disko - ]; + imports = [ disko.nixosModules.disko ]; disko.devices = { disk = { - main = { + "${config.networking.hostName}" = { type = "disk"; - device = "/dev/sda"; + device = "/dev/nvme0n1"; content = { type = "gpt"; partitions = { @@ -26,12 +24,12 @@ size = "100%"; content = { type = "luks"; - name = "crypt-hdd"; + name = "crypt-nvme"; settings.allowDiscards = true; - #passwordFile = "/tmp/secret.key"; + passwordFile = "/tmp/secret.key"; content = { type = "lvm_pv"; - vg = "nixos"; + vg = "${config.networking.hostName}"; }; }; }; @@ -41,7 +39,7 @@ }; lvm_vg = { - nixos = { + "${config.networking.hostName}" = { type = "lvm_vg"; lvs = { root = { @@ -50,28 +48,31 @@ type = "btrfs"; extraArgs = [ "-f" ]; subvolumes = { - "/@" = { + "/root" = { mountpoint = "/"; mountOptions = [ "compress=zstd" "noatime" ]; }; - "/@prev" = { + "/prev" = { mountpoint = "/prev"; mountOptions = [ "compress=zstd" "noatime" ]; }; - "/@nix" = { + "/nix" = { mountpoint = "/nix"; mountOptions = [ "compress=zstd" "noatime" ]; }; # Impermanence - "/@root" = { + "/persist" = { mountpoint = "/persist"; mountOptions = [ "compress=zstd" "noatime" ]; }; - "/@jimbo" = { + "/persist/.snapshots" = { }; + + "/jimbo" = { mountpoint = "/persist/home/jimbo"; mountOptions = [ "compress=zstd" "noatime" ]; }; + "/jimbo/.snapshots" = { }; }; }; };