From acd2d93ad81ffad72c067e0cbf90bee809276951 Mon Sep 17 00:00:00 2001 From: Raghuram Subramani Date: Thu, 10 Oct 2024 10:03:42 +0530 Subject: (impermanence): Modularize config. --- machines/x/configuration.nix | 55 +++++++------------------------------------- 1 file changed, 8 insertions(+), 47 deletions(-) (limited to 'machines/x/configuration.nix') diff --git a/machines/x/configuration.nix b/machines/x/configuration.nix index 64da9ac..19305a1 100644 --- a/machines/x/configuration.nix +++ b/machines/x/configuration.nix @@ -1,11 +1,17 @@ { lib, inputs, pkgs, ... }: -{ +let + drive = "/dev/nvme0n1"; +in { imports = [ ./hardware-configuration.nix inputs.home-manager.nixosModules.default + + (import ../../disko.nix { device = drive; }) + ] ++ (map (path: ../../modules/${path}) [ "core/global.nix" + "core/impermanence.nix" "amdgpu.nix" "amd.nix" @@ -33,57 +39,12 @@ grub = { enable = true; efiSupport = true; - device = "/dev/nvme0n1"; + device = drive; }; }; - boot.initrd.postDeviceCommands = lib.mkAfter '' - mkdir /btrfs_tmp - mount /dev/root_vg/root /btrfs_tmp - if [[ -e /btrfs_tmp/root ]]; then - mkdir -p /btrfs_tmp/old_roots - timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/root)" "+%Y-%m-%-d_%H:%M:%S") - mv /btrfs_tmp/root "/btrfs_tmp/old_roots/$timestamp" - fi - - delete_subvolume_recursively() { - IFS=$'\n' - for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do - delete_subvolume_recursively "/btrfs_tmp/$i" - done - btrfs subvolume delete "$1" - } - - for i in $(find /btrfs_tmp/old_roots/ -maxdepth 1 -mtime +30); do - delete_subvolume_recursively "$i" - done - - btrfs subvolume create /btrfs_tmp/root - umount /btrfs_tmp - ''; - - fileSystems."/persist".neededForBoot = true; - environment.persistence."/persist/system" = { - hideMounts = true; - directories = [ - "/etc/nixos" - "/var/log" - "/var/lib/bluetooth" - "/var/lib/nixos" - "/var/lib/systemd/coredump" - "/etc/NetworkManager/system-connections" - ]; - files = [ - "/etc/machine-id" - { file = "/var/keys/secret_file"; parentDirectory = { mode = "u=rwx,g=,o="; }; } - ]; - }; - boot.extraModprobeConfig = "options kvm_amd nested=1"; - nixpkgs.config.allowUnfree = true; - nixpkgs.config.allowUnfreePredicate = _: true; - services.fstrim.enable = true; networking.hostName = "x"; -- cgit v1.2.3