flake: update systemd options
This commit is contained in:
parent
2cd84df2ba
commit
ee21bd5049
1 changed files with 31 additions and 9 deletions
40
flake.nix
40
flake.nix
|
|
@ -2,26 +2,48 @@
|
|||
description = "boddle, in Anlehnung an bottle";
|
||||
|
||||
outputs = { self, nixpkgs }: let
|
||||
module = { pkgs, lib, config, ... }: {
|
||||
module = { pkgs, lib, config, ... }: let
|
||||
cfg = config.services.boddle;
|
||||
in {
|
||||
options.services.boddle = {
|
||||
enable = lib.mkEnableOption "enable";
|
||||
# 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.systemd.services.boddle = lib.mkIf config.services.boddle.enable {
|
||||
confinement.enable = true;
|
||||
unitConfig.ConditionPathExists = [
|
||||
"%S/boddle/boddle.toml"
|
||||
"%S/boddle/boddle.db"
|
||||
];
|
||||
serviceConfig.ExecStart = lib.getExe pkgs.boddle;
|
||||
unitConfig.ConditionPathExists = [ cfg.database ];
|
||||
serviceConfig.ExecStart = let
|
||||
args = lib.lists.foldl (acc: channel: acc ++ [ "--channel" channel ]) [
|
||||
(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.StateDirectory = "boddle";
|
||||
serviceConfig.DynamicUser = true;
|
||||
serviceConfig.BindPaths = [
|
||||
"%S/boddle"
|
||||
"/etc/resolv.conf"
|
||||
"${cfg.database}:%S/boddle/${cfg.nick}.db"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
|
@ -37,10 +59,10 @@
|
|||
};
|
||||
pname = "boddle";
|
||||
version = "v0.0.1";
|
||||
vendorHash = "sha256-dlQ1+skfEiPVm+IWxfwPsW8jkifo4ufZlfESbf36fFY=";
|
||||
vendorHash = "sha256-XH/u+lcVsLoWDoMPp5/rwWytTpM17mXmoLKJUnJ9BRI=";
|
||||
src = pkgs.fetchgit {
|
||||
url = "https://git.fbs42.ddnss.de/forgejo/fbs42/boddle";
|
||||
hash = "sha256-Y9WYhqcoJFTY+DuHj9YIuMryapwb/T+ZGZyCAh0kfY8=";
|
||||
hash = "sha256-6zK+oAGJz1UCo2eZZAlSH6VqMGba9g2hKnzG1kN0gYI=";
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue