mirror of
https://codeberg.org/jopejoe1/nix-conf.git
synced 2025-06-07 21:39:23 +02:00
move nixos modules to nixos-modules
This commit is contained in:
parent
7394c5f317
commit
611796f02e
29 changed files with 225 additions and 7 deletions
52
nixos-modules/repo-sync/default.nix
Normal file
52
nixos-modules/repo-sync/default.nix
Normal file
|
@ -0,0 +1,52 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
cfg = config.jopejoe1.repo-sync;
|
||||
in
|
||||
{
|
||||
options.jopejoe1.repo-sync = {
|
||||
enable = lib.mkEnableOption "Enable Repo Sync";
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
systemd.timers."repo-sync" = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnBootSec = "5m";
|
||||
OnUnitActiveSec = "15m";
|
||||
Unit = "repo-sync.service";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services."repo-sync" = {
|
||||
script = ''
|
||||
git clone git@codeberg.org:jopejoe1/nix-conf.git /var/lib/repo-sync
|
||||
git -C /var/lib/repo-sync remote add github git@github.com:jopejoe1/nix-conf.git
|
||||
git -C /var/lib/repo-sync remote add gitlab git@gitlab.com:jopejoe1/nix-conf.git
|
||||
git -C /var/lib/repo-sync pull -r github main
|
||||
git -C /var/lib/repo-sync pull -r gitlab main
|
||||
nix flake update /var/lib/repo-sync
|
||||
git -C /var/lib/repo-sync commit -m "flack.lock updated on `$(date)`"
|
||||
git -C /var/lib/repo-sync push origin
|
||||
git -C /var/lib/repo-sync push github
|
||||
git -C /var/lib/repo-sync push gitlab
|
||||
rm -r /var/lib/repo-sync
|
||||
'';
|
||||
path = [
|
||||
pkgs.openssh
|
||||
pkgs.git
|
||||
pkgs.coreutils
|
||||
pkgs.nix
|
||||
];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
User = "root";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue