diff options
Diffstat (limited to 'default.nix')
-rw-r--r-- | default.nix | 95 |
1 files changed, 59 insertions, 36 deletions
diff --git a/default.nix b/default.nix index 18169b5be1ba..e34734dc9e33 100644 --- a/default.nix +++ b/default.nix @@ -1,49 +1,72 @@ -{ nixpkgs ? import <nixpkgs> {} -}: +# This file sets up the top-level package set by traversing the package tree +# (see read-tree.nix for details) and constructing a matching attribute set +# tree. +# +# This makes packages accessible via the Nixery instance that is configured to +# use this repository as its nixpkgs source. -with nixpkgs; +{ ... }@args: -rec { - qmkSource = fetchgit { - url = "https://github.com/qmk/qmk_firmware"; - rev = "ab1650606c36f85018257aba65d9c3ff8ec42e71"; - sha256 = "1k59flkvhjzmfl0yz9z37lqhvad7m9r5wy1p1sjk5274rsmylh79"; - fetchSubmodules = true; - }; +with builtins; - qmk = import "${qmkSource}/shell.nix" { - avr = true; - teensy = true; - arm = false; - }; +let + # This definition of fix is identical to <nixpkgs>.lib.fix, but the global + # package set is not available here. + fix = f: let x = f x; in x; - layout = stdenv.mkDerivation { - name = "ergodox_ez_grfn.hex"; + # Global configuration that all packages are called with. + config = depot: { + inherit depot; - src = qmkSource; + # Pass third_party as 'pkgs' (for compatibility with external + # imports for certain subdirectories) + pkgs = depot.third_party; - inherit (qmk) buildInputs AVR_CFLAGS AVR_ASFLAGS; + kms = { + project = "tazjins-infrastructure"; + region = "europe-north1"; + keyring = "tazjins-keys"; + key = "kontemplate-key"; + }; + }; - patches = [ ./increase-tapping-delay.patch ]; + readTree' = import ./nix/readTree {}; - postPatch = '' - mkdir keyboards/ergodox_ez/keymaps/grfn - cp ${./keymap.c} keyboards/ergodox_ez/keymaps/grfn/keymap.c - ''; + localPkgs = readTree: { + fun = readTree ./fun; + lisp = readTree ./lisp; + net = readTree ./net; + nix = readTree ./nix; + ops = readTree ./ops; + presentations = readTree ./presentations; + third_party = readTree ./third_party; + tools = readTree ./tools; + users = readTree ./users; + web = readTree ./web; + }; +in fix(self: { + config = config self; - buildPhase = '' - make ergodox_ez:grfn - ''; + # Elevate 'lib' from nixpkgs + lib = import (self.third_party.nixpkgsSrc + "/lib"); - installPhase = '' - cp ergodox_ez_grfn.hex $out - ''; + # Expose readTree for downstream repo consumers. + readTree = { + __functor = x: (readTree' x.config); + config = self.config; }; - flash = writeShellScript "flash.sh" '' - ${teensy-loader-cli}/bin/teensy-loader-cli \ - -v \ - --mcu=atmega32u4 \ - -w ${layout} - ''; + # Make the path to the depot available for things that might need it + # (e.g. NixOS module inclusions) + depotPath = ./.; } + +# Add local packages as structured by readTree +// (localPkgs (readTree' (self.config // { inherit (self) lib; }))) + +# Load overrides into the top-level. +# +# This can be used to move things from third_party into the top-level, too (such +# as `lib`). +// (readTree' { depot = self; pkgs = self.third_party; }) ./overrides +) |