Initial commit
This commit is contained in:
commit
c826b8a819
15 changed files with 4417 additions and 0 deletions
63
nix/module.nix
Normal file
63
nix/module.nix
Normal file
|
@ -0,0 +1,63 @@
|
|||
{ makise-next, }:
|
||||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
types = lib.types;
|
||||
cfg = config.services.makise-next;
|
||||
toml = pkgs.formats.toml {};
|
||||
configs = let generated = (if cfg.config != null then [(toml.generate "config.toml" cfg.config)] else []);
|
||||
all = generated ++ cfg.configFiles;
|
||||
in builtins.map (x: "--config ${x}") all;
|
||||
configParameters = lib.strings.concatStringsSep " " configs;
|
||||
in
|
||||
{
|
||||
options.services.viendesu-maid = {
|
||||
autoStart = lib.mkOption {
|
||||
description = "start Maid with the system";
|
||||
type = types.bool;
|
||||
default = false;
|
||||
};
|
||||
user = lib.mkOption {
|
||||
description = "user under which Maid will run";
|
||||
type = types.str;
|
||||
};
|
||||
enable = lib.mkEnableOption "viendesu-maid";
|
||||
config = lib.mkOption {
|
||||
description = "configuration for the Maid";
|
||||
type = types.nullOr types.attrs;
|
||||
default = null;
|
||||
};
|
||||
configFiles = lib.mkOption {
|
||||
description = "list of configuration files for Maid";
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
};
|
||||
|
||||
environment = lib.mkOption {
|
||||
description = "list of environment variables";
|
||||
type = types.attrs;
|
||||
default = {};
|
||||
};
|
||||
environmentFiles = lib.mkOption {
|
||||
description = "environment variables files";
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
systemd.services.viendesu-maid = lib.mkIf cfg.enable {
|
||||
wantedBy = lib.mkIf cfg.autoStart [ "multi-user.target" ];
|
||||
after = [ "network.target" ];
|
||||
description = "VienDesu! Maid bot";
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
User = cfg.user;
|
||||
ExecStart = "${makise-next} ${configParameters}";
|
||||
EnvironmentFile = cfg.environmentFiles;
|
||||
Environment = builtins.map ({ name, value }: "${name}=${value}")
|
||||
(lib.attrsets.attrsToList cfg.environment);
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue