Skip to content

Commit e343ca1

Browse files
refactor: structured config for STATIC_ROOT
1 parent 3ff9b5f commit e343ca1

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ rec {
137137
GH_ISSUES_REPO = "sectracker-testing";
138138
GH_SECURITY_TEAM = "setracker-testing-security";
139139
GH_COMMITTERS_TEAM = "sectracker-testing-committers";
140+
STATIC_ROOT = "${toString ./src/website/static}";
140141
};
141142
};
142143

nix/web-security-tracker.nix

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,16 @@ in
108108
type = types.nullOr types.str;
109109
default = null;
110110
};
111-
env = mkOption {
111+
env = mkOption rec {
112+
description = ''
113+
Django configuration via environment variables, see `settings.py` for options.
114+
'';
112115
type = types.attrsOf types.anything;
113-
default = { };
116+
default = {
117+
STATIC_ROOT = "/var/lib/web-security-tracker/static";
118+
};
119+
# only override defaults with explicit values
120+
apply = lib.recursiveUpdate default;
114121
};
115122
settings = mkOption {
116123
type = types.attrsOf types.anything;
@@ -174,7 +181,7 @@ in
174181
{
175182
locations = {
176183
"/".proxyPass = "http://localhost:${toString cfg.wsgi-port}";
177-
"/static/".alias = "/var/lib/web-security-tracker/static/";
184+
"/static/".alias = cfg.env.STATIC_ROOT;
178185
};
179186
}
180187
// lib.optionalAttrs cfg.production {

src/website/tracker/settings.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ class Settings(BaseSettings):
3838
class DjangoSettings(BaseModel):
3939
# SECURITY WARNING: don't run with debug turned on in production!
4040
DEBUG: bool = False
41+
STATIC_ROOT: Path = Field(
42+
description="""
43+
Writeable directory for compilimg static files, such as stylesheets, when running `manage collectstatic`.
44+
"""
45+
)
4146
SYNC_GITHUB_STATE_AT_STARTUP: bool = Field(
4247
description="""
4348
Connect to GitHub when the service is started and update

0 commit comments

Comments
 (0)