diff --git a/nix/modules/spindle.nix b/nix/modules/spindle.nix --- a/nix/modules/spindle.nix +++ b/nix/modules/spindle.nix @@ -35,10 +35,10 @@ default = "0.0.0.0:6555"; description = "Address to listen on"; }; - dbPath = mkOption { + stateDir = mkOption { type = types.path; - default = "/var/lib/spindle/spindle.db"; - description = "Path to the database file"; + default = "/var/lib/spindle"; + description = "Tangled spindle data directory"; }; hostname = mkOption { @@ -150,7 +150,7 @@ LogsDirectory = "spindle"; StateDirectory = "spindle"; Environment = [ "SPINDLE_SERVER_LISTEN_ADDR=${cfg.server.listenAddr}" - "SPINDLE_SERVER_DB_PATH=${cfg.server.dbPath}" + "SPINDLE_SERVER_DATA_DIR=${cfg.server.stateDir}" "SPINDLE_SERVER_HOSTNAME=${cfg.server.hostname}" "SPINDLE_SERVER_PLC_URL=${cfg.server.plcUrl}" "SPINDLE_SERVER_DEV=${lib.boolToString cfg.server.dev}" diff --git a/nix/vm.nix b/nix/vm.nix --- a/nix/vm.nix +++ b/nix/vm.nix @@ -140,7 +140,7 @@ serviceConfig.PermissionsStartOnly = true; }; in { knot = mkDataSyncScripts "/mnt/knot-data" config.services.tangled.knot.stateDir; - spindle = mkDataSyncScripts "/mnt/spindle-data" (builtins.dirOf config.services.tangled.spindle.server.dbPath); + spindle = mkDataSyncScripts "/mnt/spindle-data" config.services.tangled.spindle.server.stateDir; }; }) ]; diff --git a/spindle/config/config.go b/spindle/config/config.go --- a/spindle/config/config.go +++ b/spindle/config/config.go @@ -3,6 +3,7 @@ import ( "context" "fmt" + "path/filepath" "github.com/bluesky-social/indigo/atproto/syntax" "github.com/sethvargo/go-envconfig" @@ -10,7 +11,6 @@ ) type Server struct { ListenAddr string `env:"LISTEN_ADDR, default=0.0.0.0:6555"` - DBPath string `env:"DB_PATH, default=spindle.db"` Hostname string `env:"HOSTNAME, required"` TapUrl string `env:"TAP_URL, required"` PlcUrl string `env:"PLC_URL, default=https://plc.directory"` @@ -18,12 +18,17 @@ Dev bool `env:"DEV, default=false"` Owner syntax.DID `env:"OWNER, required"` Secrets Secrets `env:",prefix=SECRETS_"` LogDir string `env:"LOG_DIR, default=/var/log/spindle"` + DataDir string `env:"DATA_DIR, default=/var/lib/spindle"` QueueSize int `env:"QUEUE_SIZE, default=100"` MaxJobCount int `env:"MAX_JOB_COUNT, default=2"` // max number of jobs that run at a time } func (s Server) Did() syntax.DID { return syntax.DID(fmt.Sprintf("did:web:%s", s.Hostname)) +} + +func (s Server) DBPath() string { + return filepath.Join(s.DataDir, "spindle.db") } type Secrets struct {