Browse Source

Add NixNG module

Signed-off-by: Magic_RB <magic_rb@redalder.org>
master
Magic_RB 4 months ago
parent
commit
29b1c5f140
Signed by: Magic_RB GPG Key ID: 08D5287CC5DDCA0E
  1. 6
      flake.nix
  2. 63
      module.nix

6
flake.nix

@ -33,6 +33,12 @@
}
);
nixngModules = {
camptules = ./module.nix;
};
nixngModule = self.nixngModules.camptules;
hydraJobs.camptules = self.defaultPackage;
};
}

63
module.nix

@ -0,0 +1,63 @@
{ pkgs, config, lib, ... }:
with lib;
let
cfg = config.services.camptules;
in
{
options.services.camptules = {
enable = mkEnableOption "Enable camptules Discord bot.";
package = mkOption {
description = ''
camptules package to use.
'';
type = types.package;
default = pkgs.camptules;
};
user = mkOption {
description = "User to run camptules under.";
default = "camptules";
type = types.str;
};
group = mkOption {
description = "Group to run camptules under.";
default = "camptules";
type = types.str;
};
};
config = mkIf cfg.enable {
ids.uids.camptules = 401;
ids.gids.camptules = 401;
users.users.${cfg.user} = mapAttrs (_: mkDefault) {
description = "camptules";
group = cfg.group;
home = "/var/empty";
useDefaultShell = true;
createHome = false;
uid = config.ids.uids.camptules;
};
users.groups.${cfg.group} = {
gid = mkDefault config.ids.gids.camptules;
};
init.services.camptules =
{
script = pkgs.writeShellScript "camptules-run"
''
mkdir -p /run/cfg/jmusicbot
cd /run/cfg/camptules
echo "$BOT_TOKEN" > /run/cfg/camptules/cfg
chpst -u ${cfg.user}:${cfg.group}
${cfg.package}/bin/camptules
'';
enabled = true;
};
};
}
Loading…
Cancel
Save