config/profiles/web/services/shlink.nix

52 lines
1.6 KiB
Nix
Raw Normal View History

2023-02-25 00:03:29 +01:00
{ config, pkgs, lib, mkDomain, ... }:
{
# Shlink
# URL shortener with REST API and command line interface
# manage with https://app.shlink.io/
# TODO: self-host shlink web client? https://shlink.io/documentation/shlink-web-client/
/** /
# data can be destryoed with `nixos-container destroy shlink`
virtualisation.oci-containers.containers."shlink" = {
autoStart = true;
image = "shlinkio/shlink:stable";
# https://shlink.io/documentation/install-docker-image/
environment = {
"DEFAULT_DOMAIN" = mkDomain "shlink";
"IS_HTTPS_ENABLED" = "true";
"TIMEZONE" = "Europe/Oslo";
#"GEOLITE_LICENSE_KEY" = ; # https://shlink.io/documentation/geolite-license-key/
# TODO: use postgres? default is sqlite3?
};
ports = [
"127.0.0.1:5757:8080/tcp" # webui
];
volumes = [
"/var/lib/shlink/database.sqlite:/etc/shlink/data/database.sqlite"
# TODO: where is the sqlite file?
];
};
systemd.services."create-shlink-volume-dirs" = {
wantedBy = [ "${config.virtualisation.oci-containers.backend}-shlink.service" ];
serviceConfig.Type = "oneshot";
script = ''
mkdir -p /var/lib/shlink
touch /var/lib/shlink/database.sqlite
'';
};
services.nginx.virtualHosts.${mkDomain "shlink"} = lib.mkIf config.virtualisation.oci-containers.containers."shlink".autoStart {
forceSSL = true; # addSSL = true;
enableACME = true; #useACMEHost = acmeDomain;
locations."/" = {
proxyPass = "http://127.0.0.1:5757";
proxyWebsockets = true;
};
};
programs.bash.shellAliases = {
shlink = "docker exec -it shlink shlink";
};
/**/
}