summary refs log tree commit diff
path: root/nixos/modules/virtualisation/containers.nix
diff options
context:
space:
mode:
authorIan-Woo Kim <ianwookim@gmail.com>2015-05-25 19:09:53 +0000
committerIan-Woo Kim <ianwookim@gmail.com>2015-05-25 19:09:53 +0000
commitc4f66eb85d721dcb97f717d4a6f28c3de3ff0f47 (patch)
tree6f4dfada925cbd2b150dffaf63af8900b44439ba /nixos/modules/virtualisation/containers.nix
parentcac38c8664fd60f4076061c16a44355e103d9d29 (diff)
downloadnixpkgs-c4f66eb85d721dcb97f717d4a6f28c3de3ff0f47.tar
nixpkgs-c4f66eb85d721dcb97f717d4a6f28c3de3ff0f47.tar.gz
nixpkgs-c4f66eb85d721dcb97f717d4a6f28c3de3ff0f47.tar.bz2
nixpkgs-c4f66eb85d721dcb97f717d4a6f28c3de3ff0f47.tar.lz
nixpkgs-c4f66eb85d721dcb97f717d4a6f28c3de3ff0f47.tar.xz
nixpkgs-c4f66eb85d721dcb97f717d4a6f28c3de3ff0f47.tar.zst
nixpkgs-c4f66eb85d721dcb97f717d4a6f28c3de3ff0f47.zip
unify extraBindsRW/RO into extraBinds. Now arbitrary mount point is supported.
Diffstat (limited to 'nixos/modules/virtualisation/containers.nix')
-rw-r--r--nixos/modules/virtualisation/containers.nix37
1 files changed, 23 insertions, 14 deletions
diff --git a/nixos/modules/virtualisation/containers.nix b/nixos/modules/virtualisation/containers.nix
index 512b4ee15ec..bfc75ea3efc 100644
--- a/nixos/modules/virtualisation/containers.nix
+++ b/nixos/modules/virtualisation/containers.nix
@@ -41,6 +41,9 @@ let
 
   system = config.nixpkgs.system;
 
+  mkBindFlag = d: if d.isReadOnly then " --bind-ro=${d.host}:${d.container}" else " --bind=${d.host}:${d.container}";
+  mkBindFlags = bs: concatMapStrings mkBindFlag bs;
+
 in
 
 {
@@ -128,25 +131,28 @@ in
               '';
             };
 
-            extraBindsRO = mkOption {
-              type = types.listOf types.str;
+            extraBinds = mkOption {
+              type = types.listOf types.attrs;
 	      default = [];
-	      example = [ "/home/alice" ];
+	      example = [ { host = "/home/alice";
+                            container = "/home";
+			    isReadOnly = false; }
+                        ];
               description =
 	        ''
-                  An extra list of directories that is bound to the container with read-only permission. 
+                  An extra list of directories that is bound to the container.
                 '';
             };
 
-            extraBindsRW = mkOption {
-              type = types.listOf types.str;
-	      default = [];
-	      example = [ "/home/alice" ];
-              description =
-	        ''
-                  An extra list of directories that is bound to the container with read-only permission. 
-                '';
-            };
+            #extraBindsRW = mkOption {
+            #  type = types.listOf types.str;
+	    # default = [];
+	    #  example = [ "/home/alice" ];
+            #  description =
+	    #    ''
+            #      An extra list of directories that is bound to the container with read-only permission. 
+            #    '';
+            #};
 
           };
 
@@ -359,11 +365,14 @@ in
              AUTO_START=1
            ''}
 
-           EXTRABINDS="${concatMapStrings (d: " --bind-ro=${d}") cfg.extraBindsRO + concatMapStrings (d: " --bind=${d}") cfg.extraBindsRW}"
+           EXTRABINDS="${mkBindFlags cfg.extraBinds}"
 
           '';
       }) config.containers;
 
+    #"${concatMapStrings (d: " --bind-ro=${d}") cfg.extraBindsRO + concatMapStrings (d: " --bind=${d}") cfg.extraBindsRW}"
+
+
     # Generate /etc/hosts entries for the containers.
     networking.extraHosts = concatStrings (mapAttrsToList (name: cfg: optionalString (cfg.localAddress != null)
       ''