From 597c2f9ff39f8c10dda41dd9dae442faaa90b619 Mon Sep 17 00:00:00 2001 From: Ciapa Date: Sun, 4 Feb 2024 02:06:03 +0100 Subject: [PATCH] Move postCommands to systemd service --- hosts/phoenix.lewd.wtf/services/zfs.nix | 35 ++++++++++++++++--------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/hosts/phoenix.lewd.wtf/services/zfs.nix b/hosts/phoenix.lewd.wtf/services/zfs.nix index 3d6b800..f3f6c90 100644 --- a/hosts/phoenix.lewd.wtf/services/zfs.nix +++ b/hosts/phoenix.lewd.wtf/services/zfs.nix @@ -11,18 +11,17 @@ in boot.kernelParams = [ "ip=192.168.0.42::192.168.0.1:255.255.252.0:phoenix-initrd:eno2:off:192.168.0.1" ]; - boot.initrd.network = { - enable = true; - ssh = { - enable = true; - port = 2222; - hostKeys = [ - /boot-1/initrd-ssh-key - /boot-2/initrd-ssh-key - ]; - authorizedKeys = config.users.users.root.openssh.authorizedKeys.keys; - }; - postCommands = '' + boot.initrd.systemd.services.zfsunlock = { + description = "Unlock ZFS pools"; + wantedBy = [ + "initrd.target" + ]; + before = [ + "zfs-import-zroot.service" + ]; + unitConfig.DefaultDependencies = "no"; + serviceConfig.Type = "oneshot"; + script = '' cat < /root/.profile if pgrep -x "zfs" > /dev/null then @@ -38,6 +37,18 @@ in EOF ''; }; + boot.initrd.network = { + enable = true; + ssh = { + enable = true; + port = 2222; + hostKeys = [ + /boot-1/initrd-ssh-key + /boot-2/initrd-ssh-key + ]; + authorizedKeys = config.users.users.root.openssh.authorizedKeys.keys; + }; + }; # ZFS options from https://nixos.wiki/wiki/NixOS_on_ZFS networking.hostId = "42069420";