about summary refs log tree commit diff
path: root/pkgs/build-support/vm/windows/install/default.nix
blob: fec7dac0714eeeed96b11d677f8f558637f73df6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{ isoFile
, productKey
, sshPublicKey
}:

let
  inherit (import <nixpkgs> {}) lib runCommand;

  bootstrapAfterLogin = runCommand "bootstrap.sh" {} ''
    cat > "$out" <<EOF
    mkdir -p ~/.ssh
    cat > ~/.ssh/authorized_keys <<PUBKEY
    $(cat "${sshPublicKey}")
    PUBKEY
    ssh-host-config -y -c 'binmode ntsec' -w dummy
    cygrunsrv -S sshd

    net use S: '\\192.168.0.2\nixstore'
    mkdir -p /nix/store
    mount -o bind /cygdrives/s /nix/store
    EOF
  '';

  packages = [ "openssh" ];

in {
  iso = import ../cygwin-iso {
    inherit packages;
    extraContents = lib.singleton {
      source = bootstrapAfterLogin;
      target = "bootstrap.sh";
    };
  };

  floppy = import ./unattended-image.nix {
    cygwinPackages = packages;
    inherit productKey;
  };
}