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
idea: move meta to each package #45948
Conversation
> nix edit boost currently edits generic.nix, leaving the user a bit confused about where a specific boost version is defined. Additionally, I think it is possible for OfBorg to ping maintainers if the maitainers are listed closer to the expressions being modified
cc @LnL7 |
Success on x86_64-darwin (full log) Attempted: boost Partial log (click to expand)
|
Success on x86_64-linux (full log) Attempted: boost Partial log (click to expand)
|
Success on aarch64-linux (full log) Attempted: boost Partial log (click to expand)
|
I wonder if you'd get better results simpler by tweaking this logic. Maybe |
One could argue that it makes sense to generalise certain meta fields like maintainers or platforms. This is done in a few places, but there's no real benefit in doing that IMHO. @dezgeg I don't think using |
I never understood why we even had the position tricks with |
@Ericson2314 hat do you mean position tricks? |
If we do the transition to define separate |
@graham I mean the use of |
Not in favor of this, the duplicated meta is very ugly. I propose this instead, which has the same effect: diff --git a/pkgs/development/libraries/boost/generic.nix b/pkgs/development/libraries/boost/generic.nix
index 617484e5a40..37ca77d674f 100644
--- a/pkgs/development/libraries/boost/generic.nix
+++ b/pkgs/development/libraries/boost/generic.nix
@@ -18,7 +18,7 @@
# Attributes inherit from specific versions
, version, src
, ...
-}:
+}@attrs:
# We must build at least one type of libraries
assert enableShared || enableStatic;
@@ -99,6 +99,7 @@ stdenv.mkDerivation {
homepage = http://boost.org/;
description = "Collection of C++ libraries";
license = stdenv.lib.licenses.boost;
+ position = builtins.unsafeGetAttrPos "version" attrs;
platforms = (if versionOlder version "1.59" then remove "aarch64-linux" else id) platforms.unix;
maintainers = with maintainers; [ peti wkennington ];
diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix
index 8af6d0e0400..5415ae3339c 100644
--- a/pkgs/stdenv/generic/make-derivation.nix
+++ b/pkgs/stdenv/generic/make-derivation.nix
@@ -264,12 +264,12 @@ rec {
hasOutput = out: builtins.elem out outputs;
in [( lib.findFirst hasOutput null (["bin" "out"] ++ outputs) )];
}
- // attrs.meta or {}
# Fill `meta.position` to identify the source location of the package.
// lib.optionalAttrs (pos != null) {
position = pos.file + ":" + toString pos.line;
# Expose the result of the checks for everyone to see.
- } // {
+ } // attrs.meta or {}
+ // {
available = validity.valid
&& (if config.checkMetaRecursively or false
then lib.all (d: d.meta.available or true) references That is, enable the |
Although, it doesn't have the same effect, because the result of that will be an attrset { column = 3; file = "/home/infinisil/src/nixpkgs/pkgs/development/libraries/boost/1.55.nix"; line = 4; } instead of a string. But tbh, I think this should be an attrset to begin with, it's easy for tools to construct a string from the attrset, but the inverse isn't easy and requires parsing. |
I found a way around this for ofborg :) |
currently edits generic.nix, leaving the user a bit confused about where
a specific boost version is defined. This is because Nix internally uses
builtins.unsafeGetAttrPos "description" package.meta
to find the filea package is from.
Additionally, I think it is possible for OfBorg to ping maintainers if the
maintainers are listed closer to the expressions being modified.
A con is obviously the duplication of meta fields.
A pro is the simplification of the meta: not having to do version comparisons in a generic location, for example.
cc @vcunat @peti @dezgeg @edolstra @Ericson2314 @dtzWill
What do y'all think? This PR is for Boost-only, but we could easily apply the same idea and improve the experience for many other packages with a "generic" home:
(and more)