diff options
author | aszlig <aszlig@redmoonstudios.org> | 2014-02-16 22:30:40 +0100 |
---|---|---|
committer | aszlig <aszlig@redmoonstudios.org> | 2014-02-26 04:51:59 +0100 |
commit | 707b7ad1bddf8b95ca1348260dea132b0514089d (patch) | |
tree | 3cfe054fe0c383ec7f6aa9e818a83031693cd12f /pkgs/build-support/vm | |
parent | 5258bbe4c97113dfa663a32408691fc93ee2dd9b (diff) | |
download | nixlib-707b7ad1bddf8b95ca1348260dea132b0514089d.tar nixlib-707b7ad1bddf8b95ca1348260dea132b0514089d.tar.gz nixlib-707b7ad1bddf8b95ca1348260dea132b0514089d.tar.bz2 nixlib-707b7ad1bddf8b95ca1348260dea132b0514089d.tar.lz nixlib-707b7ad1bddf8b95ca1348260dea132b0514089d.tar.xz nixlib-707b7ad1bddf8b95ca1348260dea132b0514089d.tar.zst nixlib-707b7ad1bddf8b95ca1348260dea132b0514089d.zip |
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>
Diffstat (limited to 'pkgs/build-support/vm')
-rw-r--r-- | pkgs/build-support/vm/windows/default.nix | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/pkgs/build-support/vm/windows/default.nix b/pkgs/build-support/vm/windows/default.nix index bb0833beec28..8ca31bc39d7b 100644 --- a/pkgs/build-support/vm/windows/default.nix +++ b/pkgs/build-support/vm/windows/default.nix @@ -16,18 +16,28 @@ let ]; }); - runAndSuspend = runInVM "winvm.img" { - command = lib.concatStringsSep " && " [ - "net config server /autodisconnect:-1" - "net use S: '\\\\192.168.0.2\\nixstore' /persistent:yes" - "net use X: '\\\\192.168.0.2\\xchg' /persistent:yes" - "mkdir -p /nix/store" - "mount -o bind /cygdrive/s /nix/store" - "echo /cygdrive/s /nix/store none bind 0 0 >> /etc/fstab" - "mkdir -p /tmp/xchg" - "mount -o bind /cygdrive/x /tmp/xchg" - "echo /cygdrive/x /tmp/xchg none bind 0 0 >> /etc/fstab" + runAndSuspend = let + drives = { + s = { + source = "nixstore"; + target = "/nix/store"; + }; + x = { + source = "xchg"; + target = "/tmp/xchg"; + }; + }; + + 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"; }; |