mirror of
https://github.com/NixOS/nix
synced 2025-06-24 18:01:16 +02:00
Add optionalString
to manual Nix lang utilities
Use it everywhere it could be also.
This commit is contained in:
parent
ab228d73db
commit
ba9ae691b6
2 changed files with 18 additions and 14 deletions
|
@ -42,6 +42,8 @@ rec {
|
|||
filterAttrs = pred: set:
|
||||
listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
|
||||
|
||||
optionalString = cond: string: if cond then string else "";
|
||||
|
||||
showSetting = { useAnchors }: name: { description, documentDefault, defaultValue, aliases, value }:
|
||||
let
|
||||
result = squash ''
|
||||
|
@ -74,7 +76,7 @@ rec {
|
|||
else "*machine-specific*";
|
||||
|
||||
showAliases = aliases:
|
||||
if aliases == [] then "" else
|
||||
optionalString (aliases != [])
|
||||
"**Deprecated alias:** ${(concatStringsSep ", " (map (s: "`${s}`") aliases))}";
|
||||
|
||||
in result;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue