From a5c0301ee877051d4b94bece816bc03eb071da78 Mon Sep 17 00:00:00 2001 From: Emily Date: Wed, 19 Feb 2025 20:12:22 +0000 Subject: [PATCH] flake: use stock Nixpkgs Rust toolchain MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This makes it easier to use Nixpkgs’ cross‐compilation machinery and simplifies the flake. --- .cargo/config.toml | 3 --- flake.lock | 38 -------------------------------------- flake.nix | 38 +++++++++----------------------------- 3 files changed, 9 insertions(+), 70 deletions(-) delete mode 100644 .cargo/config.toml diff --git a/.cargo/config.toml b/.cargo/config.toml deleted file mode 100644 index c7f99cb..0000000 --- a/.cargo/config.toml +++ /dev/null @@ -1,3 +0,0 @@ -# For -Zbuild-std -[target.aarch64-unknown-linux-musl] -rustflags = ["-C", "target-feature=+crt-static", "-C", "link-arg=-lgcc"] diff --git a/flake.lock b/flake.lock index 9d24d6b..04a1796 100644 --- a/flake.lock +++ b/flake.lock @@ -15,26 +15,6 @@ "type": "github" } }, - "fenix": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ], - "rust-analyzer-src": "rust-analyzer-src" - }, - "locked": { - "lastModified": 1738391509, - "narHash": "sha256-TC3xA++KgprECm/WPsLUd+a77MObZPElCW6eAsjVW1k=", - "rev": "de3ea31eb651b663449361f77d9c1e8835290470", - "revCount": 2156, - "type": "tarball", - "url": "https://api.flakehub.com/f/pinned/nix-community/fenix/0.1.2156%2Brev-de3ea31eb651b663449361f77d9c1e8835290470/0194c095-0041-7b9c-b19e-cf1c4a2adaad/source.tar.gz" - }, - "original": { - "type": "tarball", - "url": "https://flakehub.com/f/nix-community/fenix/0.1.1727.tar.gz" - } - }, "flake-compat": { "flake": false, "locked": { @@ -190,27 +170,9 @@ "root": { "inputs": { "crane": "crane", - "fenix": "fenix", "nix": "nix", "nixpkgs": "nixpkgs_2" } - }, - "rust-analyzer-src": { - "flake": false, - "locked": { - "lastModified": 1738224931, - "narHash": "sha256-1zhfA5NBqin0Z79Se85juvqQteq7uClJMEb7l2pdDUY=", - "owner": "rust-lang", - "repo": "rust-analyzer", - "rev": "3c2aca1e5e9fbabb4e05fc4baa62e807aadc476a", - "type": "github" - }, - "original": { - "owner": "rust-lang", - "ref": "nightly", - "repo": "rust-analyzer", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 49efdb5..f9e4ebc 100644 --- a/flake.nix +++ b/flake.nix @@ -4,11 +4,6 @@ inputs = { nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.tar.gz"; - fenix = { - url = "https://flakehub.com/f/nix-community/fenix/0.1.1727.tar.gz"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - # Pinned to `master` until a release containing # is cut. crane.url = "github:ipetkov/crane"; @@ -16,7 +11,7 @@ nix.url = "https://flakehub.com/f/NixOS/nix/2.tar.gz"; }; - outputs = { self, nixpkgs, fenix, crane, ... }@inputs: + outputs = { self, nixpkgs, crane, ... }@inputs: let supportedSystems = [ "aarch64-linux" @@ -35,27 +30,12 @@ inherit (pkgs) lib; inherit system; }); - - fenixToolchain = system: with fenix.packages.${system}; - combine ([ - stable.clippy - stable.rustc - stable.cargo - stable.rustfmt - stable.rust-src - stable.rust-analyzer - ] ++ nixpkgs.lib.optionals (system == "x86_64-linux") [ - targets.x86_64-unknown-linux-musl.stable.rust-std - ] ++ nixpkgs.lib.optionals (system == "aarch64-linux") [ - targets.aarch64-unknown-linux-musl.stable.rust-std - ]); in { overlays.default = final: prev: let - toolchain = fenixToolchain final.hostPlatform.system; - craneLib = (crane.mkLib final).overrideToolchain toolchain; + craneLib = crane.mkLib final; crateName = craneLib.crateNameFromCargoToml { cargoToml = ./magic-nix-cache/Cargo.toml; }; @@ -122,14 +102,14 @@ createChain 200 startFile; }); - devShells = forEachSupportedSystem ({ system, pkgs, lib }: - let - toolchain = fenixToolchain system; - in - { + devShells = forEachSupportedSystem ({ system, pkgs, lib }: { default = pkgs.mkShell { packages = with pkgs; [ - toolchain + rustc + cargo + clippy + rustfmt + rust-analyzer nix # for linking attic boost # for linking attic @@ -149,7 +129,7 @@ ]; NIX_CFLAGS_LINK = lib.optionalString pkgs.stdenv.isDarwin "-lc++abi"; - RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library"; + RUST_SRC_PATH = "${pkgs.rustPlatform.rustcSrc}/library"; }; }); };