1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 rustPlatform,
6 openssl,
7 zlib,
8 zstd,
9 pkg-config,
10 python3,
11 xorg,
12 nghttp2,
13 libgit2,
14 withDefaultFeatures ? true,
15 additionalFeatures ? (p: p),
16 testers,
17 nushell,
18 nix-update-script,
19 curlMinimal,
20}:
21
22let
23 # NOTE: when updating this to a new non-patch version, please also try to
24 # update the plugins. Plugins only work if they are compiled for the same
25 # major/minor version.
26 version = "0.106.1";
27in
28rustPlatform.buildRustPackage {
29 pname = "nushell";
30 inherit version;
31
32 src = fetchFromGitHub {
33 owner = "nushell";
34 repo = "nushell";
35 tag = version;
36 hash = "sha256-VrGsdO7RiTlf8JK3MBMcgj0z4cWUklDwikMN5Pu6JQI=";
37 };
38
39 cargoHash = "sha256-GSpR54QGiY9Yrs/A8neoKK6hMvSr3ORtNnwoz4GGprY=";
40
41 nativeBuildInputs = [
42 pkg-config
43 ]
44 ++ lib.optionals (withDefaultFeatures && stdenv.hostPlatform.isLinux) [ python3 ]
45 ++ lib.optionals stdenv.hostPlatform.isDarwin [ rustPlatform.bindgenHook ];
46
47 buildInputs = [
48 zstd
49 ]
50 ++ lib.optionals stdenv.hostPlatform.isDarwin [ zlib ]
51 ++ lib.optionals (withDefaultFeatures && stdenv.hostPlatform.isLinux) [ xorg.libX11 ]
52 ++ lib.optionals (withDefaultFeatures && stdenv.hostPlatform.isDarwin) [
53 nghttp2
54 libgit2
55 ];
56
57 buildNoDefaultFeatures = !withDefaultFeatures;
58 buildFeatures = additionalFeatures [ ];
59
60 preCheck = ''
61 export NU_TEST_LOCALE_OVERRIDE="en_US.UTF-8"
62 '';
63
64 checkPhase = ''
65 runHook preCheck
66 (
67 # The skipped tests all fail in the sandbox because in the nushell test playground,
68 # the tmp $HOME is not set, so nu falls back to looking up the passwd dir of the build
69 # user (/var/empty). The assertions however do respect the set $HOME.
70 set -x
71 HOME=$(mktemp -d) cargo test -j $NIX_BUILD_CORES --offline -- \
72 --test-threads=$NIX_BUILD_CORES \
73 --skip=repl::test_config_path::test_default_config_path \
74 --skip=repl::test_config_path::test_xdg_config_bad \
75 --skip=repl::test_config_path::test_xdg_config_empty ${lib.optionalString stdenv.hostPlatform.isDarwin ''
76 \
77 --skip=plugins::config::some \
78 --skip=plugins::stress_internals::test_exit_early_local_socket \
79 --skip=plugins::stress_internals::test_failing_local_socket_fallback \
80 --skip=plugins::stress_internals::test_local_socket
81 ''}
82 )
83 runHook postCheck
84 '';
85
86 checkInputs =
87 lib.optionals stdenv.hostPlatform.isDarwin [ curlMinimal ]
88 ++ lib.optionals stdenv.hostPlatform.isLinux [ openssl ];
89
90 passthru = {
91 shellPath = "/bin/nu";
92 tests.version = testers.testVersion {
93 package = nushell;
94 };
95 updateScript = nix-update-script { };
96 };
97
98 meta = with lib; {
99 description = "Modern shell written in Rust";
100 homepage = "https://www.nushell.sh/";
101 license = licenses.mit;
102 maintainers = with maintainers; [
103 Br1ght0ne
104 johntitor
105 joaquintrinanes
106 ryan4yin
107 ];
108 mainProgram = "nu";
109 };
110}