summaryrefslogtreecommitdiff
path: root/modules/systemd.nix
blob: 8ea13db369a65368057407ac14683e9d6b7af642 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
{ config, pkgs, ... }: {

  systemd.timers."git-auto-sync" = {
    wantedBy = [ "timers.target" ];
      timerConfig = {
        OnBootSec = "5m";
        OnUnitActiveSec = "5m";
        Unit = "git-auto-sync.service";
      };
  };

  systemd.services."git-auto-sync" = {
    script = "$HOME/scripts/git-auto-sync.sh";
    path = [
      pkgs.git
      pkgs.gh
      pkgs.keychain
      pkgs.openssh
    ];
    serviceConfig = { Type = "oneshot"; User = "kyren"; };
  };

  ###########################################################################

  systemd.timers."k-sleep-tracker" = {
    wantedBy = [ "timers.target" ];
      timerConfig = {
        OnBootSec = "1m";
        OnUnitActiveSec = "1m";
        Unit = "k-sleep-tracker.service";
      };
  };

  systemd.services."k-sleep-tracker" = {
    script = "$HOME/projects/k/bin/k tracker sleep";
    serviceConfig = { Type = "oneshot"; User = "kyren"; };
  };

  ###########################################################################

  systemd.timers."git-auto-mirror" = {
    wantedBy = [ "timers.target" ];
      timerConfig = {
        OnBootSec = "1m";
        OnUnitActiveSec = "5h";
        Unit = "git-auto-mirror.service";
      };
  };

  sops.secrets.gitea-sync-token = { owner = "kyren"; };
  sops.secrets.github-mirror-token = { owner = "kyren"; };
  systemd.services."git-auto-mirror" = {
    script = "python $HOME/scripts/gitea.py";
    path = [
      (pkgs.python312.withPackages (pypkgs: [
        pypkgs.matplotlib
        pypkgs.pandas
        pypkgs.pygithub
      ]))
    ];
    environment = {
      GITEA_TOKEN_FILE = config.sops.secrets.gitea-sync-token.path;
      GITHUB_TOKEN_FILE = config.sops.secrets.github-mirror-token.path;
    };
    serviceConfig = { Type = "oneshot"; User = "kyren"; };
  };

  ###########################################################################

  systemd.mounts = [
    { what =  "/dev/nvme1n1p4"; where = "/mnt/c"; type = "ntfs"; options = "rw,noatime"; wantedBy = ["multi-user.target"]; }
    { what =  "/dev/sda2"; where = "/mnt/e"; type = "ntfs"; options = "rw,noatime"; wantedBy = ["multi-user.target"]; }
  ];

}