From 2377533a96271e7839415258207885cd6f844855 Mon Sep 17 00:00:00 2001 From: chn Date: Sun, 9 Jul 2023 22:51:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86swap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- flake.nix | 1 + modules/boot/chn-PC.nix | 1 - modules/boot/fileSystems.nix | 2 ++ 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index c5a2615c..1eb5b06c 100644 --- a/flake.nix +++ b/flake.nix @@ -141,6 +141,7 @@ }; mdadm = "ARRAY /dev/md/swap metadata=1.2 name=chn-PC:swap UUID=2b546b8d:e38007c8:02990dd1:df9e23a4"; + swap = [ "/dev/mapper/swap" ]; }; };} ) diff --git a/modules/boot/chn-PC.nix b/modules/boot/chn-PC.nix index 36098d5a..f3e2667e 100644 --- a/modules/boot/chn-PC.nix +++ b/modules/boot/chn-PC.nix @@ -19,7 +19,6 @@ inputs: # sudo $(dirname $(realpath $(which systemctl)))/../lib/systemd/systemd-cryptsetup \ # attach swap /dev/md/swap - fido2-device=auto # sudo mkswap --uuid clear /dev/mapper/swap - swapDevices = [ { device = "/dev/mapper/swap"; } ]; # kernel, modules, ucode boot.kernelPackages = inputs.pkgs.linuxPackages_xanmod_latest; diff --git a/modules/boot/fileSystems.nix b/modules/boot/fileSystems.nix index 8256f1ba..60a23ac1 100644 --- a/modules/boot/fileSystems.nix +++ b/modules/boot/fileSystems.nix @@ -12,6 +12,7 @@ inputs: decrypt.auto = mkOption { type = types.attrsOf (types.submodule { options = { mapper = mkOption { type = types.nonEmptyStr; }; ssd = mkOption { type = types.bool; }; }; }); }; mdadm = mkOption { type = types.nullOr types.str; }; + swap = mkOption { type = types.listOf types.nonEmptyStr; }; # swap and resume # swap != resume.device if swap is a file @@ -52,6 +53,7 @@ inputs: ) (inputs.localLib.attrsToList inputs.config.nixos.fileSystems.mount.btrfs))) ); + swapDevices = builtins.map (device: { device = device; }) inputs.config.nixos.fileSystems.swap; boot.initrd = { luks.devices =