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