diff options
author | lassulus <lassulus@lassul.us> | 2023-01-02 18:47:49 +0100 |
---|---|---|
committer | lassulus <lassulus@lassul.us> | 2023-01-02 18:47:49 +0100 |
commit | 7bbcac3e5ee3ad65762e54d85a1786d077cca699 (patch) | |
tree | 409da0e5deacd9c32bde2a0a002aa7349db2192f /lass/3modules | |
parent | 5415114141754e6e1382e8e6841b902717c6de1f (diff) |
l sync-containers3: add init script
Diffstat (limited to 'lass/3modules')
-rw-r--r-- | lass/3modules/sync-containers3.nix | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lass/3modules/sync-containers3.nix b/lass/3modules/sync-containers3.nix index 645809da5..053175565 100644 --- a/lass/3modules/sync-containers3.nix +++ b/lass/3modules/sync-containers3.nix @@ -255,6 +255,24 @@ in { homeMode = "705"; })) cfg.containers; + environment.systemPackages = lib.mapAttrsToList (_: ctr: (pkgs.writers.writeDashBin "${ctr.name}_init" '' + set -efux + export PATH=${lib.makeBinPath [ + pkgs.coreutils + pkgs.cryptsetup + pkgs.libxfs.bin + ]}:$PATH + truncate -s 5G /var/lib/sync-containers3/${ctr.name}/disk + cryptsetup luksFormat /var/lib/sync-containers3/${ctr.name}/disk ${ctr.luksKey} + cryptsetup luksOpen --key-file ${ctr.luksKey} /var/lib/sync-containers3/${ctr.name}/disk ${ctr.name} + mkfs.xfs /dev/mapper/${ctr.name} + mkdir -p /var/lib/sync-containers3/${ctr.name}/state + mountpoint /var/lib/sync-containers3/${ctr.name}/state || mount /dev/mapper/${ctr.name} /var/lib/sync-containers3/${ctr.name}/state + /run/current-system/sw/bin/nixos-container start ${ctr.name} + /run/current-system/sw/bin/nixos-container run ${ctr.name} -- ${pkgs.writeDash "init" '' + mkdir -p /var/state + ''} + '')) cfg.containers; }) (lib.mkIf (cfg.containers != {}) { # networking |