mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-config.git
synced 2024-11-22 19:41:30 +00:00
clean configuration; simple-nixos-mailserver is an ordinary SP module
This commit is contained in:
parent
25bd151ef3
commit
defaca8793
|
@ -1,7 +1,7 @@
|
||||||
{ config, pkgs, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./variables-module.nix
|
./selfprivacy-module.nix
|
||||||
./volumes.nix
|
./volumes.nix
|
||||||
./users.nix
|
./users.nix
|
||||||
./letsencrypt/acme.nix
|
./letsencrypt/acme.nix
|
||||||
|
|
|
@ -25,9 +25,10 @@
|
||||||
deployment
|
deployment
|
||||||
./configuration.nix
|
./configuration.nix
|
||||||
(import ./files.nix top-level-flake.outPath)
|
(import ./files.nix top-level-flake.outPath)
|
||||||
(import ./userdata-variables.nix userdata)
|
|
||||||
selfprivacy-api.nixosModules.default
|
selfprivacy-api.nixosModules.default
|
||||||
{
|
{
|
||||||
|
# pass userdata (parsed from JSON) options to selfprivacy module
|
||||||
|
selfprivacy = userdata;
|
||||||
# embed top-level flake source folder into the build
|
# embed top-level flake source folder into the build
|
||||||
environment.etc."selfprivacy/nixos-config-source".source =
|
environment.etc."selfprivacy/nixos-config-source".source =
|
||||||
top-level-flake.outPath;
|
top-level-flake.outPath;
|
||||||
|
|
|
@ -86,32 +86,25 @@ with lib;
|
||||||
#############
|
#############
|
||||||
dns = {
|
dns = {
|
||||||
provider = mkOption {
|
provider = mkOption {
|
||||||
description = "DNS provider that was defined at the initial setup process. Default is ClOUDFLARE";
|
description = "DNS provider that was defined at the initial setup process.";
|
||||||
type = types.nullOr types.str;
|
type = types.nullOr types.str;
|
||||||
};
|
};
|
||||||
useStagingACME = mkOption {
|
useStagingACME = mkOption {
|
||||||
description = "Use staging ACME server. Default is false";
|
description = "Use staging ACME server. Default is false";
|
||||||
type = types.nullOr types.bool;
|
type = types.nullOr types.bool;
|
||||||
|
default = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
backup = {
|
backup = {
|
||||||
bucket = mkOption {
|
bucket = mkOption {
|
||||||
description = "Bucket name used for userdata backups";
|
description = "Bucket name used for userdata backups";
|
||||||
type = types.nullOr types.str;
|
type = types.nullOr types.str;
|
||||||
|
default = "";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
server = {
|
server = {
|
||||||
provider = mkOption {
|
provider = mkOption {
|
||||||
description = "Server provider that was defined at the initial setup process. Default is HETZNER";
|
description = "Server provider that was defined at the initial setup process.";
|
||||||
type = types.nullOr types.str;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
##############
|
|
||||||
# Services #
|
|
||||||
##############
|
|
||||||
email = {
|
|
||||||
location = mkOption {
|
|
||||||
default = "sda1";
|
|
||||||
type = types.nullOr types.str;
|
type = types.nullOr types.str;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -125,7 +118,7 @@ with lib;
|
||||||
};
|
};
|
||||||
rootKeys = mkOption {
|
rootKeys = mkOption {
|
||||||
description = ''
|
description = ''
|
||||||
Root SSH Keys
|
Root SSH authorized keys
|
||||||
'';
|
'';
|
||||||
type = types.nullOr (types.listOf types.str);
|
type = types.nullOr (types.listOf types.str);
|
||||||
default = [ "" ];
|
default = [ "" ];
|
||||||
|
@ -163,9 +156,5 @@ with lib;
|
||||||
default = false;
|
default = false;
|
||||||
description = "Whether to bind-mount vmail and sieve folders";
|
description = "Whether to bind-mount vmail and sieve folders";
|
||||||
};
|
};
|
||||||
##############
|
|
||||||
# Modules #
|
|
||||||
##############
|
|
||||||
# modules =
|
|
||||||
};
|
};
|
||||||
}
|
}
|
|
@ -1,7 +1,6 @@
|
||||||
[
|
[
|
||||||
[ "mailserver" ],
|
[ "mailserver" ],
|
||||||
[ "selfprivacy", "domain" ],
|
[ "selfprivacy", "domain" ],
|
||||||
[ "selfprivacy", "email" ],
|
|
||||||
[ "selfprivacy", "hashedMasterPassword" ],
|
[ "selfprivacy", "hashedMasterPassword" ],
|
||||||
[ "selfprivacy", "useBinds" ],
|
[ "selfprivacy", "useBinds" ],
|
||||||
[ "selfprivacy", "username" ],
|
[ "selfprivacy", "username" ],
|
||||||
|
|
|
@ -2,21 +2,23 @@ mailserverDate: { config, lib, ... }:
|
||||||
let
|
let
|
||||||
sp = config.selfprivacy;
|
sp = config.selfprivacy;
|
||||||
in
|
in
|
||||||
|
lib.mkIf sp.modules.simple-nixos-mailserver.enable
|
||||||
{
|
{
|
||||||
fileSystems =
|
fileSystems = lib.mkIf sp.useBinds
|
||||||
lib.mkIf (sp.modules.simple-nixos-mailserver.enable && sp.useBinds)
|
|
||||||
{
|
{
|
||||||
"/var/vmail" = {
|
"/var/vmail" = {
|
||||||
device = "/volumes/${sp.email.location}/vmail";
|
device =
|
||||||
|
"/volumes/${sp.modules.simple-nixos-mailserver.location}/vmail";
|
||||||
options = [ "bind" ];
|
options = [ "bind" ];
|
||||||
};
|
};
|
||||||
"/var/sieve" = {
|
"/var/sieve" = {
|
||||||
device = "/volumes/${sp.email.location}/sieve";
|
device =
|
||||||
|
"/volumes/${sp.modules.simple-nixos-mailserver.location}/sieve";
|
||||||
options = [ "bind" ];
|
options = [ "bind" ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
users.users = lib.mkIf sp.modules.simple-nixos-mailserver.enable {
|
users.users = {
|
||||||
virtualMail = {
|
virtualMail = {
|
||||||
isNormalUser = false;
|
isNormalUser = false;
|
||||||
};
|
};
|
||||||
|
@ -24,8 +26,8 @@ in
|
||||||
|
|
||||||
users.groups.acmereceivers.members = [ "dovecot2" "postfix" "virtualMail" ];
|
users.groups.acmereceivers.members = [ "dovecot2" "postfix" "virtualMail" ];
|
||||||
|
|
||||||
selfprivacy.modules.simple-nixos-mailserver =
|
mailserver = {
|
||||||
lib.mkIf sp.modules.simple-nixos-mailserver.enable {
|
enable = true;
|
||||||
fqdn = sp.domain;
|
fqdn = sp.domain;
|
||||||
domains = [ sp.domain ];
|
domains = [ sp.domain ];
|
||||||
|
|
||||||
|
|
|
@ -5,20 +5,10 @@
|
||||||
gitlab:simple-nixos-mailserver/nixos-mailserver;
|
gitlab:simple-nixos-mailserver/nixos-mailserver;
|
||||||
|
|
||||||
outputs = { self, mailserver }: {
|
outputs = { self, mailserver }: {
|
||||||
nixosModules.default = args@{ config, ... }:
|
nixosModules.default = _: {
|
||||||
let
|
|
||||||
module = mailserver.nixosModules.default args;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
imports = [
|
imports = [
|
||||||
module
|
mailserver.nixosModules.default
|
||||||
{
|
./options.nix
|
||||||
# tricks to rename (alias) the original module
|
|
||||||
config.mailserver =
|
|
||||||
config.selfprivacy.modules.simple-nixos-mailserver;
|
|
||||||
options.selfprivacy.modules.simple-nixos-mailserver =
|
|
||||||
module.options.mailserver;
|
|
||||||
}
|
|
||||||
(import ./config.nix mailserver.lastModifiedDate)
|
(import ./config.nix mailserver.lastModifiedDate)
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
13
sp-modules/simple-nixos-mailserver/options.nix
Normal file
13
sp-modules/simple-nixos-mailserver/options.nix
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
{ lib, ... }:
|
||||||
|
{
|
||||||
|
options.selfprivacy.modules.simple-nixos-mailserver = {
|
||||||
|
enable = lib.mkOption {
|
||||||
|
default = false;
|
||||||
|
type = with lib.types; nullOr bool;
|
||||||
|
};
|
||||||
|
location = lib.mkOption {
|
||||||
|
default = "sda1";
|
||||||
|
type = with lib.types; nullOr str;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -1,32 +0,0 @@
|
||||||
jsonData: { lib, ... }:
|
|
||||||
{
|
|
||||||
selfprivacy = jsonData // {
|
|
||||||
hostname = lib.attrsets.attrByPath [ "hostname" ] null jsonData;
|
|
||||||
domain = lib.attrsets.attrByPath [ "domain" ] null jsonData;
|
|
||||||
timezone = lib.attrsets.attrByPath [ "timezone" ] "Europe/Uzhgorod" jsonData;
|
|
||||||
stateVersion = lib.attrsets.attrByPath [ "stateVersion" ] "22.05" jsonData;
|
|
||||||
username = lib.attrsets.attrByPath [ "username" ] null jsonData;
|
|
||||||
hashedMasterPassword = lib.attrsets.attrByPath [ "hashedMasterPassword" ] null jsonData;
|
|
||||||
sshKeys = lib.attrsets.attrByPath [ "sshKeys" ] [ ] jsonData;
|
|
||||||
dns = {
|
|
||||||
provider = lib.attrsets.attrByPath [ "dns" "provider" ] "CLOUDFLARE" jsonData;
|
|
||||||
useStagingACME = lib.attrsets.attrByPath [ "dns" "useStagingACME" ] false jsonData;
|
|
||||||
};
|
|
||||||
backup = {
|
|
||||||
bucket = lib.attrsets.attrByPath [ "backup" "bucket" ] (lib.attrsets.attrByPath [ "backblaze" "bucket" ] "" jsonData) jsonData;
|
|
||||||
};
|
|
||||||
server = {
|
|
||||||
provider = lib.attrsets.attrByPath [ "server" "provider" ] "HETZNER" jsonData;
|
|
||||||
};
|
|
||||||
ssh = {
|
|
||||||
enable = lib.attrsets.attrByPath [ "ssh" "enable" ] true jsonData;
|
|
||||||
rootKeys = lib.attrsets.attrByPath [ "ssh" "rootKeys" ] [ "" ] jsonData;
|
|
||||||
passwordAuthentication = lib.attrsets.attrByPath [ "ssh" "passwordAuthentication" ] true jsonData;
|
|
||||||
};
|
|
||||||
email = {
|
|
||||||
location = lib.attrsets.attrByPath [ "email" "location" ] "sda1" jsonData;
|
|
||||||
};
|
|
||||||
users = lib.attrsets.attrByPath [ "users" ] [ ] jsonData;
|
|
||||||
volumes = lib.attrsets.attrByPath [ "volumes" ] [ ] jsonData;
|
|
||||||
};
|
|
||||||
}
|
|
Loading…
Reference in a new issue