Skip to content

Commit

Permalink
services: setup microbin service
Browse files Browse the repository at this point in the history
  • Loading branch information
alarsyo committed Dec 5, 2023
1 parent 172ca43 commit f84da22
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 0 deletions.
6 changes: 6 additions & 0 deletions hosts/hades/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions hosts/hades/secrets.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
owner = "matrix-synapse";
};

"microbin/secret-config" = {};

"miniflux/admin-credentials" = {};

"nextcloud/admin-pass" = {
Expand Down
Binary file added modules/secrets/microbin/secret-config.age
Binary file not shown.
2 changes: 2 additions & 0 deletions modules/secrets/secrets.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
1 change: 1 addition & 0 deletions services/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
./lohr.nix
./matrix.nix
./media.nix
./microbin.nix
./miniflux.nix
./monitoring.nix
./navidrome.nix
Expand Down
78 changes: 78 additions & 0 deletions services/microbin.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
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_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}"];
};
}

0 comments on commit f84da22

Please sign in to comment.