2020-04-30 23:47:54 +02:00
|
|
|
{ stdenv, lib, autoPatchelfHook, fetchzip, libunwind, libuuid, icu, curl
|
2020-04-06 13:40:22 +02:00
|
|
|
, darwin, makeWrapper, less, openssl_1_1, pam, lttng-ust }:
|
2018-05-30 03:08:50 +02:00
|
|
|
|
|
|
|
let platformString = if stdenv.isDarwin then "osx"
|
|
|
|
else if stdenv.isLinux then "linux"
|
|
|
|
else throw "unsupported platform";
|
2020-10-08 21:08:03 +02:00
|
|
|
platformSha = if stdenv.isDarwin then "0zv02h3njphrs8kgmicy7w40mmhmigdfl38f2dpwrs6z67f8vrm2"
|
2020-11-22 09:14:42 +01:00
|
|
|
else if stdenv.isLinux then "0dka2q8ijg3ryzwmxapf8aq55d0sgaj6jj0rzj2738in9g4w2hbh"
|
2018-05-30 03:08:50 +02:00
|
|
|
else throw "unsupported platform";
|
|
|
|
platformLdLibraryPath = if stdenv.isDarwin then "DYLD_FALLBACK_LIBRARY_PATH"
|
|
|
|
else if stdenv.isLinux then "LD_LIBRARY_PATH"
|
|
|
|
else throw "unsupported platform";
|
2020-04-06 13:40:22 +02:00
|
|
|
libraries = [ libunwind libuuid icu curl openssl_1_1 ] ++
|
2018-11-24 03:13:31 +01:00
|
|
|
(if stdenv.isLinux then [ pam lttng-ust ] else [ darwin.Libsystem ]);
|
2018-05-30 03:08:50 +02:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 14:41:18 +02:00
|
|
|
pname = "powershell";
|
2020-11-22 09:14:42 +01:00
|
|
|
version = "7.1.0";
|
2018-05-30 03:08:50 +02:00
|
|
|
|
|
|
|
src = fetchzip {
|
|
|
|
url = "https://github.com/PowerShell/PowerShell/releases/download/v${version}/powershell-${version}-${platformString}-x64.tar.gz";
|
|
|
|
sha256 = platformSha;
|
|
|
|
stripRoot = false;
|
|
|
|
};
|
|
|
|
|
2018-06-14 00:08:46 +02:00
|
|
|
buildInputs = [ less ] ++ libraries;
|
|
|
|
nativeBuildInputs = [ autoPatchelfHook makeWrapper ];
|
2018-05-30 03:08:50 +02:00
|
|
|
|
2020-04-30 23:47:54 +02:00
|
|
|
installPhase =
|
|
|
|
let
|
|
|
|
ext = stdenv.hostPlatform.extensions.sharedLibrary;
|
|
|
|
in ''
|
2020-04-06 13:40:22 +02:00
|
|
|
pslibs=$out/share/powershell
|
|
|
|
mkdir -p $pslibs
|
|
|
|
|
|
|
|
cp -r * $pslibs
|
|
|
|
|
2020-04-30 23:47:54 +02:00
|
|
|
rm -f $pslibs/libcrypto${ext}.1.0.0
|
|
|
|
rm -f $pslibs/libssl${ext}.1.0.0
|
2020-04-06 13:40:22 +02:00
|
|
|
|
2020-04-30 23:47:54 +02:00
|
|
|
ls $pslibs
|
|
|
|
'' + lib.optionalString (!stdenv.isDarwin) ''
|
|
|
|
patchelf --replace-needed libcrypto${ext}.1.0.0 libcrypto${ext}.1.1 $pslibs/libmi.so
|
|
|
|
patchelf --replace-needed libssl${ext}.1.0.0 libssl${ext}.1.1 $pslibs/libmi.so
|
|
|
|
'' + ''
|
|
|
|
|
|
|
|
mkdir -p $out/bin
|
2020-04-06 13:40:22 +02:00
|
|
|
|
|
|
|
makeWrapper $pslibs/pwsh $out/bin/pwsh \
|
2020-02-22 21:58:33 +01:00
|
|
|
--prefix ${platformLdLibraryPath} : "${stdenv.lib.makeLibraryPath libraries}" \
|
|
|
|
--set TERM xterm --set POWERSHELL_TELEMETRY_OPTOUT 1 --set DOTNET_CLI_TELEMETRY_OPTOUT 1
|
2018-05-30 03:08:50 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
dontStrip = true;
|
|
|
|
|
2020-04-30 23:47:54 +02:00
|
|
|
doInstallCheck = true;
|
2020-06-05 23:52:09 +02:00
|
|
|
installCheckPhase = ''
|
2020-04-30 23:47:54 +02:00
|
|
|
$out/bin/pwsh --help > /dev/null
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
2020-04-06 13:40:22 +02:00
|
|
|
description = "Powerful cross-platform (Windows, Linux, and macOS) shell and scripting language based on .NET";
|
2020-02-22 21:58:33 +01:00
|
|
|
homepage = "https://github.com/PowerShell/PowerShell";
|
2020-04-06 13:40:22 +02:00
|
|
|
maintainers = with maintainers; [ yrashk srgom ];
|
2020-02-22 21:58:33 +01:00
|
|
|
platforms = [ "x86_64-darwin" "x86_64-linux" ];
|
2018-05-30 03:08:50 +02:00
|
|
|
license = with licenses; [ mit ];
|
|
|
|
};
|
|
|
|
|
2020-02-22 21:58:33 +01:00
|
|
|
passthru = {
|
|
|
|
shellPath = "/bin/pwsh";
|
2019-12-31 19:25:47 +01:00
|
|
|
};
|
|
|
|
|
2018-05-30 03:08:50 +02:00
|
|
|
}
|