diff options
author | Weijia Wang <9713184+wegank@users.noreply.github.com> | 2024-06-10 12:46:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-10 12:46:26 +0200 |
commit | 9520d06979abe8aec8a547bc2e59f110b14959b4 (patch) | |
tree | 60c992741cb866c5c91658deaf5e41be75bfe32f | |
parent | 4c736c40be07dfbb2529a413b638234ef462e14f (diff) | |
parent | 3e86aba9d2dca5cbfa5f9f16e8942d5c0f2781e1 (diff) |
Merge pull request #266450 from CRTified/adguardhome-fix-246461
nixos/adguardhome: run --check-config before merging
-rw-r--r-- | nixos/modules/services/networking/adguardhome.nix | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/nixos/modules/services/networking/adguardhome.nix b/nixos/modules/services/networking/adguardhome.nix index 32a0abaaf8b83..5be3e0bea224a 100644 --- a/nixos/modules/services/networking/adguardhome.nix +++ b/nixos/modules/services/networking/adguardhome.nix @@ -167,8 +167,13 @@ in { preStart = optionalString (settings != null) '' if [ -e "$STATE_DIRECTORY/AdGuardHome.yaml" ] \ && [ "${toString cfg.mutableSettings}" = "1" ]; then + # First run a schema_version update on the existing configuration + # This ensures that both the new config and the existing one have the same schema_version + # Note: --check-config has the side effect of modifying the file at rest! + ${lib.getExe cfg.package} -c "$STATE_DIRECTORY/AdGuardHome.yaml" --check-config + # Writing directly to AdGuardHome.yaml results in empty file - ${pkgs.yaml-merge}/bin/yaml-merge "$STATE_DIRECTORY/AdGuardHome.yaml" "${configFile}" > "$STATE_DIRECTORY/AdGuardHome.yaml.tmp" + ${lib.getExe pkgs.yaml-merge} "$STATE_DIRECTORY/AdGuardHome.yaml" "${configFile}" > "$STATE_DIRECTORY/AdGuardHome.yaml.tmp" mv "$STATE_DIRECTORY/AdGuardHome.yaml.tmp" "$STATE_DIRECTORY/AdGuardHome.yaml" else cp --force "${configFile}" "$STATE_DIRECTORY/AdGuardHome.yaml" @@ -178,7 +183,7 @@ in { serviceConfig = { DynamicUser = true; - ExecStart = "${cfg.package}/bin/adguardhome ${args}"; + ExecStart = "${lib.getExe cfg.package} ${args}"; AmbientCapabilities = [ "CAP_NET_BIND_SERVICE" ] ++ optionals cfg.allowDHCP [ "CAP_NET_RAW" ]; Restart = "always"; |