docs/infrastructure: embed host config json
This commit is contained in:
parent
f83732c8cc
commit
133bdce658
5 changed files with 61 additions and 1 deletions
dev
28
dev/docs.nix
28
dev/docs.nix
|
@ -1,3 +1,4 @@
|
|||
{ self, ... }:
|
||||
{
|
||||
perSystem =
|
||||
{ config, pkgs, ... }:
|
||||
|
@ -20,7 +21,8 @@
|
|||
};
|
||||
}
|
||||
''
|
||||
cd $files
|
||||
cp --no-preserve=mode -r $files/* .
|
||||
cp --no-preserve=mode ${config.packages.docs-json}/*.json docs
|
||||
mkdocs build --strict --site-dir $out
|
||||
'';
|
||||
docs-linkcheck = pkgs.testers.lycheeLinkCheck rec {
|
||||
|
@ -33,6 +35,30 @@
|
|||
};
|
||||
site = config.packages.docs;
|
||||
};
|
||||
docs-json =
|
||||
pkgs.runCommand "docs-json"
|
||||
{
|
||||
buildInputs = [ pkgs.jq ];
|
||||
hosts = pkgs.writeText "hosts.json" (
|
||||
builtins.toJSON (
|
||||
pkgs.lib.mapAttrs (_: x: {
|
||||
experimental-features = x.config.nix.settings.experimental-features or [ ];
|
||||
extra-platforms = x.config.nix.settings.extra-platforms or [ ];
|
||||
system-features = x.config.nix.settings.system-features or [ ];
|
||||
inherit (x.config.nixpkgs.hostPlatform) system;
|
||||
inherit (x.config.nix.settings) sandbox;
|
||||
}) (self.darwinConfigurations // self.nixosConfigurations)
|
||||
)
|
||||
);
|
||||
}
|
||||
''
|
||||
mkdir -p $out
|
||||
for host in $(jq -r 'keys[]' $hosts); do
|
||||
jq --arg host "$host" \
|
||||
'.[$host] | walk(if type == "array" then sort else . end)' \
|
||||
--sort-keys < $hosts > $out/$host.json
|
||||
done
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue