Optimization: Derive list of silver-flame host IPs more quickly #18

Open
opened 2024-10-25 21:14:19 -07:00 by Jafner · 2 comments
Owner

Our Actions workflow to deploy Silver Flame NixOS system configurations uses a naive approach to get the IPs of hosts to add to our known_hosts file.

We evaluate the silver-flame flake, and then print the value of the deploy.nodes.[hosts].hostname outputs to a text file.

Is it possible to extract a value from the nix attribute tree without evaluating it?

Alternatively, can we make that step unnecessary by automatically accepting host keys in our deploy-rs step?

Our Actions workflow to deploy Silver Flame NixOS system configurations uses a naive approach to get the IPs of hosts to add to our known_hosts file. We evaluate the silver-flame flake, and then print the value of the `deploy.nodes.[hosts].hostname` outputs to a text file. Is it possible to extract a value from the nix attribute tree *without* evaluating it? Alternatively, can we make that step unnecessary by automatically accepting host keys in our deploy-rs step?
Jafner added this to the Automated Deployment milestone 2024-10-25 21:14:19 -07:00
Author
Owner

We can switch to a quick and dirty text search script:

cat flake.nix |\
  grep 'hostname = ' |\
  cut -d'"' -f2

Which should return each of the IPs we have listed in our deploy-rs configuration. This solution is much more fragile, and could break for any number of reasons.

We can switch to a quick and dirty text search script: ```sh cat flake.nix |\ grep 'hostname = ' |\ cut -d'"' -f2 ``` Which should return each of the IPs we have listed in our deploy-rs configuration. This solution is much more fragile, and could break for any number of reasons.
Author
Owner

We may find a better solution with nix-instantiate. Its --parse flag seems to behave exactly as lazily as we want.

We may find a better solution with [`nix-instantiate`](https://nix.dev/manual/nix/2.18/command-ref/nix-instantiate.html). Its `--parse` flag seems to behave exactly as lazily as we want.
Sign in to join this conversation.
No Label
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Jafner/Jafner.net#18
No description provided.