2023-09-12 08:44:05 -06:00
|
|
|
{ config
|
|
|
|
, lib
|
|
|
|
, pkgs
|
2024-05-10 15:06:29 -06:00
|
|
|
, inputs
|
2023-09-12 08:44:05 -06:00
|
|
|
, ...
|
2023-07-11 09:12:50 -06:00
|
|
|
}:
|
|
|
|
with pkgs; let
|
2024-05-10 15:06:29 -06:00
|
|
|
inherit (inputs.unstable.legacyPackages.${pkgs.system}) golink;
|
2022-12-01 21:00:23 -07:00
|
|
|
cfg = config.services.golink;
|
2023-09-12 08:44:05 -06:00
|
|
|
in
|
|
|
|
{
|
2022-12-01 21:00:23 -07:00
|
|
|
options = with lib; {
|
|
|
|
services.golink = {
|
|
|
|
enable = mkEnableOption "Enable golink";
|
|
|
|
|
|
|
|
user = mkOption {
|
2023-09-12 08:44:05 -06:00
|
|
|
type = with types; oneOf [ str int ];
|
2022-12-01 21:00:23 -07:00
|
|
|
default = "golink";
|
|
|
|
description = ''
|
|
|
|
The user the service will use.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
dataDir = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = "/var/lib/golink";
|
|
|
|
description = ''
|
|
|
|
Path to the golink sqlite database
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-12-12 06:45:26 -07:00
|
|
|
envFile = mkOption {
|
2022-12-01 21:00:23 -07:00
|
|
|
type = types.path;
|
|
|
|
default = "/run/secrets/golink";
|
|
|
|
description = ''
|
|
|
|
Path to a file containing the golink tailscale auth token
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
2023-09-12 08:44:05 -06:00
|
|
|
type = with types; oneOf [ str int ];
|
2022-12-01 21:00:23 -07:00
|
|
|
default = "golink";
|
|
|
|
description = ''
|
|
|
|
The user the service will use.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = golink;
|
|
|
|
defaultText = literalExpression "pkgs.golink";
|
|
|
|
description = "The package to use for golink";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
2023-09-12 08:44:05 -06:00
|
|
|
users.groups.${cfg.group} = { };
|
2022-12-01 21:00:23 -07:00
|
|
|
users.users.${cfg.user} = {
|
|
|
|
description = "golink service user";
|
|
|
|
isSystemUser = true;
|
|
|
|
home = cfg.dataDir;
|
|
|
|
createHome = true;
|
|
|
|
group = "${cfg.group}";
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.golink = {
|
|
|
|
enable = true;
|
|
|
|
description = "golink server";
|
2024-06-14 09:04:26 -06:00
|
|
|
wants = [ "network-online.target" ];
|
2022-12-01 21:00:23 -07:00
|
|
|
|
2023-09-12 08:44:05 -06:00
|
|
|
path = [ pkgs.vnstat ];
|
2022-12-01 21:00:23 -07:00
|
|
|
|
|
|
|
environment = {
|
|
|
|
HOME = cfg.dataDir;
|
|
|
|
HOSTNAME = config.networking.hostName;
|
|
|
|
};
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
|
|
|
|
|
|
|
RuntimeDirectory = "golink";
|
|
|
|
StateDirectory = "golink";
|
|
|
|
StateDirectoryMode = "0755";
|
|
|
|
CacheDirectory = "golink";
|
|
|
|
CacheDirectoryMode = "0755";
|
|
|
|
|
2022-12-12 06:45:26 -07:00
|
|
|
EnvironmentFile = cfg.envFile;
|
|
|
|
|
2023-07-11 09:12:50 -06:00
|
|
|
ExecStart = "${cfg.package}/bin/golink -sqlitedb ${cfg.dataDir}/golink.db";
|
2022-12-01 21:00:23 -07:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|