-
-
Notifications
You must be signed in to change notification settings - Fork 29
Add Nix support for building refloat, and use it in CI/CD #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,3 +10,5 @@ ui.qml | |
| *.obj | ||
| *.so | ||
| *.vescpkg | ||
|
|
||
| /result | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| { | ||
| inputs = { | ||
| nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11"; | ||
| flake-utils.url = "github:numtide/flake-utils"; | ||
| vesc-tool.url = "github:vedderb/vesc_tool/release_6_06"; | ||
| vesc-tool.inputs.nixpkgs.follows = "nixpkgs"; | ||
| }; | ||
|
|
||
| outputs = { | ||
| self, | ||
| flake-utils, | ||
| nixpkgs, | ||
| vesc-tool, | ||
| } @ inputs: | ||
| flake-utils.lib.eachSystem ["x86_64-linux"] ( | ||
| system: let | ||
| pkgs = import nixpkgs { | ||
| inherit system; | ||
| overlays = [ | ||
| (final: prev: { | ||
| vesc-tool = vesc-tool.packages.${system}.vesc-tool; | ||
| }) | ||
| (import ./nix/overlay.nix) | ||
| (final: prev: { | ||
| refloat = prev.refloat.overrideDerivation (old: { | ||
| version = prev.lib.strings.removeSuffix "\n" (builtins.readFile ./version); | ||
| src = self; | ||
|
|
||
| makeFlags = [ | ||
| "GIT_HASH=${builtins.substring 0 8 (self.rev or self.dirtyRev)}" | ||
| "BUILD_DATE=${self.lastModifiedDate}" | ||
| ]; | ||
| }); | ||
| }) | ||
| ]; | ||
| }; | ||
| in { | ||
| packages = | ||
| pkgs | ||
| // { | ||
| default = pkgs.refloat; | ||
| }; | ||
| } | ||
| ); | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| final: prev: { | ||
| refloat = final.callPackage ./refloat.nix { | ||
| gcc-arm-embedded = final.gcc-arm-embedded-13; | ||
| }; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| { | ||
| lib, | ||
| stdenv, | ||
| gcc-arm-embedded, | ||
| vesc-tool, | ||
| python3, | ||
| }: | ||
| stdenv.mkDerivation { | ||
| pname = "refloat"; | ||
| version = "0.0.0-dev"; | ||
|
|
||
| src = ../.; | ||
|
|
||
| postPatch = '' | ||
| # Python shebang is failing for some reason. Replace it with full shebang | ||
| sed -i '1s,.*,#!${lib.getExe python3},' rjsmin.py | ||
| echo "$version" > ./version | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There should ideally be one source of truth for version and you're duplicating it here. And version is set to 0.0.0-dev above. Not sure what this is supposed to be doing but given version is set to 0.0.0-dev above, not sure it even does what it's supposed to.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This delegates the single source of truth into nix, which defaults to reading the version file. If the nix package states a version, that will be embedded into the binary. I designed I think |
||
| ''; | ||
|
|
||
| doFixup = false; | ||
|
|
||
| nativeBuildInputs = [ | ||
| gcc-arm-embedded | ||
| vesc-tool | ||
| python3 | ||
| ]; | ||
|
|
||
| installPhase = '' | ||
| mkdir $out | ||
| cp src/package_lib.elf $out/refloat.elf | ||
| cp refloat.vescpkg $out | ||
| cat src/conf/confparser.h | sed -n 's/^#define .\+_SIGNATURE\W\+\([0-9]*\)/\1/p' > $out/config_signature.txt | ||
| ''; | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ugly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. I tried getting it to work with
/usr/bin/env, but it wasn't working when I tried it. I can take another look and see if there's a better way around this.