System/machines/oracles/automation.nix

74 lines
2.0 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, inputs, ... }:
let
repo-updater = pkgs.writeShellScriptBin "repo-updater"
(builtins.readFile ../../scripts/gitea/update-repo.sh);
environment = {
XDG_RUNTIME_DIR = "/tmp";
HOME = "/home/nathan";
2023-05-15 08:07:43 -04:00
NIX_PATH =
"nixpkgs=/nix/var/nix/profiles/per-user/root/channels/nixos:nixos-config=/etc/nixos/configuration.nix:/nix/var/nix/profiles/per-user/root/channels";
2023-05-15 08:12:18 -04:00
XDG_CONFIG_DIRS =
"/home/nathan/.nix-profile/etc/xdg:/etc/profiles/per-user/nathan/etc/xdg:/nix/var/nix/profiles/default/etc/xdg:/run/current-system/sw/etc/xdg";
XDG_CONFIG_HOME = "/home/nathan/.config";
};
path = with pkgs; [
git
inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}.nurl
jq
curl
openssh
bash
nix
2023-05-14 19:31:14 -04:00
nix-prefetch
];
in {
# Setup hosts for gitea automation
networking.hosts = { "100.99.69.14" = [ "git.stranger.systems" ]; };
2023-05-14 19:31:14 -04:00
# Automate updating the system flake
systemd.services."system-flake-update" = {
inherit environment;
inherit path;
script = ''
env
${repo-updater}/bin/repo-updater gitea@git.stranger.systems:nix/System.git trunk
'';
serviceConfig = {
Type = "oneshot";
User = "nathan";
Group = "users";
};
};
systemd.timers."system-flake-update" = {
wantedBy = [ "timers.target" ];
partOf = [ "system-flake-update.service" ];
timerConfig = {
OnCalendar = "Mon, 4:00";
Unit = "system-flake-update.service";
};
};
# Automate updating rust utility flake
systemd.services."rust-util-update" = {
inherit environment;
inherit path;
script = ''
env
${repo-updater}/bin/repo-updater gitea@git.stranger.systems:nix/Rust.git trunk
'';
serviceConfig = {
Type = "oneshot";
User = "nathan";
Group = "users";
};
};
systemd.timers."rust-util-update" = {
wantedBy = [ "timers.target" ];
partOf = [ "rust-util-update.service" ];
timerConfig = {
OnCalendar = "Mon, 8:00";
Unit = "rust-util-update.service";
};
};
}