API controlled timezone, autoupgrades and SSH keys

This commit is contained in:
Inex Code 2021-11-22 19:53:43 +03:00
parent a71fd79588
commit 255ea374c0
5 changed files with 74 additions and 14 deletions

View file

@ -59,8 +59,8 @@ in
environment.variables = { environment.variables = {
DOMAIN = config.services.userdata.domain; DOMAIN = config.services.userdata.domain;
}; };
system.autoUpgrade.enable = true; system.autoUpgrade.enable = config.services.userdata.autoUpgrade.enable;
system.autoUpgrade.allowReboot = false; system.autoUpgrade.allowReboot = config.services.userdata.autoUpgrade.allowReboot;
system.autoUpgrade.channel = https://nixos.org/channels/nixos-21.05-small; system.autoUpgrade.channel = https://nixos.org/channels/nixos-21.05-small;
nix = { nix = {
optimise.automatic = true; optimise.automatic = true;

View file

@ -15,9 +15,9 @@ in
group = "pleroma"; group = "pleroma";
configs = [ configs = [
(builtins.replaceStrings (builtins.replaceStrings
[ "$DOMAIN" "$LUSER" "$DB_PASSWORD" ] [ "$DOMAIN" "$LUSER" "$DB_PASSWORD" ]
[ cfg.domain cfg.username cfg.databasePassword ] [ cfg.domain cfg.username cfg.databasePassword ]
(builtins.readFile ./config.exs)) (builtins.readFile ./config.exs))
]; ];
}; };
postgresql = { postgresql = {

View file

@ -3,6 +3,17 @@
"$id": "https://git.selfprivacy.org/inex/selfprivacy-nixos-config/raw/branch/master/userdata/schema.json", "$id": "https://git.selfprivacy.org/inex/selfprivacy-nixos-config/raw/branch/master/userdata/schema.json",
"type": "object", "type": "object",
"properties": { "properties": {
"autoUpgrade": {
"type": "object",
"properties": {
"enable": {
"type": "boolean"
},
"allowReboot": {
"type": "boolean"
}
}
},
"hostname": { "hostname": {
"type": "string" "type": "string"
}, },
@ -15,6 +26,12 @@
"hashedMasterPassword": { "hashedMasterPassword": {
"type": "string" "type": "string"
}, },
"sshKeys": {
"type": "array",
"items": {
"type": "string"
}
},
"timezone": { "timezone": {
"type": "string" "type": "string"
}, },

View file

@ -9,6 +9,7 @@ in
"${cfg.username}" = { "${cfg.username}" = {
isNormalUser = true; isNormalUser = true;
hashedPassword = cfg.hashedMasterPassword; hashedPassword = cfg.hashedMasterPassword;
openssh.authorizedKeys.keys = cfg.sshKeys;
}; };
} // builtins.listToAttrs (builtins.map } // builtins.listToAttrs (builtins.map
(user: { (user: {
@ -16,6 +17,7 @@ in
value = { value = {
isNormalUser = true; isNormalUser = true;
hashedPassword = user.hashedPassword; hashedPassword = user.hashedPassword;
openssh.authorizedKeys.keys = user.sshKeys;
}; };
}) })
cfg.users); cfg.users);

View file

@ -15,6 +15,7 @@ in
default = true; default = true;
type = types.nullOr types.bool; type = types.nullOr types.bool;
}; };
# General server options
hostname = mkOption { hostname = mkOption {
description = "The hostname of the server."; description = "The hostname of the server.";
type = types.nullOr types.str; type = types.nullOr types.str;
@ -25,6 +26,28 @@ in
''; '';
type = types.nullOr types.str; type = types.nullOr types.str;
}; };
timezone = mkOption {
description = ''
Timezone used by the server
'';
type = types.nullOr types.str;
default = "Europe/Uzhgorod";
};
autoUpgrade = {
enable = mkOption {
description = "Enable auto-upgrade of the server.";
default = true;
type = types.nullOr types.bool;
};
allowReboot = mkOption {
description = "Allow the server to reboot during the upgrade.";
default = false;
type = types.nullOr types.bool;
};
};
########################
# Server admin options #
########################
username = mkOption { username = mkOption {
description = '' description = ''
Username that was defined at the initial setup process Username that was defined at the initial setup process
@ -37,6 +60,16 @@ in
''; '';
type = types.nullOr types.str; type = types.nullOr types.str;
}; };
sshKeys = mkOption {
description = ''
SSH keys of the user that was defined at the initial setup process
'';
type = types.nullOr types.str;
default = [ ];
};
###############
# API options #
###############
api = { api = {
token = mkOption { token = mkOption {
description = '' description = ''
@ -52,6 +85,9 @@ in
type = types.bool; type = types.bool;
}; };
}; };
#############
# Secrets #
#############
backblaze = { backblaze = {
bucket = mkOption { bucket = mkOption {
description = "Bucket name used for userdata backups"; description = "Bucket name used for userdata backups";
@ -72,6 +108,9 @@ in
type = types.nullOr types.str; type = types.nullOr types.str;
}; };
}; };
##############
# Services #
##############
databasePassword = mkOption { databasePassword = mkOption {
description = '' description = ''
Password for the database Password for the database
@ -126,12 +165,18 @@ in
type = types.nullOr types.bool; type = types.nullOr types.bool;
}; };
}; };
#############
# Backups #
#############
resticPassword = mkOption { resticPassword = mkOption {
description = '' description = ''
Password for the restic Password for the restic
''; '';
type = types.nullOr types.str; type = types.nullOr types.str;
}; };
#########
# SSH #
#########
ssh = { ssh = {
enable = mkOption { enable = mkOption {
default = true; default = true;
@ -142,7 +187,7 @@ in
Root SSH Keys Root SSH Keys
''; '';
type = types.nullOr (types.listOf types.str); type = types.nullOr (types.listOf types.str);
default = [""]; default = [ "" ];
}; };
passwordAuthentication = mkOption { passwordAuthentication = mkOption {
description = '' description = ''
@ -152,19 +197,15 @@ in
type = types.nullOr types.bool; type = types.nullOr types.bool;
}; };
}; };
timezone = mkOption { ###########
description = '' # Users #
Timezone used by the server ###########
'';
type = types.nullOr types.str;
default = "Europe/Uzhgorod";
};
users = mkOption { users = mkOption {
description = '' description = ''
Users that will be created on the server Users that will be created on the server
''; '';
type = types.nullOr (types.listOf (types.attrsOf types.anything)); type = types.nullOr (types.listOf (types.attrsOf types.anything));
default = []; default = [ ];
}; };
}; };
} }