config/pkgs/mk-nspawn-deployer/default.nix

30 lines
620 B
Nix
Raw Normal View History

2024-01-31 22:17:55 +01:00
{ lib
, pkgs
}:
# assumes nspawn-tarball.nix is mixed into it
nixosConfiguration:
let
hostname = nixosConfiguration.config.networking.hostName;
setup = pkgs.substituteAll {
src = ./setup-nspawn.sh;
isExecutable = true;
inherit hostname;
};
inherit (nixosConfiguration.config.system.build) tarball;
in
pkgs.runCommandNoCC "nspawn-setup-${hostname}.sh" {
nativeBuildInputs = with pkgs; [ makeself ];
} ''
mkdir -p archive/
ln -s ${setup} archive/setup.sh
ln -s ${tarball}/* archive/nixos-${hostname}.tar
makeself --follow archive/ $out setup-nixos-nspawn-${hostname} ./setup.sh
''