mediawiki: 1.42.4 -> 1.43.0 (#369641)
[NixPkgs.git] / pkgs / by-name / po / powershell / package.nix
bloba5c63c6a4a86ef119591284ff29fa2959ebb50e7
2   lib,
3   stdenv,
4   fetchurl,
5   less,
6   makeWrapper,
7   autoPatchelfHook,
8   curl,
9   icu,
10   libuuid,
11   libunwind,
12   openssl,
13   darwin,
14   lttng-ust,
15   pam,
16   testers,
17   powershell,
18   writeShellScript,
19   common-updater-scripts,
20   gnused,
21   jq,
24 let
25   ext = stdenv.hostPlatform.extensions.sharedLibrary;
26   platformLdLibraryPath =
27     {
28       darwin = "DYLD_FALLBACK_LIBRARY_PATH";
29       linux = "LD_LIBRARY_PATH";
30     }
31     .${stdenv.hostPlatform.parsed.kernel.name} or (throw "unsupported platform");
33 stdenv.mkDerivation rec {
34   pname = "powershell";
35   version = "7.4.6";
37   src =
38     passthru.sources.${stdenv.hostPlatform.system}
39       or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
41   sourceRoot = ".";
43   strictDeps = true;
45   nativeBuildInputs =
46     [
47       less
48       makeWrapper
49     ]
50     ++ lib.optionals stdenv.hostPlatform.isLinux [
51       autoPatchelfHook
52     ];
54   buildInputs =
55     [
56       curl
57       icu
58       libuuid
59       libunwind
60       openssl
61     ]
62     ++ lib.optionals stdenv.hostPlatform.isDarwin [
63       darwin.Libsystem
64     ]
65     ++ lib.optionals stdenv.hostPlatform.isLinux [
66       lttng-ust
67       pam
68     ];
70   installPhase =
71     ''
72       runHook preInstall
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
83     ''
84     + lib.optionalString stdenv.hostPlatform.isLinux ''
85       patchelf --replace-needed liblttng-ust${ext}.0 liblttng-ust${ext}.1 $out/share/powershell/libcoreclrtraceptprovider.so
87     ''
88     + ''
89       runHook postInstall
90     '';
92   dontStrip = true;
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-pILWaHh++Yw38KWnaWEH3/2z3DQMW+PRwVPsnSOQcqg=";
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-wBWbA+hfRK4edpeBigEVWNpsgT0KroSL9awTv0NdhiQ=";
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-ehja7RBbfPyAv4zAB2L+eZAQXdI/lRzDLOt0RlFlDj0=";
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-b2AVIDxHgGxcxETBnY7QGWleYQ+9lIFUJkv5yo4VdWE=";
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//')
130       if [[ "${version}" = "$NEW_VERSION" ]]; then
131         echo "The new version same as the old version."
132         exit 0
133       fi
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   };
141   meta = with lib; {
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; [
149       binaryBytecode
150       binaryNativeCode
151     ];
152   };