Github build action: build Glove80 combined firmware using Nix
This commit is contained in:
parent
744d450c2f
commit
5acdf33c06
8 changed files with 133 additions and 10 deletions
13
.github/workflows/build.yml
vendored
13
.github/workflows/build.yml
vendored
|
@ -14,7 +14,7 @@ on:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
if: ${{ always() }}
|
if: ${{ false }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: docker.io/zmkfirmware/zmk-build-arm:3.0
|
image: docker.io/zmkfirmware/zmk-build-arm:3.0
|
||||||
|
@ -104,7 +104,7 @@ jobs:
|
||||||
throw new Error('Failed to build one or more configurations');
|
throw new Error('Failed to build one or more configurations');
|
||||||
}
|
}
|
||||||
compile-matrix:
|
compile-matrix:
|
||||||
if: ${{ always() }}
|
if: ${{ false && always() }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [core-coverage, board-changes, nightly]
|
needs: [core-coverage, board-changes, nightly]
|
||||||
outputs:
|
outputs:
|
||||||
|
@ -144,7 +144,7 @@ jobs:
|
||||||
shieldArgs: JSON.stringify(shieldArgs),
|
shieldArgs: JSON.stringify(shieldArgs),
|
||||||
}));
|
}));
|
||||||
core-coverage:
|
core-coverage:
|
||||||
if: ${{ needs.get-changed-files.outputs.core-changes == 'true' }}
|
if: ${{ false && needs.get-changed-files.outputs.core-changes == 'true' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: get-changed-files
|
needs: get-changed-files
|
||||||
outputs:
|
outputs:
|
||||||
|
@ -173,7 +173,7 @@ jobs:
|
||||||
|
|
||||||
return [...include, ...coreCoverage.include];
|
return [...include, ...coreCoverage.include];
|
||||||
board-changes:
|
board-changes:
|
||||||
if: ${{ needs.get-changed-files.outputs.board-changes == 'true' }}
|
if: ${{ false && needs.get-changed-files.outputs.board-changes == 'true' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [get-grouped-hardware, get-changed-files]
|
needs: [get-grouped-hardware, get-changed-files]
|
||||||
outputs:
|
outputs:
|
||||||
|
@ -257,7 +257,7 @@ jobs:
|
||||||
});
|
});
|
||||||
}))).flat();
|
}))).flat();
|
||||||
nightly:
|
nightly:
|
||||||
if: ${{ github.event_name == 'schedule' }}
|
if: ${{ false && github.event_name == 'schedule' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: get-grouped-hardware
|
needs: get-grouped-hardware
|
||||||
outputs:
|
outputs:
|
||||||
|
@ -302,6 +302,7 @@ jobs:
|
||||||
|
|
||||||
return [...includeOnboard, ...includeInterconnect];
|
return [...includeOnboard, ...includeInterconnect];
|
||||||
get-grouped-hardware:
|
get-grouped-hardware:
|
||||||
|
if: ${{ false }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
organized-metadata: ${{ steps.organize-metadata.outputs.result }}
|
organized-metadata: ${{ steps.organize-metadata.outputs.result }}
|
||||||
|
@ -379,7 +380,7 @@ jobs:
|
||||||
return JSON.stringify(grouped).replace(/\\/g,"\\\\");
|
return JSON.stringify(grouped).replace(/\\/g,"\\\\");
|
||||||
result-encoding: string
|
result-encoding: string
|
||||||
get-changed-files:
|
get-changed-files:
|
||||||
if: ${{ github.event_name != 'schedule' }}
|
if: ${{ false && github.event_name != 'schedule' }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
outputs:
|
outputs:
|
||||||
changed-files: ${{ steps.changed-files.outputs.all }}
|
changed-files: ${{ steps.changed-files.outputs.all }}
|
||||||
|
|
62
.github/workflows/nix-build.yml
vendored
Normal file
62
.github/workflows/nix-build.yml
vendored
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
name: Build
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
paths:
|
||||||
|
- ".github/workflows/nix-build.yml"
|
||||||
|
- "default.nix"
|
||||||
|
- "app/**"
|
||||||
|
- "nix/**"
|
||||||
|
branches:
|
||||||
|
- '**'
|
||||||
|
tags:
|
||||||
|
- '**'
|
||||||
|
pull_request:
|
||||||
|
paths:
|
||||||
|
- ".github/workflows/nix-build.yml"
|
||||||
|
- "default.nix"
|
||||||
|
- "app/**"
|
||||||
|
- "nix/**"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
name: Build Glove80 Firmware
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2.4.0
|
||||||
|
- uses: cachix/install-nix-action@v16
|
||||||
|
with:
|
||||||
|
nix_path: nixpkgs=channel:nixos-22.05
|
||||||
|
- uses: cachix/cachix-action@v12
|
||||||
|
with:
|
||||||
|
name: moergo-glove80-zmk-dev
|
||||||
|
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
|
||||||
|
skipPush: "${{ github.repository != 'moergo-sc/zmk' }}"
|
||||||
|
- name: Build Glove80 combined firmware
|
||||||
|
run: nix-build -A glove80_combined -o combined
|
||||||
|
- name: Copy result out of nix store
|
||||||
|
run: cp combined/glove80.uf2 glove80.uf2
|
||||||
|
- name: Upload result
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: glove80.uf2
|
||||||
|
path: glove80.uf2
|
||||||
|
release:
|
||||||
|
name: Create Release for Tag
|
||||||
|
if: >-
|
||||||
|
github.repository == 'moergo-sc/zmk'
|
||||||
|
&& github.event_name == 'push'
|
||||||
|
&& contains(github.ref, 'refs/tags/v')
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Download compiled firmware artifact
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
with:
|
||||||
|
name: glove80.uf2
|
||||||
|
- name: Create Release for Tag
|
||||||
|
uses: ncipollo/release-action@v1
|
||||||
|
with:
|
||||||
|
artifacts: "glove80.uf2"
|
||||||
|
artifactErrorsFailBuild: true
|
||||||
|
generateReleaseNotes: true
|
|
@ -1,4 +1,4 @@
|
||||||
{ pkgs ? import <nixpkgs> {} }:
|
{ pkgs ? (import ./nix/pinned-nixpkgs.nix {}) }:
|
||||||
let
|
let
|
||||||
inherit (pkgs) newScope;
|
inherit (pkgs) newScope;
|
||||||
inherit (pkgs.lib) makeScope;
|
inherit (pkgs.lib) makeScope;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{ pkgs ? (import <nixpkgs> {})}:
|
{ pkgs ? (import ./pinned-nixpkgs.nix {}) }:
|
||||||
|
|
||||||
let
|
let
|
||||||
zmkPkgs = (import ../default.nix { inherit pkgs; });
|
zmkPkgs = (import ../default.nix { inherit pkgs; });
|
||||||
|
|
34
nix/generate-pin.rb
Executable file
34
nix/generate-pin.rb
Executable file
|
@ -0,0 +1,34 @@
|
||||||
|
#!/usr/bin/env ruby
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'json'
|
||||||
|
require 'net/http'
|
||||||
|
require 'shellwords'
|
||||||
|
|
||||||
|
def get_channel_url(channel)
|
||||||
|
uri = URI("https://channels.nixos.org/#{channel}")
|
||||||
|
res = Net::HTTP.get_response(uri)
|
||||||
|
raise 'Not a redirect' unless res.is_a?(Net::HTTPRedirection)
|
||||||
|
res['location']
|
||||||
|
end
|
||||||
|
|
||||||
|
def fetch_tarball(url)
|
||||||
|
hash = `nix-prefetch-url --unpack #{Shellwords.escape(url)}`
|
||||||
|
raise 'Prefetch failed' unless $?.success?
|
||||||
|
hash.chomp
|
||||||
|
end
|
||||||
|
|
||||||
|
def generate_pin(channel)
|
||||||
|
channel_url = get_channel_url(channel)
|
||||||
|
nixexprs = "#{channel_url}/nixexprs.tar.xz"
|
||||||
|
hash = fetch_tarball(nixexprs)
|
||||||
|
{ url: nixexprs, sha256: hash }
|
||||||
|
end
|
||||||
|
|
||||||
|
def main
|
||||||
|
channel = ENV.fetch('CHANNEL', 'nixpkgs-unstable')
|
||||||
|
pin = generate_pin(channel)
|
||||||
|
puts JSON.pretty_generate(pin)
|
||||||
|
end
|
||||||
|
|
||||||
|
main
|
4
nix/pinned-nixpkgs.json
Normal file
4
nix/pinned-nixpkgs.json
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"url": "https://releases.nixos.org/nixpkgs/22.05-darwin/nixpkgs-darwin-22.05pre383202.058d97782ed/nixexprs.tar.xz",
|
||||||
|
"sha256": "0m00195y7l2b3mrzi26ljm32s24qp5paz15fqbd49iyfjzxv7xb8"
|
||||||
|
}
|
17
nix/pinned-nixpkgs.nix
Normal file
17
nix/pinned-nixpkgs.nix
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{ system ? builtins.currentSystem }:
|
||||||
|
|
||||||
|
let
|
||||||
|
pin = builtins.fromJSON (builtins.readFile ./pinned-nixpkgs.json);
|
||||||
|
|
||||||
|
nixpkgsSrc = builtins.fetchTarball {
|
||||||
|
inherit (pin) url sha256;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
|
||||||
|
import nixpkgsSrc {
|
||||||
|
inherit system;
|
||||||
|
config = {
|
||||||
|
allowUnfree = true;
|
||||||
|
};
|
||||||
|
overlays = []; # prevent impure overlays
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
{ pkgs ? (import <nixpkgs> {})}:
|
{ pkgs ? (import ./pinned-nixpkgs.nix {}) }:
|
||||||
|
|
||||||
let
|
let
|
||||||
# need a newer west than nixpkgs packages
|
# need a newer west than nixpkgs packages
|
||||||
|
@ -28,10 +28,15 @@ let
|
||||||
intelhex
|
intelhex
|
||||||
west
|
west
|
||||||
];
|
];
|
||||||
|
|
||||||
|
requiredStdenv =
|
||||||
|
if pkgs.stdenv.hostPlatform.isLinux
|
||||||
|
then pkgs.multiStdenv
|
||||||
|
else pkgs.stdenv;
|
||||||
in
|
in
|
||||||
with pkgs;
|
with pkgs;
|
||||||
# requires multiStdenv to build 32-bit test binaries
|
# requires multiStdenv to build 32-bit test binaries
|
||||||
multiStdenv.mkDerivation {
|
requiredStdenv.mkDerivation {
|
||||||
name = "zmk-shell";
|
name = "zmk-shell";
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
|
|
Loading…
Add table
Reference in a new issue