about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--defaults.toml32
-rw-r--r--internal/config/config.go24
-rw-r--r--internal/config/source.go8
-rw-r--r--internal/fetcher/channel.go2
-rw-r--r--internal/fetcher/download.go2
-rw-r--r--internal/fetcher/nixpkgs-channel.go2
-rw-r--r--internal/importer/options.go2
-rw-r--r--internal/importer/package.go2
8 files changed, 33 insertions, 41 deletions
diff --git a/defaults.toml b/defaults.toml
index a39b592..da3eb4f 100644
--- a/defaults.toml
+++ b/defaults.toml
@@ -4,6 +4,7 @@ LogLevel = 'INFO'
 [Web]
 ListenAddress = 'localhost'
 Port = 3000
+BaseURL = 'http://localhost:3000'
 SentryDSN = ''
 Environment = 'development'
 ExtraHeadHTML = ''
@@ -41,22 +42,11 @@ trusted-types = []
 upgrade-insecure-requests = false
 worker-src = []
 
-[Web.BaseURL]
-Scheme = 'http'
-Opaque = ''
-Host = 'localhost:3000'
-Path = ''
-RawPath = ''
-OmitHost = false
-ForceQuery = false
-RawQuery = ''
-Fragment = ''
-RawFragment = ''
-
 [Web.Headers]
 x-content-type-options = 'nosniff'
 
 [Importer]
+Timeout = '30m0s'
 UpdateAt = 04:00:00
 
 [Importer.Sources]
@@ -70,8 +60,8 @@ Channel = 'darwin'
 URL = 'https://github.com/LnL7/nix-darwin/archive/master.tar.gz'
 Attribute = 'options'
 ImportPath = 'release.nix'
-FetchTimeout = 300000000000
-ImportTimeout = 900000000000
+FetchTimeout = '5m0s'
+ImportTimeout = '15m0s'
 OutputPath = 'share/doc/darwin'
 
 [Importer.Sources.darwin.Repo]
@@ -90,8 +80,8 @@ Channel = 'home-manager'
 URL = 'https://github.com/nix-community/home-manager/archive/master.tar.gz'
 Attribute = 'docs.json'
 ImportPath = 'default.nix'
-FetchTimeout = 300000000000
-ImportTimeout = 900000000000
+FetchTimeout = '5m0s'
+ImportTimeout = '15m0s'
 OutputPath = 'share/doc/home-manager'
 
 [Importer.Sources.home-manager.Repo]
@@ -110,8 +100,8 @@ Channel = 'nixpkgs'
 URL = 'https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz'
 Attribute = 'options'
 ImportPath = 'nixos/release.nix'
-FetchTimeout = 300000000000
-ImportTimeout = 900000000000
+FetchTimeout = '5m0s'
+ImportTimeout = '15m0s'
 OutputPath = 'share/doc/nixos'
 
 [Importer.Sources.nixos.Repo]
@@ -130,8 +120,8 @@ Channel = 'nixos-unstable'
 URL = ''
 Attribute = ''
 ImportPath = ''
-FetchTimeout = 300000000000
-ImportTimeout = 900000000000
+FetchTimeout = '5m0s'
+ImportTimeout = '15m0s'
 OutputPath = 'packages.json.br'
 
 [Importer.Sources.nixpkgs.Repo]
@@ -139,5 +129,3 @@ Type = 'github'
 Owner = 'NixOS'
 Repo = 'nixpkgs'
 Revision = ''
-
-[Importer.Timeout]
diff --git a/internal/config/config.go b/internal/config/config.go
index 939d7b1..3947d18 100644
--- a/internal/config/config.go
+++ b/internal/config/config.go
@@ -21,6 +21,10 @@ type URL struct {
 	*url.URL
 }
 
