vm/windows: Generate mounts from an attribute set.

This is mainly to make it easier to quickly change mappings, without
making room for errors such as typos.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
aszlig 2014-02-16 22:30:40 +01:00
parent 5258bbe4c9
commit 707b7ad1bd
No known key found for this signature in database
GPG Key ID: D0EBD0EC8C2DC961

View File

@ -16,18 +16,28 @@ let
]; ];
}); });
runAndSuspend = runInVM "winvm.img" { runAndSuspend = let
command = lib.concatStringsSep " && " [ drives = {
"net config server /autodisconnect:-1" s = {
"net use S: '\\\\192.168.0.2\\nixstore' /persistent:yes" source = "nixstore";
"net use X: '\\\\192.168.0.2\\xchg' /persistent:yes" target = "/nix/store";
"mkdir -p /nix/store" };
"mount -o bind /cygdrive/s /nix/store" x = {
"echo /cygdrive/s /nix/store none bind 0 0 >> /etc/fstab" source = "xchg";
"mkdir -p /tmp/xchg" target = "/tmp/xchg";
"mount -o bind /cygdrive/x /tmp/xchg" };
"echo /cygdrive/x /tmp/xchg none bind 0 0 >> /etc/fstab" };
genDriveCmds = letter: { source, target }: [
"net use ${letter}: '\\\\192.168.0.2\\${source}' /persistent:yes"
"mkdir -p '${target}'"
"mount -o bind '/cygdrive/${letter}' '${target}'"
"echo '/cygdrive/${letter} ${target} none bind 0 0' >> /etc/fstab"
]; ];
in runInVM "winvm.img" {
command = lib.concatStringsSep " && " ([
"net config server /autodisconnect:-1"
] ++ lib.concatLists (lib.mapAttrsToList genDriveCmds drives));
suspendTo = "state.gz"; suspendTo = "state.gz";
}; };