services: setup microbin service

This commit is contained in:
Antoine Martin 2023-12-05 13:59:21 +01:00
parent 172ca43383
commit 2584be6235
6 changed files with 90 additions and 0 deletions

View file

@ -76,6 +76,12 @@ in {
secretConfigFile = config.age.secrets."matrix-synapse/secret-config".path;
};
microbin = {
enable = true;
privatePort = 8088;
passwordFile = config.age.secrets."microbin/secret-config".path;
};
miniflux = {
enable = true;
adminCredentialsFile = config.age.secrets."miniflux/admin-credentials".path;

View file

@ -21,6 +21,8 @@
owner = "matrix-synapse";
};
"microbin/secret-config" = {};
"miniflux/admin-credentials" = {};
"nextcloud/admin-pass" = {

Binary file not shown.

View file

@ -18,6 +18,8 @@ in {
"matrix-synapse/secret-config.age".publicKeys = [alarsyo hades];
"microbin/secret-config.age".publicKeys = [alarsyo hades];
"miniflux/admin-credentials.age".publicKeys = [alarsyo hades];
"nextcloud/admin-pass.age".publicKeys = [alarsyo hades];

View file

@ -8,6 +8,7 @@
./lohr.nix
./matrix.nix
./media.nix
./microbin.nix
./miniflux.nix
./monitoring.nix
./navidrome.nix

79
services/microbin.nix Normal file
View file

@ -0,0 +1,79 @@
{
config,
lib,
pkgs,
...
}: let
inherit
(lib)
mkEnableOption
mkIf
mkOption
;
cfg = config.my.services.microbin;
domain = config.networking.domain;
hostname = config.networking.hostName;
fqdn = "${hostname}.${domain}";
in {
options.my.services.microbin = let
inherit (lib) types;
in {
enable = mkEnableOption "MicroBin file sharing app";
privatePort = mkOption {
type = types.nullOr types.port;
default = null;
example = 8080;
description = "Port to serve the app";
};
passwordFile = mkOption {
type = types.nullOr types.path;
default = null;
description = "See NixOS module description";
};
};
config = mkIf cfg.enable {
services.microbin = {
enable = true;
settings = {
MICROBIN_PORT = cfg.privatePort;
MICROBIN_BIND = "127.0.0.1";
MICROBIN_PUBLIC_PATH = "https://drop.${domain}/";
MICROBIN_READONLY = true;
MICROBIN_ENABLE_READONLY = true;
MICROBIN_THREADS = 2;
MICROBIN_GC_DAYS = 0; # turn off GC
MICROBIN_QR = true;
MICROBIN_ETERNAL_PASTA = true;
MICROBIN_DEFAULT_EXPIRY = "1week";
MICROBIN_DISABLE_TELEMETRY = true;
};
passwordFile = cfg.passwordFile;
};
my.services.restic-backup = {
paths = [
config.services.microbin.dataDir
];
};
services.nginx = {
virtualHosts = {
"drop.${domain}" = {
forceSSL = true;
useACMEHost = fqdn;
locations."/" = {
proxyPass = "http://127.0.0.1:${toString cfg.privatePort}";
};
};
};
};
security.acme.certs.${fqdn}.extraDomainNames = ["drop.${domain}"];
};
}