Skip to content

lib.filesystem.resolveDefaultNix: init#418824

Merged
hsjobeki merged 2 commits intoNixOS:masterfrom
roberth:lib-resolveDefaultNix
Jul 3, 2025
Merged

lib.filesystem.resolveDefaultNix: init#418824
hsjobeki merged 2 commits intoNixOS:masterfrom
roberth:lib-resolveDefaultNix

Conversation

@roberth
Copy link
Copy Markdown
Member

@roberth roberth commented Jun 21, 2025

This came up in #413892 and it can DRY with an existing ad hoc definition.

The existing call site was less advanced, lacking the "/foo/" case, but that won't be a problem, because it's arguably correct, and it only occurs in a diagnostic message anyway, and I've tested the message (see commit).
(Also toString and + "/default.nix" commute.)

Tested with:

  1. Replace the callPackageWith call by null, to simulate an ancient Nix
  2. Run the following commands in a terminal in nixpkgs:
    $ mkdir test/
    
    $ echo '{ asdfasdfasdf }: null' >test/default.nix
    
    $ nix repl -f .
    
    nix-repl> callPackage ./test { }
    error:
          … while calling the 'abort' builtin
            at /home/user/src/nixpkgs/lib/customisation.nix:312:7:
              311|     else
              312|       abort "lib.customisation.callPackageWith: ${error}";
                |       ^
              313|
    
          error: evaluation aborted with the following error message: 'lib.customisation.callPackageWith: Function called without required argument "asdfasdfasdf" at /home/user/src/nixpkgs/test/default.nix'
    

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • Nixpkgs 25.11 Release Notes (or backporting 24.11 and 25.05 Nixpkgs Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
  • NixOS 25.11 Release Notes (or backporting 24.11 and 25.05 NixOS Release notes)
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other contributing documentation in corresponding paths.

Add a 👍 reaction to pull requests you find important.

@roberth roberth force-pushed the lib-resolveDefaultNix branch from a614494 to 8220180 Compare June 21, 2025 19:39
@roberth roberth mentioned this pull request Jun 21, 2025
13 tasks
@roberth roberth changed the title lib.callPackageWith: Use resolveDefaultNix lib.filesystem.resolveDefaultNix: init Jun 21, 2025
roberth added 2 commits June 21, 2025 21:43
Tested with:
1. Replace the callPackageWith call by `null`, to simulate an ancient Nix
2. Run the following commands in a terminal in nixpkgs:

    $ mkdir test/

    $ echo '{ asdfasdfasdf }: null' >test/default.nix

    $ nix repl -f .

    nix-repl> callPackage ./test { }
    error:
          … while calling the 'abort' builtin
            at /home/user/src/nixpkgs/lib/customisation.nix:312:7:
              311|     else
              312|       abort "lib.customisation.callPackageWith: ${error}";
                |       ^
              313|

          error: evaluation aborted with the following error message: 'lib.customisation.callPackageWith: Function called without required argument "asdfasdfasdf" at /home/user/src/nixpkgs/test/default.nix'
@roberth roberth force-pushed the lib-resolveDefaultNix branch from 8220180 to 66016fe Compare June 21, 2025 19:43
@github-actions github-actions bot added 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person. 6.topic: lib The Nixpkgs function library labels Jun 21, 2025
@github-actions github-actions bot added 12.approvals: 2 This PR was reviewed and approved by two persons. and removed 12.approvals: 1 This PR was reviewed and approved by one person. labels Jun 21, 2025
@hsjobeki hsjobeki merged commit 8660325 into NixOS:master Jul 3, 2025
27 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: lib The Nixpkgs function library 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 12.approvals: 2 This PR was reviewed and approved by two persons.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants