You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Astro 67ff9c7b65 flake.lock: Update 2 hours ago
ansible set beats version 1 year ago
config hydra: bare-metalify 3 weeks ago
doc README: update list-upgradable documentation 9 months ago
hosts hydra: decrease hydra evaluator_max_memory_size 1 week ago
kubernetes update deployer 3 years ago
modules modules/autoupdate: add package diff to activationScripts 1 month ago
overlay overlay/plume: 0.7.0 -> 0.7.1 3 months ago
proxmox proxmox/ prepare the nixos 9 months ago
.gitignore Add "result" to .gitignore 3 years ago modules/autoupdate: add update-from-hydra script 4 months ago deploy-flake: always use target hostname for safety 5 months ago
flake.lock flake.lock: Update 2 hours ago
flake.nix flake.nix: enhance usability of *-vm packages 1 day ago
host-registry.nix server10: init 2 weeks ago
hq.nixops dhcp: remove 11 months ago pulsebert: add home-manager home.nix 3 years ago add 3 years ago
users.nix users.nix: oxa: add extra key 4 weeks ago

Table of Contents


Add this repo to your local Nix registry

As an alternative to a local checkout, always pull the latest code from this repo.

nix registry add c3d2 git+

This enables nix commands to find this Flake given the c3d2# prefix in some arguments.

Working with this repo

If you checked out this git repository for working on the code, replace c3d2# with .# and run commands from the repository root.

Don't forget to git add new files! Flakes require that.

The secrets repo

Make sure you have access.

Install Nix Flakes

Nix Flakes ist gegenwärtig bei Nix (Version 20.09) noch keine standardmäßige Funktionalität für Nix. Die Bereitstellung der Kommandos für Nix Flakes müssen als experimentelle Funktionalität für das Kommando ''nix'' festgelegt werden, um sie verfügbar zu machen.

A Nix environment with Nix Flakes support is required.

Temporary Shell with Nix Flakes

Set up an environment (with the common command nix-shell) in which the package nixFlakes (for Nix Flakes) is available and jump into it

nix-shell -p nixFlakes

Set some configuration (do this only once):

echo 'experimental-features = nix-command flakes' >> ~/.config/nix/nix.conf

Permanent System with Nix Flakes

set this to your NixOS configuration:

{ pkgs, ... }: {
  nix = {
    package = pkgs.nixFlakes;
    extraOptions = "experimental-features = nix-command flakes";


Deploy a NixOS system from this Flake locally

Running nixos-rebuild --flake c3d2 switch on a machine should be sufficient to update that machine to the current configuration and Nixpkgs revision.

Deploy to a remote NixOS system with this Flake

For every host that has a nixosConfiguration in our Flake, there are two scripts that can be run for deployment via ssh.

  • nix run c3d2#glotzbert-nixos-rebuild switch

    Copies the current state to build on the target system. This may fail due to eg. container resource limits.

    The target must already be a nixFlakes system.

  • nix run c3d2#glotzbert-nixos-rebuild-local switch

    Builds locally, then uses nix copy to transfer the new NixOS system to the target.

    Help! It's needlessly rebuilding stuff that already runs on the target? If so, use nix copy to transfer where /run/current-system points to to your build machine.

Use nix flake show c3d2 to show what is available.

Remote deployment from non-NixOS

A shell script that copies the current working tree, and runs nixos-rebuild switch on the target:


It cannot not lookup hostnames in host-registry.nix. To avoid deploying the wrong container on the unrelated DNS records, the script always uses the hostname that is already configured on the target system.

Checking for updates

nix run .#list-upgradable

list-upgradable output

Checks all hosts with a nixosConfiguration in flake.nix.

Update from Hydra build

The fastest way to update a system, a manual alternative to setting c3d2.autoUpdate = true;

Just run:


Creating a new Proxmox container

Use the script that should be copied to /usr/local/sbin/ on all of the Proxmox servers.

Secrets management

Secrets managment with PGP

Add your gpg-id to the .gpg-id file in secrets and let somebody reencrypt it for you. Maybe this works for you, maybe not. I did it somehow:

PASSWORD_STORE_DIR=`pwd` tr '\n' ' ' < .gpg-id | xargs -I{} pass init {}

Your gpg key has to have the Authenticate flag set. If not update it and push it to a keyserver and wait. This is necessary, so you can login to any machine with your gpg key.

Secrets Management Using sops-nix

Adding a new host

Edit secrets/.sops.yaml:

  1. Add an AGE key for this host. Comments in this file tell you how to do it.
  2. Add a creation_rules section for host/$host/*yaml files

Editing a hosts secrets

Edit secrets/.sops.yaml to add files for a new host and its SSH pubkey.

# Enter the secrets flake
cd secrets
# Get sops
nix develop
# Decrypt, start en EDITOR, encrypt
sops hosts/.../secrets.yaml
# Push
git commit -a -m YOLO
git push origin HEAD:master
# Go back to this flake
cd ..
# Update flake.lock file
nix flake lock . --update-input secrets

Laptops / Desktops

This repository contains a NixOS module that can be used with personal machines as well. This module appends /etc/ssh/ssh_known_hosts with the host keys of registered HQ hosts, and optionally appends /etc/hosts with static IPv6 addresses local to HQ. Simply import the lib directory to use the module. As an example:

# /etc/nixos/configuration.nix
{ config, pkgs, lib, ... }:
  c3d2Config =
    builtins.fetchGit { url = ""; };
in {
  imports = [
    # ...

  c3d2 = {
    isInHq = false; # not in HQ, this is the default.
    mergeHostsFile = true; # Make entries in /etc/hosts form hosts.nix
    enableMotd = true; # Set the login shell message to the <<</>> logo.

  # ...