fix my shit ahh flake

This commit is contained in:
do butterflies cry? 2026-03-13 23:20:38 +10:00
parent 25465a9f48
commit 4508aeab76
Signed by: cry
GPG key ID: F68745A836CA0412
2 changed files with 78 additions and 64 deletions

39
flake.lock generated
View file

@ -1,26 +1,5 @@
{
"nodes": {
"fenix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
],
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1773299640,
"narHash": "sha256-kTsZ5xGZqaeJ8jWsfZNACo/VsW3riVuIQEPWVGiqWKM=",
"owner": "nix-community",
"repo": "fenix",
"rev": "8ac78ff968869cd05d9cb42fbf63bdbc6851ec19",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1773222311,
@ -39,28 +18,10 @@
},
"root": {
"inputs": {
"fenix": "fenix",
"nixpkgs": "nixpkgs",
"systems": "systems"
}
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1773194001,
"narHash": "sha256-50PPXBtH2xfKuNfQfUNOyuIFgZPEz5QVertQWS2MQJE=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "8ed3cca4d30610fd0d3c1179c85418de2dc0a7c1",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,

103
flake.nix
View file

@ -4,9 +4,6 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
systems.url = "github:nix-systems/default";
fenix.url = "github:nix-community/fenix";
fenix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = {
@ -38,36 +35,92 @@
devShells = forAllSystems (
{
system,
pkgs,
lib,
...
}: {
default = pkgs.mkShell rec {
shell = "${pkgs.bash}/bin/bash";
strictDeps = true;
default = let
nixForBindings = pkgs.nixVersions.nix_2_32;
inherit (pkgs.rustc) llvmPackages;
in
pkgs.mkShell rec {
name = "nixide";
shell = "${pkgs.bash}/bin/bash";
strictDeps = true;
packages = with pkgs; [
cargo
rustc
inputs.fenix.packages.${system}.complete.rustfmt
];
# packages we need at runtime
packages = with pkgs; [
rustc
llvmPackages.lld
lldb
# packages we should be able to link against
buildInputs = with pkgs; [
# pipewire.dev
# libxkbcommon
# wayland
];
cargo
# cargo-c
cargo-llvm-cov
cargo-nextest
# packages we run at build time / shellHook
nativeBuildInputs = with pkgs; [
pkg-config
rustPlatform.bindgenHook
];
rust-analyzer-unwrapped
(rustfmt.override {asNightly = true;})
clippy
taplo
];
LD_LIBRARY_PATH = "$LD_LIBRARY_PATH:${builtins.toString (lib.makeLibraryPath buildInputs)}";
};
# packages we need at build time
nativeBuildInputs = with pkgs; [
pkg-config
glibc.dev
nixForBindings.dev
rustPlatform.bindgenHook
];
# packages we link against
buildInputs = with pkgs; [
stdenv.cc
nixForBindings
];
# bindgen uses clang to generate bindings, but it doesn't know where to
# find our stdenv cc's headers, so when it's gcc, we need to tell it.
postConfigure = lib.optionalString pkgs.stdenv.cc.isGNU ''
#!/usr/bin/env bash
# REF: https://github.com/nixops4/nix-bindings-rust/blob/main/bindgen-gcc.sh
# Rust bindgen uses Clang to generate bindings, but that means that it can't
# find the "system" or compiler headers when the stdenv compiler is GCC.
# This script tells it where to find them.
echo "Extending BINDGEN_EXTRA_CLANG_ARGS with system include paths..." 2>&1
BINDGEN_EXTRA_CLANG_ARGS="$${BINDGEN_EXTRA_CLANG_ARGS:-}"
export BINDGEN_EXTRA_CLANG_ARGS
include_paths=$(
echo | $NIX_CC_UNWRAPPED -v -E -x c - 2>&1 \
| awk '/#include <...> search starts here:/{flag=1;next} \
/End of search list./{flag=0} \
flag==1 {print $1}'
)
for path in $include_paths; do
echo " - $path" 2>&1
BINDGEN_EXTRA_CLANG_ARGS="$BINDGEN_EXTRA_CLANG_ARGS -I$path"
done
'';
shellHook = postConfigure;
env = let
inherit (llvmPackages) llvm libclang;
in {
LD_LIBRARY_PATH = "$LD_LIBRARY_PATH:${builtins.toString (lib.makeLibraryPath buildInputs)}";
LIBCLANG_PATH = "${libclang.lib}/lib";
RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}";
BINDGEN_EXTRA_CLANG_ARGS = "--sysroot=${pkgs.glibc.dev}";
# `cargo-llvm-cov` reads these environment variables to find these binaries,
# which are needed to run the tests
LLVM_COV = "${llvm}/bin/llvm-cov";
LLVM_PROFDATA = "${llvm}/bin/llvm-profdata";
};
};
}
);
};