Unverified Commit 0e837c2c authored by Florian Klink's avatar Florian Klink Committed by GitHub
Browse files

Merge pull request #311893 from flokli/garage-optionremove-with-working-tests

nixos/garage: reapply #309643, add assertion, fix tests
parents d25663ce ea6604c0
Loading
Loading
Loading
Loading
+38 −7
Original line number Diff line number Diff line
@@ -52,13 +52,6 @@ in
            type = types.path;
            description = "The main data storage, put this on your large storage (e.g. high capacity HDD)";
          };

          replication_mode = mkOption {
            default = "none";
            type = types.enum ([ "none" "1" "2" "3" "2-dangerous" "3-dangerous" "3-degraded" 1 2 3 ]);
            apply = v: toString v;
            description = "Garage replication mode, defaults to none, see: <https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/#replication-mode> for reference.";
          };
        };
      };
      description = "Garage configuration, see <https://garagehq.deuxfleurs.fr/documentation/reference-manual/configuration/> for reference.";
@@ -71,6 +64,44 @@ in
  };

  config = mkIf cfg.enable {

    assertions = [
      # We removed our module-level default for replication_mode. If a user upgraded
      # to garage 1.0.0 while relying on the module-level default, they would be left
      # with a config which evaluates and builds, but then garage refuses to start
      # because either replication_factor or replication_mode is required.
      # The replication_factor option also was `toString`'ed before, which is
      # now not possible anymore, so we prompt the user to change it to a string
      # if present.
      # These assertions can be removed in NixOS 24.11, when all users have been
      # warned once.
      {
        assertion = (cfg.settings ? replication_factor || cfg.settings ? replication_mode) || lib.versionOlder cfg.package "1.0.0";
        message = ''
          Garage 1.0.0 requires an explicit replication factor to be set.
          Please set replication_factor to 1 explicitly to preserve the previous behavior.
          https://git.deuxfleurs.fr/Deuxfleurs/garage/src/tag/v1.0.0/doc/book/reference-manual/configuration.md#replication_factor

        '';
      }
      {
        assertion = lib.isString (cfg.settings.replication_mode or "");
        message = ''
          The explicit `replication_mode` option in `services.garage.settings`
          has been removed and is now handled by the freeform settings in order
          to allow it being completely absent (for Garage 1.x).
          That module option previously `toString`'ed the value it's configured
          with, which is now no longer possible.

          You're still using a non-string here, please manually set it to
          a string, or migrate to the separate setting keys introduced in 1.x.

          Refer to https://garagehq.deuxfleurs.fr/documentation/working-documents/migration-1/
          for the migration guide.
        '';
      }
    ];

    environment.etc."garage.toml" = {
      source = configFile;
    };
+4 −4
Original line number Diff line number Diff line
@@ -7,10 +7,10 @@ args@{ mkNode, ver, ... }:
  };

  nodes = {
    node1 = mkNode { replicationMode = 3; publicV6Address = "fc00:1::1"; };
    node2 = mkNode { replicationMode = 3; publicV6Address = "fc00:1::2"; };
    node3 = mkNode { replicationMode = 3; publicV6Address = "fc00:1::3"; };
    node4 = mkNode { replicationMode = 3; publicV6Address = "fc00:1::4"; };
    node1 = mkNode { replicationMode = "3"; publicV6Address = "fc00:1::1"; };
    node2 = mkNode { replicationMode = "3"; publicV6Address = "fc00:1::2"; };
    node3 = mkNode { replicationMode = "3"; publicV6Address = "fc00:1::3"; };
    node4 = mkNode { replicationMode = "3"; publicV6Address = "fc00:1::4"; };
  };

  testScript = ''