Add nixos module

This commit is contained in:
Sam W 2023-05-11 17:46:13 +01:00
parent ad96876c9e
commit 7de78344d7
1 changed files with 40 additions and 1 deletions

View File

@ -49,5 +49,44 @@
};
formatter = pkgs.alejandra;
hydraJobs.build = packages.default;
});
})
// {
overlays.default = final: prev: {
rolebot = self.packages.${prev.system}.default;
};
nixosModules.default = {
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.services.rolebot;
in {
options.services.rolebot = {
enable = mkEnableOption "Enable the rolebot service";
environmentFile = mkOption {
type = types.path;
description = "Path to the environment file";
};
};
config = mkIf cfg.enable {
nixpkgs.overlays = [self.overlays.default];
systemd.services.rolebot = {
description = "Discord role bot";
wantedBy = ["multi-user.target"];
after = ["network-online.target"];
wants = ["network-online.target"];
serviceConfig = {
User = "rolebot";
ExecStart = "${pkgs.rolebot}/bin/rolebot";
Restart = "on-failure";
DynamicUser = true;
EnvironmentFile = cfg.environmentFile;
};
};
};
};
};
}