extraBindsRO/extraBindsRW

This commit is contained in:
Ian-Woo Kim 2015-05-24 16:31:59 +00:00
parent 7b49289c74
commit cac38c8664

View file

@ -127,6 +127,27 @@ in
Wether the container is automatically started at boot-time. Wether the container is automatically started at boot-time.
''; '';
}; };
extraBindsRO = 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.
'';
};
}; };
config = mkMerge config = mkMerge
@ -230,12 +251,15 @@ in
fi fi
''} ''}
# Run systemd-nspawn without startup notification (we'll # Run systemd-nspawn without startup notification (we'll
# wait for the container systemd to signal readiness). # wait for the container systemd to signal readiness).
EXIT_ON_REBOOT=1 NOTIFY_SOCKET= \ EXIT_ON_REBOOT=1 NOTIFY_SOCKET= \
exec ${config.systemd.package}/bin/systemd-nspawn \ exec ${config.systemd.package}/bin/systemd-nspawn \
--keep-unit \ --keep-unit \
-M "$INSTANCE" -D "$root" $extraFlags \ -M "$INSTANCE" -D "$root" $extraFlags \
$EXTRABINDS \
--bind-ro=/nix/store \ --bind-ro=/nix/store \
--bind-ro=/nix/var/nix/db \ --bind-ro=/nix/var/nix/db \
--bind-ro=/nix/var/nix/daemon-socket \ --bind-ro=/nix/var/nix/daemon-socket \
@ -334,6 +358,9 @@ in
${optionalString cfg.autoStart '' ${optionalString cfg.autoStart ''
AUTO_START=1 AUTO_START=1
''} ''}
EXTRABINDS="${concatMapStrings (d: " --bind-ro=${d}") cfg.extraBindsRO + concatMapStrings (d: " --bind=${d}") cfg.extraBindsRW}"
''; '';
}) config.containers; }) config.containers;