From 6f6912d3f9b96b1ace81e7d142f17141ff8ad629 Mon Sep 17 00:00:00 2001 From: Fernando Ayats Date: Mon, 24 Jul 2023 17:38:29 +0200 Subject: [PATCH] handle man --- modules/base.nix | 89 +++++++++++++++++++++++++++--------------------- 1 file changed, 51 insertions(+), 38 deletions(-) diff --git a/modules/base.nix b/modules/base.nix index 98db0b4..05a7989 100644 --- a/modules/base.nix +++ b/modules/base.nix @@ -83,46 +83,59 @@ }; config = { - # FIXME: pass other outputsToInstall as-is - wrapped = lib.recursiveUpdate (pkgs.symlinkJoin ({ - paths = [config.basePackage] ++ config.extraPackages; - nativeBuildInputs = [pkgs.makeWrapper]; - postBuild = '' - for file in $out/bin/*; do - echo "Wrapping $file" - wrapProgram $file ${ - lib.concatStringsSep " " (builtins.attrValues (builtins.mapAttrs (name: value: "--set-default ${name} ${value}") config.env)) - } ${ - lib.concatMapStringsSep " " (args: "--add-flags \"${args}\"") config.flags - } ${ - lib.concatMapStringsSep " " (p: "--prefix PATH : ${p}/bin") config.pathAdd - } ${config.extraWrapperFlags} - done + wrapped = let + result = + pkgs.symlinkJoin ({ + paths = [config.basePackage] ++ config.extraPackages; + nativeBuildInputs = [pkgs.makeWrapper]; + postBuild = '' + for file in $out/bin/*; do + echo "Wrapping $file" + wrapProgram $file ${ + lib.concatStringsSep " " (builtins.attrValues (builtins.mapAttrs (name: value: "--set-default ${name} ${value}") config.env)) + } ${ + lib.concatMapStringsSep " " (args: "--add-flags \"${args}\"") config.flags + } ${ + lib.concatMapStringsSep " " (p: "--prefix PATH : ${p}/bin") config.pathAdd + } ${config.extraWrapperFlags} + done - cd $out/bin - for exe in *; do - for file in $out/share/applications/*; do - echo "Fixing $file" - sed -i "s:/nix/store/.*/bin/$exe :$out/bin/$exe :" "$file" + cd $out/bin + for exe in *; do + for file in $out/share/applications/*; do + echo "Fixing $file" + sed -i "s:/nix/store/.*/bin/$exe :$out/bin/$exe :" "$file" + done done - done - ''; - } - // lib.getAttrs [ - "name" - # "pname" - # "version" - "meta" - ] - config.basePackage) - // (lib.optionalAttrs (lib.hasAttr "pname" config.basePackage) { - inherit (config.basePackage) pname; - }) - // (lib.optionalAttrs (lib.hasAttr "version" config.basePackage) { - inherit (config.basePackage) version; - })) { - meta.outputsToInstall = ["out"]; - }; + + + # I don't know of a better way to create a multe-output derivation for symlinkJoin + # So if the packages have man, just link them into $out + ${ + lib.concatMapStringsSep "\n" + (p: + if lib.hasAttr "man" p + then "${pkgs.xorg.lndir}/bin/lndir -silent ${p.man} $out" + else "#") + ([config.basePackage] ++ config.extraPackages) + } + ''; + } + // lib.getAttrs [ + "name" + "meta" + ] + config.basePackage) + // (lib.optionalAttrs (lib.hasAttr "pname" config.basePackage) { + inherit (config.basePackage) pname; + }) + // (lib.optionalAttrs (lib.hasAttr "version" config.basePackage) { + inherit (config.basePackage) version; + }); + in + lib.recursiveUpdate result { + meta.outputsToInstall = ["out"]; + }; }; }; in {