2023-09-24 21:37:50 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchurl
|
|
|
|
, less
|
|
|
|
, makeWrapper
|
|
|
|
, autoPatchelfHook
|
|
|
|
, curl
|
|
|
|
, icu
|
|
|
|
, libuuid
|
|
|
|
, libunwind
|
|
|
|
, openssl
|
|
|
|
, darwin
|
|
|
|
, lttng-ust
|
|
|
|
, pam
|
|
|
|
, testers
|
|
|
|
, powershell
|
|
|
|
, writeShellScript
|
|
|
|
, common-updater-scripts
|
|
|
|
, gnused
|
|
|
|
, jq
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
ext = stdenv.hostPlatform.extensions.sharedLibrary;
|
|
|
|
platformLdLibraryPath = {
|
|
|
|
darwin = "DYLD_FALLBACK_LIBRARY_PATH";
|
|
|
|
linux = "LD_LIBRARY_PATH";
|
|
|
|
}.${stdenv.hostPlatform.parsed.kernel.name} or (throw "unsupported platform");
|
2018-05-30 01:08:50 +00:00
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "powershell";
|
2024-01-13 01:30:33 +00:00
|
|
|
version = "7.4.1";
|
2018-05-30 01:08:50 +00:00
|
|
|
|
2023-09-24 21:37:50 +00:00
|
|
|
src = passthru.sources.${stdenv.hostPlatform.system}
|
|
|
|
or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
|
2018-05-30 01:08:50 +00:00
|
|
|
|
2023-05-30 08:04:59 +00:00
|
|
|
sourceRoot = ".";
|
|
|
|
|
2022-05-06 18:39:28 +00:00
|
|
|
strictDeps = true;
|
2018-05-30 01:08:50 +00:00
|
|
|
|
2023-09-24 21:37:50 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
less
|
|
|
|
makeWrapper
|
|
|
|
] ++ lib.optionals stdenv.isLinux [
|
|
|
|
autoPatchelfHook
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
curl
|
|
|
|
icu
|
|
|
|
libuuid
|
|
|
|
libunwind
|
|
|
|
openssl
|
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
darwin.Libsystem
|
|
|
|
] ++ lib.optionals stdenv.isLinux [
|
|
|
|
lttng-ust
|
|
|
|
pam
|
|
|
|
];
|
2020-04-06 11:40:22 +00:00
|
|
|
|
2023-09-24 21:37:50 +00:00
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2020-04-06 11:40:22 +00:00
|
|
|
|
2023-09-24 21:37:50 +00:00
|
|
|
mkdir -p $out/{bin,share/powershell}
|
|
|
|
cp -R * $out/share/powershell
|
|
|
|
chmod +x $out/share/powershell/pwsh
|
|
|
|
makeWrapper $out/share/powershell/pwsh $out/bin/pwsh \
|
|
|
|
--prefix ${platformLdLibraryPath} : "${lib.makeLibraryPath buildInputs}" \
|
|
|
|
--set TERM xterm \
|
|
|
|
--set POWERSHELL_TELEMETRY_OPTOUT 1 \
|
|
|
|
--set DOTNET_CLI_TELEMETRY_OPTOUT 1
|
2021-05-18 14:36:25 +00:00
|
|
|
|
2023-09-24 21:37:50 +00:00
|
|
|
'' + lib.optionalString stdenv.isLinux ''
|
|
|
|
patchelf --replace-needed liblttng-ust${ext}.0 liblttng-ust${ext}.1 $out/share/powershell/libcoreclrtraceptprovider.so
|
2020-04-06 11:40:22 +00:00
|
|
|
|
2023-09-24 21:37:50 +00:00
|
|
|
'' + ''
|
|
|
|
runHook postInstall
|
2018-05-30 01:08:50 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
dontStrip = true;
|
|
|
|
|
2023-09-24 21:37:50 +00:00
|
|
|
passthru = {
|
|
|
|
shellPath = "/bin/pwsh";
|
|
|
|
sources = {
|
|
|
|
aarch64-darwin = fetchurl {
|
|
|
|
url = "https://github.com/PowerShell/PowerShell/releases/download/v${version}/powershell-${version}-osx-arm64.tar.gz";
|
2024-01-13 01:30:33 +00:00
|
|
|
hash = "sha256-Q10TWUPw8eOmb+76AlHXPp6AdvUS3pxGnNsgXFvnGWc=";
|
2023-09-24 21:37:50 +00:00
|
|
|
};
|
|
|
|
aarch64-linux = fetchurl {
|
|
|
|
url = "https://github.com/PowerShell/PowerShell/releases/download/v${version}/powershell-${version}-linux-arm64.tar.gz";
|
2024-01-13 01:30:33 +00:00
|
|
|
hash = "sha256-cZwRVEofYyLyxY9Vkf96u3dorvl+8KOC43Efifoq3iI=";
|
2023-09-24 21:37:50 +00:00
|
|
|
};
|
|
|
|
x86_64-darwin = fetchurl {
|
|
|
|
url = "https://github.com/PowerShell/PowerShell/releases/download/v${version}/powershell-${version}-osx-x64.tar.gz";
|
2024-01-13 01:30:33 +00:00
|
|
|
hash = "sha256-H63q4MY00o8OIISTv7VBnSZd8FdwLEuoCyErZE2X3AA=";
|
2023-09-24 21:37:50 +00:00
|
|
|
};
|
|
|
|
x86_64-linux = fetchurl {
|
|
|
|
url = "https://github.com/PowerShell/PowerShell/releases/download/v${version}/powershell-${version}-linux-x64.tar.gz";
|
2024-01-13 01:30:33 +00:00
|
|
|
hash = "sha256-i+q6xEMbdem2fG2fr9iwLMAZ8h8jDqPZSuwTSMUFKdM=";
|
2023-09-24 21:37:50 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
tests.version = testers.testVersion {
|
|
|
|
package = powershell;
|
|
|
|
command = "HOME=$(mktemp -d) pwsh --version";
|
|
|
|
};
|
|
|
|
updateScript = writeShellScript "update-powershell" ''
|
|
|
|
set -o errexit
|
|
|
|
export PATH="${lib.makeBinPath [ common-updater-scripts curl gnused jq ]}"
|
|
|
|
NEW_VERSION=$(curl -s https://api.github.com/repos/PowerShell/PowerShell/releases/latest | jq .tag_name --raw-output | sed -e 's/v//')
|
|
|
|
|
|
|
|
if [[ "${version}" = "$NEW_VERSION" ]]; then
|
|
|
|
echo "The new version same as the old version."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
for platform in ${lib.escapeShellArgs meta.platforms}; do
|
|
|
|
update-source-version "powershell" "0" "${lib.fakeHash}" --source-key="sources.$platform"
|
|
|
|
update-source-version "powershell" "$NEW_VERSION" --source-key="sources.$platform"
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
};
|
2020-04-30 21:47:54 +00:00
|
|
|
|
|
|
|
meta = with lib; {
|
2020-04-06 11:40:22 +00:00
|
|
|
description = "Powerful cross-platform (Windows, Linux, and macOS) shell and scripting language based on .NET";
|
2023-09-24 21:37:50 +00:00
|
|
|
homepage = "https://microsoft.com/PowerShell";
|
|
|
|
license = licenses.mit;
|
|
|
|
mainProgram = "pwsh";
|
|
|
|
maintainers = with maintainers; [ wegank ];
|
|
|
|
platforms = builtins.attrNames passthru.sources;
|
2022-06-16 23:40:08 +00:00
|
|
|
sourceProvenance = with sourceTypes; [
|
|
|
|
binaryBytecode
|
|
|
|
binaryNativeCode
|
|
|
|
];
|
2018-05-30 01:08:50 +00:00
|
|
|
};
|
|
|
|
}
|