diff --git a/.envrc-nix b/.envrc-nix new file mode 100644 index 00000000..1d953f4b --- /dev/null +++ b/.envrc-nix @@ -0,0 +1 @@ +use nix diff --git a/.gitignore b/.gitignore index 93c801d9..66ae8e6d 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,6 @@ /zmk-config /build *.DS_Store -__pycache__ \ No newline at end of file +__pycache__ +/.direnv +.envrc diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..95b64bf1 --- /dev/null +++ b/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1638122382, + "narHash": "sha256-sQzZzAbvKEqN9s0bzWuYmRaA03v40gaJ4+iL1LXjaeI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "74f7e4319258e287b0f9cb95426c9853b282730b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1638910453, + "narHash": "sha256-fofA4tsAAdNgE+9Py0VsVbyX2ZQkgV+CVqQKGBA/dLE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "f225322e3bea8638304adfcf415cd11de99f2208", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..1499b6c0 --- /dev/null +++ b/flake.nix @@ -0,0 +1,11 @@ +{ + description = "# Zephyrâ„¢ Mechanical Keyboard (ZMK) Firmware"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + inputs.flake-utils.url = "github:numtide/flake-utils"; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let pkgs = nixpkgs.legacyPackages.${system}; + in { devShell = import ./shell.nix { inherit pkgs; }; }); +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 00000000..db301abf --- /dev/null +++ b/shell.nix @@ -0,0 +1,34 @@ +{ pkgs ? import { } }: + +with pkgs; + +let inherit (lib) ; + mach-nix = import (builtins.fetchGit { + url = "https://github.com/DavHau/mach-nix"; + ref = "master"; + }) { + python = "python3"; + }; + zephyr-requirements = fetchurl { + url = "https://raw.githubusercontent.com/zephyrproject-rtos/zephyr/v2.5.0/scripts/requirements-base.txt"; + sha256 = "919a78ba9457a8e55451450329158ff7fdcbc4a2ddb0dd76ea804c3b04a3c6c6"; + }; + python-pkgs = mach-nix.mkPython rec { + requirements = builtins.readFile zephyr-requirements; + }; +in mkShell { + buildInputs = [ + cmake + ccache + ninja + dtc + dfu-util + gcc-arm-embedded + python-pkgs + ]; + + shellHook = '' + export ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb + export GNUARMEMB_TOOLCHAIN_PATH=${pkgs.gcc-arm-embedded} + ''; +}