all repos — searchix @ 7407f6d72b4c5627542e0c7fc2dd50c70544481e

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

internal/config/default.go (view raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
package config

import (
	"strconv"
	"time"

	"github.com/pelletier/go-toml/v2"
)

var nixpkgs = Repository{
	Type:  GitHub,
	Owner: "NixOS",
	Repo:  "nixpkgs",
}

const none = "'none'"
const self = "'self'"

const maxAge = (1 * 365 * 24 * time.Hour)

var DefaultConfig = Config{
	DataPath: "./data",
	Web: &Web{
		ListenAddress: "localhost",
		Port:          3000,
		BaseURL:       mustURL("http://localhost:3000"),
		Environment:   "development",
		ContentSecurityPolicy: CSP{
			DefaultSrc: []string{none},
			BaseURI:    []string{none},
			ImgSrc:     []string{self},
			StyleSrc:   []string{self},
			// added dynamically based on final value of BaseURL
			ScriptSrc:  []string{},
			FormAction: []string{self},
			ConnectSrc: []string{self},
		},
		Headers: map[string]string{
			"strict-transport-security": "max-age=" + strconv.FormatFloat(
				maxAge.Seconds(),
				'f',
				0,
				64,
			),
			"x-content-type-options": "nosniff",
			"x-frame-options":        "DENY",
		},
		LogRequests: true,
	},
	Importer: &Importer{
		LowMemory: false,
		BatchSize: 10_000,
		Timeout:   Duration{30 * time.Minute},
		UpdateAt:  mustLocalTime("03:00:00"),
		Sources: map[string]*Source{
			"nixos": {
				Name:       "NixOS",
				Order:      0,
				Key:        "nixos",
				Enable:     true,
				Importer:   Options,
				Fetcher:    Channel,
				Channel:    "nixpkgs",
				URL:        "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz",
				ImportPath: "nixos/release.nix",
				Attribute:  "options",
				OutputPath: "share/doc/nixos",
				Timeout:    Duration{5 * time.Minute},
				Repo:       nixpkgs,
				JSONDepth:  1,
			},
			"darwin": {
				Name:       "Darwin",
				Order:      1,
				Key:        "darwin",
				Enable:     false,
				Importer:   Options,
				Fetcher:    Channel,
				Channel:    "darwin",
				URL:        "https://github.com/LnL7/nix-darwin/archive/master.tar.gz",
				ImportPath: "release.nix",
				Attribute:  "docs.optionsJSON",
				OutputPath: "share/doc/darwin",
				Timeout:    Duration{5 * time.Minute},
				Repo: Repository{
					Type:  GitHub,
					Owner: "LnL7",
					Repo:  "nix-darwin",
				},
				JSONDepth: 1,
			},
			"home-manager": {
				Name:       "Home Manager",
				Order:      2,
				Key:        "home-manager",
				Enable:     false,
				Importer:   Options,
				Channel:    "home-manager",
				URL:        "https://github.com/nix-community/home-manager/archive/master.tar.gz",
				Fetcher:    Channel,
				ImportPath: "default.nix",
				Attribute:  "docs.json",
				OutputPath: "share/doc/home-manager",
				Timeout:    Duration{5 * time.Minute},
				Repo: Repository{
					Type:  GitHub,
					Owner: "nix-community",
					Repo:  "home-manager",
				},
				JSONDepth: 1,
			},
			"nixpkgs": {
				Name:       "Nix Packages",
				Order:      3,
				Key:        "nixpkgs",
				Enable:     true,
				Importer:   Packages,
				Fetcher:    ChannelNixpkgs,
				Channel:    "nixos-unstable",
				OutputPath: "packages.json.br",
				Timeout:    Duration{15 * time.Minute},
				Repo:       nixpkgs,
				Programs: ProgramsDB{
					Enable:    true,
					Attribute: "programs.sqlite",
				},
				JSONDepth: 2,
			},
			"nur": {
				Name:     "NUR",
				Order:    4,
				Key:      "nur",
				Enable:   false,
				Importer: Packages,
				Fetcher:  Download,
				URL:      "https://alanpearce.github.io/nix-options/nur",
				Timeout:  Duration{5 * time.Minute},
				Repo: Repository{
					Type:  GitHub,
					Owner: "nix-community",
					Repo:  "nur",
				},
				JSONDepth: 1,
			},
		},
	},
}

func GetDefaultConfig() string {
	out, err := toml.Marshal(&DefaultConfig)
	if err != nil {
		panic("could not read default configuration")
	}

	return string(out)
}