From f80f0dd53d4d58644ff067b409abe8296ca056aa Mon Sep 17 00:00:00 2001 From: Jimbo Date: Sat, 2 Nov 2024 21:05:59 -0400 Subject: [PATCH] Modify Lenovo and add iwd to persistence --- flake.nix | 2 +- hosts/redmond/boot/default.nix | 40 ++++++++ hosts/redmond/default.nix | 29 ++++++ hosts/redmond/disko/default.nix | 95 +++++++++++++++++++ .../redmond/{system => }/hardware/default.nix | 9 -- hosts/redmond/home/default.nix | 8 -- hosts/redmond/system/boot/default.nix | 7 -- hosts/redmond/system/default.nix | 28 ------ .../devices/impermanence/root/default.nix | 1 + 9 files changed, 166 insertions(+), 53 deletions(-) create mode 100644 hosts/redmond/boot/default.nix create mode 100644 hosts/redmond/default.nix create mode 100644 hosts/redmond/disko/default.nix rename hosts/redmond/{system => }/hardware/default.nix (73%) delete mode 100644 hosts/redmond/home/default.nix delete mode 100644 hosts/redmond/system/boot/default.nix delete mode 100644 hosts/redmond/system/default.nix diff --git a/flake.nix b/flake.nix index bb7366e..7f2b802 100644 --- a/flake.nix +++ b/flake.nix @@ -82,7 +82,7 @@ shuttle = mkNix [ ./hosts/shuttleworth/system ]; # Pinebook Pro lacros = mkNix [ ./hosts/lacros/system ]; # Dell Chromebook - redmond = mkNix [ ./hosts/redmond/system ]; # Lenovo Laptop + redmond = mkNix [ ./hosts/redmond ]; # Lenovo Dual-Boot Laptop treefruit = mkNix [ ./hosts/treefruit/system ]; # Macbook Pro 14,1 cyberspark = mkNix [ ./hosts/cyberspark/system ]; # Dell Optiplex 7010 diff --git a/hosts/redmond/boot/default.nix b/hosts/redmond/boot/default.nix new file mode 100644 index 0000000..f34c395 --- /dev/null +++ b/hosts/redmond/boot/default.nix @@ -0,0 +1,40 @@ +{ pkgs, ... }: +{ + boot = { + kernelPackages = pkgs.linuxPackages_latest; + kernel.sysctl."vm.max_map_count" = 2147483642; + + initrd = { + systemd = { + enable = true; + services.root-reset = { + description = "Reset BTRFS root and snapshot last boot"; + wantedBy = [ "initrd.target" ]; + after = [ "dev-nixos-root.device" ]; + before = [ "sysroot.mount" ]; + unitConfig.DefaultDependencies = "no"; + serviceConfig.Type = "oneshot"; + script = '' + mkdir -p /mnt + mount /dev/nixos/root /mnt + + if [[ -e /mnt/@prev ]]; then + btrfs subvolume delete /mnt/@prev + fi + + btrfs subvolume snapshot /mnt/@ /mnt/@prev + + btrfs subvolume list -o /mnt/@ | cut -f9 -d' ' | while read subvolume; do + btrfs subvolume delete "/mnt/$subvolume" + done + + btrfs subvolume delete /mnt/@ + btrfs subvolume create /mnt/@ + + umount /mnt + ''; + }; + }; + }; + }; +} diff --git a/hosts/redmond/default.nix b/hosts/redmond/default.nix new file mode 100644 index 0000000..ca454b1 --- /dev/null +++ b/hosts/redmond/default.nix @@ -0,0 +1,29 @@ +{ config, ... }: +{ + imports = [ + ./boot + ./disko + ./hardware + + # 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 + ../../modules/system/devices/networking/wireguard/pc + + # Extras + ../../overlays + ../../variables + ]; + + networking.hostName = "redmond"; + networking.wireguard.interfaces."${config.ips.wgInt}".ips = [ "${config.ips.wgSpan}.20/24" ]; +} diff --git a/hosts/redmond/disko/default.nix b/hosts/redmond/disko/default.nix new file mode 100644 index 0000000..72cdd59 --- /dev/null +++ b/hosts/redmond/disko/default.nix @@ -0,0 +1,95 @@ +{ disko, ... }: +{ + imports = [ + disko.nixosModules.disko + ]; + + disko.devices = { + disk = { + main = { + type = "disk"; + device = "/dev/sda"; + 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-hdd"; + settings.allowDiscards = true; + #passwordFile = "/tmp/secret.key"; + content = { + type = "lvm_pv"; + vg = "nixos"; + }; + }; + }; + }; + }; + }; + }; + + lvm_vg = { + nixos = { + type = "lvm_vg"; + lvs = { + root = { + size = "100%"; + content = { + type = "btrfs"; + extraArgs = [ "-f" ]; + subvolumes = { + "/@" = { + mountpoint = "/"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/@prev" = { + mountpoint = "/prev"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/@nix" = { + mountpoint = "/nix"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + + # Impermanence + "/@root" = { + mountpoint = "/persist"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/@jimbo" = { + mountpoint = "/persist/home/jimbo"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + }; + }; + }; + swap = { + size = "8G"; + content = { + type = "swap"; + discardPolicy = "both"; + }; + }; + }; + }; + }; + }; + + # Needed for impermanence + fileSystems = { + "/persist".neededForBoot = true; + "/persist/home/jimbo".neededForBoot = true; + }; +} diff --git a/hosts/redmond/system/hardware/default.nix b/hosts/redmond/hardware/default.nix similarity index 73% rename from hosts/redmond/system/hardware/default.nix rename to hosts/redmond/hardware/default.nix index d2d12e9..d064383 100644 --- a/hosts/redmond/system/hardware/default.nix +++ b/hosts/redmond/hardware/default.nix @@ -16,15 +16,6 @@ }; fileSystems = { - "/" = { - device = "/dev/disk/by-uuid/c0fe8419-88f9-48a0-8c5b-acd4c11f8037"; - fsType = "ext4"; - }; - "/boot" = { - device = "/dev/disk/by-uuid/BF2B-9AE0"; - fsType = "vfat"; - options = [ "fmask=0022" "dmask=0022" ]; - }; "/home/jimbo/JimboNFS" = { device = "${config.ips.wgSpan}.1:/export/JimboNFS"; fsType = "nfs4"; diff --git a/hosts/redmond/home/default.nix b/hosts/redmond/home/default.nix deleted file mode 100644 index b388a2f..0000000 --- a/hosts/redmond/home/default.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ ... }: -{ - imports = [ - ../../../modules/home - ../../../modules/home/programs/misc/gaming/launchers - ../../../modules/home/programs/misc/remote-desktop - ]; -} diff --git a/hosts/redmond/system/boot/default.nix b/hosts/redmond/system/boot/default.nix deleted file mode 100644 index 8022416..0000000 --- a/hosts/redmond/system/boot/default.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ pkgs, ... }: -{ - boot = { - kernelPackages = pkgs.linuxPackages_latest; - kernel.sysctl."vm.max_map_count" = 2147483642; - }; -} diff --git a/hosts/redmond/system/default.nix b/hosts/redmond/system/default.nix deleted file mode 100644 index d1a1cd8..0000000 --- a/hosts/redmond/system/default.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ config, ... }: -{ - 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 - ../../../modules/system/devices/networking/wireguard/pc - - # Extras - ../../../overlays - ../../../variables - ]; - - networking.hostName = "redmond"; - networking.wireguard.interfaces."${config.ips.wgInt}".ips = [ "${config.ips.wgSpan}.20/24" ]; -} diff --git a/modules/system/devices/impermanence/root/default.nix b/modules/system/devices/impermanence/root/default.nix index 35cc19b..9be4220 100644 --- a/modules/system/devices/impermanence/root/default.nix +++ b/modules/system/devices/impermanence/root/default.nix @@ -11,6 +11,7 @@ "/var/lib/mpd" "/var/lib/nixos" "/var/lib/fail2ban" + "/var/lib/iwd/" "/var/lib/systemd/coredump" ]; files = [