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