nix flakes support #64

Merged
sb10q merged 7 commits from mwojcik/thermostat:nixflakes into master 2022-01-19 11:13:47 +08:00

Support for Nix flakes. Based mostly on mcu/default.nix from nix-scripts.

Tested nix develop (allows access to all the programs necessary for building, debugging, flashing) and nix build. Not tested with Hydra, I'm not sure about that one.

Support for Nix flakes. Based mostly on mcu/default.nix from nix-scripts. Tested ``nix develop`` (allows access to all the programs necessary for building, debugging, flashing) and ``nix build``. Not tested with Hydra, I'm not sure about that one.
mwojcik added 2 commits 2022-01-17 16:50:16 +08:00
sb10q reviewed 2022-01-17 18:07:40 +08:00
flake.nix Outdated
@ -0,0 +40,4 @@
};
};
patchPhase = "";

Remove?

Remove?
sb10q reviewed 2022-01-17 18:08:22 +08:00
flake.nix Outdated
@ -0,0 +43,4 @@
patchPhase = "";
nativeBuildInputs = [ pkgs.llvm ];
buildPhase = ''
export CARGO_HOME=$(mktemp -d cargo-home.XXX)

Is CARGO_HOME necessary? NAC3 doesn't use it.

Is CARGO_HOME necessary? NAC3 doesn't use it.

You can use cargoBuildFlags instead.

You can use cargoBuildFlags instead.
sb10q reviewed 2022-01-17 18:09:55 +08:00
flake.nix Outdated
@ -0,0 +48,4 @@
'';
checkPhase = ''
cargo test --target=${pkgs.rust.toRustTarget pkgs.stdenv.targetPlatform};

cargoTestFlags

cargoTestFlags
sb10q reviewed 2022-01-17 18:10:34 +08:00
flake.nix Outdated
@ -0,0 +52,4 @@
'';
# binaryName defaults to the `name` arg (i.e. the Rust package name);
# it is used as the Cargo binary filename

I don't understand this comment?

I don't understand this comment?
  • Nix convention seems to be to indent with 2 spaces (see nixpkgs).
  • README needs an update
* Nix convention seems to be to indent with 2 spaces (see nixpkgs). * README needs an update
mwojcik added 2 commits 2022-01-18 10:55:57 +08:00
mwojcik added 1 commit 2022-01-18 10:58:42 +08:00
sb10q reviewed 2022-01-18 11:05:17 +08:00
@ -0,0 +42,4 @@
nativeBuildInputs = [ pkgs.llvm ];
buildPhase = ''
cargo build --release --bin thermostat

cargoBuildFlags?

cargoBuildFlags?
Poster
Owner

Is there API of that function described somewhere for quick reference? Besides the little tutorial section...

Is there API of that function described somewhere for quick reference? Besides the little tutorial section...
Poster
Owner

Actually, using just cargoBuildFlags (--bin thermostat as release is already included) causes the build to fail, as the default builder forces --target=x86_64-linux.

Actually, using just cargoBuildFlags (``--bin thermostat`` as release is already included) causes the build to fail, as the default builder forces ``--target=x86_64-linux``.

One usually has to RTFS of nixpkgs for this kind of extended documentation :)
If there's no easy solution then overriding buildPhase is fine.

One usually has to RTFS of nixpkgs for this kind of extended documentation :) If there's no easy solution then overriding buildPhase is fine.
sb10q reviewed 2022-01-18 11:06:20 +08:00
@ -0,0 +69,4 @@
buildInputs = with pkgs; [
rustPlatform.rust.rustc
rustPlatform.rust.cargo
gcc openocd dfu-util

gcc?

gcc?
sb10q reviewed 2022-01-18 11:06:54 +08:00
@ -0,0 +71,4 @@
rustPlatform.rust.cargo
gcc openocd dfu-util
] ++ (with python3Packages; [
numpy matplotlib

Did you test this? I think this doesn't work and you need python3.withPackages instead.

Did you test this? I think this doesn't work and you need ``python3.withPackages`` instead.
Poster
Owner

Weirdly enough it seems to work

❯ nix develop

[spaqin@hera:~/m-labs/thermostat]$ python
Python 3.9.6 (default, Jun 28 2021, 08:57:49) 
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import matplotlib
>>> 
Weirdly enough it seems to work ```shell ❯ nix develop [spaqin@hera:~/m-labs/thermostat]$ python Python 3.9.6 (default, Jun 28 2021, 08:57:49) [GCC 10.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import numpy >>> import matplotlib >>> ```

This is the lab computer and those packages are already included in the system Python. You can use nix develop --ignore-environment to isolate the system profile (see https://github.com/NixOS/nix/issues/4359).

This is the lab computer and those packages are already included in the system Python. You can use ``nix develop --ignore-environment`` to isolate the system profile (see https://github.com/NixOS/nix/issues/4359).
Poster
Owner

Still available:

❯ nix develop --ignore-environment
bash-5.1$ python
Python 3.9.6 (default, Jun 28 2021, 08:57:49) 
[GCC 10.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>> import numpy 
>>> 
Still available: ```shell ❯ nix develop --ignore-environment bash-5.1$ python Python 3.9.6 (default, Jun 28 2021, 08:57:49) [GCC 10.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import matplotlib >>> import numpy >>> ```
mwojcik added 1 commit 2022-01-18 11:28:02 +08:00
sb10q reviewed 2022-01-19 10:19:01 +08:00
flake.nix Outdated
@ -0,0 +56,4 @@
dontFixup = true;
};
in rec {

rec not needed

rec not needed
sb10q reviewed 2022-01-19 10:19:11 +08:00
flake.nix Outdated
@ -0,0 +57,4 @@
dontFixup = true;
};
in rec {
packages.x86_64-linux = rec {

also here

also here
mwojcik added 1 commit 2022-01-19 10:24:18 +08:00
sb10q merged commit 4d43709f76 into master 2022-01-19 11:13:47 +08:00
sb10q referenced this issue from a commit 2022-01-19 11:13:48 +08:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/thermostat#64
There is no content yet.