Skip to content

Commit

Permalink
feat(modules/programs/dotfiles): install documentation as manpages
Browse files Browse the repository at this point in the history
Improve documentation accessibility by installing it as manpages.
  • Loading branch information
trueNAHO committed Dec 13, 2023
1 parent 2a8cfaf commit dd826fb
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
3 changes: 3 additions & 0 deletions hosts/eachDefaultSystem.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ inputs.homeManager.lib.homeManagerConfiguration {
modules = [
({config, ...}: {
imports = [
../modules/home/packages/dotfiles
../modules/homeManager/fonts
../modules/homeManager/home/packages/acpi
../modules/homeManager/home/packages/aria
Expand Down Expand Up @@ -76,6 +77,8 @@ inputs.homeManager.lib.homeManagerConfiguration {

config = {
modules = {
home.packages.dotfiles.enable = true;

homeManager = {
fonts.enable = true;

Expand Down
47 changes: 47 additions & 0 deletions modules/home/packages/dotfiles/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
config,
lib,
pkgs,
...
}: {
imports = [../../../homeManager/programs/man];
options.modules.home.packages.dotfiles.enable = lib.mkEnableOption "dotfiles";

config = lib.mkIf config.modules.home.packages.dotfiles.enable {
modules.homeManager.programs.man.enable = true;

home.packages = [
(pkgs.stdenv.mkDerivation
{
installPhase = let
manDirectory = "share/man";
tmpDirectory = "tmp_share_man";
in ''
mkdir --parent "$out/${tmpDirectory}"
trap "rm --force --recursive $out/${tmpDirectory}" EXIT
${pkgs.fd.pname} \
--extension adoc \
-X \
${pkgs.asciidoctor-with-extensions.meta.mainProgram} \
--backend manpage \
--destination-dir "$out/${tmpDirectory}"
${pkgs.fd.pname} --type file . "$out/${tmpDirectory}" |
while read -r file; do
filename="$(basename --suffix .gz "$file")"
output_directory="$out/${manDirectory}/man''${filename##*.}"
mkdir --parent "$output_directory"
mv "$file" "$output_directory"
done
'';

name = "dotfiles";
nativeBuildInputs = with pkgs; [asciidoctor-with-extensions fd];
src = ../../../..;
})
];
};
}

0 comments on commit dd826fb

Please sign in to comment.