Skip to content

shell.nix: switch to rustup#7049

Merged
xzfc merged 3 commits intodevfrom
shell.nix-rustup
Aug 13, 2025
Merged

shell.nix: switch to rustup#7049
xzfc merged 3 commits intodevfrom
shell.nix-rustup

Conversation

@xzfc
Copy link
Member

@xzfc xzfc commented Aug 13, 2025

This PR switches shell.nix from using fenix (which pins Rust versions) to rustup (lets the user manage Rust versions), so I don't have to open a bump PR when new Rust releases.

Also, update auto-generated tools/nix/npins/default.nix.

@xzfc xzfc requested review from generall and timvisee August 13, 2025 11:42
@coderabbitai

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

@xzfc xzfc force-pushed the shell.nix-rustup branch from e146a01 to 4394e39 Compare August 13, 2025 11:50
@xzfc xzfc mentioned this pull request Aug 13, 2025
3 tasks
Copy link
Member

@timvisee timvisee left a comment

Choose a reason for hiding this comment

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

I don't have a Nix system to test this on. So I'm trusting you with this one. 🧐

@xzfc xzfc merged commit 23dd2bb into dev Aug 13, 2025
13 checks passed
@xzfc xzfc deleted the shell.nix-rustup branch August 13, 2025 12:09
IvanPleshkov pushed a commit that referenced this pull request Aug 14, 2025
* shell.nix: npins upgrade

* shell.nix: bump to rust 1.89

* shell.nix: use rustup instead of fenix
timvisee pushed a commit that referenced this pull request Aug 14, 2025
* shell.nix: npins upgrade

* shell.nix: bump to rust 1.89

* shell.nix: use rustup instead of fenix
@timvisee timvisee mentioned this pull request Aug 14, 2025
@CyberShadow
Copy link

@xzfc Unfortunately this broke building Qdrant on NixOS (ironically).

$ nix-shell --pure --run 'cargo b'
error: rustup could not choose a version of cargo to run, because one wasn't specified explicitly, and no default is configured.
help: run 'rustup default stable' to download the latest stable release of Rust and set it as your default toolchain.

and with a configured rust-up:

$ nix-shell --run 'cargo b'         
Could not start dynamically linked executable: /home/vladimir/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo
NixOS cannot run dynamically linked executables intended for generic
linux environments out of the box. For more information, see:
https://nix.dev/permalink/stub-ld

@xzfc
Copy link
Member Author

xzfc commented Oct 24, 2025

@CyberShadow I've successfully built Qdrant on a fresh NixOS VM.

VM config
{ config, pkgs, ... }:
{
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  users.users.alice = {
    isNormalUser = true;
    extraGroups = [ "wheel" ];
    initialPassword = "test";
  };

  environment.systemPackages = [ pkgs.git ];

  virtualisation.vmVariant = {
    virtualisation = {
      cores = 4;
      diskSize = 32 * 1024; # in MiB
      memorySize = 8 * 1024; # in MiB
      writableStoreUseTmpfs = false; # By default it's 2 GiB tmpfs which is not enough
    };
  };

  system.stateVersion = "24.05";
}
nix-build '<nixpkgs/nixos>' -A vm -I nixpkgs=channel:nixos-25.05 -I nixos-config=./conf.nix
LD_LIBRARY_PATH= QEMU_KERNEL_PARAMS=console=ttyS0 ./result/bin/run-nixos-vm -nographic

Rustup installed from nixpkgs should run patchelf on downloaded toolchains. E.g., in the said VM:

$ file .rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo
.rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /nix/store/g3s0z9r7m1lsfxdk8bj88nw8k8q3dmmg-glibc-2.40-66/lib/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, with debug_info, not stripped

Perhaps in your case, the toolchain was either:

  • downloaded by non-nixpkgs rustup (thus not patched)
  • OR become stale (it might happen after updating nixpkgs and running nix-collect-garbage; perhaps it should be reported/fixed on Nixpkgs side)

Try to delete the toolchain and let rustup to re-download it.

@CyberShadow
Copy link

Thanks! It was probably a PEBKAC, then.

@coderabbitai coderabbitai bot mentioned this pull request Dec 16, 2025
7 tasks
@coderabbitai coderabbitai bot mentioned this pull request Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants