]> Git — Sourcephile - julm/julm-nix.git/blob - nixos/profiles/nixos-fallback.nix
nix: add nixpkgs.root
[julm/julm-nix.git] / nixos / profiles / nixos-fallback.nix
1 { config, pkgs, lib, ... }:
2 {
3 systemd.services."nixos-fallback" = {
4 after = [ "sshd.service" ];
5 #wantedBy = [ "multi-user.target" ];
6 serviceConfig = {
7 ExecStart = pkgs.writeShellScript "nixos-fallback-start" ''
8 set -ux
9 # Note that even if switch-to-configuration test
10 # restarts nixos-fallback.service,
11 # it does not change the system profile.
12 profile=/nix/var/nix/profiles/system
13 fallback=$(readlink -e /root/nixos-fallback || readlink -e $profile)
14 sleep $((10 * 60))
15 nix-env --profile $profile --set $fallback
16 $fallback/bin/switch-to-configuration switch
17 #systemctl reboot
18 '';
19 };
20 };
21 }