Skip to content

Commit

Permalink
all-packages: warn when using deprecated attributes
Browse files Browse the repository at this point in the history
The aliases are split into two groups, as mass-renaming is anticipated.
Also added fold markers as in the rest of file.
#9456

(cherry picked from commit c53018c)
  • Loading branch information
vcunat committed Aug 31, 2015
1 parent 6300b47 commit 8e8e23d
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15255,8 +15255,13 @@ let

mg = callPackage ../applications/editors/mg { };


# Attributes for backward compatibility.
}
### Aliases to attributes converted to the dashed-style.
// lib.mapAttrs (name: builtins.trace
( "Warning: using a deprecated attribute '${name}'."
+ " CamelCase and under_scores are replaced by dashed-names"
+ " to match the nix-env names better."))
{ # warnings since 2015-09
adobeReader = adobe-reader;
arduino_core = arduino-core; # added 2015-02-04
asciidocFull = asciidoc-full; # added 2014-06-22
Expand All @@ -15265,17 +15270,24 @@ let
lttngTools = lttng-tools; # added 2014-07-31
lttngUst = lttng-ust; # added 2014-07-31
jquery_ui = jquery-ui; # added 2014-09-07
youtubeDL = youtube-dl; # added 2014-10-26
youtube-dl = pythonPackages.youtube-dl; # added 2015-06-07
rdiff_backup = rdiff-backup; # added 2014-11-23
htmlTidy = html-tidy; # added 2014-12-06
libtidy = html-tidy; # added 2014-12-21
speedtest_cli = speedtest-cli; # added 2015-02-17
sqliteInteractive = sqlite-interactive; # added 2014-12-06
nfsUtils = nfs-utils; # added 2014-12-06
buildbotSlave = buildbot-slave; # added 2014-12-09
cool-old-term = cool-retro-term; # added 2015-01-31
rssglx = rss-glx; #added 2015-03-25

}
### Other attribute aliases for backward compatibility.
// lib.mapAttrs
(name: builtins.trace "Warning: using a deprecated attribute '${name}'.")
{ # warnings since 2015-09
youtubeDL = youtube-dl; # added 2014-10-26
youtube-dl = pythonPackages.youtube-dl; # added 2015-06-07
cool-old-term = cool-retro-term; # added 2015-01-31

haskell-ng = haskell; # 2015-04-19
haskellngPackages = haskellPackages; # 2015-04-19
inherit (haskell.compiler) jhc uhc; # 2015-05-15
Expand Down

6 comments on commit 8e8e23d

@edolstra
Copy link
Member

Choose a reason for hiding this comment

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

This is undesirable:

$ nix-env -qa
trace: Warning: using a deprecated attribute 'adobeReader'. CamelCase and under_scores are replaced by dashed-names to match the nix-env names better.
trace: Warning: using a deprecated attribute 'arduino_core'. CamelCase and under_scores are replaced by dashed-names to match the nix-env names better.
trace: Warning: using a deprecated attribute 'asciidocFull'. CamelCase and under_scores are replaced by dashed-names to match the nix-env names better.
trace: Warning: using a deprecated attribute 'youtube-dl'.
trace: Warning: using a deprecated attribute 'bridge_utils'. CamelCase and under_scores are replaced by dashed-names to match the nix-env names better.
trace: Warning: using a deprecated attribute 'buildbotSlave'. CamelCase and under_scores are replaced by dashed-names to match the nix-env names better.
trace: Warning: using a deprecated attribute 'cheetahTemplate'.
trace: Warning: using a deprecated attribute 'clangAnalyzer'. CamelCase and under_scores are replaced by dashed-names to match the nix-env names better.
trace: Warning: using a deprecated attribute 'cool-old-term'.
trace: Warning: using a deprecated attribute 'haskellngPackages'.
trace: Warning: using a deprecated attribute 'facter'.
trace: Warning: using a deprecated attribute 'haskell-ng'.
trace: Warning: using a deprecated attribute 'hbase'.
trace: Warning: using a deprecated attribute 'htmlTidy'. CamelCase and under_scores are replaced by dashed-names to match the nix-env names better.
trace: Warning: using a deprecated attribute 'jhc'.
trace: Warning: using a deprecated attribute 'jquery_ui'. CamelCase and under_scores are replaced by dashed-names to match the nix-env names better.
trace: Warning: using a deprecated attribute 'libtidy'. CamelCase and under_scores are replaced by dashed-names to match the nix-env names better.
trace: Warning: using a deprecated attribute 'lttngTools'. CamelCase and under_scores are replaced by dashed-names to match the nix-env names better.
trace: Warning: using a deprecated attribute 'lttngUst'. CamelCase and under_scores are replaced by dashed-names to match the nix-env names better.
trace: Warning: using a deprecated attribute 'nfsUtils'. CamelCase and under_scores are replaced by dashed-names to match the nix-env names better.
trace: Warning: using a deprecated attribute 'opentsdb'.
trace: Warning: using a deprecated attribute 'rdiff_backup'. CamelCase and under_scores are replaced by dashed-names to match the nix-env names better.
trace: Warning: using a deprecated attribute 'rssglx'. CamelCase and under_scores are replaced by dashed-names to match the nix-env names better.
trace: Warning: using a deprecated attribute 'speedtest_cli'. CamelCase and under_scores are replaced by dashed-names to match the nix-env names better.
trace: Warning: using a deprecated attribute 'sqliteInteractive'. CamelCase and under_scores are replaced by dashed-names to match the nix-env names better.
trace: Warning: using a deprecated attribute 'udevil'.
trace: Warning: using a deprecated attribute 'uhc'.
trace: Warning: using a deprecated attribute 'youtubeDL'.

@vcunat
Copy link
Member Author

@vcunat vcunat commented on 8e8e23d Aug 31, 2015

Choose a reason for hiding this comment

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

Hmm, is there a way to distinguish a nix-env listing from a specifically requested attribute? I believe deprecated aliases shouldn't be in nix-env results anyway.

@vcunat
Copy link
Member Author

@vcunat vcunat commented on 8e8e23d Aug 31, 2015

Choose a reason for hiding this comment

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

Well, I've come up with a hacky solution to this

diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 5c28db9..5252cba 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -15255,9 +15255,14 @@ let

   mg = callPackage ../applications/editors/mg { };

+  addInstantiationTrace = msg: pkg:
+    if pkg ? src then
+      pkg.overrideDerivation (attrs: { src = builtins.trace msg attrs.src; })
+    else
+      /*builtins.trace "package not traced"*/ pkg;
 }
   ### Aliases to attributes converted to the dashed-style.
