1{ stdenv
2, lib
3, fetchFromGitHub
4, rustPlatform
5, openssl
6, zlib
7, zstd
8, pkg-config
9, python3
10, xorg
11, libiconv
12, Libsystem
13, AppKit
14, Security
15, nghttp2
16, libgit2
17, doCheck ? true
18, withDefaultFeatures ? true
19, additionalFeatures ? (p: p)
20, testers
21, nushell
22, nix-update-script
23}:
24
25rustPlatform.buildRustPackage (
26 let
27 version = "0.80.0";
28 pname = "nushell";
29 in {
30 inherit version pname;
31
32 src = fetchFromGitHub {
33 owner = pname;
34 repo = pname;
35 rev = version;
36 hash = "sha256-XPN2ziwQNOilYei9SQ+e8w7g90e7/qGXgU8Gb28c5Wc=";
37 };
38
39 cargoHash = "sha256-j3YYKEGB/fDQVQIsGx+/gjPQggtQ+7YcmGi1V7bJJqM=";
40
41 nativeBuildInputs = [ pkg-config ]
42 ++ lib.optionals (withDefaultFeatures && stdenv.isLinux) [ python3 ]
43 ++ lib.optionals stdenv.isDarwin [ rustPlatform.bindgenHook ];
44
45 buildInputs = [ openssl zstd ]
46 ++ lib.optionals stdenv.isDarwin [ zlib libiconv Libsystem Security ]
47 ++ lib.optionals (withDefaultFeatures && stdenv.isLinux) [ xorg.libX11 ]
48 ++ lib.optionals (withDefaultFeatures && stdenv.isDarwin) [ AppKit nghttp2 libgit2 ];
49
50 buildFeatures = additionalFeatures [ (lib.optional withDefaultFeatures "default") ];
51
52 # TODO investigate why tests are broken on darwin
53 # failures show that tests try to write to paths
54 # outside of TMPDIR
55 doCheck = doCheck && !stdenv.isDarwin;
56
57 checkPhase = ''
58 runHook preCheck
59 echo "Running cargo test"
60 HOME=$TMPDIR cargo test
61 runHook postCheck
62 '';
63
64 meta = with lib; {
65 description = "A modern shell written in Rust";
66 homepage = "https://www.nushell.sh/";
67 license = licenses.mit;
68 maintainers = with maintainers; [ Br1ght0ne johntitor marsam ];
69 mainProgram = "nu";
70 };
71
72 passthru = {
73 shellPath = "/bin/nu";
74 tests.version = testers.testVersion {
75 package = nushell;
76 };
77 updateScript = nix-update-script { };
78 };
79})