direnv allow
produces this error on a flake that I think was working fine before:
error: attempt to call something which is not a function but a set: { appendCrateRegistries = «thunk»; buildDepsOnly = «thunk»; buildPackage = «thunk»; buildTrunkPackage = «thunk»; callPackage = «thunk»; cargo = «thunk»; cargoAudit = «thunk»; cargoBuild = «thunk»; cargoClippy = «thunk»; cargoDeny = «thunk»; «48 attributes elided» }
at /nix/store/7h196hqmxizdbiidmnbjwydy5x4kszlq-source/flake.nix:36:22:
35| inherit (pkgs) lib;
36| craneLib = (crane.mkLib pkgs).overrideToolchain
| ^
37| fenix.packages.${system}.fromManifestFile ./rust-toolchain.toml;
direnv: nix-direnv: Evaluating current devShell failed. Falling back to previous environment!
direnv: export +NIX_DIRENV_DID_FALLBACK ~PATH
Same error on my other nix machine. I am quite inexperienced with nix, so I’m questioning how I ever got my environment working in the first place since I can compile to wasm32 targets just fine. It’s possible I got my environment working with a valid flake but committed unverified changes… but that has me questioning my sanity a bit . Or maybe something did change outside of my control.
This is the commit that breaks things: Add wasm32-unknown-unknown target
I remembered struggling getting crane.mkLib
to work in that commit. Specifically I was having some errors related to lib which I fixed by adding inherit (pkgs) lib
as shown in the crane quick start example.
I assume updates to my inputs were to blame for the latter issue I fixed, but what is to blame for my current issue?
Here’s my full flake:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
crane = {
url = "github:ipetkov/crane";
inputs = {
flake-utils.follows = "flake-utils";
nixpkgs.follows = "nixpkgs";
};
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs = {
nixpkgs.follows = "nixpkgs";
flake-utils.follows = "flake-utils";
};
};
fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.rust-analyzer-src.follows = "";
};
};
outputs = { self, nixpkgs, crane, fenix, flake-utils, rust-overlay }:
flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
inherit (pkgs) lib;
craneLib = (crane.mkLib pkgs).overrideToolchain
fenix.packages.${system}.fromManifestFile ./rust-toolchain.toml;
buildInputs = with pkgs; [
# Dev tools
nixd
# Build tools
pkg-config
] ++ lib.optionals stdenv.isLinux [
alsa-lib
libxkbcommon
udev
vulkan-loader
wayland
xorg.libX11
xorg.libXcursor
xorg.libXi
xorg.libXrandr
] ++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk_11_0.frameworks.Cocoa
rustPlatform
];
in
{
devShells.default = craneLib.devShell {
inherit buildInputs;
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
RUSTFLAGS="-Z crate-attr=feature(const_trait_impl)";
};
}
);
}