Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
zowoq committed Apr 6, 2023
1 parent 24cdc53 commit 9b78254
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 43 deletions.
34 changes: 17 additions & 17 deletions build-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,43 @@ 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//.}")
ln -s "$img/bzImage" "$tmp/bzImage-$arch"
echo "$tmp/bzImage-$arch"
ln -s "$img/initrd" "$tmp/initrd-$arch"
echo "$tmp/initrd-$arch"
img=$(nix build --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}"
echo "${tmp}/initrd-${arch}"
sed -e "s!^kernel bzImage!kernel https://github.com/nix-community/nixos-images/releases/download/${tag}/bzImage-${arch}!" \
-e "s!^initrd initrd!initrd https://github.com/nix-community/nixos-images/releases/download/${tag}/initrd-${arch}!" \
-e "s!initrd=initrd!initrd=initrd-${arch}!" \
< "$img/netboot.ipxe" \
> "$tmp/netboot-$arch.ipxe"
echo "$tmp/netboot-$arch.ipxe"
<"${img}/netboot.ipxe" \
>"${tmp}/netboot-${arch}.ipxe"
echo "${tmp}/netboot-${arch}.ipxe"
}

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//.}")
echo "$out/nixos-kexec-installer-$arch.tar.gz"
out=$(nix build --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}
tmp="$(mktemp -d)"
trap 'rm -rf -- "$tmp"' EXIT
(
build_kexec_installer "$tag" "$arch" "$tmp"
build_netboot_image "$tag" "$arch" "$tmp"
build_kexec_installer "${tag}" "${arch}" "${tmp}"
build_netboot_image "${tag}" "${arch}" "${tmp}"
) | readarray -t assets
for asset in "${assets[@]}"; do
pushd "$(dirname "$asset")"
sha256sum "$(basename "$asset")" >> "$TMP/sha256sums"
pushd "$(dirname "${asset}")"
sha256sum "$(basename "${asset}")" >>"${TMP}/sha256sums"
popd
done
assets+=("$TMP/sha256sums")
assets+=("${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 "$@"
59 changes: 33 additions & 26 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,38 @@
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
];

outputs = { self, nixos-unstable, nixos-2211 }: let
supportedSystems = [ "aarch64-linux" "x86_64-linux" ];
forAllSystems = nixos-unstable.lib.genAttrs supportedSystems;
in {
packages = forAllSystems (system: let
netboot = nixpkgs: (import (nixpkgs + "/nixos/release.nix") {}).netboot.${system};
kexec-installer = nixpkgs: (nixpkgs.legacyPackages.${system}.nixos [self.nixosModules.kexec-installer]).config.system.build.kexecTarball;
in {
netboot-nixos-unstable = netboot nixos-unstable;
netboot-nixos-2211 = netboot nixos-2211;
kexec-installer-nixos-unstable = kexec-installer nixos-unstable;
kexec-installer-nixos-2211 = kexec-installer nixos-2211;
});
nixosModules.kexec-installer = import ./nix/kexec-installer/module.nix;
checks.x86_64-linux = let
pkgs = nixos-unstable.legacyPackages.x86_64-linux;
in {
kexec-installer-unstable = pkgs.callPackage ./nix/kexec-installer/test.nix {};
shellcheck = pkgs.runCommand "shellcheck" {
nativeBuildInputs = [ pkgs.shellcheck ];
} ''
shellcheck ${(pkgs.nixos [self.nixosModules.kexec-installer]).config.system.build.kexecRun}
touch $out
'';
kexec-installer-2211 = nixos-2211.legacyPackages.x86_64-linux.callPackage ./nix/kexec-installer/test.nix {};
outputs = { self, nixos-unstable, nixos-2211 }:
let
supportedSystems = [ "aarch64-linux" "x86_64-linux" ];
forAllSystems = nixos-unstable.lib.genAttrs supportedSystems;
in
{
packages = forAllSystems (system:
let
netboot = nixpkgs: (import (nixpkgs + "/nixos/release.nix") { }).netboot.${system};
kexec-installer = nixpkgs: (nixpkgs.legacyPackages.${system}.nixos [ self.nixosModules.kexec-installer ]).config.system.build.kexecTarball;
in
{
netboot-nixos-unstable = netboot nixos-unstable;
netboot-nixos-2211 = netboot nixos-2211;
kexec-installer-nixos-unstable = kexec-installer nixos-unstable;
kexec-installer-nixos-2211 = kexec-installer nixos-2211;
});
nixosModules.kexec-installer = import ./nix/kexec-installer/module.nix;
checks.x86_64-linux =
let
pkgs = nixos-unstable.legacyPackages.x86_64-linux;
in
{
kexec-installer-unstable = pkgs.callPackage ./nix/kexec-installer/test.nix { };
shellcheck = pkgs.runCommand "shellcheck"
{
nativeBuildInputs = [ pkgs.shellcheck ];
} ''
shellcheck ${(pkgs.nixos [self.nixosModules.kexec-installer]).config.system.build.kexecRun}
touch $out
'';
kexec-installer-2211 = nixos-2211.legacyPackages.x86_64-linux.callPackage ./nix/kexec-installer/test.nix { };
};
};
};
}

0 comments on commit 9b78254

Please sign in to comment.