Unverified Commit 36afa30c authored by github-actions[bot]'s avatar github-actions[bot] Committed by GitHub
Browse files

Merge master into staging-next

parents 81d4b4ce 1ca5dab7
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -516,6 +516,10 @@ checkConfigError 'The option .theOption.nested. in .other.nix. is already declar
# Test that types.optionType leaves types untouched as long as they don't need to be merged
checkConfigOutput 'ok' config.freeformItems.foo.bar ./adhoc-freeformType-survives-type-merge.nix

# Test that specifying both functor.wrapped and functor.payload isn't allowed
checkConfigError 'Type foo defines both `functor.payload` and `functor.wrapped` at the same time, which is not supported.' config.result ./default-type-merge-both.nix


# Anonymous submodules don't get nixed by import resolution/deduplication
# because of an `extendModules` bug, issue 168767.
checkConfigOutput '^1$' config.sub.specialisation.value ./extendModules-168767-imports.nix
+28 −0
Original line number Diff line number Diff line
{ lib, options, ... }:
let
  foo = lib.mkOptionType {
    name = "foo";
    functor = lib.types.defaultFunctor "foo" // {
      wrapped = lib.types.int;
      payload = 10;
    };
  };
in
{
  imports = [
    {
      options.foo = lib.mkOption {
        type = foo;
      };
    }
    {
      options.foo = lib.mkOption {
        type = foo;
      };
    }
  ];

  options.result = lib.mkOption {
    default = builtins.seq options.foo null;
  };
}
+28 −14
Original line number Diff line number Diff line
@@ -83,23 +83,37 @@ rec {
  # Default type merging function
  # takes two type functors and return the merged type
  defaultTypeMerge = f: f':
    let wrapped = f.wrapped.typeMerge f'.wrapped.functor;
        payload = f.binOp f.payload f'.payload;
    let mergedWrapped = f.wrapped.typeMerge f'.wrapped.functor;
        mergedPayload = f.binOp f.payload f'.payload;

        hasPayload = assert (f'.payload != null) == (f.payload != null); f.payload != null;
        hasWrapped = assert (f'.wrapped != null) == (f.wrapped != null); f.wrapped != null;
    in
    # cannot merge different types
    # Abort early: cannot merge different types
    if f.name != f'.name
       then null
    # simple types
    else if    (f.wrapped == null && f'.wrapped == null)
            && (f.payload == null && f'.payload == null)
       then f.type
    # composed types
    else if (f.wrapped != null && f'.wrapped != null) && (wrapped != null)
       then f.type wrapped
    # value types
    else if (f.payload != null && f'.payload != null) && (payload != null)
       then f.type payload
    else null;
    else

    if hasPayload then
      if hasWrapped then
        # Has both wrapped and payload
        throw ''
          Type ${f.name} defines both `functor.payload` and `functor.wrapped` at the same time, which is not supported.

          Use either `functor.payload` or `functor.wrapped` but not both.

          If your code worked before remove `functor.payload` from the type definition.
        ''
      else
        # Has payload
        if mergedPayload == null then null else f.type mergedPayload
    else
      if hasWrapped then
        # Has wrapped
        # TODO(@hsjobeki): This could also be a warning and removed in the future
        if mergedWrapped == null then null else f.type mergedWrapped
      else
        f.type;

  # Default type functor
  defaultFunctor = name: {
+1 −1
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ in
    (mkRemovedOptionModule [ "services" "mailpile" ] "The corresponding package was removed from nixpkgs.")
    (mkRemovedOptionModule [ "services" "marathon" ] "The corresponding package was removed from nixpkgs.")
    (mkRemovedOptionModule [ "services" "mathics" ] "The Mathics module has been removed")
    (mkRemovedOptionModule [ "services" "matrix-sliding-sync" ] "The matrix-sliding-sync package has been removed, since matrix-synapse incorporated its functionality. Simply remove `services.sliding-sync` from your NixOS Configuration, and the `.well-known` record for `org.matrix.msc3575.proxy` from your webserver")
    (mkRemovedOptionModule [ "services" "matrix-sliding-sync" ] "The matrix-sliding-sync package has been removed, since matrix-synapse incorporated its functionality. Remove `services.sliding-sync` from your NixOS Configuration, and the `.well-known` record for `org.matrix.msc3575.proxy` from your webserver")
    (mkRemovedOptionModule [ "services" "meguca" ] "Use meguca has been removed from nixpkgs")
    (mkRemovedOptionModule [ "services" "mesos" ] "The corresponding package was removed from nixpkgs.")
    (mkRemovedOptionModule [ "services" "mxisd" ] "The mxisd module has been removed as both mxisd and ma1sd got removed.")
+8 −2
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
  lib,
  pkgs,
  config,
  utils,
  ...
}:
let
@@ -61,6 +62,7 @@ in

    extraArgs = lib.mkOption {
      type = lib.types.listOf lib.types.singleLineStr;
      default = [ ];
      example = [
        "--slice-us 5000"
        "--verbose"
@@ -90,9 +92,13 @@ in

      serviceConfig = {
        Type = "simple";
        ExecStart = "${lib.getExe' cfg.package cfg.scheduler} ${lib.concatStringsSep " " cfg.extraArgs}";
        ExecStart = utils.escapeSystemdExecArgs (
          [
            (lib.getExe' cfg.package cfg.scheduler)
          ]
          ++ cfg.extraArgs
        );
        Restart = "on-failure";
        StandardError = "journal";
      };

      wantedBy = [ "multi-user.target" ];
Loading