Skip to content
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

QMK tools update #109639

Closed
wants to merge 4 commits into from
Closed

QMK tools update #109639

wants to merge 4 commits into from

Conversation

AndersonTorres
Copy link
Member

@AndersonTorres AndersonTorres commented Jan 17, 2021

Motivation for this change

qmk_firmware: 0.6.114 -> 0.11.49

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@SuperSandro2000 SuperSandro2000 changed the title Qmk qmk: rewrite expression, qmk_firmware: 0.6.114 -> 0.11.49 Jan 17, 2021
checkTarget = "test:all";

installPhase = ''
mkdir $out
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are sure about this? This shouldn't be preInstall?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seriously I don't know. I just rewrote the expression, but when I tried to test it, the GCC cross compiler didn't compile.

@AndersonTorres AndersonTorres changed the title qmk: rewrite expression, qmk_firmware: 0.6.114 -> 0.11.49 qmk_firmware: 0.6.114 -> 0.11.49 Jan 17, 2021
@AndersonTorres AndersonTorres changed the title qmk_firmware: 0.6.114 -> 0.11.49 QMK tools update Jan 17, 2021
@SuperSandro2000
Copy link
Member

This is a semi-automatic executed nixpkgs-review which does not build all packages (e.g. lumo, tensorflow or pytorch)
If you find some bugs or got suggestions for further things to search or run please reach out to SuperSandro2000 on IRC.

Result of nixpkgs-review pr 109639 run on x86_64-darwin 1

1 package failed to build and are new build failure:

@AndersonTorres
Copy link
Member Author

As far as I am looking at it, gcc10 fails compiling for ARM.

@SuperSandro2000
Copy link
Member

This is a semi-automatic executed nixpkgs-review which is checked by a human on a best effort basis and does not build all packages (e.g. lumo, tensorflow or pytorch).
If you have any questions or problems please reach out to SuperSandro2000 on IRC.

Result of nixpkgs-review pr 109639 run on x86_64-linux 1

1 package failed to build and already failed to build on hydra master:
  • qmk_firmware: log was empty
