ditch crate2nix, use fenix instead of oxalica/rust-overlay

This commit is contained in:
xenofem 2022-12-09 16:10:22 -05:00
parent b10ee2d2d9
commit 039ceeed05

View file

@ -4,14 +4,10 @@
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
crate2nix = {
url = "github:kolloch/crate2nix";
flake = false;
};
fenix.url = "github:nix-community/fenix";
};
outputs = { self, nixpkgs, utils, rust-overlay, crate2nix }: let
outputs = { self, nixpkgs, utils, fenix }: let
name = "poop-graph";
in
utils.lib.eachDefaultSystem
@ -19,22 +15,13 @@
let
pkgs = import nixpkgs {
inherit system;
overlays = [
rust-overlay.overlays.default
(final: prev: {
rustc = final.rust-bin.stable.latest.default;
cargo = final.rust-bin.stable.latest.default;
})
];
overlays = [ fenix.overlays.default ];
};
fenixStable = fenix.packages.${system}.stable;
fenixPlatform = pkgs.makeRustPlatform {
cargo = fenixStable.toolchain;
rustc = fenixStable.toolchain;
};
inherit (import "${crate2nix}/tools.nix" { inherit pkgs; })
generatedCargoNix;
project = import
(generatedCargoNix {
inherit name;
src = ./.;
})
{ inherit pkgs; };
in rec {
packages.${name} = pkgs.symlinkJoin {
inherit name;
@ -48,11 +35,25 @@
defaultPackage = packages.${name};
packages."${name}-unwrapped" = project.rootCrate.build;
packages."${name}-unwrapped" = let
cargoTOML = builtins.fromTOML (builtins.readFile ./Cargo.toml);
in fenixPlatform.buildRustPackage {
pname = name;
inherit (cargoTOML.package) version;
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
};
devShell = pkgs.mkShell {
nativeBuildInputs = with pkgs; [ rustc cargo cargo-audit stdenv.cc ];
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
devShell = with pkgs; let
fenixWith = fenixStable.withComponents [
"cargo"
"clippy"
"rust-src"
"rustc"
"rustfmt"
];
in mkShell {
nativeBuildInputs = [ fenixWith cargo-audit stdenv.cc ];
};
}
);