summary refs log tree commit diff
path: root/nixos/modules/virtualisation/containers.nix
diff options
context:
space:
mode:
authorChristian Kampka <kampka@users.noreply.github.com>2016-11-22 02:11:33 +0100
committerFranz Pletz <fpletz@fnordicwalking.de>2016-11-22 02:11:33 +0100
commit35ecef2c6d0afebf09ab6504a00b6af14ca24973 (patch)
tree9a1fe5615804344c3796408c08178ab7f3ce627f /nixos/modules/virtualisation/containers.nix
parent49d608ac0066198a88eede8dd314bc8bd75e5b08 (diff)
downloadnixpkgs-35ecef2c6d0afebf09ab6504a00b6af14ca24973.tar
nixpkgs-35ecef2c6d0afebf09ab6504a00b6af14ca24973.tar.gz
nixpkgs-35ecef2c6d0afebf09ab6504a00b6af14ca24973.tar.bz2
nixpkgs-35ecef2c6d0afebf09ab6504a00b6af14ca24973.tar.lz
nixpkgs-35ecef2c6d0afebf09ab6504a00b6af14ca24973.tar.xz
nixpkgs-35ecef2c6d0afebf09ab6504a00b6af14ca24973.tar.zst
nixpkgs-35ecef2c6d0afebf09ab6504a00b6af14ca24973.zip
containers module: Add tmpfs options (#20557)
Allows one or more directories to be mounted as a read-only file system.

This makes it convenient to run volatile containers that do not retain
application state.
Diffstat (limited to 'nixos/modules/virtualisation/containers.nix')
-rw-r--r--nixos/modules/virtualisation/containers.nix18
1 files changed, 17 insertions, 1 deletions
diff --git a/nixos/modules/virtualisation/containers.nix b/nixos/modules/virtualisation/containers.nix
index aa28a25be7a..cfc1065b729 100644
--- a/nixos/modules/virtualisation/containers.nix
+++ b/nixos/modules/virtualisation/containers.nix
@@ -129,9 +129,12 @@ let
         --setenv HOST_ADDRESS6="$HOST_ADDRESS6" \
         --setenv LOCAL_ADDRESS6="$LOCAL_ADDRESS6" \
         --setenv PATH="$PATH" \
-        ${if cfg.additionalCapabilities != null then
+        ${if cfg.additionalCapabilities != null && cfg.additionalCapabilities != [] then
           ''--capability="${concatStringsSep " " cfg.additionalCapabilities}"'' else ""
         } \
+        ${if cfg.tmpfs != null && cfg.tmpfs != [] then
+          ''--tmpfs=${concatStringsSep " --tmpfs=" cfg.tmpfs}'' else ""
+        } \
         ${containerInit cfg} "''${SYSTEM_PATH:-/nix/var/nix/profiles/system}/init"
     '';
 
@@ -367,6 +370,7 @@ let
       hostAddress6 = null;
       localAddress = null;
       localAddress6 = null;
+      tmpfs = null;
     };
 
 in
@@ -510,6 +514,18 @@ in
               '';
             };
 
+            tmpfs = mkOption {
+              type = types.listOf types.str;
+              default = [];
+              example = [ "/var" ];
+              description = ''
+                Mounts a set of tmpfs file systems into the container.
+                Multiple paths can be specified.
+                Valid items must conform to the --tmpfs argument
+                of systemd-nspawn. See systemd-nspawn(1) for details.
+              '';
+            };
+
           } // networkOptions;
 
           config = mkMerge