Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 21.05 77 lines 2.7 kB view raw
1{ stdenv, lib, autoPatchelfHook, fetchzip, libunwind, libuuid, icu, curl 2, darwin, makeWrapper, less, openssl_1_1, pam, lttng-ust }: 3 4let platformString = if stdenv.isDarwin then "osx" 5 else if stdenv.isLinux then "linux" 6 else throw "unsupported platform"; 7 platformSha = if stdenv.isDarwin then "0w44ws8b6zfixf7xz93hmplqsx18279n9x8j77y4rbzs13fldvsn" 8 else if stdenv.isLinux then "0xm7l49zhkz2fly3d751kjd5cy3ws9zji9i0061lkd06dvkch7jy" 9 else throw "unsupported platform"; 10 platformLdLibraryPath = if stdenv.isDarwin then "DYLD_FALLBACK_LIBRARY_PATH" 11 else if stdenv.isLinux then "LD_LIBRARY_PATH" 12 else throw "unsupported platform"; 13 libraries = [ libunwind libuuid icu curl openssl_1_1 ] ++ 14 (if stdenv.isLinux then [ pam lttng-ust ] else [ darwin.Libsystem ]); 15in 16stdenv.mkDerivation rec { 17 pname = "powershell"; 18 version = "7.1.3"; 19 20 src = fetchzip { 21 url = "https://github.com/PowerShell/PowerShell/releases/download/v${version}/powershell-${version}-${platformString}-x64.tar.gz"; 22 sha256 = platformSha; 23 stripRoot = false; 24 }; 25 26 buildInputs = [ less ] ++ libraries; 27 nativeBuildInputs = [ autoPatchelfHook makeWrapper ]; 28 29 installPhase = 30 let 31 ext = stdenv.hostPlatform.extensions.sharedLibrary; 32 in '' 33 pslibs=$out/share/powershell 34 mkdir -p $pslibs 35 36 cp -r * $pslibs 37 38 rm -f $pslibs/libcrypto${ext}.1.0.0 39 rm -f $pslibs/libssl${ext}.1.0.0 40 41 # At least the 7.1.3-osx package does not have the executable bit set. 42 chmod a+x $pslibs/pwsh 43 44 ls $pslibs 45 '' + lib.optionalString (!stdenv.isDarwin) '' 46 patchelf --replace-needed libcrypto${ext}.1.0.0 libcrypto${ext}.1.1 $pslibs/libmi.so 47 patchelf --replace-needed libssl${ext}.1.0.0 libssl${ext}.1.1 $pslibs/libmi.so 48 '' + '' 49 50 mkdir -p $out/bin 51 52 makeWrapper $pslibs/pwsh $out/bin/pwsh \ 53 --prefix ${platformLdLibraryPath} : "${lib.makeLibraryPath libraries}" \ 54 --set TERM xterm --set POWERSHELL_TELEMETRY_OPTOUT 1 --set DOTNET_CLI_TELEMETRY_OPTOUT 1 55 ''; 56 57 dontStrip = true; 58 59 doInstallCheck = true; 60 installCheckPhase = '' 61 # May need a writable home, seen on Darwin. 62 HOME=$TMP $out/bin/pwsh --help > /dev/null 63 ''; 64 65 meta = with lib; { 66 description = "Powerful cross-platform (Windows, Linux, and macOS) shell and scripting language based on .NET"; 67 homepage = "https://github.com/PowerShell/PowerShell"; 68 maintainers = with maintainers; [ yrashk srgom ]; 69 platforms = [ "x86_64-darwin" "x86_64-linux" ]; 70 license = with licenses; [ mit ]; 71 }; 72 73 passthru = { 74 shellPath = "/bin/pwsh"; 75 }; 76 77}