Question
In the nix/derivations/default.nix there are several src= blocks:
- Some use fixed paths to show that evaluation in principle works with fixed paths.
- Some use
relativeFileset as a hack to make toSource work with a dynamic project_root argument.
- And then there is the naive attempt to use
toSource with project_root without the relativeFileset hack, which fails...
https://github.com/NixOS/nixpkgs/blob/c385f4d30bb544e1c7b1a5d18a55e5379ebd3bc8/lib/fileset/default.nix#L420:C3
Can we add a variant of lib.fileset.toSource (like lib.fileset.toSourceRelative) which:
- sees
root as a baseDir and
fileset = lib.fileset.unions [ as a list of files relative to baseDir
Contrast: toSource sees root as a prefix which needs to be removed from all the entries in the given fileset.
project_root = /home/foo/myproject;
src = lib.fileset.toSourceRelative {
root = project_root;
fileset = lib.fileset.unions [
src/main.rs
src/build.rs
];
};
In case you want to reproduce / experiment with this, I've added this repository with all variants:
https://github.com/qknight/nix-toSource-need-help?tab=readme-ov-file#question
Question
In the nix/derivations/default.nix there are several src= blocks:
relativeFilesetas a hack to make toSource work with a dynamicproject_rootargument.toSourcewithproject_rootwithout therelativeFilesethack, which fails...https://github.com/NixOS/nixpkgs/blob/c385f4d30bb544e1c7b1a5d18a55e5379ebd3bc8/lib/fileset/default.nix#L420:C3
Can we add a variant of
lib.fileset.toSource(likelib.fileset.toSourceRelative) which:rootas a baseDir andfileset = lib.fileset.unions [as a list of files relative to baseDirContrast:
toSourceseesrootas a prefix which needs to be removed from all the entries in the givenfileset.In case you want to reproduce / experiment with this, I've added this repository with all variants:
https://github.com/qknight/nix-toSource-need-help?tab=readme-ov-file#question