Proof of concept, refactor/extract makeDerivationArgument#295105
Closed
roberth wants to merge 21 commits intoNixOS:masterfrom
Closed
Proof of concept, refactor/extract makeDerivationArgument#295105roberth wants to merge 21 commits intoNixOS:masterfrom
makeDerivationArgument#295105roberth wants to merge 21 commits intoNixOS:masterfrom
Conversation
…non-derivation package attributes
Non-__structuredAttrs compatibility logic should be handled in a simpler manner if at all in future callers of makeDerivationArgument.
…heck and doInstallCheck
…bleParallelBuilding
…dening This appears only relevant in a stdenv with a compiler. Should reconsider?
…arwinAllowLocalNetworking
… meson and cmake A generic derivation making function should not be coupled to specific build tools. This also moves the logic into separate files for good measure.
This is not complete, as described in the comment.
You can now do:
nix-repl> :b derivation (stdenv.makeDerivationArgument { name = "hi"; dontUnpack = true; buildPhase = "echo hi > $out"; dontInstall = true; })
or even:
nix-repl> :b x // { type = "derivation"; }
error: derivation name missing
nix-repl> x.drvPath
"/nix/store/zfnznggsbm48y2g130wg1h891gwbf6s4-hi.drv"
nix-repl> :b x // { name = "okay"; type = "derivation"; }
This derivation produced the following outputs:
out -> /nix/store/szky5bcmil93q0jjqprzc52mia5nfgsc-hi
The latter is obviously NOT recommended, because it does not
produce a standard package attribute set. Point is, new code
could implement that logic without duplicating what's in
Nix's built-in derivation.nix file.
Among many other improvements.
- For instance, no cmake/meson overhead where it's not needed.
- Single fixpoint NixOS#273815
roberth
added a commit
to hercules-ci/nixpkgs
that referenced
this pull request
Mar 12, 2024
These two commits make for a cleaner commit history and git blame than NixOS#295105, where this refactor was developed. See its commit messages for details and design choices, esp. up to and including 37f76fd.
13 tasks
Member
Author
|
Continued in #295378. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of changes
A clean refactor of
make-derivation.nixto extract a function that only generates thederivationargument.See commit messages for some more details.
mkDerivationthat's compatible and does not duplicate any code unnecessarily.Questions:
Does ofborg agree?
What's the possible performance impact?
removeAttrscall and I've added at least three function calls.Would it be cleaner to refactor the other way around?
This is the most mechanical and therefore more reliable method.
However, now that we know the end state of the small
mkDerivationfunction, we couldmkDerivationtomakeDerivationArgumentmkDerivationfrom this PRpassthru, or maybe it's fine, being near the end, and already nicely indentedThings done
nix.conf? (See Nix manual)sandbox = relaxedsandbox = truenix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/)Add a 👍 reaction to pull requests you find important.