docs/packages/nixos-options/default.nix

69 lines
1.6 KiB
Nix
Raw Normal View History

2024-07-20 21:55:49 +00:00
{
lib,
pkgs,
inputs,
stdenv,
supportedSystems ? [ "x86_64-linux" ],
}:
with import "${inputs.nixpkgs}/pkgs/top-level/release-lib.nix" { inherit supportedSystems; };
let
version = "nixos-unstable";
versionSuffix = "pre${toString pkgs.revCount}.${pkgs.shortRev}";
buildFromConfig =
module: sel:
forAllSystems (
system:
lib.hydraJob (
sel
(import "${inputs.nixpkgs}/nixos/lib/eval-config.nix" {
inherit system;
modules = [
module
(
{ config, ... }:
{
system.nixos.versionSuffix = versionSuffix;
system.nixos.revision = pkgs.rev or pkgs.shortRev;
# At creation time we do not have state yet, so just default to latest.
system.stateVersion = config.system.nixos.version;
fileSystems."/".device = mkDefault "/dev/sda1";
boot.loader.grub.device = mkDefault "/dev/sda";
}
)
];
}).config
)
);
options =
(buildFromConfig ({ ... }: { }) (config: config.system.build.manual.optionsJSON)).x86_64-linux;
2024-07-24 17:37:27 +00:00
customPython = pkgs.python312.withPackages (ps: [
ps.jq
ps.rich
]);
2024-07-20 21:55:49 +00:00
in
stdenv.mkDerivation {
pname = "nixos-options";
inherit version;
2024-07-24 17:37:27 +00:00
src = ./.;
nativeBuildInputs = [ customPython ];
buildPhase = ''
${customPython.interpreter} ./gen-options-md.py ${options}/share/doc/nixos/options.json
'';
2024-07-20 21:55:49 +00:00
installPhase = ''
mkdir $out
2024-07-24 17:37:27 +00:00
cp -r ./nixos-docs/* $out/
rm -rf $out/_module.md
2024-07-20 21:55:49 +00:00
'';
}