1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-21 01:09:47 +01:00

lib: remove listOrDagOf type

It has been deprecated for a long time and should be safe to remove.
This commit is contained in:
Robert Helgesson 2023-06-04 09:49:30 +02:00
parent 24d590cc32
commit 79e03fbe24
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
6 changed files with 2 additions and 104 deletions

View file

@ -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; };
};
}

View file

@ -14,7 +14,7 @@ let
in rec {
inherit (typesDag) dagOf listOrDagOf;
inherit (typesDag) dagOf;
selectorFunction = mkOptionType {
name = "selectorFunction";

View file

@ -482,7 +482,7 @@ in
};
matchBlocks = mkOption {
type = hm.types.listOrDagOf matchBlockModule;
type = hm.types.dagOf matchBlockModule;
default = {};
example = literalExpression ''
{

View file

@ -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;
}

View file

@ -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

View file

@ -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}
'';
};
}