From eda2fb0acf19654c6f8d07c3d5ca7863d9b1577a Mon Sep 17 00:00:00 2001 From: Etienne Wodey Date: Wed, 24 Apr 2024 14:58:55 +0200 Subject: [PATCH] Add rustup toolchain file --- flake.lock | 58 +++++++++++++++++++++++++++++++++++++-------- flake.nix | 34 +++++++++----------------- rust-toolchain.toml | 6 +++++ 3 files changed, 65 insertions(+), 33 deletions(-) create mode 100644 rust-toolchain.toml diff --git a/flake.lock b/flake.lock index f8dc803..e95a158 100644 --- a/flake.lock +++ b/flake.lock @@ -1,18 +1,20 @@ { "nodes": { - "mozilla-overlay": { - "flake": false, + "flake-utils": { + "inputs": { + "systems": "systems" + }, "locked": { - "lastModified": 1638887313, - "narHash": "sha256-FMYV6rVtvSIfthgC1sK1xugh3y7muoQcvduMdriz4ag=", - "owner": "mozilla", - "repo": "nixpkgs-mozilla", - "rev": "7c1e8b1dd6ed0043fb4ee0b12b815256b0b9de6f", + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", "type": "github" }, "original": { - "owner": "mozilla", - "repo": "nixpkgs-mozilla", + "owner": "numtide", + "repo": "flake-utils", "type": "github" } }, @@ -34,11 +36,32 @@ }, "root": { "inputs": { - "mozilla-overlay": "mozilla-overlay", "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay", "src-migen": "src-migen" } }, + "rust-overlay": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1713924823, + "narHash": "sha256-kOeyS3GFwgnKvzuBMmFqEAX0xwZ7Nj4/5tXuvpZ0d4U=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "8a2edac3ae926a2a6ce60f4595dcc4540fc8cad4", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" + } + }, "src-migen": { "flake": false, "locked": { @@ -54,6 +77,21 @@ "repo": "migen", "type": "github" } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 6a06127..76e6475 100644 --- a/flake.nix +++ b/flake.nix @@ -2,16 +2,15 @@ description = "Firmware for MQTT-controlled 4-channel DDS signal generator using Urukul, Humpback and STM32 NUCLEO."; inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-21.11; - inputs.mozilla-overlay = { url = github:mozilla/nixpkgs-mozilla; flake = false; }; + inputs.rust-overlay.url = github:oxalica/rust-overlay; + inputs.rust-overlay.inputs.nixpkgs.follows = "nixpkgs"; inputs.src-migen = { url = github:m-labs/migen; flake = false; }; - outputs = { self, nixpkgs, mozilla-overlay, src-migen }: + outputs = { self, nixpkgs, rust-overlay, src-migen }: let - pkgs = import nixpkgs { system = "x86_64-linux"; overlays = [ (import mozilla-overlay) ]; }; - rustManifest = pkgs.fetchurl { - url = "https://static.rust-lang.org/dist/2020-10-30/channel-rust-nightly.toml"; - sha256 = "0iygcwzh8s0lfdghj5809krvzifc1ii1wm4sd3qqn7s0rz1s14hi"; - }; + pkgs = import nixpkgs { system = "x86_64-linux"; overlays = [ (import rust-overlay) ]; }; + + rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; migen = pkgs.python3Packages.buildPythonPackage rec { name = "migen"; @@ -19,21 +18,10 @@ propagatedBuildInputs = [ pkgs.python3Packages.colorama ]; }; - targets = [ - "thumbv7em-none-eabihf" - ]; - rustChannelOfTargets = _channel: _date: targets: - (pkgs.lib.rustLib.fromManifestFile rustManifest { - inherit (pkgs) stdenv lib fetchurl patchelf; - }).rust.override { - inherit targets; - extensions = ["rust-src"]; - }; - rust = rustChannelOfTargets "nightly" null targets; - rustPlatform = pkgs.recurseIntoAttrs (pkgs.makeRustPlatform { - rustc = rust; - cargo = rust; - }); + rustPlatform = pkgs.makeRustPlatform { + rustc = rustToolchain; + cargo = rustToolchain; + }; itm = rustPlatform.buildRustPackage rec { version = "0.3.1"; @@ -142,4 +130,4 @@ }; defaultPackage.x86_64-linux = humpback-dds; }; -} \ No newline at end of file +} diff --git a/rust-toolchain.toml b/rust-toolchain.toml new file mode 100644 index 0000000..22512b8 --- /dev/null +++ b/rust-toolchain.toml @@ -0,0 +1,6 @@ +[toolchain] +channel = "nightly-2020-10-30" +targets = [ + "thumbv7em-none-eabihf", +] +profile = "minimal"