build a hugo docs page from the readme files

This commit is contained in:
goeranh 2026-03-13 18:06:20 +01:00
parent bfe941217d
commit d106386cc0
No known key found for this signature in database
5 changed files with 229 additions and 3 deletions

View file

@ -77,6 +77,46 @@
];
};
packages.x86_64-linux =
let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
# Hugo documentation site package
docs-site = pkgs.stdenv.mkDerivation {
name = "stura-infra-docs";
src = ./.;
nativeBuildInputs = [ pkgs.hugo ];
buildPhase = ''
# Create Hugo structure
mkdir -p hugo-site
cp ${./docs/hugo.yaml} hugo-site/hugo.yaml
# Install hugo-book theme
mkdir -p hugo-site/themes
cp -r ${
pkgs.fetchFromGitHub {
owner = "alex-shpak";
repo = "hugo-book";
rev = "v13";
sha256 = "sha256-r2KfmWK7BC7LjnZVvwb2Mbqnd8a6Q32fBqiQfZTpGy4=";
}
} hugo-site/themes/hugo-book
# Build content from README files
bash ${./docs/build-docs.sh} . hugo-site/content
# Build Hugo site
cd hugo-site
hugo --minify
'';
installPhase = ''
mkdir -p $out
cp -r public/* $out/
'';
};
in
builtins.foldl'
(
result: name:
@ -84,7 +124,7 @@
// {
# run nixos-rebuild switch on the target system
# the config will be built locally and copied over
"${name}-update" = nixpkgs.legacyPackages.x86_64-linux.writeShellScriptBin "update" ''
"${name}-update" = pkgs.writeShellScriptBin "update" ''
nixos-rebuild switch --flake .#${name} --target-host root@${
(builtins.head (
nixosConfigurations.${name}.config.networking.interfaces.${
@ -95,7 +135,7 @@
'';
}
)
{ }
{ inherit docs-site; }
(
# filter all nixos configs containing installer
builtins.filter (item: !nixpkgs.lib.hasInfix "-" item) (builtins.attrNames nixosConfigurations)