Skip to content

feat(flake): auto flake update #300

Open

Description

@airone01

This is already partly done with the GitHub Actions script for updating flake inputs, but right now the results of the CI are not saved to any cache because my Cachix cache is full.

So if I implement #299, I could be setting it for Cetus, ask it to upload there, and just automatically download the new system from main using something like the following:

system.autoUpgrade = {
  enable = true;
  dates = "daily";

  flake = "github:airone01/flake#hostname";

  flags = [
    "--option" "substituters" "https://nixcache.air1.one"
    "--option" "trusted-public-keys" "CACHE PUB KEY HERE"
  ];
};

...or a custom systemd service if autoUpgrade is too limited:

systemd.services.auto-deploy = {
  description = "Auto deploy NixOS config from flake";
  serviceConfig = {
    Type = "oneshot";
    ExecStart = ''
      ${pkgs.git}/bin/git -C /etc/nixos pull
      ${pkgs.nixos-rebuild}/bin/nixos-rebuild switch --flake /etc/nixos#hostname
    '';
  };
  # custom user for this service here, also sec settings to limit damage
};
systemd.timers.auto-deploy = {
  wantedBy = [ "timers.target" ];
  timerConfig = {
    OnCalendar = "hourly";
    Persistent = true;
  };
};

Alternatives to explore:

  • deploy-rs/colmena: could be useful but more for the servers Cetus and Hercules than the PCs Lyra and Cassiopeia, because their awake time is determined by when I use them? This can somewhat be changed for Lyra but not Cassiopeia, it's a laptop.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions