NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
16.46k stars 12.96k forks source link

Feature request: new meta attr for source code repository #293838

Open lolbinarycat opened 3 months ago

lolbinarycat commented 3 months ago

Problem

most packages use meta.homepage to link to the source code repository, but for projects with an actual homepage (such as luajit), finding the source code often requires clicking around various links to try to find the official repo.

for packages that use fetchFromGitHub or similar, you can usually piece the url back together with some effort, but for projects that use a source tarball (again, like luajit), you're out of luck.

Proposal

a meta.repository field that points to an http-browsable source tree.

for packages without a separate homepage, you could just set the meta.repository field instead.

Checklist


Add a :+1: reaction to issues you find important.

rhendric commented 3 months ago

Did you born yesterday?

@AndersonTorres, this is rude. OP may be misguided but that isn't license to take this tone.

ghost commented 3 months ago
  `repository` would be the first to pull directly from a complex attribute not already part of `meta`, which is a threshold worth pausing at, because of precisely the sort of problem we've just witnessed.

@rhendric what is the problem we just witnessed? we made a mistake fixed it and have a better implementation because of it that is immune to the previous failure. requiring a perfect first implementation is not a good faith argument.

lolbinarycat commented 3 months ago

More like no longer needs to be tested via CI, because for most packages there'll be nothing to test.

most packages. the entire point of testing is to catch edge cases.

As soon as ‘everyone’ is more than one nice-to-have link in the search app, I'll entertain this objection.

well guess what, i have immediate plans for other stuff i would like to do with it so... yeah it's more that nixos-search

As already noted, addressing eval errors outside of Nix is easier than inside, and consumers can always filter the packages down to a set they're interested in.

as already noted, doing so results in massive performance penalties.

You're proposing changing what src attributes are required to evaluate under what conditions just so that you can put logic intended to populate a search result field in Nixpkgs instead of in the search app—this is clearly a case of the tail wagging the dog.

this is simply misrepresenting my intent. i already said there are other usecases. i would really appreciate if people would stop telling me what i want.

rhendric commented 3 months ago

@a-n-n-a-l-e-e, I'm not requiring a perfect first implementation.

The issue is that the scope increased from ‘add a field to meta’ to ‘add a field to meta and also create a new guarantee for src to evaluate successfully in more contexts’, and that second bit is harder and more error-prone. If we agree on the value of undertaking both parts, then making a mistake in the first attempt of the second part isn't a big deal—fix it and move on, as you say. But the mistake is evidence that the second part is harder, and that even if it looks like we get it right now, problems may arise again in the future (and that comment in the PR is evidence that we're expecting those problems—and that resolution mechanism (find the comment based on stack trace breadcrumbs) is not great!). And given that the second part is harder, I assert that it isn't worth it to attempt and we should take the scope of the work back to just the first part.

@lolbinarycat

most packages. the entire point of testing is to catch edge cases.

But you don't have to test what you don't implement! I'm really confused by our disagreement here. You want to change src and then test that the change is good; I want to refrain from changing src and then there's nothing to do or test.

well guess what, i have immediate plans for other stuff i would like to do with it so... yeah it's more that nixos-search

How about discussing those plans then? That might convince me that implementing the feature the way you want is worth doing even if it involves changing the guarantees around src.

as already noted, doing so results in massive performance penalties.

And that's much less of a big deal if it doesn't happen in the heart of Nixpkgs for everyone's evaluation.

this is simply misrepresenting my intent. i already said there are other usecases. i would really appreciate if people would stop telling me what i want.

Sorry you're frustrated, but I'm going off of what you've said in this thread so far, and I think the above comment is the first time you're mentioning any other use cases in a non-hypothetical way.

lolbinarycat commented 3 months ago

But you don't have to test what you don't implement! I'm really confused by our disagreement here. You want to change src and then test that the change is good; I want to refrain from changing src and then there's nothing to do or test.

i thought you wanted to not implement it in nixpkgs.

guess what, if you move the code somewhere else, it still exists!

lolbinarycat commented 3 months ago

github sucks on mobile

rhendric commented 3 months ago

