diff options
author | Carl Richard Theodor Schneider <dev.github@crtified.me> | 2024-04-30 22:47:52 +0200 |
---|---|---|
committer | Carl Richard Theodor Schneider <dev.github@crtified.me> | 2024-05-03 20:15:02 +0200 |
commit | 3e86aba9d2dca5cbfa5f9f16e8942d5c0f2781e1 (patch) | |
tree | 8e358241cd81418ad9d98b7362e9446315d6893e | |
parent | c4b3e961671c8dcc66a87f0a62d82eeff789fa0d (diff) |
nixos/adguardhome: run --check-config before merging
To prevent merging configurations on different `schema_version`, we will now check the existing configuration, which has the side-effect of updating the `schema_version`. Fixes #246461 as described in https://github.com/NixOS/nixpkgs/issues/246461#issuecomment-1667663556
-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 df9927351edc3..06900166ef2c9 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"; |