diff --git a/flake.nix b/flake.nix index e49dc4b..1f661a1 100644 --- a/flake.nix +++ b/flake.nix @@ -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 ]; }; } );