lxdImage: split from docker profile, use generators.toYAML

Changed files
+21 -9
nixos
modules
virtualisation
+20 -8
nixos/modules/virtualisation/lxc-container.nix
···
};
};
-
toYAML = name: attrs: pkgs.runCommandNoCC name {
-
preferLocalBuild = true;
-
json = builtins.toFile "${name}.json" (builtins.toJSON attrs);
-
nativeBuildInputs = [ pkgs.remarshal ];
-
} "json2yaml -i $json -o $out";
cfg = config.virtualisation.lxc;
templates = if cfg.templates != {} then let
···
in
{
imports = [
-
../profiles/docker-container.nix # FIXME, shouldn't include something from profiles/
];
options = {
···
};
config = {
system.build.metadata = pkgs.callPackage ../../lib/make-system-tarball.nix {
contents = [
{
···
] ++ templates.files;
};
-
system.build.tarball = mkForce (pkgs.callPackage ../../lib/make-system-tarball.nix {
extraArgs = "--owner=0";
storeContents = [
···
];
extraCommands = "mkdir -p proc sys dev";
-
});
# Add the overrides from lxd distrobuilder
systemd.extraConfig = ''
···
};
};
+
toYAML = name: data: pkgs.writeText name (generators.toYAML {} data);
cfg = config.virtualisation.lxc;
templates = if cfg.templates != {} then let
···
in
{
imports = [
+
../installer/cd-dvd/channel.nix
+
../profiles/minimal.nix
+
../profiles/clone-config.nix
];
options = {
···
};
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 = [
{
···
] ++ templates.files;
};
+
system.build.tarball = pkgs.callPackage ../../lib/make-system-tarball.nix {
extraArgs = "--owner=0";
storeContents = [
···
];
extraCommands = "mkdir -p proc sys dev";
+
};
# Add the overrides from lxd distrobuilder
systemd.extraConfig = ''
+1 -1
nixos/release.nix
···
versionModule
./maintainers/scripts/lxd/lxd-image.nix
];
-
}).config.system.build.tarball.content) # use .content because this is an override
);
···
versionModule
./maintainers/scripts/lxd/lxd-image.nix
];
+
}).config.system.build.tarball)
);