-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Expand file tree
/
Copy pathpackage.nix
More file actions
121 lines (107 loc) · 3.67 KB
/
package.nix
File metadata and controls
121 lines (107 loc) · 3.67 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
120
121
{
lib,
stdenv,
fetchFromGitHub,
rustPlatform,
bashInteractive,
coreutils,
installShellFiles,
libiconv,
mdbook,
nix-update-script,
# run the compiled `just` to build the completions
installShellCompletions ? stdenv.buildPlatform.canExecute stdenv.hostPlatform,
# run the compiled `just` to build the man pages
installManPages ? stdenv.buildPlatform.canExecute stdenv.hostPlatform,
# run the compiled `generate-book` utility to prepare the files for mdbook
withDocumentation ? stdenv.buildPlatform.canExecute stdenv.hostPlatform,
}:
let
version = "1.49.0";
in
rustPlatform.buildRustPackage {
inherit version;
pname = "just";
outputs = [
"out"
]
++ lib.optionals installManPages [
"man"
]
++ lib.optionals withDocumentation [ "doc" ];
src = fetchFromGitHub {
owner = "casey";
repo = "just";
tag = version;
hash = "sha256-4vUcKHoQto4TQce4y4/MwdES0+PPlSjNvzLW77FodWs=";
};
cargoHash = "sha256-5hhwzkNgF+i5aCUoVh1VNfkNJFttyy5cLhBwu8uHmAQ=";
nativeBuildInputs =
lib.optionals (installShellCompletions || installManPages) [ installShellFiles ]
++ lib.optionals withDocumentation [ mdbook ];
buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ];
preCheck = ''
# USER must not be empty
export USER=just-user
export USERNAME=just-user
export JUST_CHOOSER="${coreutils}/bin/cat"
export XDG_RUNTIME_DIR=$(mktemp -d)
# Prevent string.rs from being changed
cp tests/string.rs $TMPDIR/string.rs
sed -i src/justfile.rs \
-i tests/*.rs \
-e "s@/bin/echo@${coreutils}/bin/echo@g" \
-e "s@/usr/bin/env@${coreutils}/bin/env@g"
# Return unchanged string.rs
cp $TMPDIR/string.rs tests/string.rs
# For shell completion tests
export PATH=${bashInteractive}/bin:$PATH
patchShebangs tests
'';
cargoBuildFlags = [
"--package=just"
]
++ (lib.optionals withDocumentation [ "--package=generate-book" ]);
checkFlags = [
"--skip=backticks::trailing_newlines_are_stripped" # Wants to use python3 as alternate shell
"--skip=choose::invoke_error_function" # wants JUST_CHOOSER to be fzf
"--skip=choose::default" # symlinks cat->fzf which fails as coreutils doesn't understand name
"--skip=config::tests::show_arguments" # interferes with JUST_CHOOSER being set
"--skip=edit::editor_precedence" # trying to run "vim" fails as there's no /usr/bin/env or which in the sandbox to find vim and the dependency is not easily patched
"--skip=shebang::run_shebang" # test case very rarely fails with "Text file busy"
];
postInstall =
lib.optionalString withDocumentation ''
$out/bin/generate-book
rm $out/bin/generate-book
# No linkcheck in sandbox
echo 'optional = true' >> book/en/book.toml
mdbook build book/en
mkdir -p $doc/share/doc/$name/html
mv ./book/en/build/* $doc/share/doc/$name/html
''
+ lib.optionalString installManPages ''
$out/bin/just --man > ./just.1
installManPage ./just.1
''
+ lib.optionalString installShellCompletions ''
installShellCompletion --cmd just \
--bash <($out/bin/just --completions bash) \
--fish <($out/bin/just --completions fish) \
--zsh <($out/bin/just --completions zsh)
'';
setupHook = ./setup-hook.sh;
passthru.updateScript = nix-update-script { };
meta = {
homepage = "https://github.com/casey/just";
changelog = "https://github.com/casey/just/blob/${version}/CHANGELOG.md";
description = "Handy way to save and run project-specific commands";
license = lib.licenses.cc0;
maintainers = with lib.maintainers; [
xrelkd
jk
ryan4yin
];
mainProgram = "just";
};
}