mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 06:53:01 +00:00
vm/windows: Add new runInWindowsVM function.
This function is quite similar to runInLinuxVM, but also ensures that the builder is run decoupled of the Nix store and using the userland inside the VM. We're now picking up the environment variables saved in the previous commit. The reason we suppress all errors from the source operation is that it would emit a ton of errors because we're trying to set read-only variables. Also, detecting whether the origBuilder is using the default builder from the stdenv is currently a bit of a workaround until we have a specialized pseudo-cross-stdenv someday in the future[TM]. Signed-off-by: aszlig <aszlig@redmoonstudios.org>
This commit is contained in:
parent
dd8b0fcf52
commit
b01c9624cf
@ -60,11 +60,39 @@ let
|
||||
inherit command;
|
||||
};
|
||||
|
||||
runFromSuspended = command: stdenv.mkDerivation {
|
||||
name = "cygwin-vm-run";
|
||||
buildCommand = ''
|
||||
${resumeAndRun command}
|
||||
'';
|
||||
};
|
||||
builder = ''
|
||||
source /tmp/xchg/saved-env 2> /dev/null || true
|
||||
export NIX_STORE=/nix/store
|
||||
export NIX_BUILD_TOP=/tmp
|
||||
export TMPDIR=/tmp
|
||||
export PATH=/empty
|
||||
cd "$NIX_BUILD_TOP"
|
||||
exec $origBuilder $origArgs
|
||||
'';
|
||||
|
||||
in runFromSuspended "uname -a"
|
||||
in {
|
||||
runInWindowsVM = drv: let
|
||||
newDrv = drv.override {
|
||||
stdenv = drv.stdenv.override {
|
||||
shell = "/bin/sh";
|
||||
};
|
||||
};
|
||||
in lib.overrideDerivation drv (attrs: {
|
||||
requiredSystemFeatures = [ "kvm" ];
|
||||
buildur = "${stdenv.shell}";
|
||||
args = ["-e" (resumeAndRun builder)];
|
||||
origArgs = attrs.args;
|
||||
origBuilder = if attrs.builder == attrs.stdenv.shell
|
||||
then "/bin/sh"
|
||||
else attrs.builder;
|
||||
|
||||
postHook = ''
|
||||
PATH=/usr/bin:/bin:/usr/sbin:/sbin
|
||||
SHELL=/bin/sh
|
||||
eval "$origPostHook"
|
||||
'';
|
||||
|
||||
origPostHook = attrs.postHook or "";
|
||||
fixupPhase = ":";
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user