diff options
| -rw-r--r-- | flake.nix | 1 | ||||
| -rw-r--r-- | machines/x/configuration.nix | 55 | ||||
| -rw-r--r-- | modules/core/global.nix | 3 | ||||
| -rw-r--r-- | modules/core/impermanence.nix | 45 |
4 files changed, 56 insertions, 48 deletions
@@ -32,7 +32,6 @@ specialArgs = { inherit inputs; }; modules = [ inputs.disko.nixosModules.default - (import ./disko.nix { device = "/dev/nvme0n1"; }) ./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"; diff --git a/modules/core/global.nix b/modules/core/global.nix index 7d372ab..71c82f0 100644 --- a/modules/core/global.nix +++ b/modules/core/global.nix @@ -15,6 +15,9 @@ in { "L+ ${nix_path} - - - - ${pkgs.path}" ]; + nixpkgs.config.allowUnfree = true; + nixpkgs.config.allowUnfreePredicate = _: true; + environment.systemPackages = with pkgs; [ man-pages man-pages-posix diff --git a/modules/core/impermanence.nix b/modules/core/impermanence.nix new file mode 100644 index 0000000..c5f3009 --- /dev/null +++ b/modules/core/impermanence.nix @@ -0,0 +1,45 @@ +{ pkgs, lib, ... }: + +{ + 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="; }; } + ]; + }; +} |
