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
tree-wide: Fix with nixUnstable #80724
Conversation
nix::baseNameOf returns std::string_view instead of std::string in unstable Nix, which cannot be autocast to `const char*` expected by `nix::LegacyArgs::LegacyArgs` constructor.
Otherwise it fails with nix = nixUnstable overlay. It will also make it easier to find it when we decide to change the experimental command's syntax.
Otherwise the nix activation script fails with nix = nixUnstable overlay. It will also make it easier to find it when we decide to change the experimental command's syntax.
Otherwise the command will likely fail with nix.package = nixUnstable set. It will also make it easier to find it when we decide to change the experimental command's syntax.
@@ -27,6 +27,7 @@ profile=/nix/var/nix/profiles/system | |||
buildHost= | |||
targetHost= | |||
maybeSudo=() | |||
NIX="nix --option 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.
We can't do this, because passing --experimental-features
overrides the setting in nix.conf. So it might disable other features.
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.
That is really unfortunate, it means we cannot dogfood nix commands.
@@ -452,7 +452,7 @@ in | |||
system.activationScripts.nix = stringAfter [ "etc" "users" ] | |||
'' | |||
# Create directories in /nix. | |||
${nix}/bin/nix ping-store --no-net | |||
${nix}/bin/nix --option experimental-features nix-command ping-store --no-net |
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.
Probably we should replace nix ping-store
by some other dummy command that opens the store. I think even something like nix-store -q
without arguments will do this.
@@ -281,7 +282,7 @@ fi | |||
|
|||
# Resolve the flake. | |||
if [[ -n $flake ]]; then | |||
flake=$(nix flake info --json "${extraBuildFlags[@]}" "${lockFlags[@]}" -- "$flake" | jq -r .url) | |||
flake=$($NIX flake info --json "${extraBuildFlags[@]}" "${lockFlags[@]}" -- "$flake" | jq -r .url) |
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.
This also requires the flakes
experimental feature. In any case, I think the user should affirmatively enable this in nix.conf
themselves. Otherwise it kind of defeats the point of experimental-features
, which is to make people aware of the fact that they're using an experimental feature.
@@ -102,6 +102,7 @@ if [[ -z $system ]]; then | |||
outLink="$tmpdir/system" | |||
nix build --out-link "$outLink" --store "$mountPoint" "${extraBuildFlags[@]}" \ | |||
--extra-substituters "$sub" \ | |||
--option 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.
We could just change this back to nix-build
(making nixos-install
consistent with nixos-rebuild
).
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.
I can do that but I thought we wanted to dogfood the stuff.
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.
Dogfooding == using it yourself, not making other users use it :-)
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.
Do we revert e88f289?
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.
No, I think we only have to change nix build
to nix-build
. IIRC it also supports the --store
argument which is what allows an install into a chroot.
|
||
struct MyArgs : nix::LegacyArgs, nix::MixEvalArgs | ||
{ | ||
using nix::LegacyArgs::LegacyArgs; | ||
}; | ||
|
||
MyArgs myArgs(nix::baseNameOf(argv[0]), [&](Strings::iterator & arg, const Strings::iterator & end) { | ||
MyArgs myArgs(pname.data(), [&](Strings::iterator & arg, const Strings::iterator & end) { |
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.
Perhaps making nix::LegacyArgs::LegacyArgs
accept std::string_view
is a cleaner idea.
Mostly fixed by #87182 |
Motivation for this change
It is great that the experimental commands are now gated but since we are dogfooding them, we need to open the gates.
I ran
nixos-rebuild switch
with the following in my config:Things done