Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow specifying commands as packages without the attrset #216

Open
lilyball opened this issue Aug 31, 2022 · 2 comments
Open

Allow specifying commands as packages without the attrset #216

lilyball opened this issue Aug 31, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@lilyball
Copy link

Is your feature request related to a problem? Please describe.

When listing commands, most of my commands are just packages that don't need additional attributes. Having to repeat the package key is tedious. In my Nix config that ends up looking like

{
  commands = with pkgs; [
    { package = cargo-deny; }
    { package = cargo-insta; }
    { package = vagrant; }
    { package = jq; }
  ];
}

Describe the solution you'd like

I'd prefer to be able to write this like

{
  commands = with pkgs; [ cargo-deny cargo-insta vagrant jq ];
}

This can be done by changing the type for commands, which is currently listOf (submodule { options = commadOptions; }), to use either or coercedTo to accept a strOrPackage in addition to the submodule. coercedTo is probably better in that you wouldn't have to change any of the code that consumes it.

Describe alternatives you've considered

A library function could be provided instead that takes a list of packages and wraps each package in the appropriate attrset, but that seems unnecessarily awkward.

@zimbatm
Copy link
Member

zimbatm commented Aug 31, 2022

Sounds good! (I mean, happy to get a PR for that)

@deemp
Copy link
Contributor

deemp commented Jan 13, 2024

Something similar is implemented in #290.

"category 1" = [
  {
    prefix = "nix run .#";
    prefixes.a.b.yq-1 = "nix run ../#";
    packages = {
      a.b = {
        jq-1 = [ "[package] jq description" pkgs.jq ];
        yq-1 = pkgs.yq-go;
        yq-2 = pkgs.yq-go;
      };
      npm = "nodePackages.npm";
    };
  }
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants