18 , common-updater-scripts
24 ext = stdenv.hostPlatform.extensions.sharedLibrary;
25 platformLdLibraryPath = {
26 darwin = "DYLD_FALLBACK_LIBRARY_PATH";
27 linux = "LD_LIBRARY_PATH";
28 }.${stdenv.hostPlatform.parsed.kernel.name} or (throw "unsupported platform");
30 stdenv.mkDerivation rec {
34 src = passthru.sources.${stdenv.hostPlatform.system}
35 or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
44 ] ++ lib.optionals stdenv.isLinux [
54 ] ++ lib.optionals stdenv.isDarwin [
56 ] ++ lib.optionals stdenv.isLinux [
64 mkdir -p $out/{bin,share/powershell}
65 cp -R * $out/share/powershell
66 chmod +x $out/share/powershell/pwsh
67 makeWrapper $out/share/powershell/pwsh $out/bin/pwsh \
68 --prefix ${platformLdLibraryPath} : "${lib.makeLibraryPath buildInputs}" \
70 --set POWERSHELL_TELEMETRY_OPTOUT 1 \
71 --set DOTNET_CLI_TELEMETRY_OPTOUT 1
73 '' + lib.optionalString stdenv.isLinux ''
74 patchelf --replace-needed liblttng-ust${ext}.0 liblttng-ust${ext}.1 $out/share/powershell/libcoreclrtraceptprovider.so
83 shellPath = "/bin/pwsh";
85 aarch64-darwin = fetchurl {
86 url = "https://github.com/PowerShell/PowerShell/releases/download/v${version}/powershell-${version}-osx-arm64.tar.gz";
87 hash = "sha256-n1A17psyDWY/BtwvmQn3SjYqhX/C5xZJnq83aA3mUJk=";
89 aarch64-linux = fetchurl {
90 url = "https://github.com/PowerShell/PowerShell/releases/download/v${version}/powershell-${version}-linux-arm64.tar.gz";
91 hash = "sha256-TuSjvi2aJz2jtwm4CRP99M4dhxzerTCdyOOI6FC8CN0=";
93 x86_64-darwin = fetchurl {
94 url = "https://github.com/PowerShell/PowerShell/releases/download/v${version}/powershell-${version}-osx-x64.tar.gz";
95 hash = "sha256-bMOVJ8TT8Rh79rD+vSJP/gxjNHXQE39qASvLAc9P4D8=";
97 x86_64-linux = fetchurl {
98 url = "https://github.com/PowerShell/PowerShell/releases/download/v${version}/powershell-${version}-linux-x64.tar.gz";
99 hash = "sha256-XPzCKK/T/85TbsRUGrr+l8Ypr81tyFyaIHEolLv2Wts=";
102 tests.version = testers.testVersion {
103 package = powershell;
104 command = "HOME=$(mktemp -d) pwsh --version";
106 updateScript = writeShellScript "update-powershell" ''
108 export PATH="${lib.makeBinPath [ common-updater-scripts curl gnused jq ]}"
109 NEW_VERSION=$(curl -s https://api.github.com/repos/PowerShell/PowerShell/releases/latest | jq .tag_name --raw-output | sed -e 's/v//')
111 if [[ "${version}" = "$NEW_VERSION" ]]; then
112 echo "The new version same as the old version."
116 for platform in ${lib.escapeShellArgs meta.platforms}; do
117 update-source-version "powershell" "$NEW_VERSION" --ignore-same-version --source-key="sources.$platform"
123 description = "Powerful cross-platform (Windows, Linux, and macOS) shell and scripting language based on .NET";
124 homepage = "https://microsoft.com/PowerShell";
125 license = licenses.mit;
126 mainProgram = "pwsh";
127 maintainers = with maintainers; [ wegank ];
128 platforms = builtins.attrNames passthru.sources;
129 sourceProvenance = with sourceTypes; [