diff --git a/pkgs/by-name/ju/just/package.nix b/pkgs/by-name/ju/just/package.nix index ea20cef8b3a1..2667c47d4580 100644 --- a/pkgs/by-name/ju/just/package.nix +++ b/pkgs/by-name/ju/just/package.nix @@ -9,16 +9,22 @@ libiconv, mdbook, nix-update-script, + installShellCompletions ? stdenv.buildPlatform.canExecute stdenv.hostPlatform, + installManPages ? stdenv.buildPlatform.canExecute stdenv.hostPlatform, + withDocumentation ? stdenv.buildPlatform.canExecute stdenv.hostPlatform, }: rustPlatform.buildRustPackage rec { pname = "just"; version = "1.38.0"; - outputs = [ - "out" - "man" - "doc" - ]; + outputs = + [ + "out" + ] + ++ lib.optionals installManPages [ + "man" + ] + ++ lib.optionals withDocumentation [ "doc" ]; src = fetchFromGitHub { owner = "casey"; @@ -29,10 +35,9 @@ rustPlatform.buildRustPackage rec { cargoHash = "sha256-JHLkjMy5b1spJrAqFCCzqgnlYTAKA1Z9Tx4w1WWuiAI="; - nativeBuildInputs = [ - installShellFiles - mdbook - ]; + nativeBuildInputs = + lib.optionals (installShellCompletions || installManPages) [ installShellFiles ] + ++ lib.optionals withDocumentation [ mdbook ]; buildInputs = lib.optionals stdenv.hostPlatform.isDarwin [ libiconv ]; preCheck = '' @@ -61,22 +66,9 @@ rustPlatform.buildRustPackage rec { ./fix-just-path-in-tests.patch ]; - postBuild = '' - cargo run --package generate-book - - 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 - - # No linkcheck in sandbox - echo 'optional = true' >> book/en/book.toml - mdbook build book/en - find . - ''; + cargoBuildFlags = [ + "--package=just" + ] ++ (lib.optionals withDocumentation [ "--package=generate-book" ]); checkFlags = [ "--skip=backticks::trailing_newlines_are_stripped" # Wants to use python3 as alternate shell @@ -87,16 +79,26 @@ rustPlatform.buildRustPackage rec { "--skip=shebang::run_shebang" # test case very rarely fails with "Text file busy" ]; - postInstall = '' - mkdir -p $doc/share/doc/$name - mv ./book/en/build/html $doc/share/doc/$name - installManPage man/just.1 - - installShellCompletion --cmd just \ - --bash completions/just.bash \ - --fish completions/just.fish \ - --zsh completions/just.zsh - ''; + 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 + mv ./book/en/build/html $doc/share/doc/$name + '' + + 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;