Add api token param

master
Inex Code 2021-11-16 13:28:16 +03:00
parent c2a4385b04
commit 3e710e61d2
4 changed files with 25 additions and 1 deletions

View File

@ -19,6 +19,12 @@ in
Enable SelfPrivacy API service Enable SelfPrivacy API service
''; '';
}; };
token = mkOption {
type = types.string;
description = ''
SelfPrivacy API token
'';
};
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
@ -28,6 +34,7 @@ in
inherit (config.environment.sessionVariables) NIX_PATH; inherit (config.environment.sessionVariables) NIX_PATH;
HOME = "/root"; HOME = "/root";
PYTHONUNBUFFERED = "1"; PYTHONUNBUFFERED = "1";
AUTH_TOKEN = cfg.token;
} // config.networking.proxy.envVars; } // config.networking.proxy.envVars;
path = [ "/var/" "/var/dkim/" pkgs.coreutils pkgs.gnutar pkgs.xz.bin pkgs.gzip pkgs.gitMinimal config.nix.package.out pkgs.nixos-rebuild pkgs.restic pkgs.mkpasswd ]; path = [ "/var/" "/var/dkim/" pkgs.coreutils pkgs.gnutar pkgs.xz.bin pkgs.gzip pkgs.gitMinimal config.nix.package.out pkgs.nixos-rebuild pkgs.restic pkgs.mkpasswd ];
after = [ "network-online.target" ]; after = [ "network-online.target" ];

View File

@ -1,7 +1,8 @@
{ pkgs, ... }: { config, pkgs, ... }:
{ {
services.selfprivacy-api = { services.selfprivacy-api = {
enable = true; enable = true;
token = config.services.userdata.api.token;
}; };
users.users."selfprivacy-api" = { users.users."selfprivacy-api" = {

View File

@ -18,6 +18,14 @@
"timezone": { "timezone": {
"type": "string" "type": "string"
}, },
"api": {
"type": "object",
"properties": {
"token": {
"type": "string"
}
}
},
"backblaze": { "backblaze": {
"type": "object", "type": "object",
"properties": { "properties": {

View File

@ -37,6 +37,14 @@ in
''; '';
type = types.nullOr types.string; type = types.nullOr types.string;
}; };
api = {
token = mkOption {
description = ''
API token used to authenticate with the server
'';
type = types.nullOr types.string;
};
};
backblaze = { backblaze = {
bucket = mkOption { bucket = mkOption {
description = "Bucket name used for userdata backups"; description = "Bucket name used for userdata backups";