create current rootfs at boot

This commit is contained in:
陈浩南 2023-06-28 00:53:05 +08:00
parent 318e185217
commit 037add7ab3

View File

@ -2,7 +2,6 @@ inputs:
{ {
config = config =
{ {
# filesystem mount # filesystem mount
fileSystems = fileSystems =
{ {
@ -93,7 +92,24 @@ inputs:
# initrd, luks # initrd, luks
boot.initrd = 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 # modules in initrd
# modprobe --show-depends # modprobe --show-depends
availableKernelModules = availableKernelModules =