move the nixosModule to nixosModules.heliwatch
This commit is contained in:
parent
873f0b639f
commit
dda6953535
60
flake.nix
60
flake.nix
|
@ -54,64 +54,6 @@
|
||||||
nativeBuildInputs ++ buildInputs;
|
nativeBuildInputs ++ buildInputs;
|
||||||
};
|
};
|
||||||
}) // {
|
}) // {
|
||||||
nixosModule = { config, lib, pkgs, ... }: {
|
nixosModules.heliwatch = import ./heliwatch/module.nix;
|
||||||
options.services.heliwatch = with lib; {
|
|
||||||
enable = mkEnableOption "Enable Heliwatch MUC bot";
|
|
||||||
jid = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
};
|
|
||||||
password = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
};
|
|
||||||
muc = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
description = "Full Jabber-Id in the form of room@service/nickname";
|
|
||||||
};
|
|
||||||
user = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "heliwatch";
|
|
||||||
};
|
|
||||||
group = mkOption {
|
|
||||||
type = types.str;
|
|
||||||
default = "heliwatch";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config =
|
|
||||||
let
|
|
||||||
cfg = config.services.heliwatch;
|
|
||||||
in
|
|
||||||
lib.mkIf cfg.enable {
|
|
||||||
users = {
|
|
||||||
users.${cfg.user} = {
|
|
||||||
isSystemUser = true;
|
|
||||||
home = "/home/heliwatch";
|
|
||||||
createHome = true;
|
|
||||||
group = cfg.group;
|
|
||||||
};
|
|
||||||
groups.${cfg.group} = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
systemd.services.heliwatch = {
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
after = [ "network.target" ];
|
|
||||||
path = with pkgs; [ bash curl ];
|
|
||||||
script = ''
|
|
||||||
${./fetch_data.sh}
|
|
||||||
exec ${self.packages.${pkgs.system}.heliwatch}/bin/heliwatch ${lib.escapeShellArgs (with cfg; [ jid password muc ])}
|
|
||||||
'';
|
|
||||||
serviceConfig = {
|
|
||||||
Type = "simple";
|
|
||||||
User = cfg.user;
|
|
||||||
Group = cfg.group;
|
|
||||||
WorkingDirectory = config.users.users.${cfg.user}.home;
|
|
||||||
ReadWritePaths = config.users.users.${cfg.user}.home;
|
|
||||||
ProtectSystem = "full";
|
|
||||||
Restart = "always";
|
|
||||||
RestartSec = "60s";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
59
heliwatch/module.nix
Normal file
59
heliwatch/module.nix
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
{ config, lib, pkgs, ... }: {
|
||||||
|
options.services.heliwatch = with lib; {
|
||||||
|
enable = mkEnableOption "Enable Heliwatch MUC bot";
|
||||||
|
jid = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
};
|
||||||
|
password = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
};
|
||||||
|
muc = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
description = "Full Jabber-Id in the form of room@service/nickname";
|
||||||
|
};
|
||||||
|
user = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "heliwatch";
|
||||||
|
};
|
||||||
|
group = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "heliwatch";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config =
|
||||||
|
let
|
||||||
|
cfg = config.services.heliwatch;
|
||||||
|
in
|
||||||
|
lib.mkIf cfg.enable {
|
||||||
|
users = {
|
||||||
|
users.${cfg.user} = {
|
||||||
|
isSystemUser = true;
|
||||||
|
home = "/home/heliwatch";
|
||||||
|
createHome = true;
|
||||||
|
group = cfg.group;
|
||||||
|
};
|
||||||
|
groups.${cfg.group} = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.services.heliwatch = {
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
after = [ "network.target" ];
|
||||||
|
path = with pkgs; [ bash curl ];
|
||||||
|
script = ''
|
||||||
|
${./fetch_data.sh}
|
||||||
|
exec ${self.packages.${pkgs.system}.heliwatch}/bin/heliwatch ${lib.escapeShellArgs (with cfg; [ jid password muc ])}
|
||||||
|
'';
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "simple";
|
||||||
|
User = cfg.user;
|
||||||
|
Group = cfg.group;
|
||||||
|
WorkingDirectory = config.users.users.${cfg.user}.home;
|
||||||
|
ReadWritePaths = config.users.users.${cfg.user}.home;
|
||||||
|
ProtectSystem = "full";
|
||||||
|
Restart = "always";
|
||||||
|
RestartSec = "60s";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user