91 lines
2.4 KiB
Nix
91 lines
2.4 KiB
Nix
|
{ config, lib, pkgs, ... }:
|
||
|
|
||
|
let
|
||
|
inherit (lib) mkIf mkOption types;
|
||
|
|
||
|
cfg = config.services.spejstore;
|
||
|
|
||
|
spejstore = (import ./default.nix);
|
||
|
cfgFile = pkgs.writeText "spejstore.cfg"
|
||
|
''
|
||
|
SPEJSTORE_DB_NAME='${cfg.databaseName}'
|
||
|
SPEJSTORE_DB_USER='${cfg.databaseUsername}'
|
||
|
SPEJSTORE_DB_PASSWORD='${cfg.databasePassword}'
|
||
|
SPEJSTORE_DB_HOST='${cfg.databaseHost}'
|
||
|
SPEJSTORE_ALLOWED_HOSTS='${cfg.hostName}'
|
||
|
SPEJSTORE_LABEL_API='${cfg.labelApiAddress}'
|
||
|
SPEJSTORE_MEDIA_ROOT='${cfg.mediaRoot}'
|
||
|
SPEJSTORE_CLIENT_ID='${cfg.spaceauthConsumerKey}'
|
||
|
SPEJSTORE_SECRET='${cfg.spaceauthConsumerSecret}'
|
||
|
'';
|
||
|
|
||
|
|
||
|
in {
|
||
|
options.services.spejstore = {
|
||
|
enable = mkOption {
|
||
|
type = types.bool;
|
||
|
default = false;
|
||
|
description = "Whether to enable spejstore";
|
||
|
};
|
||
|
spaceauthConsumerKey = mkOption {
|
||
|
type = types.str;
|
||
|
default = "";
|
||
|
description = "spaceauth consumer key";
|
||
|
};
|
||
|
spaceauthConsumerSecret = mkOption {
|
||
|
type = types.str;
|
||
|
default = "";
|
||
|
description = "spaceauth consumer secret";
|
||
|
};
|
||
|
hostName = mkOption {
|
||
|
type = types.str;
|
||
|
default = "inventory.waw.hackerspace.pl";
|
||
|
description = "hostname";
|
||
|
};
|
||
|
listenAddress = mkOption {
|
||
|
type = types.str;
|
||
|
default = "127.0.0.1:8000";
|
||
|
description = "Listen address for spejstore service";
|
||
|
};
|
||
|
labelApiAddress = mkOption {
|
||
|
type = types.str;
|
||
|
default = "http://label.waw.hackerspace.pl:4567";
|
||
|
description = "spejstore-labelmaker instance";
|
||
|
};
|
||
|
mediaRoot = mkOption {
|
||
|
type = types.path;
|
||
|
default = "";
|
||
|
description = "media storage path";
|
||
|
};
|
||
|
databaseName = mkOption {
|
||
|
type = types.str;
|
||
|
default = "spejstore";
|
||
|
description = "database name";
|
||
|
};
|
||
|
databaseHost = mkOption {
|
||
|
type = types.str;
|
||
|
default = "spejstore";
|
||
|
description = "database host";
|
||
|
};
|
||
|
databaseUsername = mkOption {
|
||
|
type = types.str;
|
||
|
default = "spejstore";
|
||
|
description = "database username";
|
||
|
};
|
||
|
databasePassword = mkOption {
|
||
|
type = types.str;
|
||
|
default = "spejstore";
|
||
|
description = "database password";
|
||
|
};
|
||
|
};
|
||
|
config = mkIf cfg.enable {
|
||
|
systemd.services.spejstore = {
|
||
|
wantedBy = [ "multi-user.target" ];
|
||
|
ExecStart = ''
|
||
|
${spejstore}/bin/spejstore runserver ${cfg.listenAddress}
|
||
|
'';
|
||
|
EnvironmentFile = [ cfgFile ];
|
||
|
};
|
||
|
};
|
||
|
}
|