nix-community / flakelight

Framework for simplifying flake setup [maintainer=@accelbread]
MIT License
177 stars 3 forks source link

Error when refer to external package #18

Closed ratson closed 3 months ago

ratson commented 3 months ago

Given https://github.com/ratson/bug-report/tree/flakelight-inputs

nix flake show github:ratson/bug-report/flakelight-inputs is giving error error: 'checks.aarch64-linux' is not an attribute set.

accelbread commented 3 months ago

Ah, that could have a better error message.

emacs-ng's flake doesn't support aarch64-linux.

Can set systems = [ "x86_64-linux" ]; to only build x86_64 outputs.

ratson commented 3 months ago

@accelbread I can get it working with

perSystem = { inputs', ... }: {
  packages = {
    emacs-ng = inputs'.emacs-ng.packages.default;
  };
};

Should that be working when using packages too? Can checks be ignored for unsupported systems?

accelbread commented 3 months ago

So with packages, it still fails when --all-systems is passed; its just that without --all-systems, nix flake show skips evaluating packages in other systems.

With packages/checks options these are evaluated as meta.supportedSystems is checked to see if the system is supported, which causes an evaluation error since the attribute does not exist. If we did not check supportedSystems, then they would not be evaluated without --all-systems since the aarch64-linux name is known without evaluating the value. That would however hide an error as the flake claims to support packages.aarch64-linux.default which fails to evaluate.

I think the most correct approach would be to not support aarch64-linux or set meta.supportedSystems to not include that system. In this case the latter wont work though since the expression needs to at least evaluate on all the flake's systems.

I'll look into seeing if I can make it more lazy, or see if something with throw could work. Unfortunately accessing an attribute that does not exist is not catchable, but might be able to figure something out there.

ratson commented 3 months ago

Many nix flakes are not properly declared its supported systems correctly, and likely never will.

Since the nix flake show works without problem when flakelight is not used, it should not require additional work to show the result. The error could be issued for nix flake check.

Limiting systems to a subset may be problematic if the nix flake supports multiple systems, and some inputs may not be used in the current system, it will cause error given the current implementation.

Or at least there should be an option to opt out generating the checks, so user could avoid the error without changing systems.

accelbread commented 3 months ago

I've removed the platform support checking feature in 3a364f9cdd7e4a48239adb2abb8e9768fc469dc6, so now the packages should not be evaluated by nix flake show unless --all-systems is passed. This makes the above commands work.

Lazyness takes care of inputs not used on current system; the issue above was that the expression failed to evaluate for a platform. Could have also been inputs'.emacs-ng.packages.default or {}, which would have evaluated to {} on platforms which emacs-ng does not support.

The checks output isn't the issue; without them the same error would have occured; its just that its what nix flake show prints since it tried evaluating checks before packages, and both end up evaluating the erroring expression.

ratson commented 3 months ago

Close as nix flake show now works without error.