summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--nixos/modules/virtualisation/lxc-container.nix28
-rw-r--r--nixos/release.nix2
2 files changed, 21 insertions, 9 deletions
diff --git a/nixos/modules/virtualisation/lxc-container.nix b/nixos/modules/virtualisation/lxc-container.nix
index 8e7eeb3525f..fb0187aabcc 100644
--- a/nixos/modules/virtualisation/lxc-container.nix
+++ b/nixos/modules/virtualisation/lxc-container.nix
@@ -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 = ''
diff --git a/nixos/release.nix b/nixos/release.nix
index 65395457ca3..6b7564a9b97 100644
--- a/nixos/release.nix
+++ b/nixos/release.nix
@@ -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)
 
   );