30 lines
620 B
Nix
30 lines
620 B
Nix
|
{ 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
|
||
|
''
|