refactor!: improve rust flake further

This commit is contained in:
Moritz Böhme 2025-06-12 17:02:56 +02:00
parent 6a45c8c099
commit e9832d91b2
No known key found for this signature in database
GPG key ID: 970C6E89EB0547A9
3 changed files with 28 additions and 20 deletions

View file

@ -1,10 +0,0 @@
# This line needs to come before anything else in Cargo.toml
cargo-features = ["codegen-backend"]
[package]
name = "example"
version = "0.1.0"
edition = "2024"
[profile.dev]
codegen-backend = "cranelift"

View file

@ -2,7 +2,14 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
rust-overlay.url = "github:oxalica/rust-overlay";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
# wild = {
# url = "github:davidlattimore/wild";
# inputs.nixpkgs.follows = "nixpkgs";
# };
};
outputs = inputs:
@ -39,7 +46,8 @@
mkDevShell = rustc:
pkgs.mkShell.override {
stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.clangStdenv;
stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.stdenv;
# stdenv = pkgs.useWildLinker pkgs.stdenv;
} {
shellHook = ''
export RUST_SRC_PATH=${pkgs.rustPlatform.rustLibSrc}
@ -50,7 +58,10 @@
in {
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
overlays = [(import inputs.rust-overlay)];
overlays = [
(import inputs.rust-overlay)
# inputs.wild.overlays.default
];
};
packages.default = self'.packages.example;
@ -58,10 +69,20 @@
packages.example = rustPackage "";
devShells.nightly = mkDevShell ((pkgs.rust-bin.selectLatestNightlyWith
(toolchain: toolchain.default)).override {
extensions = ["rustc-codegen-cranelift-preview"];
});
devShells.nightly = let
nightly = (pkgs.rust-bin.selectLatestNightlyWith
(toolchain: toolchain.default)).override {
extensions = ["rustc-codegen-cranelift-preview"];
};
devShell = mkDevShell nightly;
in
devShell.overrideAttrs (old: {
shellHook =
old.shellHook or ""
+ ''
export RUSTFLAGS="-Zcodegen-backend=cranelift"
'';
});
devShells.stable = mkDevShell pkgs.rust-bin.stable.latest.default;
devShells.msrv = mkDevShell pkgs.rust-bin.stable.${msrv}.default;
};

View file

@ -1,3 +0,0 @@
fn main() {
println!("Hello World!")
}