flake: Add nixos module

This commit is contained in:
Sam W 2023-06-16 16:49:32 +01:00
parent cff99c2788
commit e6c2eb76e9
1 changed files with 41 additions and 1 deletions

View File

@ -52,5 +52,45 @@
packages = with pkgs; [rust rust-analyzer];
};
formatter = pkgs.alejandra;
});
}) // {
overlays.default = final: prev: {
iso7010-a-day = self.packages.${prev.system}.default;
};
nixosModules.default = {
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.services.iso7010-a-day;
in {
options.services.iso7010-a-day = {
enable = mkEnableOption "Enable the iso7010 bot";
environmentFile = mkOption {
type = types.path;
description = "Path to the environment file";
};
};
config = mkIf cfg.enable {
nixpkgs.overlays = [self.overlays.default];
systemd.services.iso7010-a-day = {
description = "Samw's ISO7010 bot";
serviceConfig = {
Type = "oneshot";
DynamicUser = true;
User = "iso7010";
ExecStart = "${pkgs.iso7010-a-day}/bin/iso7010_a_day run-bot";
EnvironmentFile = cfg.environmentFile;
};
};
systemd.timers.iso7010-a-day = {
wantedBy = [ "timers.target" ];
partOf = [ "iso7010-a-day.service" ];
timerConfig.OnCalendar = [ "*-*-* 12:00:00" ];
};
};
};
};
}