Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub Actions image format builds #155

Closed
wants to merge 14 commits into from

Conversation

tomeon
Copy link
Contributor

@tomeon tomeon commented May 21, 2022

Re this comment.

This PR introduces:

  1. Nix flake check outputs for x86_64-linux (almost everything but the sd-aarch64 and sd-aarch64-installer formats) and aarch64-linux (only the sd-aarch64 and sd-aarch64-installer formats), and
  2. A set of GitHub Actions jobs that (a) evaluate the flake checks, (b) attempt to build various formats using nixos-generate with appropriate arguments, and (c) attempt to build the Nix flake check outputs.

Submitting as a draft for feedback on scope, design, and plain old fitness for purpose before proceeding further.

Link to a passing GitHub actions run is here (66th time's the charm 🥲).

@tomeon tomeon marked this pull request as draft May 21, 2022 19:28
@tomeon
Copy link
Contributor Author

tomeon commented May 21, 2022

TODO

When to run

Building (almost) all formats is time-consuming, even when running all the builds in parallel. Maybe these jobs should run only upon pull request activity, and not upon every push?

Build artifacts

The GitLab CI setup included exposing the results of the vm and vm-nogui builds as artifacts. I've ported this over to the updated GitHub Actions workflow. Not sure what value, if any, this provides.

Caching

Would it be worthwhile to cache build results? With, say, Cachix?

Useless work

Some jobs (e.g., anything involving the cloudstack format) do a bunch of work -- checking out the repo, installing Nix, etc. -- only to exit without attempting to build anything because the Nix flake doesn't define .#checks.<system>.cloudstack-<nixpkgs>. This is wasteful.

This useless work could be cut out by duplicating some of the format-exclusion logic from the Nix flake check definitions as exclude entries in the relevant job matrix.

Complexity

The flake check stuff is pretty hairy. Would welcome feedback on improving the architecture.

@tomeon tomeon force-pushed the github-actions-image-builds branch from 497f5c3 to 1e17cc7 Compare May 21, 2022 19:49
@tomeon tomeon changed the title GitHub actions image builds GitHub Actions image format builds May 21, 2022
@Mic92
Copy link
Member

Mic92 commented Jun 10, 2022

Btw. we have also have a self-hosted hercules ci setup in this organisation, which does not need to download all derivations. This might be faster than github actions. There is also an aarch64 builder included for cross-ci builds.

@Lassulus
Copy link
Collaborator

generally this goes in the right direction. I guess we want to build just 3-4 different images on every push (difference between push or PR is not big enough to matter) I guess we should build something like kexec-bundle, container, amazon, iso ? since those are the most commonly used I would guess

@Mic92
Copy link
Member

Mic92 commented Jun 10, 2022

Could you maybe move some of your commits not related to CI to a new PR? i.e. 45504ad looks like no-brainer that we can just merge as is. Than reviewing this will become faster.

@tomeon
Copy link
Contributor Author

tomeon commented Jun 17, 2022

Could you maybe move some of your commits not related to CI to a new PR?

Done, done, and done 👍

@tomeon tomeon force-pushed the github-actions-image-builds branch from 1e17cc7 to dd66dfe Compare June 17, 2022 03:32
@tomeon tomeon force-pushed the github-actions-image-builds branch from dd66dfe to 542e321 Compare July 5, 2022 20:45
Lassulus and others added 14 commits July 15, 2023 20:58
by s/-type/-xtype/ in the "find" invocation.  Now nixos-generate prints
both regular files and symlinks to regular files (like "run-nixos-vm"
for the "vm" and "vm-nogui" formats).
Namely, assert that the last line of output refers to a store path that
is a file or symlink to a file.
on nixpkgs versions prior to the commit that changed
config.system.build's type from a lazy attribute set to a submodule.

Prior to this type change, there is no system.build.kexec_tarball option
declared, so the NixOS module system does not resolve
priorities/overrides in the config.build.kexec_tarball definition.

That is, with lib.mkForce, the config.build.kexec_tarball definition
ends up being something like:

    {
      _type = "override";
      content = <...>;
      priority = 50;
    }

Removing lib.mkForce allows us to successfully and sensibly interpolate
the value (== outPath) of system.build.kexec_tarball in
system.build.kexec_bundle's builder script.

Likewise, no lib.mkOverride for system.build.raw.
to gain access to proxmox-lxc and kubevirt profiles
that build various images.  Limitation: checks only exist for
x86_64-linux and aarch64-linux.

Incidental changes:

    1. Add nixos-21.11 release as a flake input.
    2. Add the function `nixosGenerate'`, which is a generalized version
       of `nixosGenerate` that takes the additional mandatory argument
       `system` and the additional optional argument `nixpkgs` (the
       latter of which should be a nixpkgs *flake*).  This function is
       used for constructing the flake checks; `nixpkgs` needs to be
       parameterized in order to use both nixpkgs-unstable and
       nixos-21.11.
@tomeon tomeon force-pushed the github-actions-image-builds branch from 542e321 to a792c32 Compare July 16, 2023 01:09
@tomeon tomeon closed this Jul 16, 2023
@tomeon tomeon deleted the github-actions-image-builds branch July 16, 2023 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants