Commit Graph

31 Commits

Author SHA1 Message Date
Yueh-Shun Li
eb76b98770 tests.overriding: tests-fetchurl: use generated non-zero hashes
Don't use zero hashes where the hash is supposed to be non-zero.

Don't depend on nix.src.hash as nix.src might be wrapped to accept patches.
2026-06-08 15:23:38 +08:00
Yueh-Shun Li
7328b0d9f1 tests.overriding: tests-fetchgit: use generated non-zero hashes
Don't use zero hashes where the hash is supposed to be non-zero.

Don't depend on nix.src.hash as nix.src might be wrapped to accept patches.
2026-06-08 15:23:38 +08:00
Yueh-Shun Li
c781661674 tests.overriding: attach fetchgit tests
tests-fetchgit was implemented in commit 4e37d03ba2
("fetchgit: reference hash from finalAttrs.hash"),
but not attach to tests.overriding,
hence this fix.
2026-06-06 15:06:36 +08:00
Yueh-Shun Li
e7eb6868d5 overridePythonAttrs: support extension-style newArgs
Allow overridePythonAttrs to take `finalAttrs: args: { }`.
2026-04-26 17:44:11 +08:00
Yueh-Shun Li
d4956bb361 tests.overriding: add overridePythonAttrs-plain 2026-04-26 17:44:11 +08:00
Yueh-Shun Li
eddb12ac9d mkDerivation: make allowedReferences/allowedRequisites nullable when __structuredAttrs is true 2026-02-12 17:03:57 -08:00
Leona Maroni
9667e939fa test/overriding: remove python deprecated stdenv override tests
These tests now throw a warning which is prohibited inside Nixpkgs:
  Passing `stdenv` directly to `buildPythonPackage` or `buildPythonApplication` is deprecated. You should use their `.override` function instead, e.g:
    buildPythonPackage.override { stdenv = customStdenv; } { }
2026-01-05 15:44:40 +01:00
Matt Sturgeon
553a6c3d3a buildPython*: preserve overrideStdenvCompat on subsequent overrides
This is needed to support the deprecated method of overriding `stdenv`
via `overridePythonAttrs`.
2025-12-11 01:15:17 +00:00
Yueh-Shun Li
06711e45a0 tests.overriding: add overridePythonAttrs-stdenv-deprecated
Co-authored-by: Matt Sturgeon <matt@sturgeon.me.uk>
2025-12-11 03:54:59 +08:00
Yueh-Shun Li
dacf4930a9 tests.overriding: test buildPythonPackage.override
Co-authored-by: Matt Sturgeon <matt@sturgeon.me.uk>
2025-12-11 03:41:43 +08:00
Yueh-Shun Li
db3a787f4d tests.overriding: rename local variable python-package-stub -> package-stub 2025-12-11 03:16:53 +08:00
Yueh-Shun Li
ca6c090082 makeOverridablePythonPackage: take care of overrideAttrs
Make it possible to mix overridePythonAttrs and overrideAttrs, i.e.
((<pkg>.overrideAttrs (_: { foo = "a"; })).overridePythonAttrs (_: { })).foo now works

Co-authored-by: Matt Sturgeon <matt@sturgeon.me.uk>
2025-12-10 19:22:04 +08:00
Yueh-Shun Li
1653d671aa tests.overriding: modularize Python tests
Test with a pseudopackage python-package-stub.

Modularize the transforming function and testing function.
2025-12-10 19:19:06 +08:00
Yueh-Shun Li
4e37d03ba2 fetchgit: reference hash from finalAttrs.hash 2025-12-10 01:07:13 +08:00
Yueh-Shun Li
ae800ea500 fetchurl: reference outputHash from finalAttrs.hash 2025-12-10 01:02:47 +08:00
Yueh-Shun Li
ffca1c4197 tests.overriding: restructure test cases utilizing non-boolean support 2025-11-06 00:13:49 +00:00
Yueh-Shun Li
5351568405 tests.overriding: refactor and allow non-bool expected value
Co-authored-by: Matt Sturgeon <matt@sturgeon.me.uk>
2025-11-06 00:13:31 +00:00
Wolfgang Walther
5a0711127c treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
Yueh-Shun Li
ef2f8315bf fetchhg: make argument hash overridable 2025-07-09 04:08:00 +08:00
Winter
a19cd4ffb1 Revert "treewide: replace rev with tag"
This reverts commit 65a333600d.

