2022-03-30 09:31:56 +00:00
{ lib
, stdenv
, fetchFromGitHub
, rustPlatform
2024-06-20 14:57:18 +00:00
, bashInteractive
2022-03-30 09:31:56 +00:00
, coreutils
, installShellFiles
, libiconv
2023-05-24 13:37:59 +00:00
, mdbook
2023-07-15 17:15:38 +00:00
, nix-update-script
2022-03-30 09:31:56 +00:00
} :
2020-04-24 23:36:52 +00:00
rustPlatform . buildRustPackage rec {
pname = " j u s t " ;
2024-07-27 06:49:29 +00:00
version = " 1 . 3 2 . 0 " ;
2023-05-24 13:37:59 +00:00
outputs = [ " o u t " " m a n " " d o c " ] ;
2020-04-24 23:36:52 +00:00
src = fetchFromGitHub {
owner = " c a s e y " ;
repo = pname ;
2023-02-02 18:25:31 +00:00
rev = " r e f s / t a g s / ${ version } " ;
2024-07-27 06:49:29 +00:00
hash = " s h a 2 5 6 - 4 W 0 F t 4 w M 2 i L e e p q g 9 X n H V / u e j J E E 9 g I B O w m 7 a x n C 8 b o = " ;
2020-04-24 23:36:52 +00:00
} ;
2022-02-10 20:34:41 +00:00
2024-07-27 06:49:29 +00:00
cargoHash = " s h a 2 5 6 - k j v c 8 7 H K M o K W I m e A M i E S b 7 x H u A + z n X 5 z 6 M s W u 6 T h r h E = " ;
2020-04-24 23:36:52 +00:00
2023-05-24 13:37:59 +00:00
nativeBuildInputs = [ installShellFiles mdbook ] ;
2021-04-25 03:57:28 +00:00
buildInputs = lib . optionals stdenv . isDarwin [ libiconv ] ;
2020-04-24 23:36:52 +00:00
preCheck = ''
# USER must not be empty
export USER = just-user
export USERNAME = just-user
2021-06-28 23:13:55 +00:00
export JUST_CHOOSER = " ${ coreutils } / b i n / c a t "
2020-04-24 23:36:52 +00:00
2021-05-03 20:48:10 +00:00
# Prevent string.rs from being changed
cp tests/string.rs $ TMPDIR/string.rs
2020-04-24 23:36:52 +00:00
sed - i src/justfile.rs \
- i tests /* . r s \
- e " s @ / b i n / e c h o @ ${ coreutils } / b i n / e c h o @ g " \
2021-06-28 23:13:55 +00:00
- e " s @ / u s r / b i n / e n v @ ${ coreutils } / b i n / e n v @ g "
2021-05-03 20:48:10 +00:00
# Return unchanged string.rs
cp $ TMPDIR/string.rs tests/string.rs
2024-06-20 14:57:18 +00:00
# For shell completion tests
export PATH = $ { bashInteractive } /bin : $ PATH
patchShebangs tests
2020-04-24 23:36:52 +00:00
'' ;
2024-06-20 14:57:18 +00:00
patches = [
./fix-just-path-in-tests.patch
] ;
2023-05-24 13:37:59 +00:00
postBuild = ''
cargo run - - package generate-book
2024-06-20 14:57:18 +00:00
mkdir - p completions man
cargo run - - - - man > man/just.1
for shell in bash fish zsh ; do
cargo run - - - - completions $ shell > completions/just. $ shell
done
2023-05-24 13:37:59 +00:00
# No linkcheck in sandbox
echo ' optional = true' > > book/en/book.toml
mdbook build book/en
find .
'' ;
2021-06-28 23:13:55 +00:00
checkFlags = [
2024-06-20 14:57:18 +00:00
" - - s k i p = b a c k t i c k s : : t r a i l i n g _ n e w l i n e s _ a r e _ s t r i p p e d " # Wants to use python3 as alternate shell
" - - s k i p = c h o o s e : : i n v o k e _ e r r o r _ f u n c t i o n " # wants JUST_CHOOSER to be fzf
2023-07-15 17:15:38 +00:00
" - - s k i p = c h o o s e : : d e f a u l t " # symlinks cat->fzf which fails as coreutils doesn't understand name
2024-06-20 14:57:18 +00:00
" - - s k i p = c o n f i g : : t e s t s : : s h o w _ a r g u m e n t s " # interferes with JUST_CHOOSER being set
" - - s k i p = e d i t : : e d i t o r _ p r e c e d e n c e " # 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
" - - s k i p = s h e b a n g : : r u n _ s h e b a n g " # test case very rarely fails with "Text file busy"
2021-06-28 23:13:55 +00:00
] ;
2020-04-24 23:36:52 +00:00
2022-03-05 16:20:37 +00:00
postInstall = ''
2023-05-24 13:37:59 +00:00
mkdir - p $ doc/share/doc / $ name
mv ./book/en/build/html $ doc/share/doc / $ name
2022-03-05 16:20:37 +00:00
installManPage man/just.1
installShellCompletion - - cmd just \
- - bash completions/just.bash \
- - fish completions/just.fish \
- - zsh completions/just.zsh
'' ;
2023-08-22 20:05:09 +00:00
setupHook = ./setup-hook.sh ;
2023-07-15 17:15:38 +00:00
passthru . updateScript = nix-update-script { } ;
2021-02-05 17:12:51 +00:00
meta = with lib ; {
2020-04-24 23:36:52 +00:00
homepage = " h t t p s : / / g i t h u b . c o m / c a s e y / j u s t " ;
2021-06-28 23:13:55 +00:00
changelog = " h t t p s : / / g i t h u b . c o m / c a s e y / j u s t / b l o b / ${ version } / C H A N G E L O G . m d " ;
2024-06-20 14:57:18 +00:00
description = " H a n d y w a y t o s a v e a n d r u n p r o j e c t - s p e c i f i c c o m m a n d s " ;
2020-04-24 23:36:52 +00:00
license = licenses . cc0 ;
2024-07-27 06:49:29 +00:00
maintainers = with maintainers ; [ xrelkd jk ] ;
2023-08-10 07:59:29 +00:00
mainProgram = " j u s t " ;
2020-04-24 23:36:52 +00:00
} ;
}