i thought you wanted to not implement it in nixpkgs.

guess what, if you move the code somewhere else, it still exists!

This isn't the gotcha that you think it is, so the attempt at a dunk isn't exactly going to be convincing.

What you would be testing if this logic were in Nixpkgs is not the correctness of the logic itself. The logic is pretty dang simple—use meta.repository if it exists, and use src.meta.repository if it doesn't, and adjust for lists appropriately. That's a function that could be unit tested very easily, but it's not what we're discussing, I think. It seems to me that when you say you want the correctness tested in Nixpkgs, what you want to ensure is that every derivation in Nixpkgs has a src that can be accessed in this way, across all platforms and under any other weird conditions. That's hard to test and hard to guarantee going forward.

I'm proposing not making that change to the expectations around src. Implement the trivial function elsewhere. If you plan on using it in multiple places, stick it in a library. Maybe it even deserves to live in lib. So yes, that code still exists! And you can test it if you want! What won't be tested, because it won't change, is that src can be accessed in all the contexts that you might want meta. If consumers try to access src in those contexts, they can fail and recover from the failure in whatever way is appropriate for them, because that's not Nixpkgs's concern.

AndersonTorres commented 3 months ago

Did you born yesterday?

@AndersonTorres, this is rude. OP may be misguided but that isn't license to take this tone.

Not my intention, just an expression of surprise.

For someone throwing arguments like "a lot of this was made before" without backing them up, it is hilarious that the most obvious example is now requiring evidence!

AndersonTorres commented 3 months ago

requiring a perfect first implementation is not a good faith argument

the first one broke - twice, if you can't remember, Ghostie...

lolbinarycat commented 3 months ago

That's hard to test

it's really not, it's basically just nesting two for-each loops.

in my experience it isn't difficult to make src eval either.

hard to guarantee going forward.

  1. nixpkgs doesn't guarantee stability outside of stable releases
  2. i've only ever seen one pattern that breaks this expectation: indexing src based on the value of the current system
rhendric commented 3 months ago

That's hard to test

it's really not, it's basically just nesting two for-each loops.

That'll test that it works in the specific configuration that it's tested in. But a given src could depend on any configuration value, not just system, and you aren't going to test every possible permutation in CI.

hard to guarantee going forward.

  1. nixpkgs doesn't guarantee stability outside of stable releases
  2. i've only ever seen one pattern that breaks this expectation: indexing src based on the value of the current system

Yeah, so this really comes down to a risk appetite thing. If you're a move-fast-break-things person, you might see the risk as worth it. You're looking at the things you see and saying they don't look so bad. I'm looking at the spaces where there can be things I don't see and saying why risk it? I don't think there have been enough eyeballs on this for me to feel comfortable with work that has a good chance of slipping time bombs into Hydra, which take precious time and effort to resolve. Particularly when consumers who want this logic can shoulder the burden of evaluating it themselves. Why not start there and propose moving things into Nixpkgs after you've proved the value of the work?

ghost commented 3 months ago

@a-n-n-a-l-e-e, I'm not requiring a perfect first implementation.

The issue is that the scope increased from ‘add a field to meta’ to ‘add a field to meta and also create a new guarantee for src to evaluate successfully in more contexts’, and that second bit is harder and more error-prone.

so we are not trying to guarantee that src evaluates correctly. the new implementation doesn't require src to evaluate meta attributes.

lolbinarycat commented 3 months ago

That'll test that it works in the specific configuration that it's tested in. But a given src could depend on any configuration value, not just system, and you aren't going to test every possible permutation in CI.

theoretically, but i don't think they're likely to in practice.

anyways, by that argument, some combination of config options could cause nixpkgs as a whole to stop evaluating, since we're not testing every permutation.

rhendric commented 3 months ago

@a-n-n-a-l-e-e

so we are not trying to guarantee that src evaluates correctly. the new implementation doesn't require src to evaluate meta attributes.

