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

feat(apps): add git-push and deploy scripts for darwin and nixos #106

Merged
merged 2 commits into from
May 29, 2024

Conversation

steveej
Copy link
Member

@steveej steveej commented May 27, 2024

instead of rsync'ing the flake to the machine, the workflow will be to push the desired repository state to host-specific branches from which they can subsequently be deployed.

fixes #68.

  • store self.sourceInfo somewhere on the machines

demo of how to read the source revision from the machine itself:

steveej@sj-bm-hostkey0 ✓ ~/src/holo/holochain-infra 🐚 deploy-from-github ⚡
$ (
  set -xE
  git diff --exit-code HEAD $(nix run .\#ssh-macos-02 "cat /etc/nix/sourceInfo.json" | jq --raw-output '.rev')
  echo deployed from HEAD
)
+-zsh:19> nix run '.#ssh-macos-02' 'cat /etc/nix/sourceInfo.json'
+-zsh:19> jq --raw-output .rev
+ ssh administrator@hydra-minion-2.holo.host cat /etc/nix/sourceInfo.json
+-zsh:19> git diff --exit-code HEAD d49d95a4c50ce49c87957d1d3f7bb1e3a70efa45
+-zsh:20> echo deployed from HEAD
deployed from HEAD

another demo:

$ jq . <(nix run .\#ssh-sbd-0_main_infra_holo_host "cat /etc/nix/sourceInfo.json")
+ ssh root@65.108.241.120 cat /etc/nix/sourceInfo.json
{
  "lastModified": 1716839508,
  "lastModifiedDate": "20240527195148",
  "narHash": "sha256-otiepXy7lVOBHXJFhp2J4CkKxzzOUuLMmDOFOio+jgc=",
  "rev": "b5706e0d43845f512589784c3e3a9dd69dc1a300",
  "shortRev": "b5706e0"
}

instead of rsync'ing the flake to the machine, the workflow will be to
push the desired repository state to host-specific branches from which
they can subsequently be deployed.
…stem

this will allow to verify whether a machine differs from its deploy
branch in the repository.
@steveej steveej requested review from evangineer and a team May 27, 2024 19:54
config = {
environment.etc."nix/sourceInfo.json" = {
enable = true;
text = builtins.toJSON (builtins.removeAttrs self.sourceInfo ["outPath"]);
Copy link
Member Author

Choose a reason for hiding this comment

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

if the outPath attribute isn't removed the file would only contain the outPath i.e. nix-store path of the sources, which isn't helpful in this use-case.


environment.etc."nix/source" = {
enable = true;
text = self.sourceInfo.outPath;
Copy link
Member Author

Choose a reason for hiding this comment

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

this will be a text file that contains the path to the sources stored underneath /nix/store/...

@steveej steveej merged commit b1f02c7 into develop May 29, 2024
1 check passed
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.

it's unclear from which revision any given machine has been deployed
2 participants