Compare commits

..

8 Commits

Author SHA1 Message Date
dettlaff f9f20f79fb feat: flake.lock update 2024-06-06 23:16:33 +04:00
dettlaff 086cdd9bce dd 2024-06-06 22:42:13 +04:00
dettlaff d3b1398c9d dd 2024-06-06 22:28:20 +04:00
dettlaff 73cab37aa5 dede 2024-06-06 22:04:18 +04:00
dettlaff a59b4b8944 dd 2024-06-06 19:11:21 +04:00
dettlaff 63dcfcec4e фвфв 2024-06-05 16:09:59 +04:00
dettlaff 0509ceb2af fixfix 2024-06-05 07:16:34 +04:00
dettlaff 2938cfa33e feat: add roundcube 2024-05-14 00:39:21 +04:00
7 changed files with 72 additions and 29 deletions

View File

@ -1,20 +1,4 @@
{ config, pkgs, lib, ... }:
let
redis-sp-api-srv-name = "sp-api";
sp-print-api-token = pkgs.writeShellApplication {
name = "sp-print-api-token";
runtimeInputs = with pkgs; [ redis ];
text = ''
hash_token="$(redis-cli -s /run/redis-${redis-sp-api-srv-name}/redis.sock keys "token_repo:tokens:*" | head -n 1)"
hash_token="''${hash_token#"token_repo:tokens:"}"
token="$(redis-cli -s /run/redis-${redis-sp-api-srv-name}/redis.sock HGETALL "token_repo:tokens:$hash_token")"
token="$(echo "$token" | sed -n '2p')"
echo "$token"
'';
};
in
{
imports = [
./selfprivacy-module.nix
@ -31,7 +15,7 @@ in
services.selfprivacy-api.enable = true;
services.redis.servers.${redis-sp-api-srv-name} = {
services.redis.servers.sp-api = {
enable = true;
save = [
[
@ -84,7 +68,6 @@ in
environment.systemPackages = with pkgs; [
git
jq
sp-print-api-token
];
# consider environment.defaultPackages = lib.mkForce [];
documentation.enable = false; # no {man,info}-pages & docs, etc to save space

View File

@ -2,11 +2,11 @@
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1716361217,
"narHash": "sha256-mzZDr00WUiUXVm1ujBVv6A0qRd8okaITyUp4ezYRgc4=",
"lastModified": 1714531828,
"narHash": "sha256-ILsf3bdY/hNNI/Hu5bSt2/KbmHaAVhBbNUOdGztTHEg=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "46397778ef1f73414b03ed553a3368f0e7e33c2f",
"rev": "0638fe2715d998fa81d173aad264eb671ce2ebc1",
"type": "github"
},
"original": {
@ -28,17 +28,17 @@
]
},
"locked": {
"lastModified": 1716580438,
"narHash": "sha256-wWKhCiRmjrFgnHUgcxBb2mtBy9uTrY93yxpMYh/wpVY=",
"ref": "master",
"rev": "4f1d44ce74432e745f0be3b192f8cc4ae06fd169",
"revCount": 1304,
"lastModified": 1717701247,
"narHash": "sha256-MiP9/qgfxEFG0XrsNhKxKkct4g+ucNpxzUdN9c5Kklg=",
"ref": "refs/heads/master",
"rev": "8c753730c41fe9f2ba281bcabc76808bf61754fc",
"revCount": 1306,
"type": "git",
"url": "https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git"
"url": "https://git.selfprivacy.org/def/selfprivacy-rest-api.git"
},
"original": {
"type": "git",
"url": "https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git"
"url": "https://git.selfprivacy.org/def/selfprivacy-rest-api.git"
}
}
},

View File

@ -5,7 +5,7 @@
nixpkgs.url = github:nixos/nixpkgs;
selfprivacy-api.url =
git+https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git;
git+https://git.selfprivacy.org/def/selfprivacy-rest-api.git;
# make selfprivacy-api use the same shared nixpkgs
selfprivacy-api.inputs.nixpkgs.follows = "nixpkgs";
};

View File

@ -0,0 +1,15 @@
[
[
"selfprivacy",
"domain"
],
[
"selfprivacy",
"modules",
"roundcube"
],
[
"mailserver",
"fqdn"
]
]

View File

@ -0,0 +1,9 @@
{
description = "Roundcube is a web-based email client.";
outputs = { self }: {
nixosModules.default = import ./module.nix;
configPathsNeeded =
builtins.fromJSON (builtins.readFile ./config-paths-needed.json);
};
}

View File

@ -0,0 +1,35 @@
{ config, lib, ... }:
let
domain = config.selfprivacy.domain;
cfg = config.selfprivacy.modules.roundcube;
in
{
options.selfprivacy.modules.roundcube = {
enable = lib.mkOption {
default = false;
type = lib.types.bool;
};
subdomain = lib.mkOption {
default = "roundcube";
type = lib.types.strMatching "[A-Za-z0-9][A-Za-z0-9\-]{0,61}[A-Za-z0-9]";
};
};
config = lib.mkIf cfg.enable {
services.roundcube = {
enable = true;
# this is the url of the vhost, not necessarily the same as the fqdn of
# the mailserver
hostName = "${cfg.subdomain}.${config.selfprivacy.domain}";
extraConfig = ''
# starttls needed for authentication, so the fqdn required to match
# the certificate
$config['smtp_server'] = "tls://${config.mailserver.fqdn}";
$config['smtp_user'] = "%u";
$config['smtp_pass'] = "%p";
'';
};
};
}

View File

@ -89,4 +89,5 @@ lib.mkIf sp.modules.simple-nixos-mailserver.enable
virusScanning = false;
};
}