nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 153 lines 4.1 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 less, 6 makeWrapper, 7 autoPatchelfHook, 8 curl, 9 icu, 10 libuuid, 11 libunwind, 12 openssl, 13 lttng-ust, 14 pam, 15 testers, 16 powershell, 17 writeShellScript, 18 common-updater-scripts, 19 gnused, 20 jq, 21}: 22 23let 24 ext = stdenv.hostPlatform.extensions.sharedLibrary; 25 platformLdLibraryPath = 26 { 27 darwin = "DYLD_FALLBACK_LIBRARY_PATH"; 28 linux = "LD_LIBRARY_PATH"; 29 } 30 .${stdenv.hostPlatform.parsed.kernel.name} or (throw "unsupported platform"); 31in 32stdenv.mkDerivation rec { 33 pname = "powershell"; 34 version = "7.5.4"; 35 36 src = 37 passthru.sources.${stdenv.hostPlatform.system} 38 or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); 39 40 sourceRoot = "source"; 41 42 unpackPhase = '' 43 runHook preUnpack 44 mkdir -p "$sourceRoot" 45 tar xf $src --directory="$sourceRoot" 46 runHook postUnpack 47 ''; 48 49 strictDeps = true; 50 51 nativeBuildInputs = [ 52 less 53 makeWrapper 54 ] 55 ++ lib.optionals stdenv.hostPlatform.isLinux [ 56 autoPatchelfHook 57 ]; 58 59 buildInputs = [ 60 curl 61 icu 62 libuuid 63 libunwind 64 openssl 65 ] 66 ++ lib.optionals stdenv.hostPlatform.isLinux [ 67 lttng-ust 68 pam 69 ]; 70 71 installPhase = '' 72 runHook preInstall 73 74 mkdir -p $out/{bin,share/powershell} 75 cp -R * $out/share/powershell 76 chmod +x $out/share/powershell/pwsh 77 makeWrapper $out/share/powershell/pwsh $out/bin/pwsh \ 78 --prefix ${platformLdLibraryPath} : "${lib.makeLibraryPath buildInputs}" \ 79 --set TERM xterm \ 80 --set POWERSHELL_TELEMETRY_OPTOUT 1 \ 81 --set DOTNET_CLI_TELEMETRY_OPTOUT 1 82 83 '' 84 + lib.optionalString stdenv.hostPlatform.isLinux '' 85 patchelf --replace-needed liblttng-ust${ext}.0 liblttng-ust${ext}.1 $out/share/powershell/libcoreclrtraceptprovider.so 86 87 '' 88 + '' 89 runHook postInstall 90 ''; 91 92 dontStrip = true; 93 94 passthru = { 95 shellPath = "/bin/pwsh"; 96 sources = { 97 aarch64-darwin = fetchurl { 98 url = "https://github.com/PowerShell/PowerShell/releases/download/v${version}/powershell-${version}-osx-arm64.tar.gz"; 99 hash = "sha256-OqrdfKYvHk2+WRRbavJOkm1h+NqKR4K8U15QDBhBNfA="; 100 }; 101 aarch64-linux = fetchurl { 102 url = "https://github.com/PowerShell/PowerShell/releases/download/v${version}/powershell-${version}-linux-arm64.tar.gz"; 103 hash = "sha256-SzLUy4akPfuD1WAtApQpW/Ivr7+eB4XRqu+Bk4zakvg="; 104 }; 105 x86_64-darwin = fetchurl { 106 url = "https://github.com/PowerShell/PowerShell/releases/download/v${version}/powershell-${version}-osx-x64.tar.gz"; 107 hash = "sha256-zRagTBuZzay9wDN7D9DaUNvxqLToQ3vLTKkRjvcpIRo="; 108 }; 109 x86_64-linux = fetchurl { 110 url = "https://github.com/PowerShell/PowerShell/releases/download/v${version}/powershell-${version}-linux-x64.tar.gz"; 111 hash = "sha256-H9eYP+VsqeYjPxJpJe2yS/a2sz41a2mZbZJcTblOL+8="; 112 }; 113 }; 114 tests.version = testers.testVersion { 115 package = powershell; 116 command = "HOME=$(mktemp -d) pwsh --version"; 117 }; 118 updateScript = writeShellScript "update-powershell" '' 119 set -o errexit 120 export PATH="${ 121 lib.makeBinPath [ 122 common-updater-scripts 123 curl 124 gnused 125 jq 126 ] 127 }" 128 NEW_VERSION=$(curl -s https://api.github.com/repos/PowerShell/PowerShell/releases/latest | jq .tag_name --raw-output | sed -e 's/v//') 129 130 if [[ "${version}" = "$NEW_VERSION" ]]; then 131 echo "The new version same as the old version." 132 exit 0 133 fi 134 135 for platform in ${lib.escapeShellArgs meta.platforms}; do 136 update-source-version "powershell" "$NEW_VERSION" --ignore-same-version --source-key="sources.$platform" 137 done 138 ''; 139 }; 140 141 meta = { 142 description = "Powerful cross-platform (Windows, Linux, and macOS) shell and scripting language based on .NET"; 143 homepage = "https://microsoft.com/PowerShell"; 144 license = lib.licenses.mit; 145 mainProgram = "pwsh"; 146 maintainers = with lib.maintainers; [ wegank ]; 147 platforms = builtins.attrNames passthru.sources; 148 sourceProvenance = with lib.sourceTypes; [ 149 binaryBytecode 150 binaryNativeCode 151 ]; 152 }; 153}