Docs: fix rendering clan source code url

This commit is contained in:
Johannes Kirschbauer
2025-07-09 17:24:20 +02:00
parent 0e97efbbef
commit 5c234ac643
2 changed files with 18 additions and 17 deletions

View File

@@ -1,21 +1,25 @@
{ lib, ... }:
{
rec {
prefix = "https://git.clan.lol/clan/clan-core/src/branch/main/";
# Strip store paths from option declarations to make docs more stable
# This prevents documentation from rebuilding when store paths change
# but the actual content remains the same
stripStorePathsFromDeclarations = opt:
opt // {
declarations = map (decl:
stripStorePathsFromDeclarations =
opt:
opt
// {
declarations = map (
decl:
if lib.isString decl && lib.hasPrefix "/nix/store/" decl then
let
parts = lib.splitString "/" decl;
in
if builtins.length parts > 4 then
"/" + lib.concatStringsSep "/" (lib.drop 4 parts)
else
decl
if builtins.length parts > 4 then
(prefix + "/" + lib.concatStringsSep "/" (lib.drop 4 parts))
else
decl
else
decl
) opt.declarations;
};
}
}