nix flake show: Support meta attribute for apps#11297
Conversation
roberth
left a comment
There was a problem hiding this comment.
It'd be lovely to have
- a characterization test for
nix flake check - warning for unknown attribute in app
but this is already a good change.
I can add them. Do you suggest I do this here or in a different PR? |
|
Awesome. Should be fine to do here in new commits.
Grep
I think we already have some checks like that, so you could adapt it to work the same. |
|
Is this a dupe of #10980 |
|
@kjeremy It's complementary, because this is about Partially it kind of should be a duplicate because this PR doesn't solve the terminal layout issue. We could merge either one first and then apply your rendering solution to |
|
A question was raised on matrix whether this should be |
4f60b36 to
0bfc73b
Compare
|
❯ ../nix/outputs/out/bin/nix flake check
error:
… while checking flake output 'apps'
at /nix/store/n8v51gyfjrhjrfbabxwy0hh4q68q2v7v-source/flake.nix:5:6:
4| # formatter.aarch64-darwin = "foo";
5| apps.aarch64-darwin.hello = {
| ^
6| program = "${nixpkgs.lib.getExe nixpkgs.legacyPackages.aarch64-darwin.hello}";
… while checking the app definition 'apps.aarch64-darwin.hello'
at /nix/store/n8v51gyfjrhjrfbabxwy0hh4q68q2v7v-source/flake.nix:5:6:
4| # formatter.aarch64-darwin = "foo";
5| apps.aarch64-darwin.hello = {
| ^
6| program = "${nixpkgs.lib.getExe nixpkgs.legacyPackages.aarch64-darwin.hello}";
error: app 'apps.aarch64-darwin.hello' has unsupported attribute 'unknown-attr'It also throws error when ❯ ../nix/outputs/out/bin/nix flake check
warning: app 'apps.aarch64-darwin.hello' lacks attribute 'meta' |
|
description attribute for apps if presentnix flake show: Support meta attribute for apps
src/nix/run.md
Outdated
| apps.x86_64-linux.blender_2_79 = { | ||
| type = "app"; | ||
| program = "${self.packages.x86_64-linux.blender_2_79}/bin/blender"; | ||
| description = "Run Blender, a free and open-source 3D creation suite."; |
There was a problem hiding this comment.
I guess this should be meta.description?
However I'm not sure we need the meta prefix. It's necessary for derivations to distinguish derivation input attributes from metadata, but that's not the case for apps.
There was a problem hiding this comment.
Though I suppose meta is useful for distinguishing between attributes that should be an error if they're unknown, and attributes that should at most be a warning.
There was a problem hiding this comment.
I think that's a good argument.
Also users are likely to write meta because they learned it for packages, and it's nice that x.meta.description or "" works for both, if that's going to be relevant.
roberth
left a comment
There was a problem hiding this comment.
If you could add the warning and sync the docs, this looks good to me 🚀
0bfc73b to
f91d872
Compare
Done! |
Metadata information for flake apps will be useful while exploring a flake using `nix flake show`
f91d872 to
2ab93fd
Compare
This allows specifying metadata info about the flake app. This has been standardized in Nix at NixOS/nix#11297
Motivation
Metadata information for flake apps will be useful while exploring a
flake using
nix flake showContext
The outputs that follow, uses the flake:
Output without the description:
Output with the description:
The description is also included in the
jsonoutput ofnix flake show:{ "apps": { "aarch64-darwin": { "hello": { "description": "I say hello!", "type": "app" } } } }Priorities and Process
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.