lxdImage: split from docker profile, use generators.toYAML

This commit is contained in:
Maciej Krüger 2021-10-19 16:50:51 +02:00
parent 3c3349e24b
commit a797967cec
No known key found for this signature in database
GPG key ID: 0D948CE19CF49C5F
2 changed files with 21 additions and 9 deletions

View file

@ -27,11 +27,7 @@ let
};
};
toYAML = name: attrs: pkgs.runCommandNoCC name {
preferLocalBuild = true;
json = builtins.toFile "${name}.json" (builtins.toJSON attrs);
nativeBuildInputs = [ pkgs.remarshal ];
} "json2yaml -i $json -o $out";
toYAML = name: data: pkgs.writeText name (generators.toYAML {} data);
cfg = config.virtualisation.lxc;
templates = if cfg.templates != {} then let
@ -54,7 +50,9 @@ let
in
{
imports = [
../profiles/docker-container.nix # FIXME, shouldn't include something from profiles/
../installer/cd-dvd/channel.nix
../profiles/minimal.nix
../profiles/clone-config.nix
];
options = {
@ -94,6 +92,20 @@ in
};
config = {
boot.isContainer = true;
boot.postBootCommands =
''
# After booting, register the contents of the Nix store in the Nix
# database.
if [ -f /nix-path-registration ]; then
${config.nix.package.out}/bin/nix-store --load-db < /nix-path-registration &&
rm /nix-path-registration
fi
# nixos-rebuild also requires a "system" profile
${config.nix.package.out}/bin/nix-env -p /nix/var/nix/profiles/system --set /run/current-system
'';
system.build.metadata = pkgs.callPackage ../../lib/make-system-tarball.nix {
contents = [
{
@ -112,7 +124,7 @@ in
] ++ templates.files;
};
system.build.tarball = mkForce (pkgs.callPackage ../../lib/make-system-tarball.nix {
system.build.tarball = pkgs.callPackage ../../lib/make-system-tarball.nix {
extraArgs = "--owner=0";
storeContents = [
@ -130,7 +142,7 @@ in
];
extraCommands = "mkdir -p proc sys dev";
});
};
# Add the overrides from lxd distrobuilder
systemd.extraConfig = ''

View file

@ -263,7 +263,7 @@ in rec {
versionModule
./maintainers/scripts/lxd/lxd-image.nix
];
}).config.system.build.tarball.content) # use .content because this is an override
}).config.system.build.tarball)
);