Compare commits
14 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b94574c640 | |||
| a97de389e5 | |||
| 845379ac86 | |||
| e91481c405 | |||
| d3312c870a | |||
| eee561b650 | |||
| a612221e2a | |||
| 73c482ece0 | |||
| 4d4e9d980b | |||
| beb3839a6b | |||
| 0df32bf47c | |||
| f6bbbdec3e | |||
| 2a5539c204 | |||
| 9588103e67 |
@@ -86,10 +86,15 @@ in
|
|||||||
enable = true;
|
enable = true;
|
||||||
authorizedKeys = sshKeys.admins;
|
authorizedKeys = sshKeys.admins;
|
||||||
ethernetDrivers = ["r8169"];
|
ethernetDrivers = ["r8169"];
|
||||||
|
zfsExtraPools = [ "storage" ];
|
||||||
};
|
};
|
||||||
|
|
||||||
boot.initrd = {
|
boot.initrd = {
|
||||||
availableKernelModules = [ "wireguard" ];
|
availableKernelModules = [ "wireguard" ];
|
||||||
|
# postMountCommands = ''
|
||||||
|
# ip address flush dev wg-initrd
|
||||||
|
# ip link set dev wg-initrd down
|
||||||
|
# '';
|
||||||
systemd = {
|
systemd = {
|
||||||
enable = true;
|
enable = true;
|
||||||
network = {
|
network = {
|
||||||
@@ -101,15 +106,15 @@ in
|
|||||||
};
|
};
|
||||||
wireguardConfig = { PrivateKeyFile = "/etc/secrets/30-wg-initrd.key"; };
|
wireguardConfig = { PrivateKeyFile = "/etc/secrets/30-wg-initrd.key"; };
|
||||||
wireguardPeers = [{
|
wireguardPeers = [{
|
||||||
AllowedIPs = peers.fanny-initrd.allowedIPs;
|
AllowedIPs = peers.vpn.allowedIPs;
|
||||||
PublicKey = peers.fanny-initrd.publicKey;
|
PublicKey = peers.vpn.publicKey;
|
||||||
Endpoint = "${peers.vpn.publicIp}:${builtins.toString(peers.vpn.listenPort)}";
|
Endpoint = "${peers.vpn.publicIp}:${builtins.toString(peers.vpn.listenPort)}";
|
||||||
PersistentKeepalive = 25;
|
PersistentKeepalive = 25;
|
||||||
}];
|
}];
|
||||||
};
|
};
|
||||||
networks."30-wg-initrd" = {
|
networks."30-wg-initrd" = {
|
||||||
name = "wg-initrd";
|
name = "wg-initrd";
|
||||||
addresses = [{ Address = peers.fanny-initrd.address; }];
|
addresses = [{ Address = "${peers.fanny-initrd.address}/24"; }];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -22,6 +22,11 @@ in
|
|||||||
description = "Ethernet drivers to load: run `lspci -k | grep -iA4 ethernet`";
|
description = "Ethernet drivers to load: run `lspci -k | grep -iA4 ethernet`";
|
||||||
example = "r8169";
|
example = "r8169";
|
||||||
};
|
};
|
||||||
|
zfsExtraPools = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.str;
|
||||||
|
default = [ ];
|
||||||
|
description = "Name or GUID of extra ZFS pools that you wish to import during boot.";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf (cfg.enable && config.malobeo.disks.encryption) {
|
config = lib.mkIf (cfg.enable && config.malobeo.disks.encryption) {
|
||||||
@@ -32,33 +37,41 @@ in
|
|||||||
zfs = {
|
zfs = {
|
||||||
forceImportAll = true;
|
forceImportAll = true;
|
||||||
requestEncryptionCredentials = true;
|
requestEncryptionCredentials = true;
|
||||||
|
extraPools = cfg.zfsExtraPools;
|
||||||
};
|
};
|
||||||
initrd = {
|
initrd = {
|
||||||
availableKernelModules = cfg.ethernetDrivers;
|
availableKernelModules = cfg.ethernetDrivers;
|
||||||
systemd = {
|
systemd = {
|
||||||
|
initrdBin = [ pkgs.busybox pkgs.wireguard-tools pkgs.iproute2 ];
|
||||||
enable = true;
|
enable = true;
|
||||||
network.enable = true;
|
network.enable = true;
|
||||||
|
services."stopInitVpn" = {
|
||||||
|
description = "stop init vpn";
|
||||||
|
wantedBy = [
|
||||||
|
"initrd.target"
|
||||||
|
];
|
||||||
|
after = [
|
||||||
|
"zfs.target"
|
||||||
|
];
|
||||||
|
serviceConfig.StandardOutput = "journal+console";
|
||||||
|
script = ''
|
||||||
|
networkctl down wg-initrd
|
||||||
|
'';
|
||||||
|
serviceConfig.Type = "oneshot";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
network.ssh = {
|
network = {
|
||||||
enable = true;
|
flushBeforeStage2 = true;
|
||||||
port = 222;
|
ssh = {
|
||||||
authorizedKeys = cfg.authorizedKeys;
|
enable = true;
|
||||||
hostKeys = [ "/etc/ssh/initrd" ];
|
port = 222;
|
||||||
|
authorizedKeys = cfg.authorizedKeys;
|
||||||
|
hostKeys = [ "/etc/ssh/initrd" ];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
secrets = {
|
secrets = {
|
||||||
"/etc/ssh/initrd" = "/etc/ssh/initrd";
|
"/etc/ssh/initrd" = "/etc/ssh/initrd";
|
||||||
};
|
};
|
||||||
systemd.services.zfs-remote-unlock = {
|
|
||||||
description = "Prepare for ZFS remote unlock";
|
|
||||||
wantedBy = ["initrd.target"];
|
|
||||||
after = ["systemd-networkd.service"];
|
|
||||||
path = with pkgs; [ zfs ];
|
|
||||||
serviceConfig.Type = "oneshot";
|
|
||||||
script = ''
|
|
||||||
echo "zfs load-key -a; killall zfs; systemctl default" >> /var/empty/.profile
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
kernelParams = [ "ip=::::${hostName}-initrd::dhcp" ];
|
kernelParams = [ "ip=::::${hostName}-initrd::dhcp" ];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -24,14 +24,16 @@ diskkey=$(sops -d machines/$hostname/secrets/disk.key)
|
|||||||
echo
|
echo
|
||||||
if [ $# = 1 ]
|
if [ $# = 1 ]
|
||||||
then
|
then
|
||||||
echo "$diskkey" | ssh $sshoptions root@$hostname-initrd "systemd-tty-ask-password-agent" #root
|
ssh $sshoptions root@$hostname-initrd "zpool import -a"
|
||||||
|
echo "$diskkey" | ssh $sshoptions root@$hostname-initrd "zfs load-key storage/encrypted" #root
|
||||||
echo "$diskkey" | ssh $sshoptions root@$hostname-initrd "systemd-tty-ask-password-agent" #data
|
echo "$diskkey" | ssh $sshoptions root@$hostname-initrd "systemd-tty-ask-password-agent" #data
|
||||||
|
|
||||||
elif [ $# = 2 ]
|
elif [ $# = 2 ]
|
||||||
then
|
then
|
||||||
ip=$2
|
ip=$2
|
||||||
echo "$diskkey" | ssh $sshoptions root@$ip "systemd-tty-ask-password-agent" #root
|
ssh $sshoptions root@$ip "zpool import -a"
|
||||||
echo "$diskkey" | ssh $sshoptions root@$ip "systemd-tty-ask-password-agent" #data
|
echo "$diskkey" | ssh $sshoptions root@$ip "zfs load-key storage/encrypted"
|
||||||
|
echo "$diskkey" | ssh $sshoptions root@$ip "systemd-tty-ask-password-agent"
|
||||||
|
|
||||||
else
|
else
|
||||||
echo
|
echo
|
||||||
|
|||||||
Reference in New Issue
Block a user