refactor: hosts/common/programs/zeal: fewer file-level inherits

This commit is contained in:
2024-09-28 09:53:04 +00:00
parent 911e03fcb4
commit 674699bf05

View File

@@ -1,9 +1,7 @@
{ config, lib, pkgs, ... }:
let
inherit (builtins) map;
inherit (lib) mkIf mkOption optionalString types;
cfg = config.sane.programs.docsets.config;
configOpts = types.submodule {
configOpts = with lib; types.submodule {
options = {
rustPkgs = mkOption {
type = types.listOf types.str;
@@ -25,14 +23,14 @@ in {
};
sane.programs.docsets = {
configOption = mkOption {
configOption = with lib; mkOption {
type = configOpts;
default = {};
};
packageUnwrapped = pkgs.symlinkJoin {
name = "docsets";
# build each package with rust docs
paths = map (name:
paths = builtins.map (name:
let
orig = pkgs."${name}";
withDocs = orig.overrideAttrs (upstream: {
@@ -44,7 +42,7 @@ in {
"${toString withDocs}/share/docset"
) cfg.rustPkgs;
# link only the docs (not any binaries)
postBuild = optionalString (cfg.rustPkgs != []) ''
postBuild = lib.optionalString (cfg.rustPkgs != []) ''
mkdir -p $out/share/docset
mv $out/*.docset $out/share/docset
'';
@@ -53,7 +51,7 @@ in {
sandbox.enable = false; # meta-package; no binaries
};
environment.pathsToLink = mkIf config.sane.programs.zeal.enabled [
environment.pathsToLink = lib.mkIf config.sane.programs.zeal.enabled [
"/share/docset"
];
}