91 lines
2.9 KiB
Nix
91 lines
2.9 KiB
Nix
{
|
|
inputs = {
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
|
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
|
|
rust-overlay = {
|
|
url = "github:oxalica/rust-overlay";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
# wild = {
|
|
# url = "github:davidlattimore/wild";
|
|
# inputs.nixpkgs.follows = "nixpkgs";
|
|
# };
|
|
};
|
|
|
|
outputs = inputs:
|
|
inputs.flake-parts.lib.mkFlake {inherit inputs;} {
|
|
systems = ["x86_64-linux"];
|
|
perSystem = {
|
|
self',
|
|
pkgs,
|
|
system,
|
|
...
|
|
}: let
|
|
runtimeDeps = with pkgs; [];
|
|
buildDeps = with pkgs; [pkg-config rustPlatform.bindgenHook];
|
|
devDeps = with pkgs; [bacon];
|
|
|
|
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
|
msrv = cargoToml.package.rust-version;
|
|
|
|
rustPackage = features:
|
|
(pkgs.makeRustPlatform {
|
|
cargo = pkgs.rust-bin.stable.latest.minimal;
|
|
rustc = pkgs.rust-bin.stable.latest.minimal;
|
|
}).buildRustPackage {
|
|
inherit (cargoToml.package) name version;
|
|
src = ./.;
|
|
cargoLock.lockFile = ./Cargo.lock;
|
|
buildFeatures = features;
|
|
buildInputs = runtimeDeps;
|
|
nativeBuildInputs = buildDeps;
|
|
# Uncomment if your cargo tests require networking or otherwise
|
|
# don't play nicely with the Nix build sandbox:
|
|
# doCheck = false;
|
|
};
|
|
|
|
mkDevShell = rustc:
|
|
pkgs.mkShell.override {
|
|
stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.stdenv;
|
|
# stdenv = pkgs.useWildLinker pkgs.stdenv;
|
|
} {
|
|
shellHook = ''
|
|
export RUST_SRC_PATH=${pkgs.rustPlatform.rustLibSrc}
|
|
'';
|
|
buildInputs = runtimeDeps;
|
|
nativeBuildInputs = buildDeps ++ devDeps ++ [rustc];
|
|
};
|
|
in {
|
|
_module.args.pkgs = import inputs.nixpkgs {
|
|
inherit system;
|
|
overlays = [
|
|
(import inputs.rust-overlay)
|
|
# inputs.wild.overlays.default
|
|
];
|
|
};
|
|
|
|
packages.default = self'.packages.example;
|
|
devShells.default = self'.devShells.nightly;
|
|
|
|
packages.example = rustPackage "";
|
|
|
|
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;
|
|
};
|
|
};
|
|
}
|