all repos — searchix @ fbc4c583a4e2759d6b8cdbb98de2c769918ddac8

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

docs: embed defaults in app

Alan Pearce
commit

fbc4c583a4e2759d6b8cdbb98de2c769918ddac8

parent

8d5dfd90332facb2613b927cf32472915f87359d

3 files changed, 45 insertions(+), 45 deletions(-)

jump to
M config.tomlconfig.toml
@@ -1,38 +1,9 @@
[sources.nixos] - name = "NixOS" enable = true - type = "channel" channel = "nixos-unstable" - import-path = "nixos/release.nix" - attribute = "options" - output-path = "share/doc/nixos/options.json" - [sources.repo] - type = "github" - owner = "NixOS" - repo = "nixpkgs" [sources.darwin] - name = "darwin" enable = true - type = "channel" - channel = "darwin" - import-path = "release.nix" - attribute = "options" - output-path = "share/doc/darwin/options.json" - [sources.repo] - type = "github" - owner = "LnL7" - repo = "nix-darwin" [sources.home-manager] - name = "home-manager" enable = true - type = "channel" - channel = "home-manager" - import-path = "default.nix" - attribute = "docs.json" - output-path = "share/doc/home-manager/options.json" - [sources.repo] - type = "github" - owner = "nix-community" - repo = "home-manager"
M import/main.goimport/main.go
@@ -11,7 +11,6 @@ "path"
"searchix/internal/config" "searchix/internal/importer" "searchix/internal/search" - "slices" "strings" "time" )
@@ -27,11 +26,7 @@ if err != nil {
log.Fatal(err) } - enabledSources := slices.DeleteFunc(cfg.Sources, func(s importer.Source) bool { - return !s.Enable - }) - - if len(enabledSources) == 0 { + if len(cfg.Sources) == 0 { slog.Info("No sources enabled") return
@@ -47,8 +42,8 @@ defer cancel()
var imp importer.Importer var hadErrors bool - for _, source := range enabledSources { - logger := slog.With("name", source.Name, "importer", source.Type.String()) + for name, source := range cfg.Sources { + logger := slog.With("name", name, "importer", source.Type.String()) logger.Debug("starting importer") switch source.Type {
M internal/config/config.gointernal/config/config.go
@@ -7,6 +7,7 @@ "net/url"
"os" "searchix/internal/file" "searchix/internal/importer" + "time" "github.com/pelletier/go-toml/v2" "github.com/pkg/errors"
@@ -42,18 +43,51 @@ Headers: map[string]string{
"x-content-type-options": "nosniff", }, Sources: map[string]importer.Source{ - "nixos": importer.Source{ - Name: "NixOS", - Enable: true, - Type: importer.Channel, - Channel: "nixos-unstable", - ImportPath: "nixos/release.nix", - Attribute: "options", - OutputPath: "share/doc/nixos/options.json", + "nixos": { + Name: "NixOS", + Enable: true, + Type: importer.Channel, + Channel: "nixpkgs", + ImportPath: "nixos/release.nix", + Attribute: "options", + OutputPath: "share/doc/nixos/options.json", + FetchTimeout: 5 * time.Minute, + ImportTimeout: 15 * time.Minute, Repo: importer.Repository{ Type: "github", Owner: "NixOS", Repo: "nixpkgs", + }, + }, + "darwin": { + Name: "darwin", + Enable: false, + Type: importer.Channel, + Channel: "nix-darwin", + ImportPath: "release.nix", + Attribute: "options", + OutputPath: "share/doc/darwin/options.json", + FetchTimeout: 5 * time.Minute, + ImportTimeout: 15 * time.Minute, + Repo: importer.Repository{ + Type: "github", + Owner: "LnL7", + Repo: "nix-darwin", + }, + }, + "home-manager": { + Name: "home-manager", + Enable: false, + Type: importer.Channel, + ImportPath: "default.nix", + Attribute: "docs.json", + OutputPath: "share/doc/home-manager/options.json", + FetchTimeout: 5 * time.Minute, + ImportTimeout: 15 * time.Minute, + Repo: importer.Repository{ + Type: "github", + Owner: "nix-community", + Repo: "home-manager", }, }, },