-
-
Notifications
You must be signed in to change notification settings - Fork 14.9k
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
command-not-found: drop perl dependency #74789
Conversation
I tested |
} | ||
} | ||
} else if (getenv("NIX_AUTO_RUN")) { | ||
std::string attrname = std::string("nixpkgs.") + package; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is nixpkgs.
correct here or should it be nixos.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nixpkgs.
, however it will become nixpkgs#
in the future.
63c9a2e
to
e416c35
Compare
e416c35
to
3233ca3
Compare
Small typo in commit subject. |
3233ca3
to
d131ccc
Compare
fixed |
This to me is not really an improvement: it replaces a 51-line Perl script with a 141-line C++ program. As an aside, if we really want to get rid of Perl, then Rust is the way to go IMHO. BTW, I think we can get rid of the auto-install feature, it was added as a bit of a joke and nobody uses it. |
} | ||
} else if (getenv("NIX_AUTO_RUN")) { | ||
std::string attrname = std::string("nixpkgs.") + package; | ||
std::vector<const char *> args = {"nix", "run", &attrname[0], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nix run
should be avoided, it's experimental and won't work in Nix 2.4 unless you pass --experimental-features nix-command
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@edolstra is this going away in future or when does it become stable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI, nix run
is used a few places in nixpkgs (and the manual) already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not only nix run
also nix copy
and nix build
(for example in the installer).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, we should replace those by nix-build
etc. (or add --experimental-features nix-command
to those invocations, but that's tricky because it could override the user's experimental-features setting).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, maybe we should get rid of NIX_AUTO_RUN
as well, automatically downloading/running binaries is not a very secure thing to do...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's say not safe instead of secure.
} | ||
}; | ||
|
||
int queryPackages(const char *system, const char *program, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These char *
are a bit unidiomatic C++ IMHO.
|
||
#ifndef NIX_SYSTEM | ||
#error "NIX_SYSTEM not defined" | ||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are unnecessary, compilation will fail anyway if they're not defined.
d131ccc
to
f012aa4
Compare
I choose C++:
I am not sure the Rust version would be much shorter. The C++ is now 99 lines compared to 55 lines Perl. But it also generates more error messages and starts faster. |
Faster startup and remove some perl packages from the default nixos closure. Eventually we could remove perl completely from the default nixos closure.
f012aa4
to
2ccb9f5
Compare
Old closure size: 82.9M New one is faster but it probably hardly matters: Old:
New:
The C++ program is now +28 lines longer. Does this looks fine now? |
-1 on removing NIX_AUTO_INSTALL, since I'm using it. Or at least remove it in a separate PR with a release note entry. |
I am fine with whatever the consensus is. |
BTW for the record, https://github.com/bennofs/nix-index#usage-as-a-command-not-found-replacement Though from my experience it feels somewhat slower to that of the original command-not-found implementation. |
There is also a rust version alternative: #88517 |
Faster startup and remove some perl packages from the default nixos closure.
Eventually we could remove perl completely from the default nixos closure.
It now also uses
nix run
whenNIX_AUTO_RUN
is set.Motivation for this change
Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nix-review --run "nix-review wip"
./result/bin/
)nix path-info -S
before and after)Notify maintainers
cc @