This wasn't tested for correctness with something like fodwatch [0],
and should not have been (self-)merged so quickly, especially without
further review.

It also resulted in the breakage of at least one package [1] (and that's
the one we know of and was caught).

A few packages that were updated in between this commit and this revert
were not reverted back to using `rev`, but other than that, this is a
1:1 revert.

[0]: https://codeberg.org/raphaelr/fodwatch
[1]: https://github.com/NixOS/nixpkgs/pull/396904 / 758551e458
2025-04-08 02:57:25 -04:00
Pol Dellaiera
65a333600d treewide: replace rev with tag 2025-04-07 16:57:22 +02:00
Yueh-Shun Li
2439ead791 lib.extendMkDerivation: init
Add functions extendMkDerivation to lib.customisation.

Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Co-authored-by: Lin Jian <me@linj.tech>
Co-authored-by: Philip Taron <philip.taron@gmail.com>
2025-01-18 14:20:45 +08:00
Yueh-Shun Li
9e66d6ce58 tests.overriding: restructure and categorise by test targets
Split tests in the let-in block into
tests-stdenv, tests-go, and tests-python.

Place the dependent variables into the let-in block of each category.

This chore commit causes no rebuilds.
2024-12-19 22:33:31 +08:00
Yueh-Shun Li
662cf493f0 tests.overriding: format with nixfmt-rfc-style 2024-12-19 22:30:30 +08:00
Yueh-Shun Li
226b370423 tests.overriding: simplify implementation with lib.concatMapStringAttrsSep 2024-12-06 11:02:27 +08:00
Yueh-Shun Li
eed069a5bc buildGoModule: fix overrideAttrs overriding
Fix overriding of vendorHash and various attributes via the fixed point
attribute support of stdenv.mkDerivation.

Pass as derivation attributes
goModules, modRoot, vendorHash, deleteVendor, and proxyVendor.

Move goModules and vendorHash out of passthru.

Co-authored-by: Doron Behar <doron.behar@gmail.com>
2024-08-11 13:38:11 +08:00
Yueh-Shun Li
fdd16729a2 tests.overriding: structure tests as an attribut set
Make individual tests accessible via tests.override.tests.<name>
2024-07-27 22:42:30 +08:00
Artturin
42c94d06fd stdenv: fix overriding with attrset when finalAttrs isn't used
```
nix-repl> (pkgs.htop.overrideAttrs { pname = "hello-overriden"; }).pname
error:
       … while evaluating a branch condition

         at /nix/store/phn5cahwacv9wjgalygw62x8l4xbl6x3-source/lib/customisation.nix:86:7:

           85|     in
           86|       if builtins.isAttrs result then
             |       ^
           87|         result // {

       … while calling the 'isAttrs' builtin

         at /nix/store/phn5cahwacv9wjgalygw62x8l4xbl6x3-source/lib/customisation.nix:86:10:

           85|     in
           86|       if builtins.isAttrs result then
             |          ^
           87|         result // {

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: attempt to call something which is not a function but a set

       at /nix/store/phn5cahwacv9wjgalygw62x8l4xbl6x3-source/pkgs/stdenv/generic/make-derivation.nix:58:21:

           57|           f = self: super:
           58|             let x = f0 super;
             |                     ^
           59|             in
```
2023-07-03 21:34:50 +03:00
Artturin
0fdae31531 stdenv: let overrideAttrs accept attrset OR function
Makes overrideAttrs usable in the same way that `override` can be used.
It allows the first argument of `overrideAttrs` to be either a function
or an attrset, instead of only a function:

hello.overrideAttrs (old: { postBuild = "echo hello"; })
hello.overrideAttrs { postBuild = "echo hello"; }

Previously only the first example was possible.

Co-authored-by: adisbladis <adisbladis@gmail.com>
Co-authored-by: matthewcroughan <matt@croughan.sh>
2023-06-30 23:28:00 +03:00
Artturin
a0f4e8746d tests.overriding: add repeatedOverrides-pname, repeatedOverrides-entangled-pname
from https://github.com/NixOS/nixpkgs/pull/201734#pullrequestreview-1185972282
2023-01-28 12:10:47 +02:00
Artturin
9c0ac5691c tests.overriding: init
only outputs the first failing test atm
2023-01-20 19:20:03 +02:00