hercules-ci / flake-parts

❄️ Simplify Nix Flakes with the module system
https://flake.parts
MIT License
729 stars 41 forks source link

apps: Add `meta` option #240

Closed shivaraj-bh closed 2 weeks ago

shivaraj-bh commented 1 month ago

This allows specifying metadata info about the flake app. This has been standardised in Nix at https://github.com/NixOS/nix/pull/11297

Here’s an example of its usage:

# Inside perSystem
{
  apps.hello = {
    program = pkgs.hello;
    type = "app";
    meta.description = "I say hello!";
  };
}
roberth commented 1 month ago

I'm supportive of the idea, but the Nix manual states

The only supported attributes are:

  • type [...]
  • program [...]

I guess this is somewhat open to interpretation, but allowing any attribute whatsoever does not seem to be the intent. nix flake check is silent about it, but most likely that's just an oversight.

Could you open a PR to nix that documents the description attribute? That way it can become a standard, and everyone benefits from better metadata and discoverability.

As for this PR, I'd be happy to accept a description option when the Nix PR is accepted, but preferably not a freeformType, because that would let typos in these attribute names to go uncaught, and iirc a freeformType can also cause worse errors when "recursive" definitions are involved (e.g. desrcription = "something ${baseNameOf config.command}" would be an infinite recursion because of the typo+freeformType).

shivaraj-bh commented 1 month ago

Could you open a PR to nix that documents the description attribute? That way it can become a standard, and everyone benefits from better metadata and discoverability.

Good idea! Here’s the PR: https://github.com/NixOS/nix/pull/11297

shivaraj-bh commented 1 month ago

@roberth I have made changes based on what was standardised upstream

shivaraj-bh commented 3 weeks ago

@roberth Does it look good now?

srid commented 3 weeks ago

@roberth Is there anything to be done here before merging? This would be useful to implement: https://github.com/juspay/omnix/issues/163