all repos — searchix @ e062ca72b222b890e345548bd8422d5df98e9fef

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

feat: import sources from configuration in go code and index options

Alan Pearce
commit

e062ca72b222b890e345548bd8422d5df98e9fef

parent

967f6fdf5c1693d3aa27079b3ae28768fb7356c6

1 file changed, 22 insertions(+), 0 deletions(-)

changed files
M internal/config/config.gointernal/config/config.go
@@ -2,9 +2,11 @@ package config
import ( "log/slog" + "maps" "net/url" "os" "searchix/internal/file" + "searchix/internal/importer" "github.com/pelletier/go-toml/v2" "github.com/pkg/errors"
@@ -28,6 +30,7 @@ type Config struct {
DataPath string `toml:"data_path"` CSP CSP `toml:"content-security-policy"` Headers map[string]string + Sources map[string]importer.Source } var defaultConfig = Config{
@@ -38,6 +41,22 @@ },
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", + Repo: importer.Repository{ + Type: "github", + Owner: "NixOS", + Repo: "nixpkgs", + }, + }, + }, } func GetConfig() (*Config, error) {
@@ -60,6 +79,9 @@
return nil, errors.Wrap(err, "config error") } } + maps.DeleteFunc(config.Sources, func(_ string, v importer.Source) bool { + return !v.Enable + }) return &config, nil }