Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c2e5ff3fe8e1
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 61cf52bc17dd
Choose a head ref
  • 5 commits
  • 4 files changed
  • 1 contributor

Commits on Jan 11, 2020

  1. Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    LnL7 Daiderd Jordan
    Copy the full SHA
    e85b34c View commit details
  2. lib/types: improve loaOf warning

    Not all modules use name attribute as the name of the submodule, for example,
    environment.etc uses target. We will need to maintain a list of exceptions.
    jtojnar committed Jan 11, 2020

    Verified

    This commit was signed with the committer’s verified signature. The key has expired.
    LnL7 Daiderd Jordan
    Copy the full SHA
    b0c2c96 View commit details
  3. Copy the full SHA
    6fc46fb View commit details
  4. lib/types: improve loaOf message even more

    Now we suggest correct names for all options in Nixpkgs and also home-manager at the time of writing.
    jtojnar committed Jan 11, 2020
    Copy the full SHA
    13633bd View commit details

Commits on Jan 12, 2020

  1. Merge pull request #77501 from jtojnar/more-loaof-fxes

    tree-wide: fix more warning related to loaOf deprecation
    jtojnar authored Jan 12, 2020
    Copy the full SHA
    61cf52b View commit details
Showing with 80 additions and 21 deletions.
  1. +67 −5 lib/types.nix
  2. +1 −4 nixos/modules/services/mail/postfix.nix
  3. +1 −1 nixos/modules/services/mail/spamassassin.nix
  4. +11 −11 pkgs/os-specific/linux/rfkill/udev.nix
72 changes: 67 additions & 5 deletions lib/types.nix
Original file line number Diff line number Diff line change
@@ -340,29 +340,91 @@ rec {
let
padWidth = stringLength (toString (length def.value));
unnamed = i: unnamedPrefix + fixedWidthNumber padWidth i;
anyString = placeholder "name";
nameAttrs = [
{ path = [ "environment" "etc" ];
name = "target";
}
{ path = [ "containers" anyString "bindMounts" ];
name = "mountPoint";
}
{ path = [ "programs" "ssh" "knownHosts" ];
# hostNames is actually a list so we would need to handle it only when singleton
name = "hostNames";
}
{ path = [ "fileSystems" ];
name = "mountPoint";
}
{ path = [ "boot" "specialFileSystems" ];
name = "mountPoint";
}
{ path = [ "services" "znapzend" "zetup" ];
name = "dataset";
}
{ path = [ "services" "znapzend" "zetup" anyString "destinations" ];
name = "label";
}
{ path = [ "services" "geoclue2" "appConfig" ];
name = "desktopID";
}
{ path = [ "home-manager" "users" anyString "programs" "ssh" "matchBlocks" ];
name = "host"; # https://github.com/rycee/home-manager/blob/e8dbc3561373b68d12decb3c0d7c1ba245f138f7/modules/programs/ssh.nix#L265
}
{ path = [ "home-manager" "users" anyString "home" "file" ];
name = "target"; # https://github.com/rycee/home-manager/blob/0e9b7aab3c6c27bf020402e0e2ef20b65c040552/modules/files.nix#L33
}
{ path = [ "home-manager" "users" anyString "xdg" "configFile" ];
name = "target"; # https://github.com/rycee/home-manager/blob/54de0e1d79a1370e57a8f23bef89f99f9b92ab67/modules/misc/xdg.nix#L41
}
{ path = [ "home-manager" "users" anyString "xdg" "dataFile" ];
name = "target"; # https://github.com/rycee/home-manager/blob/54de0e1d79a1370e57a8f23bef89f99f9b92ab67/modules/misc/xdg.nix#L58
}
];
matched = let
equals = a: b: b == anyString || a == b;
fallback = { name = "name"; };
in findFirst ({ path, ... }: all (v: v == true) (zipListsWith equals loc path)) fallback nameAttrs;
nameAttr = matched.name;
nameValueOld = value:
if isList value then
if length value > 0 then
"[ " + concatMapStringsSep " " escapeNixString value + " ]"
else
"[ ]"
else
escapeNixString value;
nameValueNew = value: unnamed:
if isList value then
if length value > 0 then
head value
else
unnamed
else
value;
res =
{ inherit (def) file;
value = listToAttrs (
imap1 (elemIdx: elem:
{ name = elem.name or (unnamed elemIdx);
{ name = nameValueNew (elem.${nameAttr} or (unnamed elemIdx)) (unnamed elemIdx);
value = elem;
}) def.value);
};
option = concatStringsSep "." loc;
sample = take 3 def.value;
list = concatMapStrings (x: ''{ name = "${x.name or "unnamed"}"; ...} '') sample;
set = concatMapStrings (x: ''${x.name or "unnamed"} = {...}; '') sample;
more = lib.optionalString (length def.value > 3) "... ";
list = concatMapStrings (x: ''{ ${nameAttr} = ${nameValueOld (x.${nameAttr} or "unnamed")}; ...} '') sample;
set = concatMapStrings (x: ''${nameValueNew (x.${nameAttr} or "unnamed") "unnamed"} = {...}; '') sample;
msg = ''
In file ${def.file}
a list is being assigned to the option config.${option}.
This will soon be an error as type loaOf is deprecated.
See https://git.io/fj2zm for more information.
Do
${option} =
{ ${set}...}
{ ${set}${more}}
instead of
${option} =
[ ${list}...]
[ ${list}${more}]
'';
in
lib.warn msg res
5 changes: 1 addition & 4 deletions nixos/modules/services/mail/postfix.nix
Original file line number Diff line number Diff line change
@@ -612,10 +612,7 @@ in
{

environment = {
etc = singleton
{ source = "/var/lib/postfix/conf";
target = "postfix";
};
etc.postfix.source = "/var/lib/postfix/conf";

# This makes it comfortable to run 'postqueue/postdrop' for example.
systemPackages = [ pkgs.postfix ];
2 changes: 1 addition & 1 deletion nixos/modules/services/mail/spamassassin.nix
Original file line number Diff line number Diff line change
@@ -124,7 +124,7 @@ in
# Allow users to run 'spamc'.

environment = {
etc = singleton { source = spamdEnv; target = "spamassassin"; };
etc.spamassassin.source = spamdEnv;
systemPackages = [ pkgs.spamassassin ];
};

22 changes: 11 additions & 11 deletions pkgs/os-specific/linux/rfkill/udev.nix
Original file line number Diff line number Diff line change
@@ -8,18 +8,18 @@
# udev.packages = [ pkgs.rfkill_udev ];
#
# Add a hook script in the managed etc directory, e.g.:
# etc = [
# { source = pkgs.writeScript "rtfkill.hook" ''
# #!${pkgs.runtimeShell}
# etc."rfkill.hook" = {
# mode = "0755";
# text = ''
# #!${pkgs.runtimeShell}
#
# if [ "$RFKILL_STATE" -eq "1" ]; then
# exec ${config.system.build.upstart}/sbin/initctl emit -n antenna-on
# else
# exec ${config.system.build.upstart}/sbin/initctl emit -n antenna-off
# fi
# '';
# target = "rfkill.hook";
# }
# if [ "$RFKILL_STATE" -eq "1" ]; then
# exec ${config.system.build.upstart}/sbin/initctl emit -n antenna-on
# else
# exec ${config.system.build.upstart}/sbin/initctl emit -n antenna-off
# fi
# '';
# }

# Note: this package does not need the binaries
# in the rfkill package.