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

Prepare initial image #201

Open
adminy opened this issue Mar 31, 2024 · 1 comment
Open

Prepare initial image #201

adminy opened this issue Mar 31, 2024 · 1 comment

Comments

@adminy
Copy link

adminy commented Mar 31, 2024

Is there a way to configure this so that if it cannot connect to host initially, it generates an image file something like what nix build .#nixosConfigurations.nixos.config.system.build.sdImage does?

@NeverBehave
Copy link
Contributor

NeverBehave commented Apr 17, 2024

Not entirely related, and not entirely sure if this is mentioned elsewhere before, but we have been using the following way to init new systems. I would love to make this work tho.

Instantiate

You can get the result via: name=<node-name> colmena eval --instantiate -E "{ nodes, ... }: nodes.\"$name\".config.system.build.toplevel"

New machine setup

Currently the workflow for any new profile/machine setup would be:

  1. Having a bootable NixOS environment available for the target, usually boot from USB, with SSH enabled.
  1. Boot the target and setup connection to the machine
  2. Setup profile (hive.nix) and related configuration
  3. https://gist.github.com/zhaofengli/e986fa7688d6c16872b86c6ae6215c9b

What this script does is to deploy the toplevel directly using boot ssh with specify root.

The usage of this script:

# Prepare your target machine
# e.g.
# mkfs.vfat -n BOOT $TARGET_DISK_1
# mkfs.ext4 -L NIXOS $TARGET_DISK_2
# mkdir /mnt || true
# mount $TARGET_DISK_2 /mnt
# mkdir /mnt/boot || true
# mount $TARGET_DISK_1 /mnt/boot

## Make sure you have the colmena hive changes included
git add .
## The following will build the toplevel, connect to remote and apply profile. 
## READ KNOWN ISSUES below!
./install.sh <node-name> /mnt

I have my own version which dispatch reboot after install if everything went well, and if you want no substitute, see line#102(if you are deploying system without Internet): https://gist.github.com/NeverBehave/25481e005708572a14a7f8d807b0dda0

Known issues

  1. You will still need to have SSH access to the machine from the build machine, although you won't need network access without substitute
  2. Colmena's deployments specific action won't be triggered. E.g. upload keys. My workaround right now is, after the system has booted, I rerun the normal colmena apply again to have the system fully init.

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