aboutsummaryrefslogtreecommitdiff
path: root/nixos/profiles/workstation/doc.nix
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2026-10-07 06:59:42 +0200
committerMartin Fischer <martin@push-f.com>2026-10-14 06:57:39 +0200
commitd52ba0d225c018df64d32b4840549e3a8cf1ee3b (patch)
tree5fde024deca9475504ad484ab1f2a6b28b55abdf /nixos/profiles/workstation/doc.nix
parent71adbf04349a444f27f0a744f5399021363675e3 (diff)
feat(workstation): add /doc
Diffstat (limited to 'nixos/profiles/workstation/doc.nix')
-rw-r--r--nixos/profiles/workstation/doc.nix43
1 files changed, 43 insertions, 0 deletions
diff --git a/nixos/profiles/workstation/doc.nix b/nixos/profiles/workstation/doc.nix
new file mode 100644
index 0000000..d57318b
--- /dev/null
+++ b/nixos/profiles/workstation/doc.nix
@@ -0,0 +1,43 @@
+# Many packages include documentation other than man pages.
+# Nixpkgs conventionally installs this under share/doc, which NixOS
+# exposes at /run/current-system/sw/share/doc. Much of it is HTML.
+# This module collects plaintext documentation and exposes it under /doc/,
+# to make it more accessible to terminal users and digestible for LLMs.
+
+{
+ config,
+ pkgs,
+ pkgs-unstable,
+ ...
+}:
+
+let
+ gitDocs = pkgs.runCommand "git-docs" { } ''
+ mkdir -p $out
+ tar --extract --xz --file ${pkgs.git.src} \
+ --strip-components=2 --directory $out \
+ --wildcards '*/Documentation/*.adoc'
+ '';
+
+ jjDocs = pkgs.runCommand "jj-docs" { } ''
+ mkdir -p $out
+ cp -R ${pkgs.jujutsu.src}/docs/. $out/
+ # changelog.md includes CHANGELOG.md via a directive
+ cp -f ${pkgs.jujutsu.src}/CHANGELOG.md $out/changelog.md
+ '';
+
+ symlinks = {
+ nix = "${config.nix.package.src}/doc/manual/source";
+ git = "${gitDocs}";
+ jj = "${jjDocs}";
+ pi = "${pkgs-unstable.pi-coding-agent}/lib/node_modules/pi-monorepo/docs";
+ };
+in
+{
+ systemd.tmpfiles.rules = [
+ # /doc is a real directory rather than a symlink so sandbox bind mounts
+ # of /doc keep seeing updated entries when the symlinks inside it change.
+ "d /doc 0555 root root -"
+ ]
+ ++ pkgs.lib.mapAttrsToList (name: target: "L+ /doc/${name} - - - - ${target}") symlinks;
+}