-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage.nix
More file actions
105 lines (95 loc) · 2.71 KB
/
package.nix
File metadata and controls
105 lines (95 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
{
lib,
stdenv,
system,
fetchurl,
coreutils,
glibc,
icu,
openssl,
patchelf,
runtimeShell,
version,
fileVersion ? version,
hash,
}:
let
platformMap = {
x86_64-linux = "linux-x64";
aarch64-linux = "linux-arm64";
x86_64-darwin = "osx-x64";
aarch64-darwin = "osx-arm64";
};
platform = platformMap.${system};
isLinux = stdenv.hostPlatform.isLinux;
isDarwin = stdenv.hostPlatform.isDarwin;
in
stdenv.mkDerivation {
pname = "aspire-cli";
inherit version;
src = fetchurl {
url = "https://ci.dot.net/public/aspire/${version}/aspire-cli-${platform}-${fileVersion}.tar.gz";
inherit hash;
};
nativeBuildInputs = lib.optionals isLinux [ patchelf ];
dontConfigure = true;
dontBuild = true;
unpackPhase = ''
runHook preUnpack
tar -xzf "$src"
runHook postUnpack
'';
installPhase = ''
runHook preInstall
install -D -m0755 aspire "$out/libexec/aspire"
${lib.optionalString isLinux ''
patchelf \
--set-interpreter "${stdenv.cc.bintools.dynamicLinker}" \
--set-rpath "${
lib.makeLibraryPath [
glibc
icu
openssl
]
}" \
"$out/libexec/aspire"
''}
mkdir -p "$out/bin"
wrapper="$out/bin/aspire"
printf '%s\n' '#!${runtimeShell}' > "$wrapper"
printf '%s\n' 'set -euo pipefail' >> "$wrapper"
printf '%s\n' 'state_home="''${XDG_STATE_HOME:-$HOME/.local/state}"' >> "$wrapper"
printf '%s\n' 'runtime_root="$state_home/aspire-cli/${version}"' >> "$wrapper"
printf '%s\n' 'runtime_bin="$runtime_root/bin"' >> "$wrapper"
printf '%s\n' 'runtime_aspire="$runtime_bin/aspire"' >> "$wrapper"
printf '%s\n' '${coreutils}/bin/mkdir -p "$runtime_bin"' >> "$wrapper"
printf '%s\n' 'if [ ! -x "$runtime_aspire" ]; then' >> "$wrapper"
printf '%s\n' ' ${coreutils}/bin/cp "${placeholder "out"}/libexec/aspire" "$runtime_aspire"' >> "$wrapper"
printf '%s\n' ' ${coreutils}/bin/chmod 755 "$runtime_aspire"' >> "$wrapper"
printf '%s\n' 'fi' >> "$wrapper"
${lib.optionalString isLinux ''
printf '%s\n' 'export LD_LIBRARY_PATH="${
lib.makeLibraryPath [
icu
openssl
]
}''${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"' >> "$wrapper"
''}
printf '%s\n' 'exec "$runtime_aspire" "$@"' >> "$wrapper"
chmod +x "$out/bin/aspire"
runHook postInstall
'';
meta = {
description = ".NET Aspire CLI";
homepage = "https://learn.microsoft.com/dotnet/aspire/";
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
license = lib.licenses.mit;
platforms = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
mainProgram = "aspire";
};
}