From 1fb64b09e2dba34784732a61cbebc119cd847803 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Fri, 3 May 2024 11:52:06 +0200 Subject: feat: create nixos options.json importer --- .gitignore | 1 + default.nix | 4 ++++ importers/nixos-options.nix | 17 +++++++++++++++++ justfile | 3 +++ 4 files changed, 25 insertions(+) create mode 100644 importers/nixos-options.nix diff --git a/.gitignore b/.gitignore index 5849147..7297725 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ go.work /.envrc /.pre-commit-config.yaml /frontend/static/base.css +/data/ diff --git a/default.nix b/default.nix index bcd04db..3db0a44 100644 --- a/default.nix +++ b/default.nix @@ -14,6 +14,10 @@ in inherit (sources.simple-css) url sha256; }; + nixos-options = import (./. + "/importers/nixos-options.nix") { + inherit pkgs; + }; + searchix = pkgs.buildGoApplication { pname = "searchix"; version = "0.1"; diff --git a/importers/nixos-options.nix b/importers/nixos-options.nix new file mode 100644 index 0000000..894f05e --- /dev/null +++ b/importers/nixos-options.nix @@ -0,0 +1,17 @@ +{ pkgs ? import { } +, system ? builtins.currentSystem +, stateVersion ? pkgs.lib.version +, ... +}: +let + inherit (pkgs) lib; + nixos = pkgs.nixos ({ lib, pkgs, config, ... }: { + nixpkgs.hostPlatform = system; + system.stateVersion = lib.versions.majorMinor stateVersion; + }); + + doc = pkgs.nixosOptionsDoc { + inherit (nixos) options; + }; +in +doc.optionsJSON diff --git a/justfile b/justfile index b780c07..b878de3 100644 --- a/justfile +++ b/justfile @@ -4,6 +4,9 @@ default: prepare: ln -sf $(nix-build --no-out-link -A css) frontend/static/base.css +update-nixos-options: + ln -sf $(nix-build --no-out-link -A nixos-options)/share/doc/nixos/options.json data/nixos-options.json + checkformat: gofmt -d . goimports -d . -- cgit 1.4.1