-
Notifications
You must be signed in to change notification settings - Fork 15
/
install.ps1
102 lines (87 loc) · 2.36 KB
/
install.ps1
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
param (
[parameter(mandatory = $false)][Arch]$Arch,
[parameter(mandatory = $false)][switch]$NoPATH,
[parameter(mandatory = $false)][string]$NwjsPath,
[parameter(mandatory = $false)][switch]$WhatIf,
[parameter(mandatory = $false)][string]$DownloadPath
)
Add-Type -TypeDefinition @"
public enum Arch
{ x64
, x86
}
"@
Add-Type -AssemblyName System.IO.Compression.FileSystem
function Unzip
{
param([string]$zipfile, [string]$outpath)
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipfile, $outpath)
}
function Push-Env($path) {
[Environment]::SetEnvironmentVariable
("Path", $env:Path + ";$path", [System.EnvironmentVariableTarget]::Machine)
}
function Log($what){
Write-Output "[haskell-editor-setup]: $what"
}
if($WhatIf){
Log "WhatIf mode activated. No commands will be executed"
}
if([string]::IsNullOrEmpty($NwjsPath)){
$NwjsPath = "$env:APPDATA\NWJS\"
}
if([string]::IsNullOrEmpty($DownloadPath)){
$DownloadPath=$env:TEMP
}
# install nwjs
# add it to path if !$NoPATH
if($Arch -eq [Arch]::x64){
$nwjs = "https://dl.nwjs.io/v0.46.2/nwjs-sdk-v0.46.2-win-x64.zip"
} else {
$nwjs = "https://dl.nwjs.io/v0.46.2/nwjs-sdk-v0.46.2-win-ia32.zip"
}
Log "downloading nwjs..."
if(!($WhatIf)){
curl -o "$DownloadPath\nwjs.zip" $nwjs
}
Log "nwjs downloaded in $DownloadPath"
Log "unzipping nwjs"
if(!($WhatIf)){
Unzip "$DownloadPath\nwjs.zip" $NwjsPath
}
Log "nwjs unzipped in $NwjsPath"
if(!($NoPATH)){
if(!($WhatIf)){
$ActualNwjsPath = (gci $NwjsPath)[0]
Log "$ActualNwjsPath will be added to PATH"
Push-Env $ActualNwjsPath
}
} else {
Log "PATH will not be modified"
}
# install choco
Log "installing choco..."
if(!($WhatIf)){
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072;
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
}
Log "choco installed"
# install ghc
Log "installing ghc 8.6.5 through choco..."
if(!($WhatIf)){
choco install ghc --version=8.6.5
}
Log "ghc 8.6.5 installed"
# install cabal
Log "installing cabal 3.0.0.0 through choco..."
if(!($WhatIf)){
choco install cabal --version=3.0.0.0
}
Log "cabal 3.0.0.0 installed"
# check that cabal version is 3.0.0.0
Log "printing cabal version..."
if(!($WhatIf)){
cabal --version
}
Log "setup done!"