all repos — searchix @ 1fb64b09e2dba34784732a61cbebc119cd847803

Search engine for NixOS, nix-darwin, home-manager and NUR users

feat: create nixos options.json importer
Alan Pearce alan@alanpearce.eu
Fri, 03 May 2024 11:52:06 +0200
commit

1fb64b09e2dba34784732a61cbebc119cd847803

parent

0945da8f9654252008ff6bd56022f9363fd3cca6

4 files changed, 25 insertions(+), 0 deletions(-)

jump to
M .gitignore.gitignore
@@ -23,3 +23,4 @@ /.env /.envrc
 /.pre-commit-config.yaml
 /frontend/static/base.css
+/data/
M default.nixdefault.nix
@@ -14,6 +14,10 @@ css = pkgs.fetchurl {     inherit (sources.simple-css) url sha256;
   };
 
+  nixos-options = import (./. + "/importers/nixos-options.nix") {
+    inherit pkgs;
+  };
+
   searchix = pkgs.buildGoApplication {
     pname = "searchix";
     version = "0.1";
A importers/nixos-options.nix
@@ -0,0 +1,17 @@+{ pkgs ? import <nixpkgs> { }
+, 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
M justfilejustfile
@@ -4,6 +4,9 @@ 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 .