about summary refs log tree commit diff stats
path: root/internal/config
diff options
context:
space:
mode:
Diffstat (limited to 'internal/config')
-rw-r--r--internal/config/config.go24
-rw-r--r--internal/config/source.go8
2 files changed, 18 insertions, 14 deletions
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
 }