summary refs log tree commit diff
path: root/nixos/modules/profiles
diff options
context:
space:
mode:
authorJaka Hudoklin <jakahudoklin@gmail.com>2014-12-11 22:58:17 +0100
committerJaka Hudoklin <jakahudoklin@gmail.com>2014-12-11 23:17:27 +0100
commitdeb28cf0b1af905f007a9219e1e11da6859faede (patch)
treec4b11429bc9e1c88a9329c405ecfd1bdbc484a63 /nixos/modules/profiles
parenta782b890d53b5c8a336677bb7c5394f9afb4c39b (diff)
downloadnixpkgs-deb28cf0b1af905f007a9219e1e11da6859faede.tar
nixpkgs-deb28cf0b1af905f007a9219e1e11da6859faede.tar.gz
nixpkgs-deb28cf0b1af905f007a9219e1e11da6859faede.tar.bz2
nixpkgs-deb28cf0b1af905f007a9219e1e11da6859faede.tar.lz
nixpkgs-deb28cf0b1af905f007a9219e1e11da6859faede.tar.xz
nixpkgs-deb28cf0b1af905f007a9219e1e11da6859faede.tar.zst
nixpkgs-deb28cf0b1af905f007a9219e1e11da6859faede.zip
nixos: container tarball release
- Create container nixos profile
- Create lxc-container nixos config using container nixos profile
- Docker nixos image, use nixos profile for its base config
Diffstat (limited to 'nixos/modules/profiles')
-rw-r--r--nixos/modules/profiles/container.nix57
1 files changed, 57 insertions, 0 deletions
diff --git a/nixos/modules/profiles/container.nix b/nixos/modules/profiles/container.nix
new file mode 100644
index 00000000000..5b531e5c3df
--- /dev/null
+++ b/nixos/modules/profiles/container.nix
@@ -0,0 +1,57 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+ pkgs2storeContents = l : map (x: { object = x; symlink = "none"; }) l;
+
+in {
+  # Docker image config.
+  imports = [
+    ../installer/cd-dvd/channel.nix
+    ./minimal.nix
+    ./clone-config.nix
+  ];
+
+  # Create the tarball
+  system.build.tarball = import ../../lib/make-system-tarball.nix {
+    inherit (pkgs) stdenv perl xz pathsFromGraph;
+
+    contents = [];
+    extraArgs = "--owner=0";
+
+    # Some container managers like lxc need these
+    extraCommands = "mkdir -p proc sys dev";
+
+    # Add init script to image
+    storeContents = [
+      { object = config.system.build.toplevel + "/init";
+        symlink = "/init";
+      }
+    ] ++ (pkgs2storeContents [ pkgs.stdenv ]);
+  };
+
+  boot.postBootCommands =
+    ''
+      # After booting, register the contents of the Nix store in the Nix
+      # database.
+      if [ -f /nix-path-registration ]; then
+        ${config.nix.package}/bin/nix-store --load-db < /nix-path-registration &&
+        rm /nix-path-registration
+      fi
+
+      # nixos-rebuild also requires a "system" profile and an
+      # /etc/NIXOS tag.
+      touch /etc/NIXOS
+      ${config.nix.package}/bin/nix-env -p /nix/var/nix/profiles/system --set /run/current-system
+    '';
+
+  boot.isContainer = true;
+
+  # Disable some features that are not useful in a container.
+  sound.enable = mkDefault false;
+  services.udisks2.enable = mkDefault false;
+
+  # Shut up warnings about not having a boot loader.
+  system.build.installBootLoader = "${pkgs.coreutils}/bin/true";
+}