mirror of
https://git.selfprivacy.org/SelfPrivacy/selfprivacy-rest-api.git
synced 2024-11-28 06:51:28 +00:00
nixos: split script into ExecStartPre && ExecStart
This commit is contained in:
parent
679137386d
commit
5fe4c405ce
|
@ -4,6 +4,7 @@ let
|
||||||
cfg = config.services.selfprivacy-api;
|
cfg = config.services.selfprivacy-api;
|
||||||
config-id = "default";
|
config-id = "default";
|
||||||
nixos-rebuild = "${config.system.build.nixos-rebuild}/bin/nixos-rebuild";
|
nixos-rebuild = "${config.system.build.nixos-rebuild}/bin/nixos-rebuild";
|
||||||
|
nix = "${config.nix.package.out}/bin/nix";
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.services.selfprivacy-api = {
|
options.services.selfprivacy-api = {
|
||||||
|
@ -98,18 +99,19 @@ in
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
User = "root";
|
User = "root";
|
||||||
WorkingDirectory = "/etc/nixos";
|
WorkingDirectory = "/etc/nixos";
|
||||||
|
# sync top-level flake with sp-modules sub-flake
|
||||||
|
# (https://github.com/NixOS/nix/issues/9339)
|
||||||
|
ExecStartPre = ''
|
||||||
|
${nix} flake lock --override-input sp-modules path:./sp-modules
|
||||||
|
'';
|
||||||
|
ExecStart = ''
|
||||||
|
${nixos-rebuild} switch --flake .#${config-id}
|
||||||
|
'';
|
||||||
KillMode = "none";
|
KillMode = "none";
|
||||||
SendSIGKILL = "no";
|
SendSIGKILL = "no";
|
||||||
};
|
};
|
||||||
restartIfChanged = false;
|
restartIfChanged = false;
|
||||||
unitConfig.X-StopOnRemoval = false;
|
unitConfig.X-StopOnRemoval = false;
|
||||||
script = ''
|
|
||||||
# sync top-level flake with sp-modules sub-flake
|
|
||||||
# (https://github.com/NixOS/nix/issues/9339)
|
|
||||||
nix flake lock --override-input sp-modules path:./sp-modules
|
|
||||||
|
|
||||||
${nixos-rebuild} switch --flake .#${config-id}
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
# One shot systemd service to upgrade NixOS using nixos-rebuild
|
# One shot systemd service to upgrade NixOS using nixos-rebuild
|
||||||
systemd.services.sp-nixos-upgrade = {
|
systemd.services.sp-nixos-upgrade = {
|
||||||
|
@ -124,18 +126,19 @@ in
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
User = "root";
|
User = "root";
|
||||||
WorkingDirectory = "/etc/nixos";
|
WorkingDirectory = "/etc/nixos";
|
||||||
|
# TODO get URL from systemd template parameter?
|
||||||
|
ExecStartPre = ''
|
||||||
|
${nix} flake update \
|
||||||
|
--override-input selfprivacy-nixos-config git+https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-config.git?ref=flakes
|
||||||
|
'';
|
||||||
|
ExecStart = ''
|
||||||
|
${nixos-rebuild} switch --flake .#${config-id}
|
||||||
|
'';
|
||||||
KillMode = "none";
|
KillMode = "none";
|
||||||
SendSIGKILL = "no";
|
SendSIGKILL = "no";
|
||||||
};
|
};
|
||||||
restartIfChanged = false;
|
restartIfChanged = false;
|
||||||
unitConfig.X-StopOnRemoval = false;
|
unitConfig.X-StopOnRemoval = false;
|
||||||
script = ''
|
|
||||||
# TODO get URL from systemd parameter
|
|
||||||
nix flake update \
|
|
||||||
--override-input selfprivacy-nixos-config git+https://git.selfprivacy.org/SelfPrivacy/selfprivacy-nixos-config.git?ref=flakes
|
|
||||||
|
|
||||||
${nixos-rebuild} switch --flake .#${config-id}
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
# One shot systemd service to rollback NixOS using nixos-rebuild
|
# One shot systemd service to rollback NixOS using nixos-rebuild
|
||||||
systemd.services.sp-nixos-rollback = {
|
systemd.services.sp-nixos-rollback = {
|
||||||
|
@ -150,8 +153,9 @@ in
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
User = "root";
|
User = "root";
|
||||||
WorkingDirectory = "/etc/nixos";
|
WorkingDirectory = "/etc/nixos";
|
||||||
ExecStart =
|
ExecStart = ''
|
||||||
"${nixos-rebuild} switch --rollback --flake .#${config-id}";
|
${nixos-rebuild} switch --rollback --flake .#${config-id}
|
||||||
|
'';
|
||||||
KillMode = "none";
|
KillMode = "none";
|
||||||
SendSIGKILL = "no";
|
SendSIGKILL = "no";
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue