unify extraBindsRW/RO into extraBinds. Now arbitrary mount point is supported.

This commit is contained in:
Ian-Woo Kim 2015-05-25 19:09:53 +00:00
parent cac38c8664
commit c4f66eb85d

View File

@ -41,6 +41,9 @@ let
system = config.nixpkgs.system; 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 in
{ {
@ -128,25 +131,28 @@ in
''; '';
}; };
extraBindsRO = mkOption { extraBinds = mkOption {
type = types.listOf types.str; type = types.listOf types.attrs;
default = []; default = [];
example = [ "/home/alice" ]; example = [ { host = "/home/alice";
container = "/home";
isReadOnly = false; }
];
description = 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 { #extraBindsRW = mkOption {
type = types.listOf types.str; # type = types.listOf types.str;
default = []; # default = [];
example = [ "/home/alice" ]; # example = [ "/home/alice" ];
description = # 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 with read-only permission.
''; # '';
}; #};
}; };
@ -359,11 +365,14 @@ in
AUTO_START=1 AUTO_START=1
''} ''}
EXTRABINDS="${concatMapStrings (d: " --bind-ro=${d}") cfg.extraBindsRO + concatMapStrings (d: " --bind=${d}") cfg.extraBindsRW}" EXTRABINDS="${mkBindFlags cfg.extraBinds}"
''; '';
}) config.containers; }) config.containers;
#"${concatMapStrings (d: " --bind-ro=${d}") cfg.extraBindsRO + concatMapStrings (d: " --bind=${d}") cfg.extraBindsRW}"
# Generate /etc/hosts entries for the containers. # Generate /etc/hosts entries for the containers.
networking.extraHosts = concatStrings (mapAttrsToList (name: cfg: optionalString (cfg.localAddress != null) networking.extraHosts = concatStrings (mapAttrsToList (name: cfg: optionalString (cfg.localAddress != null)
'' ''