Skip to content

Commit

Permalink
Add meta.description to flake apps (#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
srid authored Sep 2, 2024
1 parent e48718c commit ed94388
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Revision history for haskell-flake

## Unreleased

- Enhancements
- Support `meta.description` in flake apps. Requires newer version of flake-parts.

## 0.5.0 (Jun 24, 2024)

- Breaking changes
Expand Down
15 changes: 9 additions & 6 deletions nix/modules/project/outputs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ let
exes = mkOption {
type = types.lazyAttrsOf appType;
description = ''
Attrset of executables from `.cabal` file.
Attrset of executables from `.cabal` file.
If the associated Haskell project has a separate bin output
(cf. `enableSeparateBinOutput`), then this exe will refer
Expand Down Expand Up @@ -90,15 +90,19 @@ in

finalPackages = config.basePackages.extend finalOverlay;

buildPackageInfo = name: value: {
buildPackageInfo = name: value: rec {
package = finalPackages.${name};
exes =
lib.listToAttrs
(map
(exe:
lib.nameValuePair exe {
program = "${lib.getBin finalPackages.${name}}/bin/${exe}";
}
lib.nameValuePair exe ({
program = "${lib.getBin package}/bin/${exe}";
meta.description =
if lib.hasAttrByPath [ "meta" "description" ] package
then "${if exe != name then "[${exe}] " else ""}${package.meta.description}"
else "Executable ${if exe != name then "${exe} from " else "for "}package ${name}";
})
)
value.cabal.executables
);
Expand All @@ -122,4 +126,3 @@ in
};
};
}

11 changes: 11 additions & 0 deletions nix/types/app-type.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@ let
A path to an executable or a derivation with `meta.mainProgram`.
'';
};
meta = lib.mkOption {
type = lib.types.lazyAttrsOf lib.types.raw;
default = { };
# TODO refer to Nix manual 2.25
description = ''
Metadata information about the app.
Standardized in Nix at <https://github.com/NixOS/nix/pull/11297>.
Note: `nix flake check` is only aware of the `description` attribute in `meta`.
'';
};
};
};
in
Expand Down

0 comments on commit ed94388

Please sign in to comment.