use rust-overlay
This commit is contained in:
29
flake.lock
generated
29
flake.lock
generated
@@ -2,11 +2,11 @@
|
|||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1775373274,
|
"lastModified": 1775403759,
|
||||||
"narHash": "sha256-rL4F2+/ixLRzbgewGRpxTqfQNmaHi+VbLTkUcedyZRw=",
|
"narHash": "sha256-cGyKiTspHEUx3QwAnV3RfyT+VOXhHLs+NEr17HU34Wo=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "bd48fcede9287ff448ecc84c4e94a4fca4bd0d72",
|
"rev": "5e11f7acce6c3469bef9df154d78534fa7ae8b6c",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -18,7 +18,28 @@
|
|||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs",
|
||||||
|
"rust-overlay": "rust-overlay"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rust-overlay": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1775445266,
|
||||||
|
"narHash": "sha256-3fgIj85WHQbOamrpIw9WY3ZL1PoEvjPOjmzMYNsEQJo=",
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"rev": "61747bc3cf2da179b9af356ae9e70f3b895b0c24",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"type": "github"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
24
flake.nix
24
flake.nix
@@ -1,23 +1,31 @@
|
|||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
||||||
|
rust-overlay = {
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
url = "github:oxalica/rust-overlay";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
outputs = {nixpkgs, ...}: let
|
outputs = {
|
||||||
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
nixpkgs,
|
||||||
esp-rs = pkgs.callPackage ./nix/esp-rs.nix {};
|
rust-overlay,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
pkgs = import nixpkgs {
|
||||||
|
system = "x86_64-linux";
|
||||||
|
overlays = [(import rust-overlay)];
|
||||||
|
};
|
||||||
|
rust-bin = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
||||||
in {
|
in {
|
||||||
devShells.x86_64-linux.default = pkgs.mkShell {
|
devShells.x86_64-linux.default = pkgs.mkShell {
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
pkgs.pkg-config
|
|
||||||
pkgs.libudev-zero
|
|
||||||
pkgs.libusb1
|
|
||||||
pkgs.espflash
|
pkgs.espflash
|
||||||
pkgs.esp-generate
|
pkgs.esp-generate
|
||||||
pkgs.rust-analyzer
|
pkgs.rust-analyzer
|
||||||
esp-rs
|
rust-bin
|
||||||
];
|
];
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
export RUSTUP_TOOLCHAIN=${esp-rs}
|
export RUSTUP_TOOLCHAIN=${rust-bin}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
178
nix/esp-rs.nix
178
nix/esp-rs.nix
@@ -1,178 +0,0 @@
|
|||||||
# MIT licensed
|
|
||||||
# code taken from https://git.sr.ht/~olk/esp-rs-nix/blob/main/esp-rs.nix
|
|
||||||
{
|
|
||||||
pkgs ? import <nixpkgs> {},
|
|
||||||
lib ? pkgs.lib,
|
|
||||||
}: let
|
|
||||||
versions = {
|
|
||||||
esp-rust = {
|
|
||||||
version = "1.93.0.0";
|
|
||||||
hash = "sha256-837shgsDonrmUqZsIhUoR+93IR8tUat67PiHfShilJc=";
|
|
||||||
};
|
|
||||||
rust-src = {
|
|
||||||
version = "1.93.0.0";
|
|
||||||
hash = "sha256-upKiKRDvubE8obME4OVewTr6PjS/p0QOqjpQfEWBfE0=";
|
|
||||||
};
|
|
||||||
gcc = {
|
|
||||||
version = "14.2.0_20241119";
|
|
||||||
xtensa-hash = "sha256-pX2KCnUoGZtgqFmZEuNRJxDMQgqYYPRpswL3f3T0nWE=";
|
|
||||||
riscv32-hash = "sha256-67O34FYUnVG2nfkfQj2yH874qDSYx4F/16xxPi0kNbY=";
|
|
||||||
};
|
|
||||||
defaultArch = "x86_64-unknown-linux-gnu";
|
|
||||||
gccArch = "x86_64-linux-gnu";
|
|
||||||
};
|
|
||||||
|
|
||||||
mkGccToolchain = {
|
|
||||||
name,
|
|
||||||
arch,
|
|
||||||
hash,
|
|
||||||
}:
|
|
||||||
pkgs.stdenv.mkDerivation {
|
|
||||||
pname = "esp-${name}-gcc";
|
|
||||||
version = versions.gcc.version;
|
|
||||||
|
|
||||||
src = pkgs.fetchzip {
|
|
||||||
url = "https://github.com/espressif/crosstool-NG/releases/download/esp-${versions.gcc.version}/${arch}-esp-elf-${versions.gcc.version}-${versions.gccArch}.tar.xz";
|
|
||||||
inherit hash;
|
|
||||||
};
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
runHook preInstall
|
|
||||||
mkdir -p $out
|
|
||||||
cp -r ./* $out/
|
|
||||||
runHook postInstall
|
|
||||||
'';
|
|
||||||
|
|
||||||
meta = with lib; {
|
|
||||||
description = "ESP32 ${name} GCC toolchain";
|
|
||||||
homepage = "https://github.com/espressif/crosstool-NG";
|
|
||||||
license = licenses.gpl2Plus;
|
|
||||||
platforms = ["x86_64-linux"];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
esp-rust-build = pkgs.stdenv.mkDerivation {
|
|
||||||
pname = "esp-rust-build";
|
|
||||||
version = versions.esp-rust.version;
|
|
||||||
|
|
||||||
src = pkgs.fetchzip {
|
|
||||||
url = "https://github.com/esp-rs/rust-build/releases/download/v${versions.esp-rust.version}/rust-${versions.esp-rust.version}-${versions.defaultArch}.tar.xz";
|
|
||||||
hash = versions.esp-rust.hash;
|
|
||||||
};
|
|
||||||
|
|
||||||
nativeBuildInputs = with pkgs; [autoPatchelfHook];
|
|
||||||
buildInputs = with pkgs; [
|
|
||||||
stdenv.cc.cc
|
|
||||||
zlib
|
|
||||||
];
|
|
||||||
|
|
||||||
patchPhase = ''
|
|
||||||
patchShebangs ./install.sh
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
runHook preInstall
|
|
||||||
mkdir -p $out
|
|
||||||
./install.sh --destdir=$out --prefix="" --disable-ldconfig --without=rust-docs-json-preview,rust-docs
|
|
||||||
runHook postInstall
|
|
||||||
'';
|
|
||||||
|
|
||||||
meta = with lib; {
|
|
||||||
description = "ESP32 Rust toolchain";
|
|
||||||
homepage = "https://github.com/esp-rs/rust-build";
|
|
||||||
license = with licenses; [
|
|
||||||
mit
|
|
||||||
asl20
|
|
||||||
];
|
|
||||||
platforms = ["x86_64-linux"];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
esp-xtensa-gcc = mkGccToolchain {
|
|
||||||
name = "xtensa";
|
|
||||||
arch = "xtensa";
|
|
||||||
hash = versions.gcc.xtensa-hash;
|
|
||||||
};
|
|
||||||
|
|
||||||
esp-riscv32-gcc = mkGccToolchain {
|
|
||||||
name = "riscv32";
|
|
||||||
arch = "riscv32";
|
|
||||||
hash = versions.gcc.riscv32-hash;
|
|
||||||
};
|
|
||||||
|
|
||||||
rust-src = pkgs.fetchzip {
|
|
||||||
url = "https://github.com/esp-rs/rust-build/releases/download/v${versions.rust-src.version}/rust-src-${versions.rust-src.version}.tar.xz";
|
|
||||||
hash = versions.rust-src.hash;
|
|
||||||
};
|
|
||||||
|
|
||||||
esp-rs-base = pkgs.symlinkJoin {
|
|
||||||
name = "esp-rs-base-${versions.esp-rust.version}";
|
|
||||||
paths = [
|
|
||||||
esp-rust-build
|
|
||||||
esp-xtensa-gcc
|
|
||||||
esp-riscv32-gcc
|
|
||||||
];
|
|
||||||
meta = {
|
|
||||||
description = "Base ESP32 toolchain components";
|
|
||||||
platforms = ["x86_64-linux"];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
pkgs.stdenv.mkDerivation {
|
|
||||||
pname = "esp-rs";
|
|
||||||
version = versions.esp-rust.version;
|
|
||||||
|
|
||||||
src = rust-src;
|
|
||||||
|
|
||||||
nativeBuildInputs = with pkgs; [
|
|
||||||
autoPatchelfHook
|
|
||||||
pkg-config
|
|
||||||
];
|
|
||||||
|
|
||||||
buildInputs = with pkgs; [
|
|
||||||
stdenv.cc.cc
|
|
||||||
zlib
|
|
||||||
];
|
|
||||||
|
|
||||||
autoPatchelfIgnoreMissingDeps = ["*"];
|
|
||||||
|
|
||||||
patchPhase = ''
|
|
||||||
patchShebangs ./install.sh
|
|
||||||
'';
|
|
||||||
|
|
||||||
installPhase = ''
|
|
||||||
runHook preInstall
|
|
||||||
|
|
||||||
# Start with the base toolchain
|
|
||||||
mkdir -p $out
|
|
||||||
cp -rL ${esp-rs-base}/* $out/
|
|
||||||
chmod -R u+w $out
|
|
||||||
|
|
||||||
# Install rust-src on top
|
|
||||||
./install.sh --destdir=$out --prefix="" --disable-ldconfig
|
|
||||||
|
|
||||||
runHook postInstall
|
|
||||||
'';
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
inherit esp-rust-build esp-xtensa-gcc esp-riscv32-gcc;
|
|
||||||
version = versions.esp-rust.version;
|
|
||||||
};
|
|
||||||
|
|
||||||
meta = with lib; {
|
|
||||||
description = "Complete ESP32 Rust development toolchain";
|
|
||||||
longDescription = ''
|
|
||||||
A complete toolchain for developing Rust applications on ESP32 microcontrollers.
|
|
||||||
Includes Rust compiler with ESP32 targets, Xtensa and RISC-V GCC toolchains,
|
|
||||||
and all necessary components for no_std ESP-HAL development.
|
|
||||||
'';
|
|
||||||
homepage = "https://github.com/esp-rs";
|
|
||||||
license = with licenses; [
|
|
||||||
mit
|
|
||||||
asl20
|
|
||||||
gpl2Plus
|
|
||||||
];
|
|
||||||
platforms = ["x86_64-linux"];
|
|
||||||
maintainers = [];
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user