-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lib/source-types.nix: remove redundant sourceType #175498
Conversation
The provenance type `fromSource` is redundant, and adds numerous special edge cases. Let's remove it. I pointed this out during the review of #161098; @risicle asked that I submit this as a seperate subsequent PR in order to not further delay the merge of #161098. Therefore, I am submitting it now. The `fromSource` provenance type is redundant; the following are semantically indistinguishable: ``` meta = { sourceProvenance = []; } meta = { sourceProvenance = [ lib.source-types.fromSource ]; } ``` Furthermore, `fromSource` gets special treatment: "a package with no `meta.sourceProvenance` set implies it has no *known* `sourceType`s **other than `fromSource`.**". This greatly complicates the "is this package built from source" routine. Consider the exemplar `allowNonSourcePredicate` to permit non-source firmware given in check-meta.nix. This predicate is likely to be a very popular policy choice for nixpkgs users, due to the level of firmware-saturation in consumer-grade hardware. It changes from: ``` allowNonSourcePredicate = with lib.lists; pkg: !(any (p: !p.isSource && p!=lib.sourceTypes.binaryFirmware) (toList pkg.meta.sourceProvenance) ``` to ``` allowNonSourcePredicate = lib.lists.any (p: p!=lib.sourceTypes.binaryFirmware) (toList pkg.meta.sourceProvenance); ``` and, if #175495 merges, even further to: ``` allowNonSourcePredicate = lib.lists.any (p: p!=lib.sourceTypes.binaryFirmware) pkg.meta.sourceProvenance; ``` Similar simplifications will be enjoyed by any predicates which users write for themselves, or any "provenance functionals" which express the `sourceProvenance` of one package as a function of the `sourceProvenance` of some subpackage.
@risicle should be added as a reviewer (am I able to add reviewers to my own PRs?) |
Without nixpkgs/pkgs/tools/security/ghidra/build.nix Line 174 in 9362275
null sourceProvenance is assumed to be [ fromSource ] , whereas an empty list has no special meaning.
What we probably neglected to do is add an equivalent of |
In that case, one of the package's
You can just add a one-attribute Note that even With
That would leave no way to express "no promises, because nobody has looked yet", which is by far the most common situation right now (and probably for the forseeable future). I think the fact that a missing attribute means "no promises" was one of the strong points of your RFC. I liked that a lot, I hope we keep it.
I may have mentioned this before, but |
This is something I thought about while I've been trawling through nixpkgs - the problem with it is in many cases a file we download contains binary elements, but we don't use them. A number of java packages for instance include a pre-built Which reminds me we should probably add a
Could still explicitly set
I realize this, but it still doesn't mean source types should diverge unless they are explicitly better (I won't say indisputably because this is the internet). Ideally using a design that is able to be ported back to the licenses system if it's successful. The licenses-style design starts off with a couple of points in its column because of consistency, and it also has the advantage of being able to filter both "by license" and "by package" with short expressions. So - I'd only personally support something that can do this and more. For a clean-slate design, my thinking would be around having a single (replaceable) default deciding function that calls out to another per-(license/sourcetype) function in its inner loop. Though it would also be nice to be able to replace the top-level function while still being able to defer a decision back to the default function ... possibly by returning |
If you're sure those binary elements aren't used in building the package's derivation outputs, then they are not relevant to the package's
If you're unsure, or want to guard against future changes, a good solution is to simply delete the unused elements before building, for example in
That's extremely unrealistic. The
I agree. I think that the simplification proposed by this PR is explicitly better (otherwise I wouldn't have opened it!) |
Sure, that's what I do - but here I was referring to why it's not sufficient to just mark the downloaded source file(s) derivation with a |
I don't think it would be particularly difficult to achieve. The new mechanism simply needs to be able to implement the old mechanism as its default behaviour, using replaceable functions.
Except it still can't allow or disallow by-source-type without having to replicate the whole loop logic in the predicate function, whereas duplicating the licenses' allowlist/blocklist attributes would enable users to make simple additions to lists. I don't see it as worth diverging for something that's just differently annoying. |
If you have the burning urge to classify different individual files within a tarball, you do it like this:
I have to say this is a pretty niche use case. But it is representable nonetheless.
I'm having trouble understanding what you mean here. Could you please give a concrete example of "replicate the whole loop logic in the predicate function"? You mean replicating the 53-character string " |
😞 |
Description of changes
The provenance type
fromSource
is redundant, and adds numerous special edge cases. Let's remove it. I pointed this out during the review of #161098; @risicle asked that I submit this as a seperate subsequent PR in order to not further delay the merge of #161098. Therefore, I am submitting it now.The
fromSource
provenance type is redundant; the following are semantically indistinguishable:Furthermore,
fromSource
gets special treatment: "a package with nometa.sourceProvenance
set implies it has no knownsourceType
s other thanfromSource
.".This complicates the "is this package built from source" routine. Consider the exemplar
allowNonSourcePredicate
to permit non-source firmware given in check-meta.nix. This predicate is likely to be a very popular policy choice for nixpkgs users, due to the firmware-saturated state of the consumer-grade hardware market. It changes from:to
and, if #175495 merges, even further to:
Similar simplifications will be enjoyed by any predicates which users write for themselves, or any "provenance functions" which express the
sourceProvenance
of one package as a function of thesourceProvenance
of some subpackage.Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)nixos/doc/manual/md-to-db.sh
to update generated release notes