Skip to content

Commit

Permalink
handle man
Browse files Browse the repository at this point in the history
  • Loading branch information
viperML committed Jul 24, 2023
1 parent b64411c commit 6f6912d
Showing 1 changed file with 51 additions and 38 deletions.
89 changes: 51 additions & 38 deletions modules/base.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 6f6912d

Please sign in to comment.