mirror of
https://github.com/nushell/nushell.git
synced 2026-11-24 02:06:06 +08:00
## Description nixpkgs turned the `xorg` set into a warning alias, thus `scripts/nix/default.nix` printed `'xorg.libX11' has been renamed to 'libx11'` on every evaluation. This takes the top-level `libx11` instead. `libX11` exists at the top level too, but only as an alias, so `libx11` is the name that stays. ## User-facing changes (Release notes) n/a ## Additional notes Checked against current nixos-unstable, evaluates without the warning.
130 lines
3.1 KiB
Nix
130 lines
3.1 KiB
Nix
# Generic builder for nushell and its included plugins.
|
|
{
|
|
stdenv,
|
|
lib,
|
|
rustPlatform,
|
|
# Allows overriding for the plugins
|
|
pname ? "nushell",
|
|
# Use this for the cargo file that the plugin has
|
|
extraCargo ? ../../Cargo.toml,
|
|
withDefaultFeatures ? true,
|
|
additionalFeatures ? (p: p),
|
|
# Package dependencies
|
|
pkg-config,
|
|
openssl,
|
|
curlMinimal,
|
|
python3,
|
|
libx11,
|
|
nghttp2,
|
|
libgit2,
|
|
zstd,
|
|
zlib,
|
|
# Mostly args and things that might be different for plugins
|
|
nativeBuildInputs ? [
|
|
pkg-config
|
|
]
|
|
++ lib.optionals (withDefaultFeatures && stdenv.hostPlatform.isLinux) [ python3 ]
|
|
++ lib.optionals stdenv.cc.isClang [ rustPlatform.bindgenHook ],
|
|
buildInputs ? [
|
|
zstd
|
|
]
|
|
++ lib.optionals stdenv.hostPlatform.isDarwin [ zlib ]
|
|
++ lib.optionals (withDefaultFeatures && stdenv.hostPlatform.isLinux) [ libx11 ]
|
|
++ lib.optionals (withDefaultFeatures && stdenv.hostPlatform.isDarwin) [
|
|
nghttp2
|
|
libgit2
|
|
],
|
|
checkInputs ?
|
|
lib.optionals stdenv.hostPlatform.isDarwin [ curlMinimal ]
|
|
++ lib.optionals stdenv.hostPlatform.isLinux [ openssl ],
|
|
|
|
# Fixed in #16914
|
|
buildAndTestSubdir ? ".",
|
|
checkFlags ? [ ],
|
|
buildType ? "release",
|
|
checkType ? buildType,
|
|
...
|
|
}@args:
|
|
let
|
|
inherit (builtins)
|
|
fromTOML
|
|
readFile
|
|
head
|
|
;
|
|
inherit (lib.fileset)
|
|
toSource
|
|
intersection
|
|
unions
|
|
difference
|
|
;
|
|
root = ../..;
|
|
cargoToml = fromTOML (readFile (root + /Cargo.toml));
|
|
# Allow for extra Cargo.toml files to be passed for crates
|
|
extraToml = fromTOML (readFile extraCargo);
|
|
|
|
version =
|
|
if (cargoToml.package.version.workspace or false) then
|
|
cargoToml.workspace.package.version
|
|
else
|
|
cargoToml.package.version;
|
|
in
|
|
rustPlatform.buildRustPackage {
|
|
inherit
|
|
pname
|
|
nativeBuildInputs
|
|
buildInputs
|
|
checkInputs
|
|
buildAndTestSubdir
|
|
checkFlags
|
|
buildType
|
|
checkType
|
|
version
|
|
;
|
|
|
|
# Crates will need to build with their Cargo.toml
|
|
src = toSource {
|
|
inherit root;
|
|
fileset = (
|
|
intersection root (
|
|
difference (unions (
|
|
map (p: root + p) [
|
|
/Cargo.toml
|
|
/Cargo.lock
|
|
/src
|
|
/crates
|
|
/tests
|
|
/assets
|
|
/benches
|
|
/toolkit
|
|
/scripts
|
|
]
|
|
)) ./.
|
|
)
|
|
);
|
|
};
|
|
|
|
cargoLock = {
|
|
lockFile = root + /Cargo.lock;
|
|
# Required for some of the dependencies in this repo
|
|
allowBuiltinFetchGit = true;
|
|
};
|
|
|
|
buildNoDefaultFeatures = !withDefaultFeatures;
|
|
buildFeatures = additionalFeatures [ ];
|
|
|
|
# Builds the plugins for the test using the right profile, otherwise the
|
|
# plugins cannot be found.
|
|
NUSHELL_CARGO_PROFILE = checkType;
|
|
NU_TEST_LOCALE_OVERRIDE = "en_US.UTF-8";
|
|
preCheck = ''
|
|
export HOME=$(mktemp -d)
|
|
'';
|
|
meta = {
|
|
description = extraToml.package.description or cargoToml.package.description;
|
|
homepage =
|
|
if cargoToml == extraToml then cargoToml.package.homepage else extraToml.package.repository or null;
|
|
license = lib.licenses.mit;
|
|
mainProgram = (head (extraToml.bin or [ extraToml.package ])).name or pname;
|
|
};
|
|
}
|