NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.76k stars 1.52k forks source link

Custom flake checkers (as plugins?) #3487

Open vikanezrimaya opened 4 years ago

vikanezrimaya commented 4 years ago

Right now nix flake check checks sanity of a lot of common flake attributes, but it fails to consider that there are tools that might extend flakes' usability beyond what Nix and NixOS offers - e.g. home-manager. Currently in my personal flake (https://gitlab.com/vikanezrimaya/nix-flake) I use homeManagerModules and homeManagerConfigurations as additional flake outputs for home-manager and an attribute called activationPackage, that for every machine deploys a NixOS configuration and my personal home-manager config. Nix warns me of existence of these attributes as if they're typos. I'd like to somehow extend Nix (maybe with a plugin somehow embedded in a flake?) that will type-check all of the custom attributes I designed.

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

vikanezrimaya commented 3 years ago

Might not be urgent, but still important for me.

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

gytis-ivaskevicius commented 3 years ago

Does this solve your problem? https://github.com/numtide/flake-utils/tree/master/examples/checks-utils

So what you'd do is compare the attribute type. To be fair more specific utilities for this use case should be defined

stale[bot] commented 2 years ago

I marked this as stale due to inactivity. → More info

Infinidoge commented 2 years ago

checks-utils isn't a (proper) solution. The problem is that nix flake check gives messages like:

warning: unknown flake output 'deploy'
warning: unknown flake output 'lib'
warning: unknown flake output 'homeConfigurations'

Which, given that other tools may define their own flake outputs, is unhelpful. Adding in a form of plugins which lets you extend the flake definition would be ideal.

Using checks (which checks-utils definitely helps with) can give you most of what is wanted, though it somewhat muddles the output by having those sanity checks being a part of the general checks attribute, instead of being in their own section.

(Ran into the issue as I've been trying to migrate my own projects to better make use of nix flake check)

nakoo commented 3 months ago

I feel the same. I believe there is better way instead of hard-coded like this https://github.com/nixos/nix/blob/master/src/nix/flake.cc#L773-L785

I'm patiently waiting https://github.com/NixOS/nix/pull/8892 would be merged but sadly it takes a lot of time than I expected.