2020-06-14 12:15:00 +08:00
{ pkgs }:
2020-06-18 01:58:09 +08:00
let
wfvm = import ./.. { inherit pkgs ; } ;
in
2020-06-18 18:19:43 +08:00
rec {
2020-06-14 12:15:00 +08:00
anaconda3 = {
name = " A n a c o n d a 3 " ;
script = let
Anaconda3 = pkgs . fetchurl {
name = " A n a c o n d a 3 . e x e " ;
2020-06-16 19:46:50 +08:00
url = " h t t p s : / / r e p o . a n a c o n d a . c o m / a r c h i v e / A n a c o n d a 3 - 2 0 2 0 . 0 2 - W i n d o w s - x 8 6 _ 6 4 . e x e " ;
sha256 = " 0 n 3 1 l 8 l 8 9 j r j r b z b i f x b j n r 3 g 3 2 0 l y 9 i 4 z f y q b f 3 l 9 b l f 4 y g b h l 3 " ;
2020-06-14 12:15:00 +08:00
} ;
2020-06-17 23:40:49 +08:00
in
''
2020-06-14 12:15:00 +08:00
ln - s $ { Anaconda3 } ./Anaconda3.exe
2020-06-17 23:40:49 +08:00
win-put Anaconda3 . exe .
2020-06-14 12:15:00 +08:00
echo Running Anaconda installer . . .
win-exec ' start /wait " " . \ Anaconda3 . exe /S /D = % UserProfile % \ Anaconda3'
echo Anaconda installer finished
2020-06-17 23:40:49 +08:00
'' ;
2020-06-14 12:15:00 +08:00
} ;
msys2 = {
name = " M S Y S 2 " ;
buildInputs = [ pkgs . expect ] ;
script = let
2020-06-17 17:08:35 +08:00
msys2 = pkgs . fetchurl {
2020-06-14 12:15:00 +08:00
name = " m s y s 2 . e x e " ;
url = " h t t p s : / / g i t h u b . c o m / m s y s 2 / m s y s 2 - i n s t a l l e r / r e l e a s e s / d o w n l o a d / 2 0 2 0 - 0 6 - 0 2 / m s y s 2 - x 8 6 _ 6 4 - 2 0 2 0 0 6 0 2 . e x e " ;
sha256 = " 1 m s w l f y b v k 4 2 v d r 4 r 8 5 d y p g k w h r p 5 f f 4 7 g c b x g j q w q 8 6 y m 4 4 x z d 4 " ;
} ;
msys2-auto-install = pkgs . fetchurl {
url = " h t t p s : / / r a w . g i t h u b u s e r c o n t e n t . c o m / m s y s 2 / m s y s 2 - i n s t a l l e r / m a s t e r / a u t o - i n s t a l l . j s " ;
sha256 = " 0 w w 4 8 x c h 2 q 4 2 7 c 5 8 a r g 5 l l a k f k f z h 3 k b 3 2 k a h w p l p 0 s 7 j c 8 2 2 4 g 7 " ;
} ;
in ''
ln - s $ { msys2 } ./msys2.exe
ln - s $ { msys2-auto-install } ./auto-install.js
2020-06-17 23:40:49 +08:00
win-put msys2 . exe .
win-put auto-install . js .
2020-06-14 12:15:00 +08:00
echo Running MSYS2 installer . . .
# work around MSYS2 installer bug that prevents it from closing at the end of unattended install
expect - c ' set timeout 600 ; spawn win-exec " . \\ m s y s 2 . e x e - - s c r i p t a u t o - i n s t a l l . j s - v I n s t a l l P r e f i x = C : \\ m s y s 6 4 " ; expect FinishedPageCallback { close } '
echo MSYS2 installer finished
'' ;
} ;
msys2-packages = {
name = " M S Y S 2 - p a c k a g e s " ;
script = let
msys-packages = import ./msys_packages.nix { inherit pkgs ; } ;
msys-packages-put = pkgs . lib . strings . concatStringsSep " \n "
2020-06-17 23:40:49 +08:00
( map ( package : '' w i n - p u t ${ package } ' m s y s p a c k a g e s ' '' ) msys-packages ) ;
2020-06-14 12:15:00 +08:00
in
# Windows command line is so shitty it can't even do glob expansion. Why do people use Windows?
''
win-exec ' mkdir msyspackages'
$ { msys-packages-put }
cat > installmsyspackages . bat < < EOF
set MSYS = c : \ msys64
set ARCH = 64
set PATH = % MSYS % \ usr \ bin ; % MSYS % \ mingw % ARCH % \ bin ; % PATH %
2020-06-15 00:28:31 +08:00
bash - c " p a c m a n - U - - n o c o n f i r m C : / U s e r s / w f v m / m s y s p a c k a g e s / * "
2020-06-14 12:15:00 +08:00
EOF
2020-06-17 23:40:49 +08:00
win-put installmsyspackages . bat .
2020-06-14 12:15:00 +08:00
win-exec installmsyspackages
'' ;
} ;
2020-06-17 21:51:36 +08:00
cmake = {
name = " C M a k e " ;
script = let
cmake = pkgs . fetchurl {
name = " c m a k e . m s i " ;
url = " h t t p s : / / g i t h u b . c o m / K i t w a r e / C M a k e / r e l e a s e s / d o w n l o a d / v 3 . 1 8 . 0 - r c 1 / c m a k e - 3 . 1 8 . 0 - r c 1 - w i n 6 4 - x 6 4 . m s i " ;
sha256 = " 1 n 3 2 j z b g 9 w 3 v f b v y i 9 j q i j z 9 7 g n 1 z s k 1 w 5 2 2 6 w l r x d 2 a 9 d 4 w 1 h r n " ;
} ;
in
''
ln - s $ { cmake } cmake . msi
2020-06-17 23:40:49 +08:00
win-put cmake . msi .
2020-06-17 21:51:36 +08:00
win-exec " m s i e x e c . e x e / q / i c m a k e . m s i A D D _ C M A K E _ T O _ P A T H = S y s t e m "
'' ;
} ;
2020-06-17 17:45:57 +08:00
msvc = {
2020-06-18 18:19:43 +08:00
# This is quite fragile and annoying, M$ have done their best to make the VS installation process shitty.
# The instructions here are vaguely correct:
2020-06-18 01:58:09 +08:00
# https://docs.microsoft.com/en-us/visualstudio/install/create-an-offline-installation-of-visual-studio?view=vs-2019
2020-06-18 18:19:43 +08:00
# We are giving the VM network access here, so of course the M$ spyware does not miss the opportunity to phone home and cause problems.
# Split the download into two, so that each part completes before M$ Windoze 10 activation crap kicks in.
# TODO: Probably it is possible to block access specifically to the M$ activation server instead and still be able to download VS (more robust, better privacy).
2020-06-17 17:45:57 +08:00
name = " M S V C " ;
script = let
2020-06-18 01:58:09 +08:00
bootstrapper = pkgs . fetchurl {
2020-06-18 15:34:53 +08:00
url = " h t t p s : / / d o w n l o a d . v i s u a l s t u d i o . m i c r o s o f t . c o m / d o w n l o a d / p r / a c 0 5 c 4 f 5 - 0 d a 1 - 4 2 9 f - 8 7 0 1 - c e 5 0 9 a c 6 9 9 2 6 / c c 9 5 5 6 1 3 7 c 6 6 a 3 7 3 6 7 0 3 7 6 d 6 d b 2 f c 5 c 5 c 9 3 7 b 2 b 0 b f 7 b 3 d 3 c a c 1 1 c 6 9 e 3 3 6 1 5 5 1 1 / v s _ C o m m u n i t y . e x e " ;
sha256 = " 0 4 a m c 4 r r x i h i m h y 3 s y x z n 2 r 3 g j f 5 q l p x p m k n 0 d k p 7 8 v 6 g h 9 m d 5 f c " ;
2020-06-17 17:45:57 +08:00
} ;
2020-06-18 01:58:09 +08:00
# This touchy-feely "community" piece of trash seems deliberately crafted to break Wine, so we use the VM to run it.
2020-06-18 18:19:43 +08:00
download-1 = wfvm . utils . wfvm-run {
name = " d o w n l o a d - v s - 1 " ;
2020-06-18 01:58:09 +08:00
image = wfvm . makeWindowsImage { } ;
isolateNetwork = false ;
script =
''
ln - s $ { bootstrapper } vs_Community . exe
$ { wfvm . utils . win-put } /bin/win-put vs_Community . exe
rm vs_Community . exe
2020-06-18 18:19:43 +08:00
echo " R u n n i n g V i s u a l S t u d i o i n s t a l l e r i n d o w n l o a d m o d e . . . "
2020-06-18 15:34:53 +08:00
$ { wfvm . utils . win-exec } /bin/win-exec " v s _ C o m m u n i t y . e x e - - q u i e t - - n o r e s t a r t - - l a y o u t c : \v s l a y o u t - - a d d M i c r o s o f t . V i s u a l S t u d i o . W o r k l o a d . N a t i v e D e s k t o p - - i n c l u d e R e c o m m e n d e d - - l a n g e n - U S "
2020-06-18 18:19:43 +08:00
echo " R e t r i e v i n g V S l a y o u t f r o m V M . . . "
2020-06-18 11:08:09 +08:00
$ { wfvm . utils . win-get } /bin/win-get /c : /vslayout
2020-06-18 01:58:09 +08:00
'' ;
} ;
2020-06-18 18:19:43 +08:00
cache-1 = pkgs . stdenv . mkDerivation {
name = " v s - 1 " ;
2020-06-17 17:45:57 +08:00
outputHashAlgo = " s h a 2 5 6 " ;
outputHashMode = " r e c u r s i v e " ;
2020-06-18 15:34:53 +08:00
outputHash = " 0 f p 7 a 6 p r j p 8 n 8 s i r w d a y 1 3 w i s 3 x y z h m r w i 3 7 7 y 3 x 8 9 n x z y s p 0 m n v " ;
2020-06-17 17:45:57 +08:00
phases = [ " b u i l d P h a s e " ] ;
2020-06-18 18:19:43 +08:00
buildInputs = [ download-1 ] ;
2020-06-18 01:58:09 +08:00
buildPhase =
''
mkdir $ out
cd $ out
2020-06-18 18:50:01 +08:00
wfvm-run-download-vs-1
2020-06-18 01:58:09 +08:00
'' ;
2020-06-17 17:45:57 +08:00
} ;
2020-06-18 18:19:43 +08:00
download-2 = wfvm . utils . wfvm-run {
name = " d o w n l o a d - v s - 2 " ;
image = wfvm . makeWindowsImage { } ;
isolateNetwork = false ;
script =
''
echo " S e n d i n g p r e v i o u s V S l a y o u t t o V M . . . "
# If we don't do that, it breaks on reception with permission issues. Unfortunately, it seems there is no way to tell sftp
# not to set files to read-only mode on the Windows VM.
cp - - no-preserve = mode , ownership - R $ { cache-1 } /vslayout vslayout
$ { wfvm . utils . win-put } /bin/win-put vslayout /c : /
rm - rf vslayout
echo " R u n n i n g V i s u a l S t u d i o i n s t a l l e r i n d o w n l o a d m o d e . . . "
$ { wfvm . utils . win-exec } /bin/win-exec " c d \v s l a y o u t & & v s _ C o m m u n i t y . e x e - - q u i e t - - n o r e s t a r t - - l a y o u t c : \v s l a y o u t - - a d d M i c r o s o f t . V i s u a l S t u d i o . C o m p o n e n t . W i n d o w s 8 1 S D K - - i n c l u d e R e c o m m e n d e d - - l a n g e n - U S "
echo " R e t r i e v i n g V S l a y o u t f r o m V M . . . "
$ { wfvm . utils . win-get } /bin/win-get /c : /vslayout
'' ;
} ;
cache-2 = pkgs . stdenv . mkDerivation {
name = " v s - 2 " ;
outputHashAlgo = " s h a 2 5 6 " ;
outputHashMode = " r e c u r s i v e " ;
outputHash = " 0 w g w n q 1 4 2 m m 3 r j g 1 f m p i 5 a a d b n 1 m 7 9 8 d a 1 4 g 4 7 p r c d 1 m 1 y n p 7 l 0 p " ;
phases = [ " b u i l d P h a s e " ] ;
buildInputs = [ download-2 ] ;
buildPhase =
''
mkdir $ out
cd $ out
wfvm-run-download-vs-2
'' ;
} ;
2020-06-17 17:45:57 +08:00
in
''
2020-06-18 18:19:43 +08:00
ln - s $ { cache-2 } /vslayout vslayout
2020-06-18 14:16:56 +08:00
win-put vslayout /c : /
echo " R u n n i n g V i s u a l S t u d i o i n s t a l l e r "
win-exec " c d \v s l a y o u t & & s t a r t / w a i t v s _ C o m m u n i t y . e x e - - p a s s i v e - - w a i t & & e c h o % e r r o r l e v e l % "
2020-06-17 17:45:57 +08:00
'' ;
} ;
2020-06-14 12:15:00 +08:00
}