NixOS system configurations + dotfiles via home-manager
1{
2 local.desktops.grancel =
3 { config, pkgs, ... }:
4 {
5 hjem.extraModules = [
6 {
7 systemd.services.update-flake.path = [
8 config.nix.package
9 pkgs.jujutsu
10 pkgs.git
11 pkgs.openssh
12 ];
13 systemd.services.update-flake = {
14 environment.SSH_AUTH_SOCK = "%t/ssh-agent";
15 serviceConfig.Type = "oneshot";
16 serviceConfig.ExecStart = pkgs.writers.writeFish "update-flake" ''
17 test -d /etc/nixos; or exit 0
18 cd /etc/nixos
19 jj root; or exit 0
20
21 jj new --quiet
22 set restore (jj log --no-graph -r @- -T 'change_id.shortest(8)')
23 echo Will restore $restore
24
25 set remote github
26 echo Fetching remote $remote
27 jj git fetch --remote $remote
28 jj new main@$remote
29
30 echo Starting flake update
31 git config set --local user.name 'Peter Rice (automated)'
32 git config set --local user.email noreply@pvsr.dev
33 nix flake update --commit-lock-file
34 git config unset --local user.name
35 git config unset --local user.email
36
37 set bookmark flake-update
38 jj bookmark set -B -r "@- ~ main@$remote" $bookmark
39 and jj git push --remote $remote --bookmark $bookmark
40
41 jj edit $restore
42 '';
43 };
44 systemd.timers.update-flake = {
45 timerConfig = {
46 OnCalendar = "Fri *-*-* 07:00";
47 Persistent = true;
48 };
49 wantedBy = [ "timers.target" ];
50 };
51 }
52 ];
53 };
54}