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

main
xenofem 2022-12-09 16:10:22 -05:00
parent b10ee2d2d9
commit 039ceeed05
1 changed files with 26 additions and 25 deletions

View File

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