Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ rec {
GH_ISSUES_REPO = "sectracker-testing";
GH_SECURITY_TEAM = "setracker-testing-security";
GH_COMMITTERS_TEAM = "sectracker-testing-committers";
STATIC_ROOT = "${toString ./src/website/static}";
};
};

Expand Down
14 changes: 10 additions & 4 deletions nix/web-security-tracker.nix
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,16 @@ in
type = types.nullOr types.str;
default = null;
};
env = mkOption {
env = mkOption rec {
description = ''
Django configuration via environment variables, see `settings.py` for options.
'';
type = types.attrsOf types.anything;
default = { };
default = {
STATIC_ROOT = "/var/lib/web-security-tracker/static/"; # trailing slash is required!
};
# only override defaults with explicit values
apply = lib.recursiveUpdate default;
};
settings = mkOption {
type = types.attrsOf types.anything;
Expand Down Expand Up @@ -152,7 +159,6 @@ in
services = {
# TODO(@fricklerhandwerk): move all configuration over to pydantic-settings
web-security-tracker.settings = {
STATIC_ROOT = mkDefault "/var/lib/web-security-tracker/static";
DEBUG = mkDefault false;
ALLOWED_HOSTS = mkDefault [
(with cfg; if production then domain else "*")
Expand All @@ -174,7 +180,7 @@ in
{
locations = {
"/".proxyPass = "http://localhost:${toString cfg.wsgi-port}";
"/static/".alias = "/var/lib/web-security-tracker/static/";
"/static/".alias = cfg.env.STATIC_ROOT;
};
}
// lib.optionalAttrs cfg.production {
Expand Down
5 changes: 5 additions & 0 deletions src/website/tracker/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ class Settings(BaseSettings):
class DjangoSettings(BaseModel):
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG: bool = False
STATIC_ROOT: Path = Field(
description="""
Writeable directory for compilimg static files, such as stylesheets, when running `manage collectstatic`.
"""
)
SYNC_GITHUB_STATE_AT_STARTUP: bool = Field(
description="""
Connect to GitHub when the service is started and update
Expand Down