The new implementation being #300313? Which contains this code?

      # NOTE: this will fail if src fails to eval, in that case either set meta.repository manually to prevent this default from being evaluated, or just make sure src doesn't fail to eval.
      repository =
        if attrs ? src.meta.homepage
        then attrs.src.meta.homepage
        else if attrs ? srcs && isList attrs.srcs
        then unlist (map (src: src.meta.homepage) (filter (src: src ? meta.homepage) attrs.srcs))
        else [];

That's the code that doesn't require src? The code that fails ‘if src fails to eval’? Can you clarify?

@lolbinarycat

anyways, by that argument, some combination of config options could cause nixpkgs as a whole to stop evaluating, since we're not testing every permutation.

Yes, some combination of config options could do that. I don't know what point you're trying to make with that statement.

ghost commented 3 months ago

@a-n-n-a-l-e-e

so we are not trying to guarantee that src evaluates correctly. the new implementation doesn't require src to evaluate meta attributes.

The new implementation being #300313? Which contains this code?

      # NOTE: this will fail if src fails to eval, in that case either set meta.repository manually to prevent this default from being evaluated, or just make sure src doesn't fail to eval.
      repository =
        if attrs ? src.meta.homepage
        then attrs.src.meta.homepage
        else if attrs ? srcs && isList attrs.srcs
        then unlist (map (src: src.meta.homepage) (filter (src: src ? meta.homepage) attrs.srcs))
        else [];

That's the code that doesn't require src? The code that fails ‘if src fails to eval’? Can you clarify?

right. src not evaluating will not prevent access to other fields in meta, which was the issue before. trying to evaluate repository will still be problematic but i'm not sure it's worth adding additional checks to repository to prevent errors related to src. it's possible, checking that sourceProvence isSource, but perhaps not necessary. my point is that adding the repository field will not break current usage.

AndersonTorres commented 3 months ago

it's possible, checking that sourceProvence isSource

this is another assumption that can be broken easily.

(currently I am more inclined to an "outside nix" approach (scripting, manual fixup, treewide, small steps), in case someone asks me.)

lolbinarycat commented 3 months ago

What about assembly?

unless you are using import-from-derivation (which is banned in nixpkgs), assembly will never be interpreted at eval time, only at build time.

Indeed we can argue font glyphs are exactly like that.

font glyphs are binary data, not binary code. it could be argued that truetype fonts contain vm bytecode, but they certainly do not contain native code.

ghost commented 3 months ago

so i wanted to see how many aborts are generated from trying pkg.meta.repository over all packages with the hydra systems x64/aarch64 linux & darwin. so hacked the script below which runs the check meta eval. Running the script i found 19 files that needed to be modified to throw. (probably better way to do this but here is a hacked 1st attempt)

