Unverified Commit 6b66e2fc authored by Vladimír Čunát's avatar Vladimír Čunát
Browse files

nixos/knot: compatibility with 23.05 config

- run conf-check iff keyFiles == [] (like in 23.05; this was my bug)
- support extraConfig + keyFiles

- but warning will still be shown if extraConfig is used,
  and it might be slightly confusing
parent 860c01bd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -109,7 +109,7 @@

- `pass` now does not contain `password-store.el`.  Users should get `password-store.el` from Emacs lisp package set `emacs.pkgs.password-store`.

- `services.knot` now supports `.settings` from RFC42.  The change is not 100% compatible with the previous `.extraConfig`.
- `services.knot` now supports `.settings` from RFC42.  The previous `.extraConfig` still works the same, but it displays a warning now.

- `mu` now does not install `mu4e` files by default.  Users should get `mu4e` from Emacs lisp package set `emacs.pkgs.mu4e`.

+10 −6
Original line number Diff line number Diff line
@@ -103,11 +103,15 @@ let
  in result;

  configFile = if cfg.settingsFile != null then
    assert cfg.settings == {} && cfg.keyFiles == [];
    # Note: with extraConfig, the 23.05 compat code did include keyFiles from settingsFile.
    assert cfg.settings == {} && (cfg.keyFiles == [] || cfg.extraConfig != null);
    cfg.settingsFile
  else pkgs.writeTextFile {
  else
    mkConfigFile yamlConfig;

  mkConfigFile = configString: pkgs.writeTextFile {
    name = "knot.conf";
    text = (concatMapStringsSep "\n" (file: "include: ${file}") cfg.keyFiles) + "\n" + yamlConfig;
    text = (concatMapStringsSep "\n" (file: "include: ${file}") cfg.keyFiles) + "\n" + configString;
    # TODO: maybe we could do some checks even when private keys complicate this?
    checkPhase = lib.optionalString (cfg.keyFiles == []) ''
      ${cfg.package}/bin/knotc --config=$out conf-check
@@ -174,7 +178,7 @@ in {
        description = lib.mdDoc ''
          As alternative to ``settings``, you can provide whole configuration
          directly in the almost-YAML format of Knot DNS.
          You might want to utilize ``writeTextFile`` for this.
          You might want to utilize ``pkgs.writeText "knot.conf" "longConfigString"`` for this.
        '';
      };

@@ -189,9 +193,9 @@ in {
    };
  };
  imports = [
    # Compatibility with NixOS 23.05.  At least partial, as it fails assert if used with keyFiles.
    # Compatibility with NixOS 23.05.
    (mkChangedOptionModule [ "services" "knot" "extraConfig" ] [ "services" "knot" "settingsFile" ]
      (config: pkgs.writeText "knot.conf" config.services.knot.extraConfig)
      (config: mkConfigFile config.services.knot.extraConfig)
    )
  ];