19 common-updater-scripts,
25 ext = stdenv.hostPlatform.extensions.sharedLibrary;
26 platformLdLibraryPath =
28 darwin = "DYLD_FALLBACK_LIBRARY_PATH";
29 linux = "LD_LIBRARY_PATH";
31 .${stdenv.hostPlatform.parsed.kernel.name} or (throw "unsupported platform");
33 stdenv.mkDerivation rec {
38 passthru.sources.${stdenv.hostPlatform.system}
39 or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
50 ++ lib.optionals stdenv.hostPlatform.isLinux [
62 ++ lib.optionals stdenv.hostPlatform.isDarwin [
65 ++ lib.optionals stdenv.hostPlatform.isLinux [
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}" \
80 --set POWERSHELL_TELEMETRY_OPTOUT 1 \
81 --set DOTNET_CLI_TELEMETRY_OPTOUT 1
84 + lib.optionalString stdenv.hostPlatform.isLinux ''
85 patchelf --replace-needed liblttng-ust${ext}.0 liblttng-ust${ext}.1 $out/share/powershell/libcoreclrtraceptprovider.so
95 shellPath = "/bin/pwsh";
97 aarch64-darwin = fetchurl {
98 url = "https://github.com/PowerShell/PowerShell/releases/download/v${version}/powershell-${version}-osx-arm64.tar.gz";
99 hash = "sha256-pILWaHh++Yw38KWnaWEH3/2z3DQMW+PRwVPsnSOQcqg=";
101 aarch64-linux = fetchurl {
102 url = "https://github.com/PowerShell/PowerShell/releases/download/v${version}/powershell-${version}-linux-arm64.tar.gz";
103 hash = "sha256-wBWbA+hfRK4edpeBigEVWNpsgT0KroSL9awTv0NdhiQ=";
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-ehja7RBbfPyAv4zAB2L+eZAQXdI/lRzDLOt0RlFlDj0=";
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-b2AVIDxHgGxcxETBnY7QGWleYQ+9lIFUJkv5yo4VdWE=";
114 tests.version = testers.testVersion {
115 package = powershell;
116 command = "HOME=$(mktemp -d) pwsh --version";
118 updateScript = writeShellScript "update-powershell" ''
122 common-updater-scripts
128 NEW_VERSION=$(curl -s https://api.github.com/repos/PowerShell/PowerShell/releases/latest | jq .tag_name --raw-output | sed -e 's/v//')
130 if [[ "${version}" = "$NEW_VERSION" ]]; then
131 echo "The new version same as the old version."
135 for platform in ${lib.escapeShellArgs meta.platforms}; do
136 update-source-version "powershell" "$NEW_VERSION" --ignore-same-version --source-key="sources.$platform"
142 description = "Powerful cross-platform (Windows, Linux, and macOS) shell and scripting language based on .NET";
143 homepage = "https://microsoft.com/PowerShell";
144 license = licenses.mit;
145 mainProgram = "pwsh";
146 maintainers = with maintainers; [ wegank ];
147 platforms = builtins.attrNames passthru.sources;
148 sourceProvenance = with sourceTypes; [