script.sh ```bash #!/usr/bin/env bash # https://github.com/NixOS/ofborg?tab=readme-ov-file#running-meta-checks-locally curl -OL https://raw.githubusercontent.com/NixOS/ofborg/released/ofborg/src/outpaths.nix GC_INITIAL_HEAP_SIZE=4g nix-env -f ./outpaths.nix -qaP --no-name --out-path --arg checkMeta true > out-paths # transform out-paths to: # pkgs: with pkgs; [ # pkg-name.meta.repository or null # ... # ] # need to remove packages with names that include '+' and .if. and pkgs-lib-tests cat out-paths | \ gawk '{gsub("\\.[^.]*$", ".meta.repository or null", $1); print $1}' | \ sort -u | \ sed -e '/haskellPackages.if/d' \ -e '/pkgs-lib-tests/d' \ -e '/+/d' | \ awk 'BEGIN{ print "pkgs: with pkgs; ["} { print $0 } END{ print "]"}' > out-paths.nix for sys in x86_64-darwin x86_64-linux aarch64-darwin aarch64-linux; do nix eval --impure --expr 'with import ./. { system = '"\"$sys\""'; }; map (t: builtins.tryEval t) ((import ./out-paths.nix) pkgs)' done ```
nixpkgs.diff add repository to meta and add throw to 19 files ```diff diff --git a/pkgs/applications/audio/renoise/default.nix b/pkgs/applications/audio/renoise/default.nix index d3462ecc6ad5..a56d43876fb0 100644 --- a/pkgs/applications/audio/renoise/default.nix +++ b/pkgs/applications/audio/renoise/default.nix @@ -39,7 +39,7 @@ in stdenv.mkDerivation rec { releasePath else let - platform = platforms.${stdenv.system}; + platform = platforms.${stdenv.system} or (throw "unsupported system ${stdenv.hostPlatform.system}"); urlVersion = lib.replaceStrings [ "." ] [ "_" ] version; in fetchurl { url = diff --git a/pkgs/applications/gis/udig/default.nix b/pkgs/applications/gis/udig/default.nix index 8510918d4cab..264445336cd3 100644 --- a/pkgs/applications/gis/udig/default.nix +++ b/pkgs/applications/gis/udig/default.nix @@ -13,7 +13,7 @@ let hash = "sha256-Ihk3InHB3/tEYRqH2ozhokz2GN8Gfig5DJkO/8P1LJs="; }; }; - src = srcs.${stdenv.hostPlatform.system}; + src = srcs.${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}"); meta = with lib; { description = "User-friendly Desktop Internet GIS"; diff --git a/pkgs/applications/graphics/sane/backends/brscan4/default.nix b/pkgs/applications/graphics/sane/backends/brscan4/default.nix index ec8efcc27c2a..c15b3033a265 100644 --- a/pkgs/applications/graphics/sane/backends/brscan4/default.nix +++ b/pkgs/applications/graphics/sane/backends/brscan4/default.nix @@ -21,7 +21,7 @@ stdenv.mkDerivation rec { url = "https://download.brother.com/welcome/dlf006645/${pname}-${version}.amd64.deb"; sha256 = "sha256-Gpr5456MCNpyam3g2qPo7S3aEZFMaUGR8bu7YmRY8xk="; }; - }."${stdenv.hostPlatform.system}"; + }."${stdenv.hostPlatform.system}" or (throw "unsupported system ${stdenv.hostPlatform.system}"); unpackPhase = '' ar x $src diff --git a/pkgs/applications/misc/1password-gui/default.nix b/pkgs/applications/misc/1password-gui/default.nix index 32825d3ba523..5a7e4914f8cd 100644 --- a/pkgs/applications/misc/1password-gui/default.nix +++ b/pkgs/applications/misc/1password-gui/default.nix @@ -51,7 +51,7 @@ let }; src = fetchurl { - inherit (sources.${channel}.${stdenv.system}) url hash; + inherit (sources.${channel}.${stdenv.system} or (throw "unsupported system ${stdenv.hostPlatform.system}")) url hash; }; meta = with lib; { diff --git a/pkgs/applications/networking/cluster/hadoop/default.nix b/pkgs/applications/networking/cluster/hadoop/default.nix index d5bae9ad885b..5f44e39d008c 100644 --- a/pkgs/applications/networking/cluster/hadoop/default.nix +++ b/pkgs/applications/networking/cluster/hadoop/default.nix @@ -35,7 +35,7 @@ let src = fetchurl { url = "mirror://apache/hadoop/common/hadoop-${finalAttrs.version}/hadoop-${finalAttrs.version}" + optionalString stdenv.isAarch64 "-aarch64" + ".tar.gz"; - inherit (platformAttrs.${stdenv.system}) hash; + inherit (platformAttrs.${stdenv.system} or (throw "Unsupported system: ${stdenv.system}")) hash; }; doCheck = true; diff --git a/pkgs/applications/networking/instant-messengers/discord/default.nix b/pkgs/applications/networking/instant-messengers/discord/default.nix index 40e9c77e57a7..423f6cb2f1db 100644 --- a/pkgs/applications/networking/instant-messengers/discord/default.nix +++ b/pkgs/applications/networking/instant-messengers/discord/default.nix @@ -52,7 +52,7 @@ let }; aarch64-darwin = x86_64-darwin; }; - src = srcs.${stdenv.hostPlatform.system}.${branch}; + src = srcs.${stdenv.hostPlatform.system}.${branch} or (throw "${stdenv.hostPlatform.system} not supported on ${branch}"); meta = with lib; { description = "All-in-one cross-platform voice and text chat for gamers"; diff --git a/pkgs/applications/science/electronics/picoscope/default.nix b/pkgs/applications/science/electronics/picoscope/default.nix index c7242117b68c..3aa5cb22aa52 100644 --- a/pkgs/applications/science/electronics/picoscope/default.nix +++ b/pkgs/applications/science/electronics/picoscope/default.nix @@ -49,7 +49,7 @@ let # If we don't have a platform available, put a dummy version here, so at # least evaluation succeeds. sources = - (lib.importJSON ./sources.json).${stdenv.system} or { picoscope.version = "unknown"; }; + (lib.importJSON ./sources.json).${stdenv.system} or (throw "unsupported system ${stdenv.system}"); scopePkg = name: { url, version, sha256 }: diff --git a/pkgs/applications/version-management/radicle-upstream/default.nix b/pkgs/applications/version-management/radicle-upstream/default.nix index 97fec6257dd1..69c960ed78e8 100644 --- a/pkgs/applications/version-management/radicle-upstream/default.nix +++ b/pkgs/applications/version-management/radicle-upstream/default.nix @@ -15,7 +15,7 @@ let sha256 = "sha256-EuWGbn6qggi8/9Rci8iaXfuVKE+QXb1BHEYDvotR/q4="; }; }; - src = srcs.${stdenv.hostPlatform.system}; + src = srcs.${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}"); contents = appimageTools.extract { inherit name src; }; diff --git a/pkgs/applications/virtualization/firecracker/default.nix b/pkgs/applications/virtualization/firecracker/default.nix index d9bab2169623..2c3ec6c9a75b 100644 --- a/pkgs/applications/virtualization/firecracker/default.nix +++ b/pkgs/applications/virtualization/firecracker/default.nix @@ -13,7 +13,7 @@ let dlbin = sha256: fetchurl { url = "${baseurl}/v${version}/firecracker-v${version}-${suffix}.tgz"; - sha256 = sha256."${stdenv.hostPlatform.system}"; + sha256 = sha256."${stdenv.hostPlatform.system}"or (throw "unsupported system ${stdenv.hostPlatform.system}"); }; in diff --git a/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix b/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix index 40681faae8ae..d03419e96570 100644 --- a/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix +++ b/pkgs/development/compilers/oraclejdk/jdk-linux-base.nix @@ -80,7 +80,7 @@ let result = stdenv.mkDerivation rec { in requireFile { name = "jdk-${productVersion}u${patchVersion}-${platformName}.tar.gz"; url = "http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html"; - sha256 = sha256.${stdenv.hostPlatform.system}; + sha256 = sha256.${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}"); }; nativeBuildInputs = [ file makeWrapper ] diff --git a/pkgs/development/compilers/temurin-bin/jdk-darwin-base.nix b/pkgs/development/compilers/temurin-bin/jdk-darwin-base.nix index 14871813273d..8f6831a7907c 100644 --- a/pkgs/development/compilers/temurin-bin/jdk-darwin-base.nix +++ b/pkgs/development/compilers/temurin-bin/jdk-darwin-base.nix @@ -24,7 +24,7 @@ let sourcePerArch.${cpuName}.version or (throw "unsupported CPU ${cpuName}"); src = fetchurl { - inherit (sourcePerArch.${cpuName}) url sha256; + inherit (sourcePerArch.${cpuName} or (throw "unsupported system ${stdenv.hostPlatform.system}")) url sha256; }; # See: https://github.com/NixOS/patchelf/issues/10 diff --git a/pkgs/development/libraries/libcef/default.nix b/pkgs/development/libraries/libcef/default.nix index d6d098110af8..ce83c3c22cd4 100644 --- a/pkgs/development/libraries/libcef/default.nix +++ b/pkgs/development/libraries/libcef/default.nix @@ -73,7 +73,7 @@ let platforms."aarch64-linux".sha256 = "16sbfk599h96wcsmpbxlwsvq0n1pssmm8dpwmjsqfrn1464dvs68"; platforms."x86_64-linux".sha256 = "1wa4nv28saz96kar9svdarfz6c4rnbcqz0rqxzl9zclnhfzhqdiw"; - platformInfo = builtins.getAttr stdenv.hostPlatform.system platforms; + platformInfo = platforms.${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}"); in stdenv.mkDerivation rec { pname = "cef-binary"; diff --git a/pkgs/development/tools/azure-static-sites-client/default.nix b/pkgs/development/tools/azure-static-sites-client/default.nix index 08e56de7335b..452976b7282a 100644 --- a/pkgs/development/tools/azure-static-sites-client/default.nix +++ b/pkgs/development/tools/azure-static-sites-client/default.nix @@ -21,7 +21,7 @@ let }; sources = { "x86_64-linux" = fetchBinary "linux-x64"; - "x86_64-darwin" = fetchBinary "macOS"; + "x86_64-darwin" = fetchBinary "osx-x64"; }; in stdenv.mkDerivation { diff --git a/pkgs/servers/meteor/default.nix b/pkgs/servers/meteor/default.nix index 0ce2189568cb..7830d309b082 100644 --- a/pkgs/servers/meteor/default.nix +++ b/pkgs/servers/meteor/default.nix @@ -20,7 +20,7 @@ in stdenv.mkDerivation { inherit version; pname = "meteor"; - src = srcs.${system}; + src = srcs.${system} or (throw "unsupported system ${system}"); #dontStrip = true; diff --git a/pkgs/stdenv/generic/check-meta.nix b/pkgs/stdenv/generic/check-meta.nix index 1cd1ae6dd72e..f1f486b115a8 100644 --- a/pkgs/stdenv/generic/check-meta.nix +++ b/pkgs/stdenv/generic/check-meta.nix @@ -10,7 +10,9 @@ let concatMapStrings concatMapStringsSep concatStrings + filter findFirst + head isDerivation length concatMap @@ -39,6 +41,11 @@ let toPretty ; + unlist = list: + if length list == 1 + then head list + else list; + # If we're in hydra, we can dispense with the more verbose error # messages and make problems easier to spot. inHydra = config.inHydra or false; @@ -303,6 +310,10 @@ let (listOf str) str ]; + repository = union [ + (listOf str) + str + ]; downloadPage = str; changelog = union [ (listOf str) @@ -452,8 +463,14 @@ let let outputs = attrs.outputs or [ "out" ]; hasOutput = out: builtins.elem out outputs; - in - { + in { + repository = + if attrs ? src.meta.homepage + then attrs.src.meta.homepage + else if attrs ? srcs && isList attrs.srcs + then unlist (map (src: src.meta.homepage) (filter (src: src ? meta.homepage) attrs.srcs)) + else []; + # `name` derivation attribute includes cross-compilation cruft, # is under assert, and is sanitized. # Let's have a clean always accessible version here. diff --git a/pkgs/tools/archivers/rar/default.nix b/pkgs/tools/archivers/rar/default.nix index 3799afd736ef..fabcfde887e0 100644 --- a/pkgs/tools/archivers/rar/default.nix +++ b/pkgs/tools/archivers/rar/default.nix @@ -37,7 +37,7 @@ stdenv.mkDerivation { pname = "rar"; inherit version; - src = fetchurl (srcs.${stdenv.hostPlatform.system}); + src = fetchurl (srcs.${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}")); dontBuild = true; diff --git a/pkgs/tools/misc/geekbench/5.nix b/pkgs/tools/misc/geekbench/5.nix index 7784b3632a73..49efe2ea0bf9 100644 --- a/pkgs/tools/misc/geekbench/5.nix +++ b/pkgs/tools/misc/geekbench/5.nix @@ -26,7 +26,7 @@ stdenv.mkDerivation { inherit version; pname = "geekbench"; - src = fetchurl (sources.${stdenv.system}); + src = fetchurl (sources.${stdenv.system} or (throw "unsupported system ${stdenv.hostPlatform.system}")); dontConfigure = true; dontBuild = true; diff --git a/pkgs/tools/misc/geekbench/6.nix b/pkgs/tools/misc/geekbench/6.nix index 4ac5f1d0e49a..373d93dc193c 100644 --- a/pkgs/tools/misc/geekbench/6.nix +++ b/pkgs/tools/misc/geekbench/6.nix @@ -27,7 +27,7 @@ stdenv.mkDerivation { inherit version; pname = "geekbench"; - src = fetchurl (sources.${stdenv.system}); + src = fetchurl (sources.${stdenv.system} or (throw "unsupported system ${stdenv.hostPlatform.system}")); dontConfigure = true; dontBuild = true; diff --git a/pkgs/tools/misc/hakuneko/default.nix b/pkgs/tools/misc/hakuneko/default.nix index 0ad8c5907a70..0359da603ccb 100644 --- a/pkgs/tools/misc/hakuneko/default.nix +++ b/pkgs/tools/misc/hakuneko/default.nix @@ -36,7 +36,7 @@ stdenv.mkDerivation rec { url = "https://github.com/manga-download/hakuneko/releases/download/v${version}/hakuneko-desktop_${version}_linux_i386.deb"; sha256 = "32017d26bafffaaf0a83dd6954d3926557014af4022a972371169c56c0e3d98b"; }; - }."${stdenv.hostPlatform.system}"; + }."${stdenv.hostPlatform.system}" or (throw "unsupported system ${stdenv.hostPlatform.system}"); dontBuild = true; dontConfigure = true; diff --git a/pkgs/tools/security/sonar-scanner-cli/default.nix b/pkgs/tools/security/sonar-scanner-cli/default.nix index 553019299ba7..b97a2bc3a105 100644 --- a/pkgs/tools/security/sonar-scanner-cli/default.nix +++ b/pkgs/tools/security/sonar-scanner-cli/default.nix @@ -19,7 +19,7 @@ in stdenv.mkDerivation rec { inherit version; pname = "sonar-scanner-cli"; - src = fetchurl sonarScannerArchPackage.${stdenv.hostPlatform.system}; + src = fetchurl sonarScannerArchPackage.${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}"); nativeBuildInputs = [ unzip ]; ```

