Skip to content

Commit

Permalink
Nix shell updates (Nixpkgs 2024-02-23, QMK CLI 1.1.5) (qmk#23143)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigprof authored Feb 26, 2024
1 parent 65a04ea commit 34a113c
Show file tree
Hide file tree
Showing 5 changed files with 524 additions and 644 deletions.
44 changes: 14 additions & 30 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -1,29 +1,9 @@
let
# We specify sources via Niv: use "niv update nixpkgs" to update nixpkgs, for example.
sources = import ./util/nix/sources.nix { };

# `tomlkit` >= 0.8.0 is required to build `jsonschema` >= 4.11.0 (older
# version do not support some valid TOML syntax: sdispater/tomlkit#148). The
# updated `tomlkit` must be used by `makeRemoveSpecialDependenciesHook`
# inside `poetry2nix`, therefore just providing the updated version through
# our `nix/pyproject.toml` does not work, and using an overlay is required.
pythonOverlay = final: prev: {
python3 = prev.python3.override {
packageOverrides = self: super: {
tomlkit = super.tomlkit.overridePythonAttrs(old: rec {
version = "0.11.4";
src = super.fetchPypi {
inherit (old) pname;
inherit version;
sha256 = "sha256-MjWpAQ+uVDI+cnw6wG+3IHUv5mNbNCbjedrsYPvUSoM=";
};
});
};
};
};
in
# However, if you want to override Niv's inputs, this will let you do that.
{ pkgs ? import sources.nixpkgs { overlays = [ pythonOverlay ]; }
{ pkgs ? import sources.nixpkgs { }
, poetry2nix ? pkgs.callPackage (import sources.poetry2nix) { }
, avr ? true
, arm ? true
Expand All @@ -49,26 +29,30 @@ let
pythonEnv = poetry2nix.mkPoetryEnv {
projectDir = ./util/nix;
overrides = poetry2nix.overrides.withDefaults (self: super: {
pillow = super.pillow.overridePythonAttrs(old: {
# Use preConfigure from nixpkgs to fix library detection issues and
# impurities which can break the build process; this also requires
# adding propagatedBuildInputs and buildInputs from the same source.
propagatedBuildInputs = (old.buildInputs or []) ++ pkgs.python3.pkgs.pillow.propagatedBuildInputs;
buildInputs = (old.buildInputs or []) ++ pkgs.python3.pkgs.pillow.buildInputs;
preConfigure = (old.preConfigure or "") + pkgs.python3.pkgs.pillow.preConfigure;
});
qmk = super.qmk.overridePythonAttrs(old: {
# Allow QMK CLI to run "qmk" as a subprocess (the wrapper changes
# $PATH and breaks these invocations).
dontWrapPythonPrograms = true;

# Fix "qmk setup" to use the Python interpreter from the environment
# when invoking "qmk doctor" (sys.executable gets its value from
# $NIX_PYTHONEXECUTABLE, which is set by the "qmk" wrapper from the
# Python environment, so "qmk doctor" then runs with the proper
# $NIX_PYTHONPATH too, because sys.executable actually points to
# another wrapper from the same Python environment).
postPatch = ''
substituteInPlace qmk_cli/subcommands/setup.py \
--replace "[Path(sys.argv[0]).as_posix()" \
"[Path(sys.executable).as_posix(), Path(sys.argv[0]).as_posix()"
'';
});
});
};
in
mkShell {
name = "qmk-firmware";

buildInputs = [ clang-tools dfu-programmer dfu-util diffutils git pythonEnv niv ]
buildInputs = [ clang-tools_11 dfu-programmer dfu-util diffutils git pythonEnv niv ]
++ lib.optional avr [
pkgsCross.avr.buildPackages.binutils
pkgsCross.avr.buildPackages.gcc8
Expand Down
Loading

0 comments on commit 34a113c

Please sign in to comment.