Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions doc/languages-frameworks/python.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ All parameters from `stdenv.mkDerivation` function are still supported. The foll

##### Overriding Python packages

The `buildPythonPackage` function has a `overridePythonAttrs` method that
The `buildPythonPackage` function has a `overrideArgs` method that
can be used to override the package. In the following example we create an
environment where we have the `blaze` package using an older version of `pandas`.
We override first the Python interpreter and pass
Expand All @@ -628,7 +628,7 @@ with import <nixpkgs> {};
(let
python = let
packageOverrides = self: super: {
pandas = super.pandas.overridePythonAttrs(old: rec {
pandas = super.pandas.overrideArgs(old: rec {
version = "0.19.1";
src = super.fetchPypi {
pname = "pandas";
Expand Down Expand Up @@ -894,7 +894,7 @@ with import <nixpkgs> {};
(let
python = let
packageOverrides = self: super: {
pandas = super.pandas.overridePythonAttrs(old: {name="foo";});
pandas = super.pandas.overrideArgs(old: {name="foo";});
};
in pkgs.python35.override {inherit packageOverrides;};

Expand Down
2 changes: 1 addition & 1 deletion nixos/tests/common/letsencrypt/common.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# Need to override the attribute used by simp_le, which is python3Packages
python3Packages = (super.python3.override {
packageOverrides = lib.const (pysuper: {
certifi = pysuper.certifi.overridePythonAttrs (attrs: {
certifi = pysuper.certifi.overrideArgs (attrs: {
postPatch = (attrs.postPatch or "") + ''
cat "${self.cacert}/etc/ssl/certs/ca-bundle.crt" \
> certifi/cacert.pem
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/editors/jupyter/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ let
in

with python3.pkgs; toPythonModule (
notebook.overridePythonAttrs(oldAttrs: {
notebook.overrideArgs(oldAttrs: {
makeWrapperArgs = ["--set JUPYTER_PATH ${jupyterPath}"];
})
)
2 changes: 1 addition & 1 deletion pkgs/applications/misc/khal/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let
packageOverrides = self: super: {

# https://github.com/pimutils/khal/issues/780
python-dateutil = super.python-dateutil.overridePythonAttrs (oldAttrs: rec {
python-dateutil = super.python-dateutil.overrideArgs (oldAttrs: rec {
version = "2.6.1";
src = oldAttrs.src.override {
inherit version;
Expand Down
2 changes: 1 addition & 1 deletion pkgs/applications/misc/khard/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let
packageOverrides = self: super: {

# https://github.com/pimutils/khal/issues/780
python-dateutil = super.python-dateutil.overridePythonAttrs (oldAttrs: rec {
python-dateutil = super.python-dateutil.overrideArgs (oldAttrs: rec {
version = "2.6.1";
src = oldAttrs.src.override {
inherit version;
Expand Down
6 changes: 3 additions & 3 deletions pkgs/applications/misc/octoprint/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ let

pythonPackages = python2.pkgs.override {
overrides = self: super: with self; {
backports_ssl_match_hostname = super.backports_ssl_match_hostname.overridePythonAttrs (oldAttrs: rec {
backports_ssl_match_hostname = super.backports_ssl_match_hostname.overrideArgs (oldAttrs: rec {
version = "3.4.0.2";
src = oldAttrs.src.override {
inherit version;
sha256 = "07410e7fb09aab7bdaf5e618de66c3dac84e2e3d628352814dc4c37de321d6ae";
};
});

flask = super.flask.overridePythonAttrs (oldAttrs: rec {
flask = super.flask.overrideArgs (oldAttrs: rec {
version = "0.12.4";
src = oldAttrs.src.override {
inherit version;
Expand Down Expand Up @@ -63,7 +63,7 @@ let
doCheck = false;
};

pylru = super.pylru.overridePythonAttrs (oldAttrs: rec {
pylru = super.pylru.overrideArgs (oldAttrs: rec {
version = "1.0.9";
src = oldAttrs.src.override {
inherit version;
Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/networking/flexget/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ let
python' = python.override { inherit packageOverrides; };

packageOverrides = self: super: {
sqlalchemy = super.sqlalchemy.overridePythonAttrs (old: rec {
sqlalchemy = super.sqlalchemy.overrideArgs (old: rec {
version = "1.1.10";
src = old.src.override {
inherit version;
sha256 = "1lvb14qclrx0qf6qqx8a8hkx5akk5lk3dvcqz8760v9hya52pnfv";
};
});

guessit = super.guessit.overridePythonAttrs (old: rec {
guessit = super.guessit.overrideArgs (old: rec {
version = "2.1.4";
src = old.src.override {
inherit version;
Expand Down
197 changes: 101 additions & 96 deletions pkgs/build-support/rust/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,100 +3,105 @@ let
fetchcargo = import ./fetchcargo.nix {
inherit stdenv cacert git rust cargo-vendor python3;
};
in
{ name, cargoSha256 ? "unset"
, src ? null
, srcs ? null
, cargoPatches ? []
, patches ? []
, sourceRoot ? null
, logLevel ? ""
, buildInputs ? []
, cargoUpdateHook ? ""
, cargoDepsHook ? ""
, cargoBuildFlags ? []

, cargoVendorDir ? null
, ... } @ args:

assert cargoVendorDir == null -> cargoSha256 != "unset";

let
cargoDeps = if cargoVendorDir == null
then fetchcargo {
inherit name src srcs sourceRoot cargoUpdateHook;
patches = cargoPatches;
sha256 = cargoSha256;
}
else null;

setupVendorDir = if cargoVendorDir == null
then ''
unpackFile "$cargoDeps"
cargoDepsCopy=$(stripHash $(basename $cargoDeps))
chmod -R +w "$cargoDepsCopy"
''
else ''
cargoDepsCopy="$sourceRoot/${cargoVendorDir}"
'';

in stdenv.mkDerivation (args // {
inherit cargoDeps;

patchRegistryDeps = ./patch-registry-deps;

buildInputs = [ cacert git rust.cargo rust.rustc ] ++ buildInputs;

patches = cargoPatches ++ patches;

configurePhase = args.configurePhase or ''
runHook preConfigure
# noop
runHook postConfigure
'';

postUnpack = ''
eval "$cargoDepsHook"

${setupVendorDir}

mkdir .cargo
config="$(pwd)/$cargoDepsCopy/.cargo/config";
if [[ ! -e $config ]]; then
config=${./fetchcargo-default-config.toml};
fi;
substitute $config .cargo/config \
--subst-var-by vendor "$(pwd)/$cargoDepsCopy"

unset cargoDepsCopy

export RUST_LOG=${logLevel}
'' + (args.postUnpack or "");

buildPhase = with builtins; args.buildPhase or ''
runHook preBuild
echo "Running cargo build --release ${concatStringsSep " " cargoBuildFlags}"
cargo build --release --frozen ${concatStringsSep " " cargoBuildFlags}
runHook postBuild
'';

checkPhase = args.checkPhase or ''
runHook preCheck
echo "Running cargo test"
cargo test
runHook postCheck
'';

doCheck = args.doCheck or true;

installPhase = args.installPhase or ''
runHook preInstall
mkdir -p $out/bin $out/lib
find target/release -maxdepth 1 -type f -executable ! \( -regex ".*\.\(so.[0-9.]+\|so\|a\|dylib\)" \) -print0 | xargs -r -0 cp -t $out/bin
find target/release -maxdepth 1 -regex ".*\.\(so.[0-9.]+\|so\|a\|dylib\)" -print0 | xargs -r -0 cp -t $out/lib
rmdir --ignore-fail-on-non-empty $out/lib $out/bin
runHook postInstall
'';

passthru = { inherit cargoDeps; } // (args.passthru or {});
})
buildRustPackage =
{ name, cargoSha256 ? "unset"
, src ? null
, srcs ? null
, cargoPatches ? []
, patches ? []
, sourceRoot ? null
, logLevel ? ""
, buildInputs ? []
, cargoUpdateHook ? ""
, cargoDepsHook ? ""
, cargoBuildFlags ? []

, cargoVendorDir ? null
, ... } @ args:

assert cargoVendorDir == null -> cargoSha256 != "unset";

let
cargoDeps = if cargoVendorDir == null
then fetchcargo {
inherit name src srcs sourceRoot cargoUpdateHook;
patches = cargoPatches;
sha256 = cargoSha256;
}
else null;

setupVendorDir = if cargoVendorDir == null
then ''
unpackFile "$cargoDeps"
cargoDepsCopy=$(stripHash $(basename $cargoDeps))
chmod -R +w "$cargoDepsCopy"
''
else ''
cargoDepsCopy="$sourceRoot/${cargoVendorDir}"
'';

in stdenv.mkDerivation (args // {
inherit cargoDeps;

patchRegistryDeps = ./patch-registry-deps;

buildInputs = [ cacert git rust.cargo rust.rustc ] ++ buildInputs;

patches = cargoPatches ++ patches;

configurePhase = args.configurePhase or ''
runHook preConfigure
# noop
runHook postConfigure
'';

postUnpack = ''
eval "$cargoDepsHook"

${setupVendorDir}

mkdir .cargo
config="$(pwd)/$cargoDepsCopy/.cargo/config";
if [[ ! -e $config ]]; then
config=${./fetchcargo-default-config.toml};
fi;
substitute $config .cargo/config \
--subst-var-by vendor "$(pwd)/$cargoDepsCopy"

unset cargoDepsCopy

export RUST_LOG=${logLevel}
'' + (args.postUnpack or "");

buildPhase = with builtins; args.buildPhase or ''
runHook preBuild
echo "Running cargo build --release ${concatStringsSep " " cargoBuildFlags}"
cargo build --release --frozen ${concatStringsSep " " cargoBuildFlags}
runHook postBuild
'';

checkPhase = args.checkPhase or ''
runHook preCheck
echo "Running cargo test"
cargo test
runHook postCheck
'';

doCheck = args.doCheck or true;

installPhase = args.installPhase or ''
runHook preInstall
mkdir -p $out/bin $out/lib
find target/release -maxdepth 1 -type f -executable ! \( -regex ".*\.\(so.[0-9.]+\|so\|a\|dylib\)" \) -print0 | xargs -r -0 cp -t $out/bin
find target/release -maxdepth 1 -regex ".*\.\(so.[0-9.]+\|so\|a\|dylib\)" -print0 | xargs -r -0 cp -t $out/lib
rmdir --ignore-fail-on-non-empty $out/lib $out/bin
runHook postInstall
'';

passthru = { inherit cargoDeps; } // (args.passthru or {});
}) // {
overrideArgs = f: buildRustPackage (args // (f args));
};

in buildRustPackage
2 changes: 1 addition & 1 deletion pkgs/development/arduino/platformio/chrootenv.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let
packageOverrides = self: super: {

# https://github.com/platformio/platformio-core/issues/349
click = super.click.overridePythonAttrs (oldAttrs: rec {
click = super.click.overrideArgs (oldAttrs: rec {
version = "5.1";
src = oldAttrs.src.override {
inherit version;
Expand Down
Loading