Skip to content

nixosConfiguration support for std-action #40

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

Open
womfoo opened this issue Mar 16, 2025 · 3 comments
Open

nixosConfiguration support for std-action #40

womfoo opened this issue Mar 16, 2025 · 3 comments

Comments

@womfoo
Copy link

womfoo commented Mar 16, 2025

  cellBlocks = with hive.blockTypes;
    [ (nixosConfigurations // { ci.build = true; })` 

Doesn't generate enough details for std-action (missing proviso / drvPath attrs in nix eval .#__std.ci.x86_64-linux.)

Is this out of scope since it falls outside the cell block's scope (harvest/collect/transform)?

I'm not familiar with the internals of std/hive, but happy to implement it if someone can guide me!

@blaggacao
Copy link
Collaborator

This shouldn't fall out of scope.

If there's no kvm build necessary, it should even build on GitHub actions.

The nixos blocktype is implemented here, so any modification to the blocktype necessary to be eligible for std-action needs to go there: https://github.com/divnix/hive/blob/main/src/blockTypes/nixosConfigurations.nix

Proviso should be optional: https://github.com/divnix/std-action/blob/4d88d45cacadad99e60218b4ed83037a5884a33c/discover/eval.sh#L54 — but it can be implemented so as to avoid building a nixos build twice, since the only reasonable "registry" of a finished build is the cache, we can use the normal nix build proviso: https://github.com/divnix/std/blob/main/src/std/fwlib/actions/build-proviso.sh

While actionDrv is the wrapping script that is executed locally / or by the final step, targetDrv is the main build artifact wrapped into the actionDrv, for example:

nix build '.#__std.actions.x86_64-linux."david"."nixosConfigurations"."meerkat"."build"'cat result 
#!/nix/store/gwgqdl0242ymlikq9s9s62gkp5cvyal3-bash-5.2p37/bin/bash
bin=$(nix build .#nixosConfigurations.david-meerkat.system --no-link --print-out-paths)/sw/bin
export PATH=$bin:$PATH
 nixos-rebuild build --flake "$PRJ_ROOT" $@ 

In that actionDrv wrapper, nixosConfigurations.david-meerkat.system would be the targetDrv, which btw seems a bug. It should be nixosConfigurations.david-meerkat.config.system.build.toplevel, ergo nixosConfigurations.david-meerkat.config.system.build.toplevel.drvPath which according to above paisano-nix/core link should be drvPath-collected from the target, if the target is set correctly (which thangs to the apparent bug does not seem the case, here).

@blaggacao
Copy link
Collaborator

You can check out what the target holds in the nixosConfiguration block type, but since the actual nixosConfigurations are located elsewhere in the tree (namely under .nixosConfiguration) rather than directly under the cell block, we might still continue to reconstruct the path with regard to the entire flake as we do now and can't work with target directly. Still, we can extract the targetDrv from drvPath and assign it manually to the action output (iirc as sisters to the command attribute).

@womfoo
Copy link
Author

womfoo commented Mar 18, 2025

Thanks @blaggacao for the detailed explanation! Let me give this a shot and prepare a PR

For now, my approach would be

  1. Pass .#nixosConfigurations.${hostname}.config.system.build.toplevel.drvPath as drvPath
  2. New proviso script, as the existing one in std relies on nix-store --realise --dry-run /nix/store/***.drv and can't use the format in step 1.

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

No branches or pull requests

2 participants