-
Notifications
You must be signed in to change notification settings - Fork 346
/
package.nix
98 lines (84 loc) · 2.42 KB
/
package.nix
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
{ lib
, stdenv
, makeBinaryWrapper
, installShellFiles
, rustPlatform
, nix
, cachix
, darwin
, sqlx-cli
, openssl
, pkg-config
, glibcLocalesUtf8
, build_tasks ? false
}:
rustPlatform.buildRustPackage {
pname = "devenv";
version = "1.3.1";
# WARN: building this from src/modules/tasks.nix fails.
# There is something being prepended to the path, hence the .*.
src = lib.sourceByRegex ./. [
".*\.cargo(/.*)?$"
".*Cargo\.toml"
".*Cargo\.lock"
".*devenv(/.*)?"
".*devenv-eval-cache(/.*)?"
".*devenv-run-tests(/.*)?"
".*devenv-tasks(/.*)?"
".*nix-conf-parser(/.*)?"
".*xtask(/.*)?"
];
cargoBuildFlags =
if build_tasks
then [ "-p devenv-tasks" ]
else [ "-p devenv -p devenv-run-tests" ];
doCheck = !build_tasks;
cargoLock = {
lockFile = ./Cargo.lock;
};
nativeBuildInputs = [
installShellFiles
makeBinaryWrapper
pkg-config
] ++ lib.optional (!build_tasks) sqlx-cli;
buildInputs = [ openssl ]
++ lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.SystemConfiguration;
# Force sqlx to use the prepared queries
SQLX_OFFLINE = true;
# A local database to use for preparing queries
DATABASE_URL = "sqlite:nix-eval-cache.db";
preBuild = lib.optionalString (!build_tasks) ''
cargo sqlx database setup --source devenv-eval-cache/migrations
cargo sqlx prepare --workspace
'';
postInstall =
let
setDefaultLocaleArchive =
lib.optionalString (glibcLocalesUtf8 != null) ''
--set-default LOCALE_ARCHIVE ${glibcLocalesUtf8}/lib/locale/locale-archive
'';
in
lib.optionalString (!build_tasks) ''
wrapProgram $out/bin/devenv \
--prefix PATH ":" "$out/bin:${cachix}/bin" \
--set DEVENV_NIX ${nix} \
${setDefaultLocaleArchive} \
# TODO: problematic for our library...
wrapProgram $out/bin/devenv-run-tests \
--prefix PATH ":" "$out/bin:${cachix}/bin" \
--set DEVENV_NIX ${nix} \
${setDefaultLocaleArchive} \
# Generate manpages
cargo xtask generate-manpages --out-dir man
installManPage man/*
# Generate shell completions
compdir=./completions
for shell in bash fish zsh; do
cargo xtask generate-shell-completion $shell --out-dir $compdir
done
installShellCompletion --cmd devenv \
--bash $compdir/devenv.bash \
--fish $compdir/devenv.fish \
--zsh $compdir/_devenv
'';
}