From 61ce6779fb21972971d6342cde20f100e91249e4 Mon Sep 17 00:00:00 2001 From: Bastien Riviere Date: Wed, 24 Apr 2024 10:27:02 +0200 Subject: [PATCH] feat: add nix flake --- .envrc | 1 + .gitignore | 2 ++ flake.lock | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 65 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 153 insertions(+) create mode 100644 .envrc create mode 100644 .gitignore create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b91777e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/.direnv +/result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..6f46b79 --- /dev/null +++ b/flake.lock @@ -0,0 +1,85 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": "nixpkgs-lib" + }, + "locked": { + "lastModified": 1712014858, + "narHash": "sha256-sB4SWl2lX95bExY2gMFG5HIzvva5AVMJd4Igm+GpZNw=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "9126214d0a59633752a136528f5f3b9aa8565b7d", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1713805509, + "narHash": "sha256-YgSEan4CcrjivCNO5ZNzhg7/8ViLkZ4CB/GrGBVSudo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1e1dc66fe68972a76679644a5577828b6a7e8be4", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-lib": { + "locked": { + "dir": "lib", + "lastModified": 1711703276, + "narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d8fe5e6c92d0d190646fb9f1056741a229980089", + "type": "github" + }, + "original": { + "dir": "lib", + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs", + "zmk-nix": "zmk-nix" + } + }, + "zmk-nix": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1713659352, + "narHash": "sha256-oyhYpWbkXpQYRhBDQnqPfZkSrhn0ZwHh8uo5Pz+pgLE=", + "owner": "lilyinstarlight", + "repo": "zmk-nix", + "rev": "ed74f5ab581e78e5d8af48bbd822068cdb8ee5fb", + "type": "github" + }, + "original": { + "owner": "lilyinstarlight", + "repo": "zmk-nix", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..535074f --- /dev/null +++ b/flake.nix @@ -0,0 +1,65 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + + zmk-nix = { + url = "github:lilyinstarlight/zmk-nix"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = + inputs@{ flake-parts, self, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + systems = [ + "x86_64-linux" + "aarch64-linux" + ]; + + perSystem = + { + inputs', + lib, + pkgs, + ... + }: + { + packages = rec { + default = inputs'.nixpkgs.legacyPackages.linkFarm "zmk-config-default" [ + { + name = "sweep"; + path = sweep; + } + ]; + + sweep = inputs'.zmk-nix.legacyPackages.buildSplitKeyboard { + name = "firmware"; + + src = inputs.nixpkgs.lib.sourceFilesBySuffices self [ + "sweep.conf" + "sweep.keymap" + ".yml" + ]; + + board = "nice_nano_v2"; + shield = "lotus58_%PART%"; + + zephyrDepsHash = "sha256-Afxy2Dt3dUnkK+K4evsjyEIHI+sWVbJIWQ826p74SMo="; + + meta = { + description = "sweep firmware"; + license = inputs.nixpkgs.lib.licenses.mit; + platforms = inputs.nixpkgs.lib.platforms.all; + }; + }; + + update = inputs'.zmk-nix.packages.update; + }; + + devShells = { + default = inputs'.zmk-nix.devShells.default; + }; + }; + }; +}