Contains the reusable Free Your Tech! stack. If your organisation wants to host its own infrastructure, it can deploy our stack with ease, and enjoy a reliable, low maintenance server and a variety of free, high quality services in a suite. https://freeyourtech.org/services
  • Rust 55.2%
  • Nix 44.8%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-11-13 14:31:29 +01:00
cli refactor: membership sync (#138) 2026-10-04 23:24:35 +02:00
hosts Luisa's SSH key added (#142) 2026-11-13 14:31:29 +01:00
modules refactor: membership sync (#138) 2026-10-04 23:24:35 +02:00
npins update: sources (#141) 2026-10-27 00:42:55 +01:00
.gitignore refactor: freeyourtech CLI in Rust (#135) 2026-09-24 10:51:09 +02:00
.sops.yaml add testing hcloud deployment (#88) 2026-03-19 20:13:55 +01:00
Cargo.lock refactor: membership sync (#138) 2026-10-04 23:24:35 +02:00
Cargo.toml refactor: freeyourtech CLI in Rust (#135) 2026-09-24 10:51:09 +02:00
default.nix refactor: freeyourtech CLI in Rust (#135) 2026-09-24 10:51:09 +02:00
LICENSE-APACHE Rearrange secrets, separate production, staging, etc (#15) 2025-11-29 21:39:19 +01:00
LICENSE-MIT Rearrange secrets, separate production, staging, etc (#15) 2025-11-29 21:39:19 +01:00
README.md refactor: freeyourtech CLI in Rust (#135) 2026-09-24 10:51:09 +02:00

FYT Infrastructure

Infrastructure as Code (IaC) and Operations as Code (OaC) repository using Nix and related tools.

Repository Structure

.
├── hosts/         # Deployment specific configurations
├── modules/       # Shared NixOS and Terraform modules, scripts, etc.
├── npins/         # Pinned nix inputs, edit with npins CLI
├── default.nix    # Project outputs (devshell, vm, servers)
└── .sops.yaml     # Secrets encryption config

Secrets

All secrets in the repository are encrypted using SOPS. Each deployment may have its own secrets file, access with age keys are controlled on the file granularity level. There are a few different secret values needed for setting up and maintaining the server. Contrary to earlier versions of this project, no secrets are stored with git-crypt anymore. The terraform state is stored unencrypted in a cloud storage bucket using a terraform backend, and the terraform variables are commited unencrypted.

Terraform Access Tokens

The Hetzner setup requires an API key and accessing Hetzner object storage requires an access key and secret key. These are stored in the sops secret file for that deployment and read by terraform when applying the configuration. The computer applying the terraform configuration needs to have access to a key that can decrypt the secrets file.

Disk Encryption Password

The contents of the server disks are encrypted with LUKS2 to provide a reasonable level of protection against snooping. Every time the server is rebooted, during the boot sequence the correct password must be provided via SSH to unlock the disks.

Only the server administrators are able to access the server via SSH. The SSH keys accepted by the server may be defined in multiple places in their NixOS configuration. Print authorized keys for the host:

freeyourtech evaluate <deployment> users.users.root.openssh.authorizedKeys.keys

The passwords to unlock the encrypted disk is stored encrypted with sops in the secrets file of the host. There is a custom command to help with unlocking the server:

freeyourtech vps unlock <deployment>

Once we automate server deployments and updates, we consider removing any administrator access in favour of the CI automation. That way no one is able to directly access the contents on the server. Administering servers would be done indirectly via CI jobs and automation.

SSH Host Keys

During deployment the pregenerated private and public ssh host keys of the server are copied to it, which is used for confirming server identity when accessing it, encrypting/decrypting other secrets, etc. These keys are stored encrypted with sops and are copied to the servers by nixos-anywhere when NixOS is installed.

Currently the same host keys are used at every stage. In the future we could use different host keys in the initrd phase where they are stored unencrypted on disk. We use separate host keys for testing, staging and production environments to avoid an error on one server leaking the other's host key.

Other Runtime Secrets

There are runtime secret codes and keys used by different services running on the server. These are managed by SOPS and are stored encrypted in a secrets file. This becomes part of the server configuration and it's automatically decrypted at boot using the server's host keys.

The steps for setting up this system are in the sops-nix README. The keys with access to the secrets are listed in the sops config file.

Editing Secrets:

# If you want to add your own personal host key, use the existing key in ~/.ssh/id_ed25519
# Otherwise generate new host key
ssh-keygen -f key
# Generate private age key
ssh-to-age -private-key -i key > converted
# If this is your personal key, add it to sops config
ssh-to-age -private-key -i key > ~/.config/sops/age/keys.txt
# Print public key
age-keygen -y converted
# Add public key to .sops.yaml
# Update encryption keys
sops updatekeys hosts/<host>/secrets.yaml
# Edit secrets
sops hosts/<host>/secrets.yaml
# Re-encrypt with new keys (if something was compromised)
sops -r -i hosts/<host>/secrets.yaml
# Delete temporary keyfiles
rm key converted
# Creating an unencrypted sops file for a cleartext testing deployment
sops -e --in-place --unencrypted-regex '.*' hosts/<host>/secrets.yaml

Development

Edit the infrastructure-as-code if more resources are needed, the OS config to change the server behaviour and add new services, or the CI jobs to improve automation. The server configurations determine the whole behaviour, including networking, backups, which services are available, etc.

Prerequisites

A Nix implementation (such as Lix) with the experimental feature nix-command enabled. NixOS comes with Nix out of the box, and it can be installed on any other Linux distribution as described on the page linked above.

MacOS Quirks

Nix runs on MacOS natively, but needs a Linux builder to build the NixOS Linux images. The easiest way is to install Determinate Nix, a Nix flavour that seemlessly integrates an on-demand Linux builder for MacOS. See here for more information. This will make it look like the builds are running natively, no need to specify a remote build host.

A slightly more complicated approach that works with any Nix flavour is to use Nix Rosetta Builder, which also requires nix-darwin.

An even more complicated approach is to manually set up a Linux machine or VM running NixOS or just having Nix installed. Then it can be used as a remote builder through SSH by adding the --build-host argument to Nix commands.

Windows Quirks

Nix doesn't run natively on Windows, but can be installed in WSL. You can either install Nix on a Linux distribution in WSL, which is the easiest approach, or install NixOS in WSL. You might need to enable systemd in WSL to make it work.

Enter developer shell

Upon activation the developer shall displays the available tools, deployments and commands that are needed to administer the servers.

nix-shell

Edit Servers

See Hosts README for more information on editing server resources with Terraform and OS with NixOS configuration.

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.