2024-04-16 17:06:45 +00:00
|
|
|
{ inputs, self, ... }:
|
2024-04-12 13:22:20 +00:00
|
|
|
{
|
|
|
|
perSystem =
|
2024-04-12 14:37:50 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
self',
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}:
|
2024-04-16 17:06:45 +00:00
|
|
|
let
|
|
|
|
# Simply evaluated options (JSON)
|
|
|
|
# { clanCore = «derivation JSON»; clanModules = { ${name} = «derivation JSON» }; }
|
|
|
|
jsonDocs = import ./get-module-docs.nix {
|
|
|
|
inherit (inputs) nixpkgs;
|
2024-04-17 10:52:04 +00:00
|
|
|
inherit pkgs self;
|
2024-04-16 17:06:45 +00:00
|
|
|
inherit (self.nixosModules) clanCore;
|
|
|
|
inherit (self) clanModules;
|
|
|
|
};
|
|
|
|
|
|
|
|
clanModulesFileInfo = pkgs.writeText "info.json" (builtins.toJSON jsonDocs.clanModules);
|
2024-04-17 10:52:04 +00:00
|
|
|
clanModulesReadmes = pkgs.writeText "info.json" (builtins.toJSON jsonDocs.clanModulesReadmes);
|
2024-04-16 17:06:45 +00:00
|
|
|
|
|
|
|
# Simply evaluated options (JSON)
|
|
|
|
renderOptions =
|
|
|
|
pkgs.runCommand "renderOptions.py"
|
|
|
|
{
|
|
|
|
# TODO: ruff does not splice properly in nativeBuildInputs
|
|
|
|
depsBuildBuild = [ pkgs.ruff ];
|
|
|
|
nativeBuildInputs = [
|
|
|
|
pkgs.python3
|
|
|
|
pkgs.mypy
|
|
|
|
];
|
|
|
|
}
|
|
|
|
''
|
|
|
|
install ${./scripts/renderOptions.py} $out
|
|
|
|
patchShebangs --build $out
|
|
|
|
|
|
|
|
ruff format --check --diff $out
|
|
|
|
ruff --line-length 88 $out
|
|
|
|
mypy --strict $out
|
|
|
|
'';
|
|
|
|
|
2024-05-24 14:54:51 +00:00
|
|
|
asciinema-player-js = pkgs.fetchurl {
|
|
|
|
url = "https://github.com/asciinema/asciinema-player/releases/download/v3.7.0/asciinema-player.min.js";
|
|
|
|
sha256 = "sha256-Ymco/+FinDr5YOrV72ehclpp4amrczjo5EU3jfr/zxs=";
|
|
|
|
};
|
|
|
|
asciinema-player-css = pkgs.fetchurl {
|
|
|
|
url = "https://github.com/asciinema/asciinema-player/releases/download/v3.7.0/asciinema-player.css";
|
|
|
|
sha256 = "sha256-GZMeZFFGvP5GMqqh516mjJKfQaiJ6bL38bSYOXkaohc=";
|
|
|
|
};
|
|
|
|
|
2024-04-16 17:06:45 +00:00
|
|
|
module-docs = pkgs.runCommand "rendered" { nativeBuildInputs = [ pkgs.python3 ]; } ''
|
2024-06-17 10:42:28 +00:00
|
|
|
export CLAN_CORE=${jsonDocs.clanCore}/share/doc/nixos/options.json
|
2024-04-16 17:06:45 +00:00
|
|
|
# A file that contains the links to all clanModule docs
|
|
|
|
export CLAN_MODULES=${clanModulesFileInfo}
|
2024-04-17 10:52:04 +00:00
|
|
|
export CLAN_MODULES_READMES=${clanModulesReadmes}
|
2024-04-16 17:06:45 +00:00
|
|
|
|
|
|
|
mkdir $out
|
|
|
|
|
|
|
|
# The python script will place mkDocs files in the output directory
|
|
|
|
python3 ${renderOptions}
|
|
|
|
'';
|
|
|
|
in
|
2024-04-12 13:22:20 +00:00
|
|
|
{
|
2024-04-16 17:06:45 +00:00
|
|
|
devShells.docs = pkgs.callPackage ./shell.nix {
|
2024-05-07 11:23:03 +00:00
|
|
|
inherit (self'.packages) docs clan-cli-docs;
|
2024-04-16 17:06:45 +00:00
|
|
|
inherit module-docs;
|
2024-05-24 14:54:51 +00:00
|
|
|
inherit asciinema-player-js;
|
|
|
|
inherit asciinema-player-css;
|
2024-04-16 17:06:45 +00:00
|
|
|
};
|
2024-04-12 13:22:20 +00:00
|
|
|
packages = {
|
2024-04-16 17:06:45 +00:00
|
|
|
docs = pkgs.python3.pkgs.callPackage ./default.nix {
|
2024-05-07 11:23:03 +00:00
|
|
|
inherit (self'.packages) clan-cli-docs;
|
2024-04-16 17:06:45 +00:00
|
|
|
inherit (inputs) nixpkgs;
|
|
|
|
inherit module-docs;
|
2024-05-24 14:54:51 +00:00
|
|
|
inherit asciinema-player-js;
|
|
|
|
inherit asciinema-player-css;
|
2024-04-16 17:06:45 +00:00
|
|
|
};
|
2024-04-12 14:37:50 +00:00
|
|
|
deploy-docs = pkgs.callPackage ./deploy-docs.nix { inherit (config.packages) docs; };
|
2024-04-16 17:06:45 +00:00
|
|
|
inherit module-docs;
|
2024-04-12 13:22:20 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|