[edit] opened PRs to change aborts to throw (and fix a typo)

AndersonTorres commented 3 months ago

What about assembly?

unless you are using import-from-derivation (which is banned in nixpkgs), assembly will never be interpreted at eval time, only at build time.

Irrelevant. There is nothing hindering someone to write code like "throw when host is not x86" when facing a fromSource.

font glyphs are binary data, not binary code.

Data-code distinction lose most of its explanatory power since before the first worm, passing through undergrounds like Forth, Lisp and Phrack, and nowadays with the dreadful xzdoor.

Further it misses the point I tried to convey: a non-fromSource can evaluate despite not being fromSource.

Nonetheless my catastrophic example does not affect the argument: neither fromSource implies src will eval, nor non-fromSource implies src will break.

lolbinarycat commented 3 months ago

There is nothing hindering someone to write code like "throw when host is not x86"

a throw error would be fine, actually. it would be caught by a tryEval in release-attrpaths-superset

calling abort would not be fine, and would probably cause CI to fail.

the only exceptions i know are calling abort within src on an unsupported platform, or in a transient derivation which is not exposed to hydra.

so... don't do that?

rhendric commented 2 months ago

right. src not evaluating will not prevent access to other fields in meta, which was the issue before. trying to evaluate repository will still be problematic but i'm not sure it's worth adding additional checks to repository to prevent errors related to src. it's possible, checking that sourceProvence isSource, but perhaps not necessary. my point is that adding the repository field will not break current usage.

You don't know that. Current usage can include toJSONing the meta attributes of every package in the list. This currently works—I just confirmed it—and would break with your proposed change.

I'm fine with #300286 but I think any PR that makes meta depend on src, even in the way you're currently endorsing, should be reviewed by more of the community before it is merged.

nixos-discourse commented 2 months ago

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/when-should-meta-attributes-be-computed/42833/1

lolbinarycat commented 2 months ago

Current usage can include toJSONing the meta attributes of every package in the list

if that is a usage we want to support then it should have a CI test.