about summary refs log tree commit diff stats
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/config/config.go19
-rw-r--r--internal/config/repository.go (renamed from internal/importer/repository.go)2
-rw-r--r--internal/config/source.go (renamed from internal/importer/source-type.go)2
-rw-r--r--internal/importer/channel.go3
-rw-r--r--internal/importer/importer.go11
-rw-r--r--internal/importer/ingest.go5
-rw-r--r--internal/importer/nixpkgs-channel.go3
7 files changed, 26 insertions, 19 deletions
diff --git a/internal/config/config.go b/internal/config/config.go
index 71b56be..340b027 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -6,7 +6,6 @@ import (
 	"maps"
 	"net/url"
 	"os"
-	"searchix/internal/importer"
 	"time"
 
 	"github.com/pelletier/go-toml/v2"
@@ -32,7 +31,7 @@ type Config struct {
 	CSP           CSP           `toml:"content-security-policy"`
 	ExtraBodyHTML template.HTML `toml:"extra-body-html"`
 	Headers       map[string]string
-	Sources       map[string]*importer.Source
+	Sources       map[string]*Source
 }
 
 var defaultConfig = Config{
@@ -43,12 +42,12 @@ var defaultConfig = Config{
 	Headers: map[string]string{
 		"x-content-type-options": "nosniff",
 	},
-	Sources: map[string]*importer.Source{
+	Sources: map[string]*Source{
 		"nixos": {
 			Name:          "NixOS",
 			Key:           "nixos",
 			Enable:        true,
-			Type:          importer.Channel,
+			Type:          Channel,
 			Channel:       "nixpkgs",
 			URL:           "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz",
 			ImportPath:    "nixos/release.nix",
@@ -56,7 +55,7 @@ var defaultConfig = Config{
 			OutputPath:    "share/doc/nixos/options.json",
 			FetchTimeout:  5 * time.Minute,
 			ImportTimeout: 15 * time.Minute,
-			Repo: importer.Repository{
+			Repo: Repository{
 				Type:  "github",
 				Owner: "NixOS",
 				Repo:  "nixpkgs",
@@ -66,7 +65,7 @@ var defaultConfig = Config{
 			Name:          "Darwin",
 			Key:           "darwin",
 			Enable:        false,
-			Type:          importer.Channel,
+			Type:          Channel,
 			Channel:       "darwin",
 			URL:           "https://github.com/LnL7/nix-darwin/archive/master.tar.gz",
 			ImportPath:    "release.nix",
@@ -74,7 +73,7 @@ var defaultConfig = Config{
 			OutputPath:    "share/doc/darwin/options.json",
 			FetchTimeout:  5 * time.Minute,
 			ImportTimeout: 15 * time.Minute,
-			Repo: importer.Repository{
+			Repo: Repository{
 				Type:  "github",
 				Owner: "LnL7",
 				Repo:  "nix-darwin",
@@ -86,13 +85,13 @@ var defaultConfig = Config{
 			Enable:        false,
 			Channel:       "home-manager",
 			URL:           "https://github.com/nix-community/home-manager/archive/master.tar.gz",
-			Type:          importer.Channel,
+			Type:          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{
+			Repo: Repository{
 				Type:  "github",
 				Owner: "nix-community",
 				Repo:  "home-manager",
@@ -123,7 +122,7 @@ func GetConfig(filename string) (*Config, error) {
 		}
 	}
 
-	maps.DeleteFunc(config.Sources, func(_ string, v *importer.Source) bool {
+	maps.DeleteFunc(config.Sources, func(_ string, v *Source) bool {
 		return !v.Enable
 	})
 
diff --git a/internal/importer/repository.go b/internal/config/repository.go
index 6cfd55e..8c17a4f 100644
--- a/internal/importer/repository.go
+++ b/internal/config/repository.go
@@ -1,4 +1,4 @@
-package importer
+package config
 
 import (
 	"fmt"
diff --git a/internal/importer/source-type.go b/internal/config/source.go
index 0e9bb73..2b1b440 100644
--- a/internal/importer/source-type.go
+++ b/internal/config/source.go
@@ -1,4 +1,4 @@
-package importer
+package config
 
 import (
 	"fmt"
diff --git a/internal/importer/channel.go b/internal/importer/channel.go
index 70aa9de..fb6668c 100644
--- a/internal/importer/channel.go
+++ b/internal/importer/channel.go
@@ -7,6 +7,7 @@ import (
 	"os"
 	"os/exec"
 	"path"
+	"searchix/internal/config"
 	"searchix/internal/file"
 	"searchix/internal/search"
 	"strconv"
@@ -17,7 +18,7 @@ import (
 
 type ChannelImporter struct {
 	DataPath   string
-	Source     *Source
+	Source     *config.Source
 	SourceFile string
 	Logger     *slog.Logger
 }
diff --git a/internal/importer/importer.go b/internal/importer/importer.go
index 0f7978d..5f251b0 100644
--- a/internal/importer/importer.go
+++ b/internal/importer/importer.go
@@ -4,6 +4,7 @@ import (
 	"context"
 	"log/slog"
 	"path"
+	"searchix/internal/config"
 	"searchix/internal/search"
 	"sync"
 )
@@ -14,7 +15,7 @@ type Importer interface {
 }
 
 func NewNixpkgsChannelImporter(
-	source *Source,
+	source *config.Source,
 	dataPath string,
 	logger *slog.Logger,
 ) *NixpkgsChannelImporter {
@@ -27,7 +28,11 @@ func NewNixpkgsChannelImporter(
 	}
 }
 
-func NewChannelImporter(source *Source, dataPath string, logger *slog.Logger) *ChannelImporter {
+func NewChannelImporter(
+	source *config.Source,
+	dataPath string,
+	logger *slog.Logger,
+) *ChannelImporter {
 	fullpath := path.Join(dataPath, source.Channel)
 
 	return &ChannelImporter{
@@ -39,7 +44,7 @@ func NewChannelImporter(source *Source, dataPath string, logger *slog.Logger) *C
 
 type importConfig struct {
 	Filename string
-	Source   *Source
+	Source   *config.Source
 	Logger   *slog.Logger
 }
 
diff --git a/internal/importer/ingest.go b/internal/importer/ingest.go
index 7706807..f78722a 100644
--- a/internal/importer/ingest.go
+++ b/internal/importer/ingest.go
@@ -7,6 +7,7 @@ import (
 	"net/url"
 	"os"
 	"reflect"
+	"searchix/internal/config"
 	"searchix/internal/options"
 
 	"github.com/bcicen/jstream"
@@ -108,14 +109,14 @@ type OptionIngester struct {
 	ms      *mapstructure.Decoder
 	optJSON nixOptionJSON
 	infile  *os.File
-	source  *Source
+	source  *config.Source
 }
 
 type Ingester[T options.NixOption] interface {
 	Process() (<-chan *T, <-chan error)
 }
 
-func NewOptionProcessor(inpath string, source *Source) (*OptionIngester, error) {
+func NewOptionProcessor(inpath string, source *config.Source) (*OptionIngester, error) {
 	infile, err := os.Open(inpath)
 	if err != nil {
 		return nil, errors.WithMessagef(err, "failed to open input file %s", inpath)
diff --git a/internal/importer/nixpkgs-channel.go b/internal/importer/nixpkgs-channel.go
index 2ee6027..7aaa816 100644
--- a/internal/importer/nixpkgs-channel.go
+++ b/internal/importer/nixpkgs-channel.go
@@ -7,6 +7,7 @@ import (
 	"net/url"
 	"os"
 	"path"
+	"searchix/internal/config"
 	"searchix/internal/file"
 	"searchix/internal/search"
 
@@ -15,7 +16,7 @@ import (
 
 type NixpkgsChannelImporter struct {
 	DataPath string
-	Source   *Source
+	Source   *config.Source
 	Logger   *slog.Logger
 }