It builds!

This commit is contained in:
Inex Code 2021-11-15 13:29:20 +03:00
parent 85aaf52635
commit 4ba0dd5396
7 changed files with 41 additions and 38 deletions

View file

@ -35,7 +35,7 @@
}; };
nameservers = [ "1.1.1.1" "1.0.0.1" ]; nameservers = [ "1.1.1.1" "1.0.0.1" ];
}; };
time.timeZone = "Europe/Uzhgorod"; time.timeZone = config.services.userdata.timezone;
i18n.defaultLocale = "en_GB.UTF-8"; i18n.defaultLocale = "en_GB.UTF-8";
users.users.root.openssh.authorizedKeys.keys = config.services.userdata.rootSshKeys; users.users.root.openssh.authorizedKeys.keys = config.services.userdata.rootSshKeys;
services.openssh = { services.openssh = {

View file

@ -43,24 +43,24 @@ in
stop; stop;
} }
''; '';
} // builtins.listToAttrs (builtins.map };
(user: { } // builtins.listToAttrs (builtins.map
name = "${user.username}@${cfg.domain}"; (user: {
value = { name = "${user.username}@${cfg.domain}";
hashedPassword = user.hashedPassword; value = {
catchAll = [ cfg.domain ]; hashedPassword = user.hashedPassword;
sieveScript = '' catchAll = [ cfg.domain ];
require ["fileinto", "mailbox"]; sieveScript = ''
if header :contains "Chat-Version" "1.0" require ["fileinto", "mailbox"];
{ if header :contains "Chat-Version" "1.0"
fileinto :create "DeltaChat"; {
stop; fileinto :create "DeltaChat";
} stop;
''; }
}; '';
}) };
cfg.users); })
}; cfg.users);
extraVirtualAliases = { extraVirtualAliases = {
"admin@${cfg.domain}" = "${cfg.username}@${cfg.domain}"; "admin@${cfg.domain}" = "${cfg.username}@${cfg.domain}";

View file

@ -37,5 +37,7 @@ in
''; '';
users.users.pleroma = { users.users.pleroma = {
extraGroups = [ "postgres" ]; extraGroups = [ "postgres" ];
isNormalUser = false;
isSystemUser = true;
}; };
} }

View file

@ -15,6 +15,9 @@
"hashedMasterPassword": { "hashedMasterPassword": {
"type": "string" "type": "string"
}, },
"timezone": {
"type": "string"
},
"backblaze": { "backblaze": {
"type": "object", "type": "object",
"properties": { "properties": {

View file

@ -1,12 +1,23 @@
{ pkgs, config, ... }: { pkgs, config, ... }:
let
cfg = config.services.userdata;
in
{ {
users.mutableUsers = false; users.mutableUsers = false;
users = { users = {
users = { users = {
"${config.services.userdata.username}" = { "${cfg.username}" = {
isNormalUser = true; isNormalUser = true;
hashedPassword = config.services.userdata.hashedMasterPassword; hashedPassword = cfg.hashedMasterPassword;
}; };
}; } // builtins.listToAttrs (builtins.map
(user: {
name = "${user.username}";
value = {
isNormalUser = true;
hashedPassword = user.hashedPassword;
};
})
cfg.users);
}; };
} }

View file

@ -8,19 +8,6 @@ let
if cfg.direction == "" if cfg.direction == ""
then "" then ""
else "--direction=${cfg.direction}"; else "--direction=${cfg.direction}";
userDef = {
options = {
username = mkOption {
type = types.nullOr types.string;
};
hashedPassword = mkOption {
type = types.nullOr types.string;
};
sshKeys = mkOption {
type = types.nullOr types.listOf types.string;
};
};
};
in in
{ {
options.services.userdata = { options.services.userdata = {
@ -134,7 +121,7 @@ in
description = '' description = ''
Root SSH Keys Root SSH Keys
''; '';
type = types.nullOr types.listOf types.string; type = types.nullOr (types.listOf types.string);
}; };
timezone = mkOption { timezone = mkOption {
description = '' description = ''
@ -147,7 +134,7 @@ in
description = '' description = ''
Users that will be created on the server Users that will be created on the server
''; '';
type = with types; nullOr listOf attrsOf (submodule userDef); type = types.nullOr (types.listOf (types.attrsOf types.anything));
}; };
}; };
} }

View file

@ -1,6 +1,6 @@
{ pkgs, ... }: { pkgs, ... }:
{ {
services = { services = {
userdata = builtins.fromJSON (builtins.readFile "./userdata/userdata.json"); userdata = builtins.fromJSON (builtins.readFile ./userdata/userdata.json);
}; };
} }