infra/README.md

163 lines
4.5 KiB
Markdown
Raw Normal View History

# nix-community infrastructure
2020-05-03 15:10:15 +02:00
Welcome to the Nix Community infrastructure project. This project holds all
the NixOS and Terraform configuration for this organization.
## Community builder
We also provide one x86 hetzner build machine as a public remote builder for the
nix community. If you want access read the security guide lines on
[aarch64-build-box](https://github.com/nix-community/aarch64-build-box). Than
add your username to `roles/builder/users.nix`. Don't keep any important data
in your home! We will regularly delete `/home` without further notice.
### Using your NixOS home-manager configuration on the hosts
If you happen to have your NixOS & home-manager configurations intertwined but
you'd like your familiar environment on our infrastructure you can evaluate
`pkgs.writeShellScript "hm-activate" config.systemd.services.home-manager-<yourusername>.serviceConfig.ExecStart`
from your NixOS configuration, and send this derivation to be realized remotely:
(in case you aren't a Nix trusted user)
``` console
# somehow get the .drv of the above expression into $path
$ nix copy --to ssh://build01.nix-community.org --derivation $path
$ ssh build01.nix-community.org
$ nix-store -r $path
$ $path
```
*(My [implementation](https://github.com/ckiee/nixfiles/blob/aac57f56e417e31f00fd495d8a30fb399ecbc19b/deploy/hm-only.nix#L10) of [this](https://github.com/ckiee/nixfiles/blob/aac57f56e417e31f00fd495d8a30fb399ecbc19b/bin/c#L92-L95) ~ckie)*
2020-05-03 15:10:15 +02:00
## Support
2019-08-12 17:24:59 +00:00
2021-07-17 18:00:26 +02:00
If you hit any issues, ping us on Matrix in the
2021-11-11 17:38:50 +01:00
[nix-community](https://matrix.to/#/#nix-community:nixos.org)
2021-07-17 18:00:26 +02:00
room (see the admin list below) or create an issue here:
2020-05-03 15:10:15 +02:00
[New Issue](https://github.com/nix-community/infra/issues/new).
2019-08-12 17:24:59 +00:00
2020-05-03 15:10:15 +02:00
### Administrators
2020-03-26 18:00:49 +01:00
2020-04-02 16:35:03 -07:00
* @adisbladis
2020-03-26 18:00:49 +01:00
* @flokli
* @grahamc
* @Mic92
2020-03-26 18:00:49 +01:00
* @nlewo
* @ryantm
* @zimbatm
2019-08-12 17:24:59 +00:00
## Services
2020-05-03 15:10:15 +02:00
* BuildKite agent - on build01
* GitLab agent - on build01
* hound - on build01
* https://hydra.nix-community.org - on build01
* matterbridge - on build01
* ryantm-updater bot - on build02
2020-05-03 15:10:15 +02:00
## Hosts
### `build01` ![build01](https://healthchecks.io/badge/c9e58e14-c706-4084-959b-17b06fbd124f/QFBOLbO1/build01.svg)
This machine is perfect for running heavy builds.
* Provider: Hetzner
* CPU: AMD Ryzen 7 1700X Eight-Core Processor
* RAM: 64GB
* Drives: 2 x 512 GB SATA SSD
### `build02`
This machine currently just runs r-ryantm/nixpkgs-update.
* Provider: Hetzner
* CPU: AMD Ryzen 7 3700X Eight-Core Processor
* RAM: 64GB DDR4 ECC
* Drives: 2 x 1 TB NVME in RAID 1
2020-05-03 15:10:15 +02:00
### `build03`
This machine is a replacement for build01.
* Provider: Hetzner
* CPU: AMD Ryzen 5 3600 6-Core Processor
* RAM: 64GB DDR4 ECC
* Drives: 2 x 512 GB NVME in RAID 1
2021-08-18 08:55:14 +02:00
### `build04`
This machine is meant as an aarch64 builder for our hydra instance running on build03.
* Provider: Oracle cloud
* Instance type: [Ampere A1 Compute](https://www.oracle.com/cloud/compute/arm/)
* CPU: 4 VCPUs on an Ampere Altra (arm64)
* RAM: 24GB
* Drives: 200 GB Block
2021-01-20 20:25:19 -08:00
## Cache
All the builds on these machines are pushed to https://nix-community.cachix.org/
2020-05-03 15:10:15 +02:00
Thanks to Cachix for sponsoring our binary cache!
## File hierarchy
2020-05-03 15:10:15 +02:00
* ./build\d+ - build machines
* ./ci.sh - What is executed by CI
2021-10-03 14:18:57 +02:00
* ./deploy - Deploy script
* ./nix - pinned Nix dependencies and overlays
* ./roles - shared NixOS configuration modules
* ./secrets - git-crypt encrypted secrets
* ./services - single instances of NixOS services
2020-05-03 15:10:15 +02:00
* ./terraform - Setup DNS
* ./users - NixOS configuration of our admins
2020-05-03 15:10:15 +02:00
2021-03-20 06:17:29 +01:00
## Deployment commands:
```console
$ ./deploy
```
If you want to reboot a machine, use the following
command to also deploy secrets afterwards:
```console
2021-10-24 01:43:19 +02:00
$ inv deploy --hosts build02 reboot --hosts build02
2021-03-20 06:17:29 +01:00
```
## Install/Fix system from Hetzner recovery mode
2021-10-24 01:41:22 +02:00
1. Install kexec image from Hetzner recovery system as described in [kexec.nix](roles/kexec.nix) and boot into it
2. Format and/or mount all filesystems to /mnt:
```console
$ inv format-disks --hosts buildXX --disks /dev/nvme0n1,/dev/nvme1n1
2021-05-11 18:46:11 +02:00
```
2021-10-24 01:41:22 +02:00
3. Setup secrets
```console
$ inv setup-secret --hosts buildXX
```
4. Generate configuration and download to the repo
```console
$ nixos-generate-config --root /tmp
2022-01-16 09:52:55 +01:00
# optional, in most cases one can import roles/hardware/hetzner-amd.nix
2021-10-24 01:41:22 +02:00
$ scp buildXX.nix-community.org:/tmp/etc/nixos/hardware-configuration.nix buildXX/hardware-configuration.nix
```
2021-10-24 01:41:22 +02:00
5. Build and install
2021-05-12 20:27:38 +02:00
```console
2021-10-24 01:41:22 +02:00
$ inv install-nixos --hosts buildXX
```
2021-05-12 20:27:38 +02:00
### Debug VM
You can start a vm from the rescue system in order to debug the boot:
```console
2021-05-12 20:27:38 +02:00
$ nix-shell -p qemu_kvm --run 'qemu-kvm -m 10G -hda /dev/sda -hdb /dev/sdb -curses -cpu host -enable-kvm'
```