powered by Yesod Newsfeed
Tough times don't last, tough people do.
Pascal Wittmann

Auto-upgrade with NixOS and NixOps

Since the end of last year NixOS has an auto-upgrade feature. Some weeks ago I decided to move my server from an unstable version of NixOS to the latest stable version. That made it easier for me to activate the auto-upgrade feature. However the first time the auto-upgrade was triggered it failed, since I deploy my server with NixOps and therefore there the file /etc/nixos/configuration.nix does not exist.

Until I have a real fix for this problem I decided to live with the workaround of copying the configuration with NixOps to the server and to create a custom configuration.nix that wraps around the NixOps configuration of the server. This resulted in the following code in my server configuration:

system.autoUpgrade.enable = true;
system.autoUpgrade.channel = https://nixos.org/channels/nixos-16.03;
systemd.services.nixos-upgrade.environment.NIXOS_CONFIG = pkgs.writeText "configuration.nix" ''
  all@{ lib, ... }: lib.filterAttrs (n: v: n != "deployment")
    ((import /etc/nixos/current/default.nix).server all)

system.activationScripts = {
  configuration = ''
    rm /etc/nixos/current/* #*/
    ln -s ${./.}/* /etc/nixos/current #*/

Here is the full configuration.


Kommentare für diesen Eintrag als RSS Feed
am 8.11.2018 schrieb Anonymous Antworten

Thanks for this! It's just what I needed!


Leave a Reply

netcup Ökostrom