From 4ba0dd5396dbe5da5cf1d335d9878b9e70bbbd97 Mon Sep 17 00:00:00 2001 From: Inex Code Date: Mon, 15 Nov 2021 13:29:20 +0300 Subject: [PATCH] It builds! --- configuration.nix | 2 +- mailserver/system/mailserver.nix | 36 ++++++++++++++++---------------- social/pleroma.nix | 2 ++ userdata/schema.json | 3 +++ users.nix | 17 ++++++++++++--- variables-module.nix | 17 ++------------- variables.nix | 2 +- 7 files changed, 41 insertions(+), 38 deletions(-) diff --git a/configuration.nix b/configuration.nix index ee84133..4c54a15 100644 --- a/configuration.nix +++ b/configuration.nix @@ -35,7 +35,7 @@ }; 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"; users.users.root.openssh.authorizedKeys.keys = config.services.userdata.rootSshKeys; services.openssh = { diff --git a/mailserver/system/mailserver.nix b/mailserver/system/mailserver.nix index aafa677..222e11c 100644 --- a/mailserver/system/mailserver.nix +++ b/mailserver/system/mailserver.nix @@ -43,24 +43,24 @@ in stop; } ''; - } // builtins.listToAttrs (builtins.map - (user: { - name = "${user.username}@${cfg.domain}"; - value = { - hashedPassword = user.hashedPassword; - catchAll = [ cfg.domain ]; - sieveScript = '' - require ["fileinto", "mailbox"]; - if header :contains "Chat-Version" "1.0" - { - fileinto :create "DeltaChat"; - stop; - } - ''; - }; - }) - cfg.users); - }; + }; + } // builtins.listToAttrs (builtins.map + (user: { + name = "${user.username}@${cfg.domain}"; + value = { + hashedPassword = user.hashedPassword; + catchAll = [ cfg.domain ]; + sieveScript = '' + require ["fileinto", "mailbox"]; + if header :contains "Chat-Version" "1.0" + { + fileinto :create "DeltaChat"; + stop; + } + ''; + }; + }) + cfg.users); extraVirtualAliases = { "admin@${cfg.domain}" = "${cfg.username}@${cfg.domain}"; diff --git a/social/pleroma.nix b/social/pleroma.nix index 4850a36..7a0446e 100644 --- a/social/pleroma.nix +++ b/social/pleroma.nix @@ -37,5 +37,7 @@ in ''; users.users.pleroma = { extraGroups = [ "postgres" ]; + isNormalUser = false; + isSystemUser = true; }; } diff --git a/userdata/schema.json b/userdata/schema.json index 0d10a19..8f3f07f 100644 --- a/userdata/schema.json +++ b/userdata/schema.json @@ -15,6 +15,9 @@ "hashedMasterPassword": { "type": "string" }, + "timezone": { + "type": "string" + }, "backblaze": { "type": "object", "properties": { diff --git a/users.nix b/users.nix index 400a057..f1b825c 100644 --- a/users.nix +++ b/users.nix @@ -1,12 +1,23 @@ { pkgs, config, ... }: +let + cfg = config.services.userdata; +in { users.mutableUsers = false; users = { users = { - "${config.services.userdata.username}" = { + "${cfg.username}" = { 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); }; } diff --git a/variables-module.nix b/variables-module.nix index 5031030..ff9a0d5 100644 --- a/variables-module.nix +++ b/variables-module.nix @@ -8,19 +8,6 @@ let if cfg.direction == "" then "" 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 { options.services.userdata = { @@ -134,7 +121,7 @@ in description = '' Root SSH Keys ''; - type = types.nullOr types.listOf types.string; + type = types.nullOr (types.listOf types.string); }; timezone = mkOption { description = '' @@ -147,7 +134,7 @@ in description = '' 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)); }; }; } diff --git a/variables.nix b/variables.nix index 5c5adbf..79fb145 100644 --- a/variables.nix +++ b/variables.nix @@ -1,6 +1,6 @@ { pkgs, ... }: { services = { - userdata = builtins.fromJSON (builtins.readFile "./userdata/userdata.json"); + userdata = builtins.fromJSON (builtins.readFile ./userdata/userdata.json); }; }