2021-10-24 13:36:13 +01:00
|
|
|
{
|
2022-09-01 14:07:57 +01:00
|
|
|
description = "ISO7010 Twitter bot";
|
2021-10-24 13:36:13 +01:00
|
|
|
|
|
|
|
inputs = {
|
2021-11-17 22:55:49 +00:00
|
|
|
utils.url = "github:numtide/flake-utils";
|
2023-07-15 15:14:30 +01:00
|
|
|
devshell = {
|
|
|
|
url = "github:numtide/devshell";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
naersk = {
|
|
|
|
url = "github:nix-community/naersk";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
rust-overlay = {
|
|
|
|
url = "github:oxalica/rust-overlay";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2021-10-24 13:36:13 +01:00
|
|
|
};
|
|
|
|
|
2022-09-01 14:07:57 +01:00
|
|
|
outputs = {
|
|
|
|
self,
|
|
|
|
nixpkgs,
|
|
|
|
utils,
|
|
|
|
naersk,
|
|
|
|
devshell,
|
|
|
|
rust-overlay,
|
|
|
|
}:
|
2021-11-17 22:55:49 +00:00
|
|
|
utils.lib.eachDefaultSystem (system: let
|
2022-09-01 14:07:57 +01:00
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
overlays = [(import rust-overlay)];
|
|
|
|
};
|
2023-06-16 16:12:47 +01:00
|
|
|
rust = pkgs.rust-bin.stable.latest.default.override {
|
|
|
|
extensions = [ "rust-src" ];
|
|
|
|
};
|
2022-09-01 14:07:57 +01:00
|
|
|
# Override naersk to use our chosen rust version from rust-overlay
|
|
|
|
naersk-lib = naersk.lib.${system}.override {
|
|
|
|
cargo = rust;
|
|
|
|
rustc = rust;
|
|
|
|
};
|
2023-06-16 16:12:47 +01:00
|
|
|
packig = naersk-lib.buildPackage {
|
2022-09-01 14:07:57 +01:00
|
|
|
pname = "iso7010-a-day";
|
2021-11-17 22:55:49 +00:00
|
|
|
root = ./.;
|
2024-03-30 21:45:27 +00:00
|
|
|
buildInputs = [pkgs.openssl pkgs.pkg-config];
|
2021-10-24 13:36:13 +01:00
|
|
|
};
|
2023-06-16 16:12:47 +01:00
|
|
|
in {
|
|
|
|
packages.default = packig;
|
2022-09-01 14:07:57 +01:00
|
|
|
|
2023-06-16 16:12:47 +01:00
|
|
|
apps.default = utils.lib.mkApp {drv = packig;};
|
2022-09-01 14:07:57 +01:00
|
|
|
|
2023-06-16 16:12:47 +01:00
|
|
|
hydraJobs.build = packig;
|
2022-09-01 14:07:57 +01:00
|
|
|
|
|
|
|
# Provide a dev env with rust and rls
|
|
|
|
devShells.default = let
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
2023-06-16 16:12:47 +01:00
|
|
|
overlays = [devshell.overlays.default];
|
2022-09-01 14:07:57 +01:00
|
|
|
};
|
|
|
|
in
|
|
|
|
pkgs.devshell.mkShell {
|
2022-09-13 16:44:00 +01:00
|
|
|
packages = with pkgs; [rust rust-analyzer];
|
2022-09-01 14:07:57 +01:00
|
|
|
};
|
|
|
|
formatter = pkgs.alejandra;
|
2023-06-16 16:49:32 +01:00
|
|
|
}) // {
|
|
|
|
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" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2021-11-17 22:55:49 +00:00
|
|
|
}
|