diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0f6499e..fd09b7c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -15,27 +15,19 @@ jobs: build: runs-on: ubuntu-latest steps: + - id: date + run: | + date=$(date +'%Y-%m-%d') + echo "Date: $date" + echo "date=$date" >> $GITHUB_OUTPUT - uses: actions/checkout@v4 - with: - submodules: recursive - - uses: actions/checkout@v4 - with: - repository: moergo-sc/zmk - ref: main - path: src - - uses: cachix/install-nix-action@v25 - with: - nix_path: nixpkgs=channel:nixos-22.05 - - uses: cachix/cachix-action@v14 - with: - name: moergo-glove80-zmk-dev - skipPush: true - - name: Build Glove80 combined firmware - run: nix-build config -o combined - - name: Copy result out of nix store - run: cp combined/glove80.uf2 glove80.uf2 + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main + - uses: DeterminateSystems/flake-checker-action@main + - name: Build Glove80 firmware + run: nix build - name: Upload result uses: actions/upload-artifact@v4 with: - name: glove80.uf2 - path: glove80.uf2 + name: glove80-${{ steps.date.outputs.date }}.uf2 + path: result/glove80.uf2 diff --git a/.gitignore b/.gitignore index ae5408c..06503ac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *~ env/ +result diff --git a/config/default.nix b/config/default.nix deleted file mode 100644 index 0d9645c..0000000 --- a/config/default.nix +++ /dev/null @@ -1,10 +0,0 @@ -{ pkgs ? import {} }: - -let - firmware = import ../src {}; - config = ./.; - - glove80_left = firmware.zmk.override { board = "glove80_lh"; keymap = "${config}/glove80.keymap"; kconfig = "${config}/glove80.conf"; }; - glove80_right = firmware.zmk.override { board = "glove80_rh"; keymap = "${config}/glove80.keymap"; kconfig = "${config}/glove80.conf"; }; - -in firmware.combine_uf2 glove80_left glove80_right diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..df605a3 --- /dev/null +++ b/flake.lock @@ -0,0 +1,120 @@ +{ + "nodes": { + "devshell": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1711099426, + "narHash": "sha256-HzpgM/wc3aqpnHJJ2oDqPBkNsqWbW0WfWUO8lKu8nGk=", + "owner": "numtide", + "repo": "devshell", + "rev": "2d45b54ca4a183f2fdcf4b19c895b64fbf620ee8", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709336216, + "narHash": "sha256-Dt/wOWeW6Sqm11Yh+2+t0dfEWxoMxGBvv3JpIocFl9E=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "f7b3c975cf067e56e7cda6cb098ebe3fb4d74ca2", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1701680307, + "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "glove80-zmk": { + "flake": false, + "locked": { + "lastModified": 1708071572, + "narHash": "sha256-wbFkwJk9NJtDyjM7D/k1TCeeOXelhVhc3itfGKKZzcw=", + "owner": "moergo-sc", + "repo": "zmk", + "rev": "2fad527cc5abed5bb59b4d4a4b0ee511d0e514e9", + "type": "github" + }, + "original": { + "owner": "moergo-sc", + "repo": "zmk", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1711163522, + "narHash": "sha256-YN/Ciidm+A0fmJPWlHBGvVkcarYWSC+s3NTPk/P+q3c=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "44d0940ea560dee511026a53f0e2e2cde489b4d4", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "devshell": "devshell", + "flake-parts": "flake-parts", + "glove80-zmk": "glove80-zmk", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..e98b6b3 --- /dev/null +++ b/flake.nix @@ -0,0 +1,81 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + glove80-zmk = { + url = "github:moergo-sc/zmk"; + flake = false; + }; + flake-parts = { + url = "github:hercules-ci/flake-parts"; + inputs.nixpkgs-lib.follows = "nixpkgs"; + }; + devshell = { + url = "github:numtide/devshell"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { + self, + nixpkgs, + glove80-zmk, + flake-parts, + devshell, + } @ inputs: + flake-parts.lib.mkFlake {inherit inputs;} { + systems = nixpkgs.lib.systems.flakeExposed; + imports = [ + inputs.devshell.flakeModule + ]; + + perSystem = { + config, + pkgs, + system, + ... + }: { + packages.default = let + firmware = import glove80-zmk {inherit pkgs;}; + + keymap = ./config/glove80.keymap; + kconfig = ./config/glove80.conf; + + glove80_left = firmware.zmk.override { + inherit keymap kconfig; + board = "glove80_lh"; + }; + + glove80_right = firmware.zmk.override { + inherit keymap kconfig; + board = "glove80_rh"; + }; + in + firmware.combine_uf2 glove80_left glove80_right; + + devshells.default.commands = [ + { + name = "flash"; + command = /*bash*/ '' + set +e + + root="/run/media/$(whoami)" + dest_folder_name=$(ls $root | grep GLV80) + dest="$root"/"$dest_folder_name" + + if [[ -n "$dest_folder_name" && -d "$dest" ]]; then + echo Flashing to "$dest" + cp ${config.packages.default}/glove80.uf2 "$dest"/CURRENT.UF2 + exit 0 + else + echo "Error: Glove80 keyboard is not plugged-in" + exit 1 + fi + ''; + help = "builds the firmware and copies it to the plugged-in keybaord half"; + } + ]; + + formatter = pkgs.alejandra; + }; + }; +}