Skip to content

Commit

Permalink
switch to hercules ci
Browse files Browse the repository at this point in the history
  • Loading branch information
zowoq committed Apr 6, 2023
1 parent 5ebb759 commit 9457781
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 45 deletions.
25 changes: 0 additions & 25 deletions .github/workflows/build.yml

This file was deleted.

9 changes: 2 additions & 7 deletions bors.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
cut_body_after = "" # don't include text from the PR body in the merge commit message
status = [
# garnix
"Evaluate flake.nix",
"package netboot-nixos-2211 [x86_64-linux]",
"package kexec-installer-nixos-2211 [x86_64-linux]",
"package kexec-installer-nixos-unstable [x86_64-linux]",
"check kexec-installer-unstable [x86_64-linux]",
"package netboot-nixos-unstable [x86_64-linux]"
"ci/hercules/onPush/default",
"ci/hercules/evaluation",
]
22 changes: 12 additions & 10 deletions build-images.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#!/usr/bin/env nix-shell
#!nix-shell -p nix -p coreutils -p bash -p gh -i bash
# shellcheck shell=bash
#!/usr/bin/env bash
set -xeuo pipefail
shopt -s lastpipe

build_netboot_image() {
declare -r tag=$1 arch=$2 tmp=$3
img=$(nix build --print-out-paths --option accept-flake-config true -L ".#packages.${arch}.netboot-${tag//./}")
img=$(nix build --extra-experimental-features 'nix-command flakes' --print-out-paths --option accept-flake-config true -L ".#packages.${arch}.netboot-${tag//./}")
ln -s "${img}/bzImage" "${tmp}/bzImage-${arch}"
echo "${tmp}/bzImage-${arch}"
ln -s "${img}/initrd" "${tmp}/initrd-${arch}"
Expand All @@ -21,17 +19,19 @@ build_netboot_image() {

build_kexec_installer() {
declare -r tag=$1 arch=$2 tmp=$3
out=$(nix build --print-out-paths --option accept-flake-config true -L ".#packages.${arch}.kexec-installer-${tag//./}")
out=$(nix build --extra-experimental-features 'nix-command flakes' --print-out-paths --option accept-flake-config true -L ".#packages.${arch}.kexec-installer-${tag//./}")
echo "${out}/nixos-kexec-installer-${arch}.tar.gz"
}

main() {
declare -r tag=${1:-nixos-unstable} arch=${2:-x86_64-linux}
declare -r tag=$1
tmp="$(mktemp -d)"
trap 'rm -rf -- "$tmp"' EXIT
(
build_kexec_installer "${tag}" "${arch}" "${tmp}"
build_netboot_image "${tag}" "${arch}" "${tmp}"
for arch in x86_64-linux aarch64-linux; do
build_kexec_installer "${tag}" "${arch}" "${tmp}"
build_netboot_image "${tag}" "${arch}" "${tmp}"
done
) | readarray -t assets
for asset in "${assets[@]}"; do
pushd "$(dirname "${asset}")"
Expand All @@ -40,9 +40,11 @@ main() {
done
assets+=("${TMP}/sha256sums")

cat "${TMP}/sha256sums"

# Since we cannot atomically update a release, we delete the old one before
gh release delete "${tag}" </dev/null || true
gh release create --title "${tag} (build $(date +"%Y-%m-%d"))" "${tag}" "${assets[@]}" </dev/null
#gh release delete "${tag}" </dev/null || true
#gh release create --title "${tag} (build $(date +"%Y-%m-%d"))" "${tag}" "${assets[@]}" </dev/null
}

main "$@"
58 changes: 58 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 29 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,45 @@
inputs.nixos-unstable.url = "github:NixOS/nixpkgs/nixos-unstable-small";
inputs.nixos-2211.url = "github:NixOS/nixpkgs/release-22.11";

inputs.hercules-ci-effects.url = "github:hercules-ci/hercules-ci-effects";
inputs.hercules-ci-effects.inputs.hercules-ci-agent.follows = "";
inputs.hercules-ci-effects.inputs.nixpkgs.follows = "nixos-unstable";

nixConfig.extra-substituters = [
"https://cache.garnix.io"
"https://nix-community.cachix.org"
];
nixConfig.extra-trusted-public-keys = [
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];

outputs = { self, nixos-unstable, nixos-2211 }:
outputs = { self, nixos-unstable, nixos-2211, hercules-ci-effects, ... }:
let
supportedSystems = [ "aarch64-linux" "x86_64-linux" ];
forAllSystems = nixos-unstable.lib.genAttrs supportedSystems;
in
{
effects = { src ? { ref = null; }, ... }:
let
pkgs = nixos-unstable.legacyPackages.x86_64-linux;
hciEffects = hercules-ci-effects.lib.withPkgs pkgs;
in
{
release = hciEffects.runIf (src.ref != "refs/heads/master") (
hciEffects.mkEffect {
name = "release";
inputs = with pkgs; [ bash gh nix ];
src = pkgs.lib.cleanSource ./.;
secretsMap.githubToken = { type = "GitToken"; };
effectScript = ''
export GH_TOKEN="$(readSecretString githubToken .token)"
bash ./build-images.sh nixos-unstable
bash ./build-images.sh nixos-21.11
'';
}
);
};

packages = forAllSystems (system:
let
netboot = nixpkgs: (import (nixpkgs + "/nixos/release.nix") { }).netboot.${system};
Expand Down

0 comments on commit 9457781

Please sign in to comment.