From 037add7ab3b2635e1fa6bc5f7b391d8979b2373c Mon Sep 17 00:00:00 2001 From: chn Date: Wed, 28 Jun 2023 00:53:05 +0800 Subject: [PATCH] create current rootfs at boot --- modules/boot/chn-PC.nix | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/modules/boot/chn-PC.nix b/modules/boot/chn-PC.nix index ee3b31b2..4d81f11d 100644 --- a/modules/boot/chn-PC.nix +++ b/modules/boot/chn-PC.nix @@ -2,7 +2,6 @@ inputs: { config = { - # filesystem mount fileSystems = { @@ -93,7 +92,24 @@ inputs: # initrd, luks boot.initrd = { - systemd.enable = true; + systemd = + { + enable = true; + services.create-current-rootfs = + { + wantedBy = [ "cryptsetup.target" ]; + after = [ "cryptsetup.target" ]; + before = [ "local-fs.target" ]; + unitConfig.DefaultDependencies = false; + serviceConfig.Type = "oneshot"; + script = + '' + mount /dev/mapper/root /mnt -m + btrfs subvolume create /mnt/nix/rootfs/current + unmount /mnt + ''; + }; + }; # modules in initrd # modprobe --show-depends availableKernelModules =