Skip to content

om show: display description for flake apps #163

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

Closed
Tracked by #162
shivaraj-bh opened this issue Jul 17, 2024 · 10 comments · Fixed by #251
Closed
Tracked by #162

om show: display description for flake apps #163

shivaraj-bh opened this issue Jul 17, 2024 · 10 comments · Fixed by #251
Assignees
Labels
enhancement New feature or request

Comments

@shivaraj-bh
Copy link
Member

shivaraj-bh commented Jul 17, 2024

What will it take for us to show a description for flake apps, such as haskell-template below? Packages already have them.

image

Originally posted by @srid in #157 (comment)

Also see: #157 (comment)

@shivaraj-bh shivaraj-bh changed the title omnix-cli: Description for flake apps in om show omnix-cli:om show should display description for flake apps Jul 17, 2024
@shivaraj-bh shivaraj-bh changed the title omnix-cli:om show should display description for flake apps omnix-cli: om show should display description for flake apps Jul 17, 2024
@srid srid added the enhancement New feature or request label Jul 17, 2024
@shivaraj-bh
Copy link
Member Author

I was able to display description for a flake app in a flake that doesn’t use flake-parts:

🐚 nix --extra-experimental-features 'nix-command flakes' show-config --json
🐚 /nix/store/n02w2ybg9fc78grzz9i2aj49q3rysp7m-nix-2.24.0pre20240801_af10904/bin/nix flake show --legacy --allow-import-from-derivation --json --default-flake-schemas /nix/store/y8j5b7canf0la2dfnbd004m9n5zlm8l1-source .
🚀 Apps (nix run .#<name>)
╭───────┬──────────────╮
│ name  │ description  │
├───────┼──────────────┤
│ hello │ I say hello! │
╰───────┴──────────────╯

This involved a one-line addition to flake-schemas, see shivaraj-bh/flake-schemas@16dc944. The flake.nix used above is:

{
  inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
  outputs = { self, nixpkgs, ... }:{
    apps.aarch64-darwin.hello = {
      program = "${nixpkgs.lib.getExe nixpkgs.legacyPackages.aarch64-darwin.hello}";
      type = "app";
      description = "I say hello!";
    };
  };
}

In order to support this in flake-parts we can make apps option a free-form type?

@srid
Copy link
Member

srid commented Aug 7, 2024

Interesting.

In order to support this in flake-parts we can make apps option a free-form type?

You should open an issue on https://github.com/hercules-ci/flake-parts proposing to support app descriptions using any specific approach, then Robert can provide feedback.

(Why a freeform type though? Isn't adding description here sufficient? But let's discuss this in flake-parts repo).

@shivaraj-bh
Copy link
Member Author

shivaraj-bh commented Aug 7, 2024

I didn’t see this message earlier. But I went ahead and created a PR: hercules-ci/flake-parts#240

Edit: You can find my reasoning for freeform type in the PR description

@srid
Copy link
Member

srid commented Aug 7, 2024

This involved a one-line addition to flake-schemas, see shivaraj-bh/flake-schemas@16dc944.

Can you open PR on flake-schemas proposing this change? That discussion there might be relevant. I'm wondering why app.description, rather than say app.meta.description. Does this violate any of the constraints in Nix proper?

@shivaraj-bh
Copy link
Member Author

This involved a one-line addition to flake-schemas, see shivaraj-bh/flake-schemas@16dc944.

Can you open PR on flake-schemas proposing this change? That discussion there might be relevant. I'm wondering why app.description, rather than say app.meta.description. Does this violate any of the constraints in Nix proper?

We could use app.meta.description to stick to the convention of how its done in derivations. I was just checking to see if custom attributes in apps.<name> even works.

@srid
Copy link
Member

srid commented Aug 7, 2024

I was just checking to see if custom attributes in apps.<name> even works.

See if nix flake check fails if you there are custom attributes. At least it does for templates (see #200)

@shivaraj-bh
Copy link
Member Author

{
  inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
  inputs.flake-parts.url = "github:shivaraj-bh/flake-parts/freeform-app-type";
  outputs = { flake-parts, ... }@inputs: flake-parts.lib.mkFlake { inherit inputs; } {
    systems = [ "aarch64-darwin" ];
    perSystem = { pkgs, ... }: {
      apps.hello = {
        program = pkgs.hello;
        type = "app";
        description = "I say hello!";
      };
    };
  };
}

Tried it with ^

~/oss/tmp
❯ nix flake check

~/oss/tmp
❯ echo $?
0

@shivaraj-bh
Copy link
Member Author

This involved a one-line addition to flake-schemas, see shivaraj-bh/flake-schemas@16dc944.

Can you open PR on flake-schemas proposing this change? That discussion there might be relevant. I'm wondering why app.description, rather than say app.meta.description. Does this violate any of the constraints in Nix proper?

DeterminateSystems/flake-schemas#31

@srid srid mentioned this issue Aug 9, 2024
9 tasks
@srid
Copy link
Member

srid commented Aug 31, 2024

DeterminateSystems/flake-schemas#31 is the only thing blocking this PR? I think it should be fine for us to maintain a temporary fork (of flake-schemas; preferably in @juspay org) until upstream merges our PRs.

@shivaraj-bh shivaraj-bh changed the title omnix-cli: om show should display description for flake apps om show: display description for flake apps Sep 2, 2024
@srid srid closed this as completed in #251 Sep 2, 2024
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

Successfully merging a pull request may close this issue.

2 participants