-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathpackage.nix
More file actions
119 lines (104 loc) · 3.32 KB
/
Copy pathpackage.nix
File metadata and controls
119 lines (104 loc) · 3.32 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# TODO: move this to nixpkgs
# This file aims to be a replacement for the nixpkgs derivation.
{
buildFeatures ? [ ],
buildNoDefaultFeatures ? false,
buildPackages,
dbus,
fetchFromGitHub,
installManPages ? stdenv.buildPlatform.canExecute stdenv.hostPlatform,
installShellCompletions ? stdenv.buildPlatform.canExecute stdenv.hostPlatform,
installShellFiles,
lib,
openssl,
pkg-config,
rustPlatform,
stdenv,
}:
let
nativeTls = builtins.elem "native-tls" buildFeatures;
notify = builtins.elem "notify" buildFeatures;
# dbus calls libgcc outline atomics that the static aarch64 link cannot
# resolve (__aarch64_ldset4_sync & co), so inline them instead.
dbus' =
if stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64 then
dbus.overrideAttrs (old: {
env = (old.env or { }) // {
NIX_CFLAGS_COMPILE = (old.env.NIX_CFLAGS_COMPILE or "") + " -mno-outline-atomics";
};
})
else
dbus;
in
rustPlatform.buildRustPackage (finalAttrs: {
__structuredAttrs = true;
inherit buildNoDefaultFeatures;
pname = "ortie";
version = "2.2.0";
cargoHash = "";
src = fetchFromGitHub {
owner = "pimalaya";
repo = finalAttrs.pname;
tag = "v${finalAttrs.version}";
hash = "";
};
env = {
# pkg-config hands the linker libdbus but no rpath, leaving a binary that
# cannot find it: not in postInstall, which runs it, nor once installed.
NIX_LDFLAGS = lib.optionalString (notify && !stdenv.hostPlatform.isWindows) (
"-rpath " + lib.getLib dbus' + "/lib"
);
# openssl should not be provided by vendors, not even on windows
OPENSSL_NO_VENDOR = 1;
};
nativeBuildInputs = [
pkg-config
installShellFiles
];
buildInputs =
lib.optional nativeTls openssl
# dbus is provided by vendors on windows
++ lib.optional (notify && !stdenv.hostPlatform.isWindows) dbus';
buildFeatures =
buildFeatures
# dbus is provided by vendors on windows
++ lib.optional (notify && stdenv.hostPlatform.isWindows) "vendored";
postInstall =
let
exe =
if stdenv.buildPlatform.canExecute stdenv.hostPlatform then
"$out/bin/${finalAttrs.pname}"
else
lib.getExe buildPackages.${finalAttrs.pname};
in
''
mkdir -p $out/share/{completions,man}
${exe} manuals -d "$out"/share/man
${exe} completions -d "$out"/share/completions bash elvish fish powershell zsh
''
+ lib.optionalString installManPages ''
installManPage "$out"/share/man/*
''
+ lib.optionalString installShellCompletions ''
installShellCompletion --cmd ${finalAttrs.pname} \
--bash "$out"/share/completions/${finalAttrs.pname}.bash \
--fish "$out"/share/completions/${finalAttrs.pname}.fish \
--zsh "$out"/share/completions/_${finalAttrs.pname}
'';
# disable impure integration tests: they bind sockets and spawn processes
cargoTestFlags = [ "--bins" ];
meta = {
description = "CLI to manage OAuth 2.0 tokens";
mainProgram = finalAttrs.pname;
homepage = "https://github.com/pimalaya/${finalAttrs.pname}";
changelog = "https://github.com/pimalaya/${finalAttrs.pname}/releases/${finalAttrs.src.tag}";
license = with lib.licenses; [
asl20
mit
];
maintainers = with lib.maintainers; [
soywod
bobberb
];
};
})