flake: update systemd options

This commit is contained in:
Jonas Rabenstein 2025-01-25 00:37:37 +01:00
commit 0869ab985d

View file

@ -2,27 +2,46 @@
description = "boddle, in Anlehnung an bottle"; description = "boddle, in Anlehnung an bottle";
outputs = { self, nixpkgs }: let outputs = { self, nixpkgs }: let
module = { pkgs, lib, config, ... }: { module = { pkgs, lib, config, ... }: let
cfg = config.services.boddle;
in {
options.services.boddle = { options.services.boddle = {
enable = lib.mkEnableOption "enable"; enable = lib.mkEnableOption "enable";
# TODO: configurability # TODO: configurability
server = lib.mkOption {
type = lib.types.strMatching ".+:[1-9][0-9]*";
default = "irc.ircnet.com:6667";
};
nick = lib.mkOption {
type = lib.types.strMatching "[^ ]+";
default = "boddle";
};
database = lib.mkOption {
type = lib.types.strMatching "/.+";
default = "/var/lib/boddle/${cfg.nick}.db";
};
channels = lib.mkOption {
type = lib.types.coercedTo lib.types.nonEmptyStr (lib.strings.splitString " ") (lib.types.nonEmptyListOf (lib.types.strMatching "[^ ]+"));
};
}; };
config.nixpkgs.overlays = [ self.overlay ]; config.nixpkgs.overlays = [ self.overlay ];
config.systemd.services.boddle = lib.mkIf config.services.boddle.enable { config.systemd.services.boddle = lib.mkIf config.services.boddle.enable {
confinement.enable = true; confinement.enable = true;
unitConfig.ConditionPathExists = [ unitConfig.ConditionPathExists = [ cfg.database ];
"%S/boddle/boddle.toml" serviceConfig.ExecStart = let
"%S/boddle/boddle.db" args = lib.lists.foldl (acc: channel: acc ++ [ "--channel" channel ]) [
]; (lib.getExe pkgs.boddle)
serviceConfig.ExecStart = lib.getExe pkgs.boddle; "--server" cfg.server
"--nick" cfg.nick
"--database" "./${cfg.nick}.db"
] cfg.channels;
in lib.strings.escapeShellArgs args;
serviceConfig.WorkingDirectory = "%S/boddle"; serviceConfig.WorkingDirectory = "%S/boddle";
serviceConfig.StateDirectory = "boddle"; serviceConfig.StateDirectory = "boddle";
serviceConfig.DynamicUser = true; serviceConfig.DynamicUser = true;
serviceConfig.BindPaths = [ serviceConfig.BindPaths = [ "${cfg.database}:%S/boddle/${cfg.nick}.db" ];
"%S/boddle"
];
}; };
}; };
@ -37,10 +56,10 @@
}; };
pname = "boddle"; pname = "boddle";
version = "v0.0.1"; version = "v0.0.1";
vendorHash = "sha256-dlQ1+skfEiPVm+IWxfwPsW8jkifo4ufZlfESbf36fFY="; vendorHash = "sha256-XH/u+lcVsLoWDoMPp5/rwWytTpM17mXmoLKJUnJ9BRI=";
src = pkgs.fetchgit { src = pkgs.fetchgit {
url = "https://git.fbs42.ddnss.de/forgejo/fbs42/boddle"; url = "https://git.fbs42.ddnss.de/forgejo/fbs42/boddle";
hash = "sha256-Y9WYhqcoJFTY+DuHj9YIuMryapwb/T+ZGZyCAh0kfY8="; hash = "sha256-6zK+oAGJz1UCo2eZZAlSH6VqMGba9g2hKnzG1kN0gYI=";
}; };
}; };