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

Exploratory: Add bootstrap script hook #1505

Open
wants to merge 3 commits into
base: release-1.7
Choose a base branch
from

Conversation

exFalso
Copy link

@exFalso exFalso commented Feb 9, 2022

Hi, this PR is more of an exploratory PR, to see whether this idea is useful for the general public. Internally at our company we're using nixops to deploy to non-NixOS systemd distributions. One of the issues we used to have is that nixops makes certain assumptions about the target machine, namely that it has a working multi-user nix installation, and that it has a keys group defined for secrets. For a while we've handled this explicitly outside nixops, we basically made the machine look like NixOS for the purposes of nixops.

However, with a small addition to nixops, we now tackle this issue much more elegantly. Namely, this PR adds a nullable config option deployment.bootstrapScript, which (if set) is run on the master SSH connection before any nix-specific actions are taken, but after the resource closure has been built. This allows us to do the nix installation and certain early setup (like mounting of /nix from a separate hard disk), independent of the /nix/store.

The actual mechanism I added is a bit broken as it only handles None type targets, but the control flow of the resource configuration is a bit too tricky and I couldn't figure out how to do it for a general resource type.

Question is, is this a useful enough feature to be included upstream? If so, can I get any pointers to how to expose the option to a more generic resource type? Also, the changes are on top of the 1.7 tag (the PR is submitted against release-1.7, which seems to have diverged from the tag(??)), would this feature go into 2.0 only? I tried upgrading to 2.0 but got into a bunch of unrelated issues with deployment.

Thank you!

Comment on lines +61 to +62
type = types.nullOr types.lines;
default = null;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type = types.nullOr types.lines;
default = null;
type = types.lines;
default = "";

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