!FBuJyWXTGcGtHTPphC:nixos.org

Nix Rust

464 Members
Rust111 Servers

Load older messages


SenderMessageTime
3 Sep 2024
@emilazy:matrix.orgemily is there a nice way to run clippy in nix flake check? 23:19:20
4 Sep 2024
@getchoo:matrix.orggetchoo
stdenv.mkDerivation {
  name = "check-clippy";
  inherit (aRustPackage) src cargoDeps;

  nativeBuildInputs = [ cargo clippy rustPlatform.cargoSetupHook ];

  buildPhase = "cargo clippy";
}

with aRustPackage being a derivation for the project you're running clippy on

01:51:59
@getchoo:matrix.orggetchoothere are probably ways to do this better/re-use more stuff from the parent package like it's native/buildInputs but01:53:24
@getchoo:matrix.orggetchoohopefully you get the idea lol01:53:29
@getchoo:matrix.orggetchoo *
stdenv.mkDerivation {
  name = "check-clippy";
  inherit (aRustPackage) src cargoDeps;

  nativeBuildInputs = [ cargo clippy rustPlatform.cargoSetupHook ];

  buildPhase = "cargo clippy | tee $out";
}

with aRustPackage being a derivation for the project you're running clippy on

01:53:55
@emilazy:matrix.orgemily right, I ended up doing something like that with runCommandCC since asking :) 01:58:10
@emilazy:matrix.orgemilywas just hoping there was something more "native"01:58:14
@emilazy:matrix.orgemily I considered doing an .overrideAttrs and changing all the phases too 01:58:38
@getchoo:matrix.orggetchooit's not a bad option i just hate disabling some other stuff like the install step lol02:03:27
@emilazy:matrix.orgemilyyeah it's annoying02:04:04
@emilazy:matrix.orgemily
        clippy = config.packages.default.overrideAttrs (prevAttrs: {
          name = "clippy-check";

          nativeBuildInputs = prevAttrs.nativeBuildInputs or [ ] ++ [ pkgs.clippy ];

          dontBuild = true;

          checkPhase = ''
            runHook preCheck
            cargo clippy
            runHook postCheck
          '';

          installPhase = ''
            runHook preInstall
            touch $out
            runHook postInstall
          '';
        });
02:04:12
@emilazy:matrix.orgemily not very pretty, but it seems nicer since it works with buildInputs etc. 02:04:23
@julius:mtx.liftm.deˈt͡sɛːzaɐ̯
nixos login: root (automatic login)
User not known to the underlying authentication module

I'm amazed that that is possible.

03:52:30
@julius:mtx.liftm.deˈt͡sɛːzaɐ̯ I was thinking I could do some fun networking experiments with containers = listToAttrs (genList (idx: { name = "c${toString idx}"; value = /* some container config */; };) 100);, but the time this takes to evaluate is ridiculous. 04:49:14
@prism019:matrix.orgPrism019Redacted or Malformed Event05:25:39
@julius:mtx.liftm.deˈt͡sɛːzaɐ̯Yay, https://github.com/NixOS/nixpkgs/blob/12228ff1752d7b7624a54e9c1af4b222b3c1073b/nixos/modules/virtualisation/nixos-containers.nix#L846-L847 doesn't escape the interface names, so if your interface has a -, the container won't start..05:26:10
@julius:mtx.liftm.deˈt͡sɛːzaɐ̯* Yay, https://github.com/NixOS/nixpkgs/blob/12228ff1752d7b7624a54e9c1af4b222b3c1073b/nixos/modules/virtualisation/nixos-containers.nix#L846-L847 doesn't escape the interface names, so if your interface has a -, the container won't start.. (Time to write a bug report…)05:26:26
@prism019:matrix.orgPrism019Apologies for that, phone was unlocked in my pocket.05:28:59
@julius:mtx.liftm.deˈt͡sɛːzaɐ̯ ("Talk to the hand" was common phrase in my school days to shut someone up. Now I talked to the butt. ;)) 05:32:56
@justastream:matrix.orgStream joined the room.09:45:15
@justastream:matrix.orgStreamhey friends09:45:22
@justastream:matrix.orgStream

I'm really hoping some of you have the technical know-how to help me here, because I really don't want to uninstall NixOs!

For simplicity, all I want is a global install of rustup or oxalica/rust-overlay so I can write Rust code again!

I've got Rust compiling in shell.nix but I'm keen on a global install (I'm a full time Rust engineer) that plays nice with my RustRover IDE.

Setup:

  • OS: NixOs
  • Flakes: enabled
  • IDE: RustRover

Can someone please please help me? I took two days off this week to contribute to OSS and all I've managed is to beat my head against a Nix wall 🙏

09:58:00
@k900:0upti.meK900 Generally, adding rustup to environment.systemPackages should mostly work 09:58:42
@k900:0upti.meK900But also, generally, you don't actually want a system-wide install09:58:54
@justastream:matrix.orgStream

Oh, forgot to add, my "rustup environment.systemPackages" doesn't work because:

  The system library `openssl` required by crate `openssl-sys` was not found.
  The file `openssl.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.
  The PKG_CONFIG_PATH environment variable is not set.

  HINT: if you have installed the library, try setting PKG_CONFIG_PATH to the directory containing `openssl.pc`.


  --- stderr
  thread 'main' panicked at /home/justastream/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-sys-0.9.103/build/find_normal.rs:190:5:


  Could not find directory of OpenSSL installation, and this `-sys` crate cannot
  proceed without this knowledge. If OpenSSL is installed and this crate had
  trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
  compilation process.

  Make sure you also have the development packages of openssl installed.
  For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.

  If you're in a situation where you think the directory *should* be found
  automatically, please open a bug at https://github.com/sfackler/rust-openssl
  and include information about your system as well as this message.

  $HOST = x86_64-unknown-linux-gnu
  $TARGET = x86_64-unknown-linux-gnu
  openssl-sys = 0.9.103


  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
10:00:14
@k900:0upti.meK900That's not a rustup issue10:00:23
@k900:0upti.meK900That's basically the reason you don't want a system-wide install10:00:34
@k900:0upti.meK900It's trying to find openssl, which is a C library10:00:41
@k900:0upti.meK900Which is generally not something Nix is designed to provide access to system-wdie10:00:53
@k900:0upti.meK900* Which is generally not something Nix is designed to provide access to system-wide10:00:55

Show newer messages


Back to Room ListRoom Version: 6