Merge pull request #163443 from ncfavier/fix-types-package

lib.types.package: only call toDerivation when necessary
This commit is contained in:
Robert Hensing 2022-03-11 11:56:44 +01:00 committed by GitHub
commit a15fbdb88f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 4 deletions

View File

@ -368,13 +368,21 @@ rec {
emptyValue = { value = {}; }; emptyValue = { value = {}; };
}; };
# derivation is a reserved keyword. # A package is a top-level store path (/nix/store/hash-name). This includes:
# - derivations
# - more generally, attribute sets with an `outPath` or `__toString` attribute
# pointing to a store path, e.g. flake inputs
# - strings with context, e.g. "${pkgs.foo}" or (toString pkgs.foo)
# - hardcoded store path literals (/nix/store/hash-foo) or strings without context
# ("/nix/store/hash-foo"). These get a context added to them using builtins.storePath.
package = mkOptionType { package = mkOptionType {
name = "package"; name = "package";
check = x: isDerivation x || isStorePath x; check = x: isDerivation x || isStorePath x;
merge = loc: defs: merge = loc: defs:
let res = mergeOneOption loc defs; let res = mergeOneOption loc defs;
in if isDerivation res then res else toDerivation res; in if builtins.isPath res || (builtins.isString res && ! builtins.hasContext res)
then toDerivation res
else res;
}; };
shellPackage = package // { shellPackage = package // {

View File

@ -22,7 +22,8 @@ merging is handled.
`types.package` `types.package`
: A derivation or a store path. : A top-level store path. This can be an attribute set pointing
to a store path, like a derivation or a flake input.
`types.anything` `types.anything`

View File

@ -43,7 +43,9 @@
</term> </term>
<listitem> <listitem>
<para> <para>
A derivation or a store path. A top-level store path. This can be an attribute set
pointing to a store path, like a derivation or a flake
input.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>