Loading nixos/doc/manual/development/settings-options.section.md +4 −0 Original line number Diff line number Diff line Loading @@ -312,6 +312,8 @@ have a predefined type and string generator already declared under may be transformed into multiple key-value pairs depending on `listToValue`). The attribute `lib.type.atom` contains the used INI atom. `pkgs.formats.iniWithGlobalSection` { *`listsAsDuplicateKeys`* ? false, *`listToValue`* ? null, \.\.\. } : A function taking an attribute set with values Loading @@ -333,6 +335,8 @@ have a predefined type and string generator already declared under attrset of key-value pairs for a single section, the global section which preceedes the section definitions. The attribute `lib.type.atom` contains the used INI atom. `pkgs.formats.toml` { } : A function taking an empty attribute set (for future extensibility) Loading nixos/modules/services/mail/public-inbox.nix +1 −1 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ let stateDir = "/var/lib/public-inbox"; gitIni = pkgs.formats.gitIni { listsAsDuplicateKeys = true; }; iniAtom = elemAt gitIni.type/*attrsOf*/.functor.wrapped/*attrsOf*/.functor.wrapped/*either*/.functor.wrapped 0; iniAtom = gitIni.lib.types.atom; useSpamAssassin = cfg.settings.publicinboxmda.spamcheck == "spamc" || cfg.settings.publicinboxwatch.spamcheck == "spamc"; Loading pkgs/pkgs-lib/formats.nix +19 −13 Original line number Diff line number Diff line Loading @@ -123,9 +123,9 @@ rec { } else singleIniAtom; iniSection = { listsAsDuplicateKeys, listToValue, atomsCoercedToLists }@args: attrsOf (iniAtom args) // { description = "section of an INI file (attrs of " + (iniAtom args).description + ")"; iniSection = atom: attrsOf atom // { description = "section of an INI file (attrs of " + atom.description + ")"; }; maybeToList = listToValue: if listToValue != null then lib.mapAttrs (key: val: if lib.isList val then listToValue val else val) else lib.id; Loading @@ -144,12 +144,14 @@ rec { assert atomsCoercedToLists != null -> (listsAsDuplicateKeys || listToValue != null); let atomsCoercedToLists' = if atomsCoercedToLists == null then false else atomsCoercedToLists; atom = iniAtom { inherit listsAsDuplicateKeys listToValue; atomsCoercedToLists = atomsCoercedToLists'; }; in { type = lib.types.attrsOf ( iniSection { inherit listsAsDuplicateKeys listToValue; atomsCoercedToLists = atomsCoercedToLists'; } iniSection atom ); lib.types.atom = atom; generate = name: value: lib.pipe value Loading @@ -174,24 +176,26 @@ rec { assert atomsCoercedToLists != null -> (listsAsDuplicateKeys || listToValue != null); let atomsCoercedToLists' = if atomsCoercedToLists == null then false else atomsCoercedToLists; atom = iniAtom { inherit listsAsDuplicateKeys listToValue; atomsCoercedToLists = atomsCoercedToLists'; }; in { type = lib.types.submodule { options = { sections = lib.mkOption rec { type = lib.types.attrsOf ( iniSection { inherit listsAsDuplicateKeys listToValue; atomsCoercedToLists = atomsCoercedToLists'; } iniSection atom ); default = {}; description = type.description; }; globalSection = lib.mkOption rec { type = iniSection { inherit listsAsDuplicateKeys listToValue; atomsCoercedToLists = atomsCoercedToLists'; }; type = iniSection atom; default = {}; description = "global " + type.description; }; }; }; lib.types.atom = atom; generate = name: { sections ? {}, globalSection ? {}, ... }: pkgs.writeText name (lib.generators.toINIWithGlobalSection (removeAttrs args ["listToValue" "atomsCoercedToLists"]) { Loading @@ -200,15 +204,17 @@ rec { }); }; gitIni = { listsAsDuplicateKeys ? false, ... }@args: { type = let gitIni = { listsAsDuplicateKeys ? false, ... }@args: let atom = iniAtom { listsAsDuplicateKeys = listsAsDuplicateKeys; inherit listsAsDuplicateKeys; listToValue = null; atomsCoercedToLists = false; }; in attrsOf (attrsOf (either atom (attrsOf atom))); in { type = attrsOf (attrsOf (either atom (attrsOf atom))); lib.types.atom = atom; generate = name: value: pkgs.writeText name (lib.generators.toGitINI value); }; Loading Loading
nixos/doc/manual/development/settings-options.section.md +4 −0 Original line number Diff line number Diff line Loading @@ -312,6 +312,8 @@ have a predefined type and string generator already declared under may be transformed into multiple key-value pairs depending on `listToValue`). The attribute `lib.type.atom` contains the used INI atom. `pkgs.formats.iniWithGlobalSection` { *`listsAsDuplicateKeys`* ? false, *`listToValue`* ? null, \.\.\. } : A function taking an attribute set with values Loading @@ -333,6 +335,8 @@ have a predefined type and string generator already declared under attrset of key-value pairs for a single section, the global section which preceedes the section definitions. The attribute `lib.type.atom` contains the used INI atom. `pkgs.formats.toml` { } : A function taking an empty attribute set (for future extensibility) Loading
nixos/modules/services/mail/public-inbox.nix +1 −1 Original line number Diff line number Diff line Loading @@ -7,7 +7,7 @@ let stateDir = "/var/lib/public-inbox"; gitIni = pkgs.formats.gitIni { listsAsDuplicateKeys = true; }; iniAtom = elemAt gitIni.type/*attrsOf*/.functor.wrapped/*attrsOf*/.functor.wrapped/*either*/.functor.wrapped 0; iniAtom = gitIni.lib.types.atom; useSpamAssassin = cfg.settings.publicinboxmda.spamcheck == "spamc" || cfg.settings.publicinboxwatch.spamcheck == "spamc"; Loading
pkgs/pkgs-lib/formats.nix +19 −13 Original line number Diff line number Diff line Loading @@ -123,9 +123,9 @@ rec { } else singleIniAtom; iniSection = { listsAsDuplicateKeys, listToValue, atomsCoercedToLists }@args: attrsOf (iniAtom args) // { description = "section of an INI file (attrs of " + (iniAtom args).description + ")"; iniSection = atom: attrsOf atom // { description = "section of an INI file (attrs of " + atom.description + ")"; }; maybeToList = listToValue: if listToValue != null then lib.mapAttrs (key: val: if lib.isList val then listToValue val else val) else lib.id; Loading @@ -144,12 +144,14 @@ rec { assert atomsCoercedToLists != null -> (listsAsDuplicateKeys || listToValue != null); let atomsCoercedToLists' = if atomsCoercedToLists == null then false else atomsCoercedToLists; atom = iniAtom { inherit listsAsDuplicateKeys listToValue; atomsCoercedToLists = atomsCoercedToLists'; }; in { type = lib.types.attrsOf ( iniSection { inherit listsAsDuplicateKeys listToValue; atomsCoercedToLists = atomsCoercedToLists'; } iniSection atom ); lib.types.atom = atom; generate = name: value: lib.pipe value Loading @@ -174,24 +176,26 @@ rec { assert atomsCoercedToLists != null -> (listsAsDuplicateKeys || listToValue != null); let atomsCoercedToLists' = if atomsCoercedToLists == null then false else atomsCoercedToLists; atom = iniAtom { inherit listsAsDuplicateKeys listToValue; atomsCoercedToLists = atomsCoercedToLists'; }; in { type = lib.types.submodule { options = { sections = lib.mkOption rec { type = lib.types.attrsOf ( iniSection { inherit listsAsDuplicateKeys listToValue; atomsCoercedToLists = atomsCoercedToLists'; } iniSection atom ); default = {}; description = type.description; }; globalSection = lib.mkOption rec { type = iniSection { inherit listsAsDuplicateKeys listToValue; atomsCoercedToLists = atomsCoercedToLists'; }; type = iniSection atom; default = {}; description = "global " + type.description; }; }; }; lib.types.atom = atom; generate = name: { sections ? {}, globalSection ? {}, ... }: pkgs.writeText name (lib.generators.toINIWithGlobalSection (removeAttrs args ["listToValue" "atomsCoercedToLists"]) { Loading @@ -200,15 +204,17 @@ rec { }); }; gitIni = { listsAsDuplicateKeys ? false, ... }@args: { type = let gitIni = { listsAsDuplicateKeys ? false, ... }@args: let atom = iniAtom { listsAsDuplicateKeys = listsAsDuplicateKeys; inherit listsAsDuplicateKeys; listToValue = null; atomsCoercedToLists = false; }; in attrsOf (attrsOf (either atom (attrsOf atom))); in { type = attrsOf (attrsOf (either atom (attrsOf atom))); lib.types.atom = atom; generate = name: value: pkgs.writeText name (lib.generators.toGitINI value); }; Loading