Compare commits

...

2 Commits

Author SHA1 Message Date
mwojcik 2108ab0782 readme: update build instructions for flakes 2022-01-18 10:55:52 +08:00
mwojcik af9f3903be flakes: cleanup 2022-01-18 10:55:26 +08:00
2 changed files with 75 additions and 81 deletions

View File

@ -8,20 +8,22 @@
### Reproducible build with Nix
See the `mcu` folder of the [nix-scripts repository](https://git.m-labs.hk/M-Labs/nix-scripts).
Thermostat firmware is packaged using the [Nix](https://nixos.org) Flakes system. Install Nix 2.4+ and enable flakes by adding ``experimental-features = nix-command flakes`` to ``nix.conf`` (e.g. ``~/.config/nix/nix.conf``).
Once you have Flakes enabled, you can use ``nix build`` to build the firmware.
### Development environment
Clone this repository and [nix-scripts](https://git.m-labs.hk/M-Labs/nix-scripts).
Clone this repository and with Nix Flakes enabled, use the following commands:
```shell
nix-shell -I nix-scripts=[path to nix-scripts checkout]
nix develop
cargo build --release
```
The resulting ELF file will be located under `target/thumbv7em-none-eabihf/release/thermostat`
The resulting ELF file will be located under `target/thumbv7em-none-eabihf/release/thermostat`.
Alternatively, you can install the Rust toolchain without Nix using rustup; see the channel manifest file in nix-scripts (`channel-rust-nightly.toml`) to determine which Rust version to use.
Alternatively, you can install the Rust toolchain without Nix using rustup; see the Rust manifest file pulled in `flake.nix` to determine which Rust version to use.
## Debugging

View File

@ -40,19 +40,11 @@
};
};
patchPhase = "";
nativeBuildInputs = [ pkgs.llvm ];
buildPhase = ''
export CARGO_HOME=$(mktemp -d cargo-home.XXX)
cargo build --release --bin thermostat
'';
checkPhase = ''
cargo test --target=${pkgs.rust.toRustTarget pkgs.stdenv.targetPlatform};
'';
# binaryName defaults to the `name` arg (i.e. the Rust package name);
# it is used as the Cargo binary filename
installPhase = ''
mkdir -p $out $out/nix-support
cp target/thumbv7em-none-eabihf/release/thermostat $out/thermostat.elf