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 12, 2023
1 parent 104df53 commit 0edd3ae
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
7 changes: 6 additions & 1 deletion hosts/eachDefaultSystem.nix
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ inputs.homeManager.lib.homeManagerConfiguration {
../modules/homeManager/systemd/user/tmpfiles/rules
../modules/homeManager/wayland/windowManager/hyprland
../modules/homeManager/xdg
../modules/programs/dotfiles
../modules/programs/nixvim
../modules/services/battery
../modules/stylix
Expand Down Expand Up @@ -161,7 +162,11 @@ inputs.homeManager.lib.homeManagerConfiguration {
xdg.enable = true;
};

programs.nixvim.enable = true;
programs = {
dotfiles.enable = true;
nixvim.enable = true;
};

services.battery.enable = true;
stylix.enable = true;
wayland.enable = true;
Expand Down
47 changes: 47 additions & 0 deletions modules/programs/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.programs.dotfiles.enable = lib.mkEnableOption "dotfiles";

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

home.packages = [
(pkgs.stdenv.mkDerivation
{
installPhase = let
manDirectory = "share/man";
tmpDirectory = "assets";
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 man];
src = ../../..;
})
];
};
}

0 comments on commit 0edd3ae

Please sign in to comment.