From 44e9130010a0eb74c94a10a934eed1032d0c0aef Mon Sep 17 00:00:00 2001 From: atse Date: Tue, 25 Jun 2024 15:46:25 +0800 Subject: [PATCH] Use oxalica's rust-overlay Follow ARTIQ, and in this project lets us include the version number directly in flake.nix instead of linking to the toml file of a specific release date, as we use stable Rust. Also, from nixpkgs manual: both oxalica's overlay and fenix better integrate with nix and cache optimizations. Because of this and ergonomics, either of those community projects should be preferred to the Mozilla's Rust overlay (nixpkgs-mozilla). --- flake.lock | 40 ++++++++++++++++++++++------------------ flake.nix | 33 +++++++++++++-------------------- 2 files changed, 35 insertions(+), 38 deletions(-) diff --git a/flake.lock b/flake.lock index 79fe89d..b5a5ff0 100644 --- a/flake.lock +++ b/flake.lock @@ -1,21 +1,5 @@ { "nodes": { - "mozilla-overlay": { - "flake": false, - "locked": { - "lastModified": 1690536331, - "narHash": "sha256-aRIf2FB2GTdfF7gl13WyETmiV/J7EhBGkSWXfZvlxcA=", - "owner": "mozilla", - "repo": "nixpkgs-mozilla", - "rev": "db89c8707edcffefcd8e738459d511543a339ff5", - "type": "github" - }, - "original": { - "owner": "mozilla", - "repo": "nixpkgs-mozilla", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1691421349, @@ -34,8 +18,28 @@ }, "root": { "inputs": { - "mozilla-overlay": "mozilla-overlay", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "rust-overlay": "rust-overlay" + } + }, + "rust-overlay": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1719281921, + "narHash": "sha256-LIBMfhM9pMOlEvBI757GOK5l0R58SRi6YpwfYMbf4yc=", + "owner": "oxalica", + "repo": "rust-overlay", + "rev": "b6032d3a404d8a52ecfc8571ff0c26dfbe221d07", + "type": "github" + }, + "original": { + "owner": "oxalica", + "repo": "rust-overlay", + "type": "github" } } }, diff --git a/flake.nix b/flake.nix index 803e774..203351d 100644 --- a/flake.nix +++ b/flake.nix @@ -2,31 +2,24 @@ description = "Firmware for the Sinara 8451 Thermostat"; inputs.nixpkgs.url = github:NixOS/nixpkgs/nixos-23.05; - inputs.mozilla-overlay = { url = github:mozilla/nixpkgs-mozilla; flake = false; }; + inputs.rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; - outputs = { self, nixpkgs, mozilla-overlay }: + outputs = { self, nixpkgs, rust-overlay }: let - pkgs = import nixpkgs { system = "x86_64-linux"; overlays = [ (import mozilla-overlay) ]; }; - rustManifest = pkgs.fetchurl { - url = "https://static.rust-lang.org/dist/2022-12-15/channel-rust-stable.toml"; - hash = "sha256-S7epLlflwt0d1GZP44u5Xosgf6dRrmr8xxC+Ml2Pq7c="; - }; + pkgs = import nixpkgs { system = "x86_64-linux"; overlays = [ (import rust-overlay) ]; }; - 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 "stable" null targets; - rustPlatform = pkgs.recurseIntoAttrs (pkgs.makeRustPlatform { + rust = pkgs.rust-bin.stable."1.66.0".default.override { + extensions = [ "rust-src" ]; + targets = [ "thumbv7em-none-eabihf" ]; + }; + rustPlatform = pkgs.makeRustPlatform { rustc = rust; cargo = rust; - }); + }; + thermostat = rustPlatform.buildRustPackage { name = "thermostat"; version = "0.0.0"; -- 2.44.1