2024-03-03 15:31:37 +00:00
|
|
|
{
|
|
|
|
description = "Firmware for the NaxGCC";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-23.11";
|
|
|
|
|
|
|
|
rust-overlay.url = "github:oxalica/rust-overlay";
|
|
|
|
|
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
|
|
|
|
2024-03-18 09:36:47 +00:00
|
|
|
embassy-rs-patched = {
|
2024-04-05 10:39:39 +00:00
|
|
|
url = "git+https://gitea@git.naxdy.org/NaxdyOrg/embassy?ref=naxgcc-fw";
|
2024-03-18 09:36:47 +00:00
|
|
|
flake = false;
|
|
|
|
};
|
|
|
|
|
2024-03-03 15:31:37 +00:00
|
|
|
naersk = {
|
|
|
|
url = "github:nmattia/naersk";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
outputs =
|
|
|
|
{ self
|
|
|
|
, nixpkgs
|
|
|
|
, rust-overlay
|
|
|
|
, flake-utils
|
|
|
|
, naersk
|
2024-03-18 09:36:47 +00:00
|
|
|
, embassy-rs-patched
|
2024-03-03 15:31:37 +00:00
|
|
|
}: (flake-utils.lib.eachDefaultSystem (system:
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
overlays = [
|
|
|
|
rust-overlay.overlays.default
|
|
|
|
];
|
|
|
|
config.allowUnsupportedSystem = true;
|
|
|
|
};
|
|
|
|
|
2024-03-18 09:36:47 +00:00
|
|
|
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
|
2024-03-03 15:31:37 +00:00
|
|
|
extensions = [
|
|
|
|
"rust-src"
|
|
|
|
];
|
|
|
|
targets = [
|
|
|
|
"thumbv6m-none-eabi"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
naersk_lib = naersk.lib.${system}.override {
|
|
|
|
cargo = rustToolchain;
|
|
|
|
rustc = rustToolchain;
|
|
|
|
};
|
|
|
|
|
|
|
|
CARGO_BUILD_TARGET = "thumbv6m-none-eabi";
|
|
|
|
|
2024-03-18 09:36:47 +00:00
|
|
|
prepCmd = ''
|
|
|
|
mkdir -p lib
|
|
|
|
rm lib/embassy-rs || true
|
|
|
|
ln -s "${embassy-rs-patched}" lib/embassy-rs
|
|
|
|
'';
|
2024-03-03 15:31:37 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
packages.default = self.packages.${system}.naxgcc-fw-uf2;
|
|
|
|
|
|
|
|
packages.naxgcc-fw-uf2 = pkgs.runCommandLocal "${self.packages.${system}.naxgcc-fw.pname}-uf2-${self.packages.${system}.naxgcc-fw.version}" { } ''
|
|
|
|
mkdir -p $out/bin
|
|
|
|
${pkgs.elf2uf2-rs}/bin/elf2uf2-rs ${self.packages.${system}.naxgcc-fw}/bin/${self.packages.${system}.naxgcc-fw.pname} $out/bin/${self.packages.${system}.naxgcc-fw.pname}.uf2
|
|
|
|
'';
|
|
|
|
|
|
|
|
packages.naxgcc-fw = naersk_lib.buildPackage {
|
|
|
|
pname = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.name;
|
|
|
|
version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.version;
|
|
|
|
|
2024-03-18 09:36:47 +00:00
|
|
|
prePatch = prepCmd;
|
2024-03-03 15:31:37 +00:00
|
|
|
|
|
|
|
src = self;
|
|
|
|
|
|
|
|
cargoBuildOptions = _orig: _orig ++ [
|
|
|
|
"--target=${CARGO_BUILD_TARGET}"
|
|
|
|
];
|
|
|
|
|
2024-04-03 12:33:47 +00:00
|
|
|
# if a tree falls in the forest and no one is around to hear it, does it make a sound?
|
|
|
|
DEFMT_LOG = "off";
|
2024-03-03 15:31:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
devShells.default = pkgs.mkShell {
|
|
|
|
nativeBuildInputs = builtins.attrValues {
|
|
|
|
inherit rustToolchain;
|
2024-03-18 09:36:47 +00:00
|
|
|
inherit (pkgs) gcc-arm-embedded elf2uf2-rs picotool probe-rs cargo-expand;
|
2024-03-03 15:31:37 +00:00
|
|
|
};
|
|
|
|
|
2024-03-04 21:48:03 +00:00
|
|
|
CARGO_TARGET_THUMBV6M_NONE_EABI_RUNNER = "probe-rs run --chip RP2040 --protocol swd";
|
2024-03-11 23:08:34 +00:00
|
|
|
DEFMT_LOG = "debug";
|
2024-03-04 21:48:03 +00:00
|
|
|
|
2024-03-11 23:08:34 +00:00
|
|
|
inherit CARGO_BUILD_TARGET;
|
2024-03-18 09:36:47 +00:00
|
|
|
|
|
|
|
shellHook = prepCmd;
|
2024-03-03 15:31:37 +00:00
|
|
|
};
|
|
|
|
}));
|
|
|
|
}
|