builder for '/nix/store/h358kr3mxcl4sqcb2c9z0nwqbl1xcmza-arm-none-eabihf-stage-static-gcc-debug-10.2.0.drv' failed with exit code 2; last 10 log lines:                                       echo timestamp > stmp-int-hdrs                                                                                                                                                              /build/build/./gcc/xgcc -B/build/build/./gcc/ -xc -nostdinc /dev/null -S -o /dev/null -fself-test=../../gcc-10.2.0/gcc/testsuite/selftests                                                  cc1: error: '-mfloat-abi=hard': selected processor lacks an FPU                                                                                                                             cc1: note: self-tests are not enabled in this build                                                                                                                                         make[2]: *** [../../gcc-10.2.0/gcc/c/Make-lang.in:124: s-selftest-c] Error 1                                                                                                                rm gcc.pod                                                                                                                                                                                  make[2]: Leaving directory '/build/build/gcc'                                                                                                                                               make[1]: *** [Makefile:4372: all-gcc] Error 2
  make[1]: Leaving directory '/build/build'
    make: *** [Makefile:939: all] Error 2
	cannot build derivation '/nix/store/3a9hwl9kvqp2vnzgih3pmp6k91qnqmql-arm-none-eabihf-stage-static-gcc-debug-wrapper-10.2.0.drv': 1 dependencies couldn't be built
	cannot build derivation '/nix/store/bg7rqr7gn3wz4bpx0g8pscci99h5b37f-stdenv-linux.drv': 1 dependencies couldn't be built
	cannot build derivation '/nix/store/cyyqz1maq9ak0jnlbak9yid19zfp0bpd-newlib-3.3.0-arm-none-eabihf.drv': 1 dependencies couldn't be built
	cannot build derivation '/nix/store/4bac4c2i0p0vfkpcwpd3dq0p3xms25lb-arm-none-eabihf-binutils-wrapper-2.34.drv': 1 dependencies couldn't be built
	cannot build derivation '/nix/store/xwvaabgdh9rnpd8zpz43byfhz1qxp031-arm-none-eabihf-stage-final-gcc-debug-10.2.0.drv': 2 dependencies couldn't be built
	cannot build derivation '/nix/store/d9npghga1ar6n7977yl13b1y1w5cj6r8-arm-none-eabihf-stage-final-gcc-debug-wrapper-10.2.0.drv': 3 dependencies couldn't be built
	cannot build derivation '/nix/store/5hph3wvnn0f8mmqgzk1cjqv93fmxskkn-qmk_firmware-0.11.49.drv': 1 dependencies couldn't be built
	cannot build derivation '/nix/store/5js13700nlmr6421rs9jszm5w2ipyvs0-env.drv': 1 dependencies couldn't be built
	```

@AndersonTorres
Copy link
Member Author

Error log:

arm-none-eabihf-stage-static-gcc-debug> echo timestamp > stmp-int-hdrs
arm-none-eabihf-stage-static-gcc-debug> /build/build/./gcc/xgcc -B/build/build/./gcc/ -xc -nostdinc /dev/null -S -o /dev/null -fself-test=../../gcc-10.2.0/gcc/testsuite/selftests
arm-none-eabihf-stage-static-gcc-debug> cc1: error: '-mfloat-abi=hard': selected processor lacks an FPU
arm-none-eabihf-stage-static-gcc-debug> cc1: note: self-tests are not enabled in this build
arm-none-eabihf-stage-static-gcc-debug> make[2]: *** [../../gcc-10.2.0/gcc/c/Make-lang.in:124: s-selftest-c] Error 1
arm-none-eabihf-stage-static-gcc-debug> rm gcc.pod
arm-none-eabihf-stage-static-gcc-debug> make[2]: Leaving directory '/build/build/gcc'
arm-none-eabihf-stage-static-gcc-debug> make[1]: *** [Makefile:4372: all-gcc] Error 2
arm-none-eabihf-stage-static-gcc-debug> make[1]: Leaving directory '/build/build'
arm-none-eabihf-stage-static-gcc-debug> make: *** [Makefile:939: all] Error 2
avr-stage-static-gcc-debug> checking for stdint.h... no
error: --- Error --- nix-daemon
builder for '/nix/store/h358kr3mxcl4sqcb2c9z0nwqbl1xcmza-arm-none-eabihf-stage-static-gcc-debug-10.2.0.drv' failed with exit code 2; last 10 log lines:
echo timestamp > stmp-int-hdrs
/build/build/./gcc/xgcc -B/build/build/./gcc/ -xc -nostdinc /dev/null -S -o /dev/null -fself-test=../../gcc-10.2.0/gcc/testsuite/selftests
cc1: error: '-mfloat-abi=hard': selected processor lacks an FPU
cc1: note: self-tests are not enabled in this build
make[2]: *** [../../gcc-10.2.0/gcc/c/Make-lang.in:124: s-selftest-c] Error 1
rm gcc.pod
make[2]: Leaving directory '/build/build/gcc'
make[1]: *** [Makefile:4372: all-gcc] Error 2
make[1]: Leaving directory '/build/build'
make: *** [Makefile:939: all] Error 2
error: --- Error --- nix-daemon
1 dependencies of derivation '/nix/store/3a9hwl9kvqp2vnzgih3pmp6k91qnqmql-arm-none-eabihf-stage-static-gcc-debug-wrapper-10.2.0.drv' failed to build
error: --- Error --- nix-daemon
1 dependencies of derivation '/nix/store/bg7rqr7gn3wz4bpx0g8pscci99h5b37f-stdenv-linux.drv' failed to build
error: --- Error --- nix-daemon
1 dependencies of derivation '/nix/store/cyyqz1maq9ak0jnlbak9yid19zfp0bpd-newlib-3.3.0-arm-none-eabihf.drv' failed to build
error: --- Error --- nix-daemon
1 dependencies of derivation '/nix/store/d9npghga1ar6n7977yl13b1y1w5cj6r8-arm-none-eabihf-stage-final-gcc-debug-wrapper-10.2.0.drv' failed to build
error: --- Error --- nix-daemon
1 dependencies of derivation '/nix/store/npgrkv833xmzwc72phwp6g5x7b71i660-qmk_firmware-0.6.144.drv' failed to build
error: --- Error -------------------------------------------------------------------------------------------------------------------------------- nix
error: --- Error --- nix-daemon
1 dependencies of derivation '/nix/store/s01w3yj31yyj0zilsimibfcsw6is1kax-qmk_cli-0.0.39.drv' failed to build

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/qmk-firmware-build-fails-with-gcc-cross-compilation-failure/11086/1

@SuperSandro2000 SuperSandro2000 marked this pull request as draft January 21, 2021 00:12
@SuperSandro2000
Copy link
Member

I marked the PR as a draft until the above linked issue is fixed. Feel free to undraft at any time.

@AndersonTorres
Copy link
Member Author

Indeed it is a serious bug:

#96921

@AndersonTorres
Copy link
Member Author

With the closing of #96921 I will take it back!

@SuperSandro2000
Copy link
Member

Result of nixpkgs-review pr 109639 run on x86_64-linux 1

2 packages failed to build:
  • qmk_cli
  • qmk_firmware

@AndersonTorres
Copy link
Member Author

This is monstruous, and I am a bit afraid of having no time to compile it.

@bb2020
Copy link
Member

bb2020 commented Feb 24, 2021

Hi. As far as I know, qmk builds with avrgcc 8.2 avrgcc 8.3 only. Current version in nixpkgs is already 8.2, but updating it may break this package.

@bb2020
Copy link
Member

bb2020 commented Feb 24, 2021

On other platforms, qmk command can be used to compile your own fork (for custom layouts). Is it possible to have a qmk_cli that includes build tools? It should find gcc or binutils at runtime. Then qmk_cli can be used to compile qmk_firmware itself.

@AndersonTorres
Copy link
Member Author

@bb2020 I am compiling the qmk cli tool too, but I am a bit confused.

If I am not wrong, QMK upstream recommends to use the QMK CLI to make all the tasks, such as download the C sources, compile and flash the firmware in the keyboard.

It compiles fine (just a Python package indeed) but I don't know the best way to use it in NixOS.

@bb2020
Copy link
Member

bb2020 commented Feb 25, 2021

@bb2020 I am compiling the qmk cli tool too, but I am a bit confused.

If I am not wrong, QMK upstream recommends to use the QMK CLI to make all the tasks, such as download the C sources, compile and flash the firmware in the keyboard.

It compiles fine (just a Python package indeed) but I don't know the best way to use it in NixOS.

Yes, on a regular Linux distro you run python3 -m pip install --user qmk. It installs qmk_cli from pypi imperatively. And then running qmk setup installs build tools and clones the qmk_firmware repo. Obviously qmk setup is not suitable for NixOS. If we can have a working qmk build, it should be enough.

There is actually little need for qmk_firmware package. Because most people will override default layouts anyway. For this, a wrapper can be used like this. keymap.c can be pushed into the Nix store and then compiled along with qmk_firmware. However, sometimes updating QMK breaks some functionality. This is bad because it is hard to revert without proper keyboard. So clone your own qmk_firmware fork and then compile it with qmk build approach is much better.

@cole-h
Copy link
Member

cole-h commented Feb 25, 2021

@ofborg eval

@AndersonTorres
Copy link
Member Author

AndersonTorres commented Feb 26, 2021

@bb2020 but in a certain sense QMK Firmware source is a "dependency" for QMK CLI. If someone merely downloads QMK CLI and successfully clones it (and this cloning requires git), the source code still requires GCC and all related paraphernalia.

If I remember it correctly, the QMK CLI can work with a local QMK Firmware tree, obviating the qmk clone stuff.
This way, it would be interesting if the QMK Firmware expression merely downloads the pure source code. This way, a convenient script could copy the /nix/store/${hash}-qmk-firmware to the current directory.

@bb2020
Copy link
Member

bb2020 commented Feb 26, 2021

@bb2020 but in a certain sense QMK Firmware source is a "dependency" for QMK CLI. If someone merely downloads QMK CLI and successfully clones it (and this cloning requires git), the source code still requires GCC and all related paraphernalia.

I see. The problem is, on other platforms, qmk setup installs the toolchain globally. This is akin to something like;
nix-env -iA nixos.pkgsCross.avr.buildPackages.gcc
nix-env -iA nixos.pkgsCross.avr.buildPackages.binutils
nix-env -iA nixos.dfu-programmer etc.

This closure uses required tools as intermediate and does not export them to compile a custom version of QMK. Actually QMK has a shell.nix to solve this problem. However this one compiles gcc from scratch, I presume.

Is it possible to have a wrapper like this for qmk_cli to make it find all the dependencies at runtime?

@AndersonTorres
Copy link
Member Author

I am thinking in something like a sandbox. Indeed the QMK CLI documentation seems to suggest that it is amenable to this approach.

@bb2020 bb2020 mentioned this pull request Apr 2, 2021
10 tasks
@dotlambda dotlambda mentioned this pull request Apr 2, 2021
10 tasks
@bb2020
Copy link
Member

bb2020 commented Apr 2, 2021

@AndersonTorres I've simplified cli.nix a little bit. What are your opinions?

This is just a rewrite of the QMK expression, in order to accomodate the future
QMK CLI tools.
@AndersonTorres
Copy link
Member Author

Looks cleaner. I will manually update this.

But the main concern still stands: what to do with this?

I am a bit rusty with Nix, but my idea is to nixify this: create an environment where the QMK tool is present, the tools needed to build QMK source code are present too, and the source code is not downloaded by "impure" means.

@AndersonTorres
Copy link
Member Author

AndersonTorres commented Apr 7, 2021

Burning everything now we have a package for qmk_cli and the qmk_firmware was dropped.

#118324
#118340

Look somewhere else.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants