From 029a181e7e1c58fd6ff3e768515948df073b6412 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Fri, 18 Oct 2024 02:49:26 +0100 Subject: [PATCH] assignment: added section on basic use cases including devshell. --- _git.tar.gz | 4 +-- src/skynet/nix.md | 72 +++++++++++++++++++++++++++++++++++++++++------ 2 files changed, 66 insertions(+), 10 deletions(-) diff --git a/_git.tar.gz b/_git.tar.gz index 8a81847..e77017d 100644 --- a/_git.tar.gz +++ b/_git.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6d132d72e9f11832b7b7ec8a4394df7ebaa50765c9da822b1be35eec1f4196d8 -size 370321 +oid sha256:d9b374501f6d61ccc6c223e50623dbf3735912c8ec28a1629184b0f213efb9ab +size 377633 diff --git a/src/skynet/nix.md b/src/skynet/nix.md index 80613c4..7ca0654 100644 --- a/src/skynet/nix.md +++ b/src/skynet/nix.md @@ -157,19 +157,66 @@ Since these systems share a base config (with tehir individual applications laye Combine that with teh ability to deploy them via our own selfhosted CI/CD we have a strong foundation to work off of. ## How we use it -### Requirements -{add warnign that git and git-lfs should also need to be in teh path} +Nix cannot run on Windows, though it cna be installed into WSL. +Please refer to the below downloads to get a base system up and running -### Download +* [Git][git_git] + * As we are using a git repo this is a hard requirement. +* [Git LFS][git_lfs] + * For storing non text files such as images. +* [Nix][nix_install] + * Cant really use nix without thi installed. + +### Dev Shell +After cloning the repo use ``nix develop`` to set up a terminal shell with the environment for working with Skynet NixOS. +It (currently) adds [Colmena][dev_colmena], [Agenix][dev_agenix] and [Attic][dev_attic]. + +Another example of a dev shell can be [our discord bot][dev_discord-bot]. +This one sets up a rust enviroment. + +Of course you can also look at the dev shell for this [wiki][dev_wiki]. +For the wiki we need to ensure that the dependencies for building it are present for all users so tehy dont have to figure out how to manually install them. ### Colmena -#### Local -##### Building +[Colmena][dev_colmena] is our build and deployment tool. -##### Repl +Building is pretty easy, just run ``colmena build``. +Downside of that command is it will try to build everything all at once which is a *lot*. +A more practical approach is to build a single server or a group of servers. +```shell +# build the Skynet server, names cna be found in teh flake.nix +colmena build --on skynet -#### Deployment +# build a group of servers, in this case any one with teh tag of active-core +colmena build --on @active-core +``` +To be able to deploy to Skynet two things are required. +* Be on teh UL network + * This can also be accomplished by being on the VPN. +* Have an ssh key configured that can access the servers + * TLDR be an admin. + +### Agenix +[Agenix][dev_agenix] is our secrets manager. +To be able to use this tool your pub ssh key must be in ``secrets/secrets.nix``. +As you would expect this is an admin only tool. +This file also defines the names and permissions for each secret. + +```shell +# have to be in teh secrets folder for all these commands. +cd secrets + +# edit the secret +agenix -e path/to/secret.age + +# re-key all secrets, this is done when a new key is added or removed. +agenix -r +``` + +### Attic +[Attic][dev_attic] is teh tool that we use for our nix cache (hosted at ). +It is not often it is used by the dev and its own [documentation][dev_attic_docs] covers it best. @@ -183,4 +230,13 @@ Combine that with teh ability to deploy them via our own selfhosted CI/CD we hav [nix_lix]: https://lix.systems/ [nix_lix_about]: https://lix.systems/about/ [skynet_disconnect]: https://public.skynet.ie/postmortem/2023-01-12_Loss-of-network-access.html -[skynet_disconnect_reenactment]: https://forgejo.skynet.ie/Computer_Society/presentations_compsoc/media/branch/main/src/slides/skynet/0_intro_img1.png \ No newline at end of file +[skynet_disconnect_reenactment]: https://forgejo.skynet.ie/Computer_Society/presentations_compsoc/media/branch/main/src/slides/skynet/0_intro_img1.png +[git_git]: https://git-scm.com/downloads +[git_lfs]: https://git-lfs.com/ +[nix_install]: https://nixos.org/download/ +[dev_colmena]: https://colmena.cli.rs/unstable/ +[dev_agenix]: https://github.com/ryantm/agenix +[dev_attic]: https://github.com/zhaofengli/attic +[dev_attic_docs]: https://docs.attic.rs/introduction.html +[dev_discord-bot]: https://forgejo.skynet.ie/Skynet/discord-bot/src/commit/80c9191eeec29ba20ef4084713eca7fe0cab7412/flake.nix#L65 +[dev_wiki]: https://forgejo.skynet.ie/Skynet/wiki/src/commit/ab0add44756d4992fc2b2da4eba163016ccb3d1c/flake.nix#L35