From dd826fb0225b05e39eefa0dc876a92f005bf3d79 Mon Sep 17 00:00:00 2001 From: NAHO <90870942+trueNAHO@users.noreply.github.com> Date: Tue, 12 Dec 2023 14:53:56 +0100 Subject: [PATCH] feat(modules/programs/dotfiles): install documentation as manpages Improve documentation accessibility by installing it as manpages. --- hosts/eachDefaultSystem.nix | 3 ++ modules/home/packages/dotfiles/default.nix | 47 ++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 modules/home/packages/dotfiles/default.nix diff --git a/hosts/eachDefaultSystem.nix b/hosts/eachDefaultSystem.nix index c9073bec..98fb7fdd 100644 --- a/hosts/eachDefaultSystem.nix +++ b/hosts/eachDefaultSystem.nix @@ -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 @@ -76,6 +77,8 @@ inputs.homeManager.lib.homeManagerConfiguration { config = { modules = { + home.packages.dotfiles.enable = true; + homeManager = { fonts.enable = true; diff --git a/modules/home/packages/dotfiles/default.nix b/modules/home/packages/dotfiles/default.nix new file mode 100644 index 00000000..85e3e606 --- /dev/null +++ b/modules/home/packages/dotfiles/default.nix @@ -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 = ../../../..; + }) + ]; + }; +}