-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
False positive UnnededRec when 'chaining' inherit #59
Comments
I don't have the bandwidth to get to this soon, but would be happy to merge
a PR fixing this.
…On Sat, Aug 28, 2021 at 3:36 PM chriswarbo ***@***.***> wrote:
Similar to #43 <#43>
The following code defines an attrset containing lib (taken from import
<nixpkgs> {}) and escapeShellArg (taken from lib):
rec {
inherit (import <nixpkgs> {}) lib;
inherit (lib) escapeShellArg;
}
Welcome to Nix version 2.3.11. Type :? for help.
nix-repl> import ./example.nix
{ escapeShellArg = «lambda @ /nix/store/xdk4f76azzwg5qami5w250kh9l79sszh-nixpkgs-src/lib/strings.nix:318:20»; lib = { ... }; }
This needs rec, otherwise we can't inherit from the lib variable.
Welcome to Nix version 2.3.11. Type :? for help.
nix-repl> import ./example.nix
error: undefined variable 'lib' at /Users/chrisw/DeleteMe/example.nix:3:12
However, nix-linter thinks the rec is not needed:
$ nix-linter example.nix
Unneeded `rec` on set at example.nix:1:1-4:2
For context, I often use this pattern alongside with, e.g. a non-toy
example:
with rec {
inherit (builtins) isList toJSON;
inherit (nixpkgs)
bash
callPackage
coreutils
gnugrep
gnused
jq
lib
runCommand
writeReferencesToFile;
inherit (lib) concatMapStringsSep escapeShellArg;
inherit (helpers.util) script;
};
rec {
...
}
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#59>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGRJXGTK5NNELK2KUHVRKLT7DX4HANCNFSM5C7FZ3TA>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Open
@chriswarbo I'm curious; is there a reason you use |
@Radvendii I wrote up my reasoning at NixOS/nix#1361 (comment) (Warbo is my personal account; chriswarbo is my work account) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Similar to #43
The following code defines an attrset containing
lib
(taken fromimport <nixpkgs> {}
) andescapeShellArg
(taken fromlib
):This needs
rec
, otherwise we can't inherit from thelib
variable.However, nix-linter thinks the
rec
is not needed:For context, I often use this pattern alongside
with
, e.g. a non-toy example:The text was updated successfully, but these errors were encountered: