diff --git a/modules/lib/types-dag.nix b/modules/lib/types-dag.nix index 46694f2ae..5fdd58228 100644 --- a/modules/lib/types-dag.nix +++ b/modules/lib/types-dag.nix @@ -57,57 +57,4 @@ in rec { functor = (defaultFunctor name) // { wrapped = elemType; }; nestedTypes.elemType = elemType; }; - - # A directed acyclic graph of some inner type OR a list of that - # inner type. This is a temporary hack for use by the - # `programs.ssh.matchBlocks` and is only guaranteed to be vaguely - # correct! - # - # In particular, adding a dependency on one of the "unnamed-N-M" - # entries generated by a list value is almost guaranteed to destroy - # the list's order. - # - # This function will be removed in version 20.09. - listOrDagOf = elemType: - let - paddedIndexStr = list: i: - let padWidth = stringLength (toString (length list)); - in fixedWidthNumber padWidth i; - - convertAll = loc: defs: - let - convertListValue = namePrefix: def: - let - vs = def.value; - pad = paddedIndexStr vs; - makeEntry = i: v: nameValuePair "${namePrefix}.${pad i}" v; - warning = '' - In file ${def.file} - a list is being assigned to the option '${ - concatStringsSep "." loc - }'. - This will soon be an error due to the list form being deprecated. - Please use the attribute set form instead with DAG functions to - express the desired order of entries. - ''; - in warn warning (listToAttrs (imap1 makeEntry vs)); - - convertValue = i: def: - if isList def.value then - convertListValue "unnamed-${paddedIndexStr defs i}" def - else - def.value; - in imap1 (i: def: def // { value = convertValue i def; }) defs; - - dagType = dagOf elemType; - in mkOptionType rec { - name = "listOrDagOf"; - description = "list or DAG of ${elemType.description}s"; - check = x: isList x || dagType.check x; - merge = loc: defs: dagType.merge loc (convertAll loc defs); - getSubOptions = dagType.getSubOptions; - getSubModules = dagType.getSubModules; - substSubModules = m: listOrDagOf (elemType.substSubModules m); - functor = (defaultFunctor name) // { wrapped = elemType; }; - }; } diff --git a/modules/lib/types.nix b/modules/lib/types.nix index 0195bbfc8..671f3d7ea 100644 --- a/modules/lib/types.nix +++ b/modules/lib/types.nix @@ -14,7 +14,7 @@ let in rec { - inherit (typesDag) dagOf listOrDagOf; + inherit (typesDag) dagOf; selectorFunction = mkOptionType { name = "selectorFunction"; diff --git a/modules/programs/ssh.nix b/modules/programs/ssh.nix index 0d616bdfd..2e29a03d5 100644 --- a/modules/programs/ssh.nix +++ b/modules/programs/ssh.nix @@ -482,7 +482,7 @@ in }; matchBlocks = mkOption { - type = hm.types.listOrDagOf matchBlockModule; + type = hm.types.dagOf matchBlockModule; default = {}; example = literalExpression '' { diff --git a/tests/lib/types/default.nix b/tests/lib/types/default.nix index acb565012..f8a7e77cf 100644 --- a/tests/lib/types/default.nix +++ b/tests/lib/types/default.nix @@ -1,7 +1,6 @@ { lib-types-dag-submodule = ./dag-submodule.nix; lib-types-dag-merge = ./dag-merge.nix; - lib-types-list-or-dag-merge = ./list-or-dag-merge.nix; lib-types-gvariant-merge = ./gvariant-merge.nix; } diff --git a/tests/lib/types/list-or-dag-merge-result.txt b/tests/lib/types/list-or-dag-merge-result.txt deleted file mode 100644 index 5fb67a510..000000000 --- a/tests/lib/types/list-or-dag-merge-result.txt +++ /dev/null @@ -1,15 +0,0 @@ -before:before -between:between -after:after -unnamed-1.1:k -unnamed-1.2:l -unnamed-2.01:a -unnamed-2.02:b -unnamed-2.03:c -unnamed-2.04:d -unnamed-2.05:e -unnamed-2.06:f -unnamed-2.07:g -unnamed-2.08:h -unnamed-2.09:i -unnamed-2.10:j diff --git a/tests/lib/types/list-or-dag-merge.nix b/tests/lib/types/list-or-dag-merge.nix deleted file mode 100644 index 4706c5ced..000000000 --- a/tests/lib/types/list-or-dag-merge.nix +++ /dev/null @@ -1,33 +0,0 @@ -{ config, lib, pkgs, ... }: - -let - inherit (lib) concatStringsSep hm mkMerge mkOption types; - - dag = lib.hm.dag; - - result = let - sorted = dag.topoSort config.tested.dag; - data = map (e: "${e.name}:${e.data}") sorted.result; - in concatStringsSep "\n" data + "\n"; - -in { - options.tested.dag = mkOption { type = hm.types.listOrDagOf types.str; }; - - config = { - tested = mkMerge [ - { dag = [ "k" "l" ]; } - { dag = [ "a" "b" "c" "d" "e" "f" "g" "h" "i" "j" ]; } - { dag.after = "after"; } - { dag.before = dag.entryBefore [ "after" ] "before"; } - { dag.between = dag.entryBetween [ "after" ] [ "before" ] "between"; } - ]; - - home.file."result.txt".text = result; - - nmt.script = '' - assertFileContent \ - home-files/result.txt \ - ${./list-or-dag-merge-result.txt} - ''; - }; -}