forked from M-Labs/thermostat
Compare commits
2 Commits
e749a96971
...
2108ab0782
Author | SHA1 | Date | |
---|---|---|---|
2108ab0782 | |||
af9f3903be |
12
README.md
12
README.md
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user