-  // lib.mapAttrs (name: builtins.trace
+  // lib.mapAttrs (name: addInstantiationTrace
     ( "Warning: using a deprecated attribute '${name}'."
     + " CamelCase and under_scores are replaced by dashed-names"
     + " to match the nix-env names better."))
@@ -15282,7 +15287,7 @@ let
 }
   ### Other attribute aliases for backward compatibility.
   // lib.mapAttrs
-      (name: builtins.trace "Warning: using a deprecated attribute '${name}'.")
+      (name: addInstantiationTrace "Warning: using a deprecated attribute '${name}'.")
 { # warnings since 2015-09
   youtubeDL = youtube-dl;  # added 2014-10-26
   youtube-dl = pythonPackages.youtube-dl; # added 2015-06-07

Currently there are only two renames that go silent with it, and the notorious overrideDerivation is only used when printing the message (i.e. not often). Should I push it, or can anyone see a better option?

@edolstra
Copy link
Member

Choose a reason for hiding this comment

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

Dunno, it's a bit too hacky for me...

I don't really see a good short-term solution other than removing the trace messages. Long-term solution would be to have a separate attribute set containing the packages for nix-env.

@vcunat
Copy link
Member Author

@vcunat vcunat commented on 8e8e23d Aug 31, 2015

Choose a reason for hiding this comment

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

Long-term solution would be to have a separate attribute set containing the packages for nix-env.

I'm not so sure about that. The behavior with patch above is that nix-env -q shows no warning, but nix-env -i does (i.e. it warns iff you instantiate through a deprecated name).

@vcunat
Copy link
Member Author

@vcunat vcunat commented on 8e8e23d Sep 2, 2015

Choose a reason for hiding this comment

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

@edolstra, is the hackiness level of this low enough?

{ # inspired by `traceDrvLicenses`
  addInstantiationTrace = msg: pkg:
    pkg // {
      drvPath = builtins.trace msg pkg.drvPath;
      outPath = builtins.trace msg pkg.outPath;
    };
}

For me it reports on instantiation and does nothing nix-env -qa. It doesn't cover all cases, as e.g. on nix-instantiate -A inotifyTools.out it reports nothing, but IMHO it's fairly close to what we want. It does cover the case of using the attribute in buildInputs. We can improve later, if need be and/or we find a better way. EDIT: using nix-env -qas still triggers a report, but that seems hard to avoid, as some kind of instantiation is done in that case. Demo: 9e84cb3.

Please sign in to comment.