0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-14 06:00:33 +03:00

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 { toYAML = name: data: pkgs.writeText name (generators.toYAML {} data);
preferLocalBuild = true;
json = builtins.toFile "${name}.json" (builtins.toJSON attrs);
nativeBuildInputs = [ pkgs.remarshal ];
} "json2yaml -i $json -o $out";
cfg = config.virtualisation.lxc; cfg = config.virtualisation.lxc;
templates = if cfg.templates != {} then let templates = if cfg.templates != {} then let
@ -54,7 +50,9 @@ let
in in
{ {
imports = [ 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 = { options = {
@ -94,6 +92,20 @@ in
}; };
config = { 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 { system.build.metadata = pkgs.callPackage ../../lib/make-system-tarball.nix {
contents = [ contents = [
{ {
@ -112,7 +124,7 @@ in
] ++ templates.files; ] ++ 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"; extraArgs = "--owner=0";
storeContents = [ storeContents = [
@ -130,7 +142,7 @@ in
]; ];
extraCommands = "mkdir -p proc sys dev"; extraCommands = "mkdir -p proc sys dev";
}); };
# Add the overrides from lxd distrobuilder # Add the overrides from lxd distrobuilder
systemd.extraConfig = '' systemd.extraConfig = ''

View file

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