+func (u *URL) MarshalText() ([]byte, error) {
+	return []byte(u.URL.String()), nil
+}
+
 func (u *URL) UnmarshalText(text []byte) (err error) {
 	u.URL, err = url.Parse(string(text))
 
@@ -35,6 +39,10 @@ type Duration struct {
 	time.Duration
 }
 
+func (d *Duration) MarshalText() ([]byte, error) {
+	return []byte(d.Duration.String()), nil
+}
+
 func (d *Duration) UnmarshalText(text []byte) (err error) {
 	d.Duration, err = time.ParseDuration(string(text))
 	if err != nil {
@@ -122,8 +130,8 @@ var defaultConfig = Config{
 				ImportPath:    "nixos/release.nix",
 				Attribute:     "options",
 				OutputPath:    "share/doc/nixos",
-				FetchTimeout:  5 * time.Minute,
-				ImportTimeout: 15 * time.Minute,
+				FetchTimeout:  Duration{5 * time.Minute},
+				ImportTimeout: Duration{15 * time.Minute},
 				Repo:          nixpkgs,
 			},
 			"darwin": {
@@ -137,8 +145,8 @@ var defaultConfig = Config{
 				ImportPath:    "release.nix",
 				Attribute:     "options",
 				OutputPath:    "share/doc/darwin",
-				FetchTimeout:  5 * time.Minute,
-				ImportTimeout: 15 * time.Minute,
+				FetchTimeout:  Duration{5 * time.Minute},
+				ImportTimeout: Duration{15 * time.Minute},
 				Repo: Repository{
 					Type:  "github",
 					Owner: "LnL7",
@@ -156,8 +164,8 @@ var defaultConfig = Config{
 				ImportPath:    "default.nix",
 				Attribute:     "docs.json",
 				OutputPath:    "share/doc/home-manager",
-				FetchTimeout:  5 * time.Minute,
-				ImportTimeout: 15 * time.Minute,
+				FetchTimeout:  Duration{5 * time.Minute},
+				ImportTimeout: Duration{15 * time.Minute},
 				Repo: Repository{
 					Type:  "github",
 					Owner: "nix-community",
@@ -172,8 +180,8 @@ var defaultConfig = Config{
 				Fetcher:       ChannelNixpkgs,
 				Channel:       "nixos-unstable",
 				OutputPath:    "packages.json.br",
-				FetchTimeout:  5 * time.Minute,
-				ImportTimeout: 15 * time.Minute,
+				FetchTimeout:  Duration{5 * time.Minute},
+				ImportTimeout: Duration{15 * time.Minute},
 				Repo:          nixpkgs,
 			},
 		},
diff --git a/internal/config/source.go b/internal/config/source.go
index 1fab61d..15b1aa0 100644
--- a/internal/config/source.go
+++ b/internal/config/source.go
@@ -1,9 +1,5 @@
 package config
 
-import (
-	"time"
-)
-
 type Source struct {
 	Name          string
 	Key           string
@@ -14,8 +10,8 @@ type Source struct {
 	URL           string
 	Attribute     string
 	ImportPath    string
-	FetchTimeout  time.Duration
-	ImportTimeout time.Duration
+	FetchTimeout  Duration
+	ImportTimeout Duration
 	OutputPath    string
 	Repo          Repository
 }
diff --git a/internal/fetcher/channel.go b/internal/fetcher/channel.go
index cadbab2..5dc84b4 100644
--- a/internal/fetcher/channel.go
+++ b/internal/fetcher/channel.go
@@ -25,7 +25,7 @@ type ChannelFetcher struct {
 func (i *ChannelFetcher) FetchIfNeeded(
 	parent context.Context,
 ) (f FetchedFiles, updated bool, err error) {
-	ctx, cancel := context.WithTimeout(parent, i.Source.FetchTimeout)
+	ctx, cancel := context.WithTimeout(parent, i.Source.FetchTimeout.Duration)
 	defer cancel()
 
 	dest := i.DataPath
diff --git a/internal/fetcher/download.go b/internal/fetcher/download.go
index 7657825..4165886 100644
--- a/internal/fetcher/download.go
+++ b/internal/fetcher/download.go
@@ -26,7 +26,7 @@ var files = map[string]string{
 func (i *DownloadFetcher) FetchIfNeeded(
 	parent context.Context,
 ) (f FetchedFiles, updated bool, err error) {
-	ctx, cancel := context.WithTimeout(parent, i.Source.FetchTimeout)
+	ctx, cancel := context.WithTimeout(parent, i.Source.FetchTimeout.Duration)
 	defer cancel()
 
 	root := i.DataPath
diff --git a/internal/fetcher/nixpkgs-channel.go b/internal/fetcher/nixpkgs-channel.go
index c135641..e36728c 100644
--- a/internal/fetcher/nixpkgs-channel.go
+++ b/internal/fetcher/nixpkgs-channel.go
@@ -32,7 +32,7 @@ var filesToFetch = map[string]string{
 func (i *NixpkgsChannelFetcher) FetchIfNeeded(
 	parent context.Context,
 ) (f FetchedFiles, updated bool, err error) {
-	ctx, cancel := context.WithTimeout(parent, i.Source.FetchTimeout)
+	ctx, cancel := context.WithTimeout(parent, i.Source.FetchTimeout.Duration)
 	defer cancel()
 
 	root := i.DataPath
diff --git a/internal/importer/options.go b/internal/importer/options.go
index 51a6eb4..8ce684c 100644
--- a/internal/importer/options.go
+++ b/internal/importer/options.go
@@ -88,7 +88,7 @@ func NewOptionProcessor(infile io.ReadCloser, source *config.Source) (*OptionIng
 }
 
 func (i *OptionIngester) Process(parent context.Context) (<-chan nix.Importable, <-chan error) {
-	ctx, cancel := context.WithTimeout(parent, i.source.ImportTimeout)
+	ctx, cancel := context.WithTimeout(parent, i.source.ImportTimeout.Duration)
 	results := make(chan nix.Importable)
 	errs := make(chan error)
 
diff --git a/internal/importer/package.go b/internal/importer/package.go
index c10a96d..dbc5854 100644
--- a/internal/importer/package.go
+++ b/internal/importer/package.go
@@ -105,7 +105,7 @@ func convertToLicense(in map[string]any) *nix.License {
 }
 
 func (i *PackageIngester) Process(parent context.Context) (<-chan nix.Importable, <-chan error) {
-	ctx, cancel := context.WithTimeout(parent, i.source.ImportTimeout)
+	ctx, cancel := context.WithTimeout(parent, i.source.ImportTimeout.Duration)
 	results := make(chan nix.Importable)
 	errs := make(chan error)