use system configured nix and nixos-rebuild
This commit is contained in:
parent
40c48532b6
commit
16ba56e9dc
3 changed files with 39 additions and 31 deletions
|
|
@ -129,36 +129,43 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
"update-flake" = {
|
"update-flake" =
|
||||||
path = with pkgs; [
|
let
|
||||||
git
|
script = pkgs.writeShellApplication {
|
||||||
openssh
|
name = "update-flake-script";
|
||||||
nix
|
runtimeInputs = with pkgs; [
|
||||||
nixos-rebuild
|
git
|
||||||
];
|
openssh
|
||||||
script = ''
|
config.nix.package
|
||||||
[[ ! -d '/root/nixconf' ]] && git clone git@github.com:itepastra/nixconf /root/nixconf
|
config.system.build.nixos-rebuild
|
||||||
cd /root/nixconf
|
];
|
||||||
git fetch
|
text = ''
|
||||||
git reset --hard origin/main
|
[[ ! -d '/root/nixconf' ]] && git clone git@github.com:itepastra/nixconf /root/nixconf
|
||||||
git pull
|
cd /root/nixconf
|
||||||
nix flake update --commit-lock-file
|
git fetch
|
||||||
nixos-rebuild boot -L --flake .
|
git reset --hard origin/main
|
||||||
git push
|
git pull
|
||||||
'';
|
nix flake update --commit-lock-file
|
||||||
serviceConfig = {
|
nixos-rebuild boot -L --flake .
|
||||||
Type = "oneshot";
|
git push
|
||||||
User = "root";
|
'';
|
||||||
RemainAfterExit = true;
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
User = "root";
|
||||||
|
ExecStart = "${script}/bin/update-flake-script";
|
||||||
|
RemainAfterExit = true;
|
||||||
|
};
|
||||||
|
wants = [
|
||||||
|
"network-online.target"
|
||||||
|
];
|
||||||
|
after = [
|
||||||
|
"network-online.target"
|
||||||
|
];
|
||||||
|
restartIfChanged = false;
|
||||||
};
|
};
|
||||||
wants = [
|
|
||||||
"network-online.target"
|
|
||||||
];
|
|
||||||
after = [
|
|
||||||
"network-online.target"
|
|
||||||
];
|
|
||||||
restartIfChanged = false;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
user.services.polkit-gnome-authentication-agent-1 = {
|
user.services.polkit-gnome-authentication-agent-1 = {
|
||||||
description = "polkit-gnome-authentication-agent-1";
|
description = "polkit-gnome-authentication-agent-1";
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
# and in the NixOS manual (accessible by running ‘nixos-help’).
|
# and in the NixOS manual (accessible by running ‘nixos-help’).
|
||||||
|
|
||||||
{
|
{
|
||||||
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
|
@ -75,7 +76,7 @@
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "exec";
|
Type = "exec";
|
||||||
User = "root";
|
User = "root";
|
||||||
ExecStart = "${pkgs.nixos-rebuild-ng}/bin/nixos-rebuild switch --flake github:itepastra/nixconf";
|
ExecStart = "${config.system.build.nixos-rebuild}/bin/nixos-rebuild switch --flake github:itepastra/nixconf";
|
||||||
};
|
};
|
||||||
wants = [
|
wants = [
|
||||||
"network-online.target"
|
"network-online.target"
|
||||||
|
|
|
||||||
|
|
@ -122,7 +122,7 @@ in
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "exec";
|
Type = "exec";
|
||||||
User = "root";
|
User = "root";
|
||||||
ExecStart = "${pkgs.nixos-rebuild-ng}/bin/nixos-rebuild boot --flake github:itepastra/nixconf";
|
ExecStart = "${config.system.build.nixos-rebuild}/bin/nixos-rebuild switch --flake github:itepastra/nixconf";
|
||||||
ExecStopPost = ''shutdown -r +5 "Preparing update finished, rebooting..."'';
|
ExecStopPost = ''shutdown -r +5 "Preparing update finished, rebooting..."'';
|
||||||
};
|
};
|
||||||
wants = [
|
wants = [
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue