Add nixos module
This commit is contained in:
parent
ad96876c9e
commit
7de78344d7
41
flake.nix
41
flake.nix
|
@ -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;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue