forked from cachix/devenv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package.nix
62 lines (50 loc) · 1.75 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
{ pkgs, inputs, build_tasks ? false }:
pkgs.rustPlatform.buildRustPackage {
pname = "devenv";
version = "1.2";
# WARN: building this from src/modules/tasks.nix fails.
# There is something being prepended to the path, hence the .*.
src = pkgs.lib.sourceByRegex ./. [
".*\.cargo(/.*)?$"
".*Cargo\.toml"
".*Cargo\.lock"
".*devenv(/.*)?"
".*tasks(/.*)?"
".*devenv-run-tests(/.*)?"
".*xtask(/.*)?"
];
cargoBuildFlags = if build_tasks then [ "-p tasks" ] else [ "-p devenv -p devenv-run-tests" ];
doCheck = !build_tasks;
cargoLock = {
lockFile = ./Cargo.lock;
};
nativeBuildInputs = [
pkgs.makeWrapper
pkgs.pkg-config
pkgs.installShellFiles
];
buildInputs = [ pkgs.openssl ] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
pkgs.darwin.apple_sdk.frameworks.SystemConfiguration
];
postInstall = pkgs.lib.optionalString (!build_tasks) ''
wrapProgram $out/bin/devenv \
--set DEVENV_NIX ${inputs.nix.packages.${pkgs.stdenv.system}.nix} \
--prefix PATH ":" "$out/bin:${inputs.cachix.packages.${pkgs.stdenv.system}.cachix}/bin"
# TODO: problematic for our library...
wrapProgram $out/bin/devenv-run-tests \
--set DEVENV_NIX ${inputs.nix.packages.${pkgs.stdenv.system}.nix} \
--prefix PATH ":" "$out/bin:${inputs.cachix.packages.${pkgs.stdenv.system}.cachix}/bin"
# 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
'';
}