nushell: refactor

- fix tests on darwin
- respect withDefaultFeatures = false
- don't use lib.optional in a list
- remove libiconv from buildInputs since it is the default
- formatting
This commit is contained in:
figsoda 2023-07-02 12:04:48 -04:00
parent 3cf540aa14
commit 90e4770f81

View File

@ -8,7 +8,6 @@
, pkg-config , pkg-config
, python3 , python3
, xorg , xorg
, libiconv
, Libsystem , Libsystem
, AppKit , AppKit
, Security , Security
@ -22,16 +21,17 @@
, nix-update-script , nix-update-script
}: }:
rustPlatform.buildRustPackage ( let
let
version = "0.82.0"; version = "0.82.0";
in
rustPlatform.buildRustPackage {
pname = "nushell"; pname = "nushell";
in { inherit version;
inherit version pname;
src = fetchFromGitHub { src = fetchFromGitHub {
owner = pname; owner = "nushell";
repo = pname; repo = "nushell";
rev = version; rev = version;
hash = "sha256-D/R+/60Lo2rLUA/313CTJQookqSNtbD7LnVf0vBC9Qc="; hash = "sha256-D/R+/60Lo2rLUA/313CTJQookqSNtbD7LnVf0vBC9Qc=";
}; };
@ -43,32 +43,22 @@ rustPlatform.buildRustPackage (
++ lib.optionals stdenv.isDarwin [ rustPlatform.bindgenHook ]; ++ lib.optionals stdenv.isDarwin [ rustPlatform.bindgenHook ];
buildInputs = [ openssl zstd ] buildInputs = [ openssl zstd ]
++ lib.optionals stdenv.isDarwin [ zlib libiconv Libsystem Security ] ++ lib.optionals stdenv.isDarwin [ zlib Libsystem Security ]
++ lib.optionals (withDefaultFeatures && stdenv.isLinux) [ xorg.libX11 ] ++ lib.optionals (withDefaultFeatures && stdenv.isLinux) [ xorg.libX11 ]
++ lib.optionals (withDefaultFeatures && stdenv.isDarwin) [ AppKit nghttp2 libgit2 ]; ++ lib.optionals (withDefaultFeatures && stdenv.isDarwin) [ AppKit nghttp2 libgit2 ];
buildFeatures = additionalFeatures [ (lib.optional withDefaultFeatures "default") ]; buildNoDefaultFeatures = !withDefaultFeatures;
buildFeatures = additionalFeatures [ ];
# TODO investigate why tests are broken on darwin inherit doCheck;
# failures show that tests try to write to paths
# outside of TMPDIR
doCheck = doCheck && !stdenv.isDarwin;
checkPhase = '' checkPhase = ''
runHook preCheck runHook preCheck
echo "Running cargo test" echo "Running cargo test"
HOME=$TMPDIR cargo test HOME=$(mktemp -d) cargo test
runHook postCheck runHook postCheck
''; '';
meta = with lib; {
description = "A modern shell written in Rust";
homepage = "https://www.nushell.sh/";
license = licenses.mit;
maintainers = with maintainers; [ Br1ght0ne johntitor marsam ];
mainProgram = "nu";
};
passthru = { passthru = {
shellPath = "/bin/nu"; shellPath = "/bin/nu";
tests.version = testers.testVersion { tests.version = testers.testVersion {
@ -76,4 +66,12 @@ rustPlatform.buildRustPackage (
}; };
updateScript = nix-update-script { }; updateScript = nix-update-script { };
}; };
})
meta = with lib; {
description = "A modern shell written in Rust";
homepage = "https://www.nushell.sh/";
license = licenses.mit;
maintainers = with maintainers; [ Br1ght0ne johntitor marsam ];
mainProgram = "nu";
};
}