Skip to content

Conversation

a-kenji
Copy link
Contributor

@a-kenji a-kenji commented Jul 21, 2025

Fallback to nixos-facter from nixpkgs if not available in the booted system.
This way we can skip the specific image requirement, while still
supporting the specific nixos-facter in a booted image, if
available.
Can improve bootstrapping of nixos-anywhere.

Alternatives:

  • Since this implementation directly runs nixos-facter from nixpkgs
    we could theoretically get an uncached version and would need to
    build. We could test for that with --max-jobs 0 and give an
    approriate error message.

Tested:

  • This has been tested manually, but if required I can add a nixosTest for the functionality.

@a-kenji a-kenji requested review from Lassulus, Enzime and Mic92 July 21, 2025 19:51
…ystem

Fallback to `nixos-facter` from `nixpkgs` if not available in the booted system.
This way we can skip the specific image requirement, while still
supporting the specific `nixos-facter` in a booted image, if
`available`.
Can improve bootstrapping of `nixos-anywhere`.

Alternatives:
- Since this implementation directly runs `nixos-facter` from `nixpkgs`
  we could theoretically get an uncached version and would need to
  build. We could test for that with `--max-jobs 0` and give an
  approriate error message.
@a-kenji a-kenji force-pushed the ke-run-nixos-facter branch from 9fd3610 to d944503 Compare July 21, 2025 20:23
@a-kenji a-kenji added this pull request to the merge queue Jul 22, 2025
Merged via the queue into nix-community:main with commit 57730f9 Jul 22, 2025
4 checks passed
@a-kenji a-kenji deleted the ke-run-nixos-facter branch July 22, 2025 09:31
@Enzime
Copy link
Member

Enzime commented Jul 24, 2025

Looks like nixOptions isn't being quoted correctly over SSH:

If I run this on a machine without experimental-features = nix-command flakes:

+ step 'Generating facter.json using nixos-facter from nixpkgs'
+ echo '### Generating facter.json using nixos-facter from nixpkgs ###'
+ runSshNoTty -o ConnectTimeout=10 '' nix run --extra-experimental-features 'nix-command flakes' --no-write-lock-file -L nixpkgs#nixos-facter
+ ssh -o IdentitiesOnly=yes -i /tmp/tmp.VQpXObgWld/nixos-anywhere -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@example.local -o ConnectTimeout=10 '' nix run --extra-experimental-features 'nix-command flakes' --no-write-lock-file -L nixpkgs#nixos-facter
Warning: Permanently added 'example.local' (ED25519) to the list of known hosts.
error: experimental Nix feature 'flakes' is disabled; add '--extra-experimental-features flakes' to enable it

If I run this on a machine with experimental-features = nix-command flakes:

+ step 'Generating facter.json using nixos-facter from nixpkgs'
+ echo '### Generating facter.json using nixos-facter from nixpkgs ###'
+ runSshNoTty -o ConnectTimeout=10 '' nix run --extra-experimental-features 'nix-command flakes' --no-write-lock-file -L nixpkgs#nixos-facter
+ ssh -o IdentitiesOnly=yes -i /tmp/tmp.xak2g9IHuf/nixos-anywhere -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@example.local -o ConnectTimeout=10 '' nix run --extra-experimental-features 'nix-command flakes' --no-write-lock-file -L nixpkgs#nixos-facter
Warning: Permanently added 'example.local' (ED25519) to the list of known hosts.
error: cannot find flake 'flake:flakes' in the flake registries

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.

3 participants