Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions lib/types.nix
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ rec {


# When adding new types don't forget to document them in
# nixos/doc/manual/development/option-types.xml!
# nixos/doc/manual/development/option-types.section.md!
types = rec {

raw = mkOptionType rec {
Expand Down Expand Up @@ -395,10 +395,12 @@ rec {
merge = mergeEqualOption;
};

listOf = elemType: mkOptionType rec {
# NixOS apparently has a different notion of "type" than nix(lang)
# does; see discussion in GH #173568
Comment on lines +398 to +399
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the type of comment you would like to have in your code base?
It is accusatory and it lacks real meaning. Can't even paste a URL. A few extra words could have fixed that. (and a lazy Ctrl+L Ctrl+C to copy the whole url)

(I'll shut up now, but I figured this is useful feedback for your future PRs)

Copy link
Author

@ghost ghost Jun 5, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would be happy to include complete URLs, and will do so in the future. It wasn't laziness. Some people get cranky about big long URLs messing up the line-wrapping in multi-line comments. Other people insist on prefixing issue numbers to identify the bugtracker (BZ for Bugzilla, etc) in case the project migrates from one to another in the future. Personally, I don't have strong feelings about any of these things, and just go along with the prevailing trend. Now that I know, my future PRs which reference github issues from a comment will use a complete URL.

Regarding the part of the comment before the question mark:

Is this the type of comment you would like to have in your code base?

It is highly non-obvious that types.nix uses a different definition of "list of <type>" than the Nix language definition does. I do think that non-obvious departures should be documented with comments. Is it documented somewhere else?

listOfGeneralized = isNixOS: elemType: mkOptionType rec {
name = "listOf";
description = "list of ${elemType.description}";
check = isList;
description = "list of ${elemType.description}s";
check = v: isList v && (isNixOS || all elemType.check v);
merge = loc: defs:
map (x: x.value) (filter (x: x ? value) (concatLists (imap1 (n: def:
imap1 (m: def':
Expand All @@ -417,6 +419,9 @@ rec {
nestedTypes.elemType = elemType;
};

listOf = listOfGeneralized true;
listOf' = listOfGeneralized false;

nonEmptyListOf = elemType:
let list = addCheck (types.listOf elemType) (l: l != []);
in list // {
Expand Down
10 changes: 8 additions & 2 deletions nixos/doc/manual/development/option-types.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,14 @@ Composed types are types that take a type as parameter. `listOf

`types.listOf` *`t`*

: A list of *`t`* type, e.g. `types.listOf
int`. Multiple definitions are merged with list concatenation.
: A list, probably but not certainly of *`t`* type, e.g. `types.listOf
int`. Multiple definitions are merged with list concatenation. The
`check` method will not examine the types of the list elements.

`types.listOf'` *`t`*

: A list of *`t`* type, e.g. `types.listOf' int`. Multiple definitions
are merged with list concatenation.

`types.attrsOf` *`t`*

Expand Down
18 changes: 17 additions & 1 deletion nixos/doc/manual/from_md/development/option-types.section.xml
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,26 @@
<literal>types.listOf</literal>
<emphasis><literal>t</literal></emphasis>
</term>
<listitem>
<para>
A list, probably but not certainly of
<emphasis><literal>t</literal></emphasis> type, e.g.
<literal>types.listOf int</literal>. Multiple definitions
are merged with list concatenation. The
<literal>check</literal> method will not examine the types
of the list elements.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<literal>types.listOf'</literal>
<emphasis><literal>t</literal></emphasis>
</term>
<listitem>
<para>
A list of <emphasis><literal>t</literal></emphasis> type,
e.g. <literal>types.listOf int</literal>. Multiple
e.g. <literal>types.listOf' int</literal>. Multiple
definitions are merged with list concatenation.
</para>
</listitem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let
homepage = "https://keepass.info/plugins.html#otpkeyprov";
platforms = with lib.platforms; linux;
license = lib.licenses.gpl2;
maintainers = [ lib.maintainers.ente ];
maintainers = [ /*lib.maintainers.ente*/ ];
};

pluginFilename = "OtpKeyProv.plgx";
Expand Down
4 changes: 2 additions & 2 deletions pkgs/applications/window-managers/sway/contrib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ grimshot = stdenv.mkDerivation rec {
homepage = "https://github.com/swaywm/sway/tree/master/contrib";
license = licenses.mit;
platforms = platforms.all;
maintainers = with maintainers; [
sway-unwrapped.meta.maintainers
maintainers = with maintainers;
sway-unwrapped.meta.maintainers ++ [
evils
];
};
Expand Down
2 changes: 1 addition & 1 deletion pkgs/development/tools/parsing/javacc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ stdenv.mkDerivation rec {
homepage = "https://javacc.github.io/javacc";
description = "A parser generator for building parsers from grammars";
license = licenses.bsd2;
maintainers = [ teams.deshaw.members ];
maintainers = teams.deshaw.members;
};
}
2 changes: 1 addition & 1 deletion pkgs/games/quake3/quake3e/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ stdenv.mkDerivation rec {
license = licenses.gpl2;
platforms = platforms.linux;
maintainers = with maintainers; [ pmiddend ];
badPlatforms = [ platforms.aarch64 ];
badPlatforms = platforms.aarch64;
};
}
10 changes: 5 additions & 5 deletions pkgs/pkgs-lib/formats.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ rec {
str
path
(attrsOf valueType)
(listOf valueType)
(listOf' valueType)
]) // {
description = "JSON value";
};
Expand Down Expand Up @@ -78,7 +78,7 @@ rec {
str
path
(attrsOf valueType)
(listOf valueType)
(listOf' valueType)
]) // {
description = "YAML value";
};
Expand Down Expand Up @@ -110,7 +110,7 @@ rec {

iniAtom =
if listsAsDuplicateKeys then
coercedTo singleIniAtom lib.singleton (listOf singleIniAtom) // {
coercedTo singleIniAtom lib.singleton (listOf' singleIniAtom) // {
description = singleIniAtom.description + " or a list of them for duplicate keys";
}
else if listToValue != null then
Expand Down Expand Up @@ -155,7 +155,7 @@ rec {
str
path
(attrsOf valueType)
(listOf valueType)
(listOf' valueType)
] // {
description = "TOML value";
};
Expand Down Expand Up @@ -269,7 +269,7 @@ rec {
float
str
(attrsOf valueType)
(listOf valueType)
(listOf' valueType)
]) // {
description = "Elixir value";
};
Expand Down
18 changes: 9 additions & 9 deletions pkgs/stdenv/generic/check-meta.nix
Original file line number Diff line number Diff line change
Expand Up @@ -222,14 +222,14 @@ let
mainProgram = str;
longDescription = str;
branch = str;
homepage = either (listOf str) str;
homepage = either (listOf' str) str;
downloadPage = str;
changelog = either (listOf str) str;
license = either (listOf lib.types.attrs) (either lib.types.attrs str);
maintainers = listOf (attrsOf str);
changelog = either (listOf' str) str;
license = let license = either lib.types.attrs str; in either license (listOf' license);
maintainers = listOf' (attrsOf str);
priority = int;
platforms = listOf str;
hydraPlatforms = listOf str;
platforms = listOf' str;
hydraPlatforms = listOf' str;
broken = bool;
unfree = bool;
unsupported = bool;
Expand All @@ -248,12 +248,12 @@ let

# Weirder stuff that doesn't appear in the documentation?
maxSilent = int;
knownVulnerabilities = listOf str;
knownVulnerabilities = listOf' str;
name = str;
version = str;
tag = str;
executables = listOf str;
outputsToInstall = listOf str;
executables = listOf' str;
outputsToInstall = listOf' str;
position = str;
available = bool;
isBuildPythonPackage = platforms;
Expand Down
2 changes: 1 addition & 1 deletion pkgs/tools/security/ghidra/build.nix
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ in stdenv.mkDerivation rec {
homepage = "https://ghidra-sre.org/";
platforms = [ "x86_64-linux" "x86_64-darwin" ];
license = licenses.asl20;
maintainers = [ "roblabla" ];
maintainers = with maintainers; [ roblabla ];
};

}
2 changes: 1 addition & 1 deletion pkgs/tools/security/onlykey-agent/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ let
meta = oa.meta // {
description = "Using OnlyKey as hardware SSH and GPG agent";
homepage = "https://github.com/trustcrypto/onlykey-agent/tree/ledger";
maintainers = with maintainers; [ kalbasit ];
maintainers = with lib.maintainers; [ kalbasit ];
};
});
in
Expand Down
4 changes: 2 additions & 2 deletions pkgs/top-level/config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let
/* Internal stuff */

warnings = mkOption {
type = types.listOf types.str;
type = types.listOf' types.str;
default = [];
internal = true;
};
Expand Down Expand Up @@ -99,7 +99,7 @@ let
};

showDerivationWarnings = mkOption {
type = types.listOf (types.enum [ "maintainerless" ]);
type = types.listOf' (types.enum [ "maintainerless" ]);
default = [];
description = ''
Which warnings to display for potentially dangerous
Expand Down