NixOS and Home-Manager configuration.
- Build:
nixos-rebuild build --flake .#<hostname>- Switch (usually requires
sudo):
nixos-rebuild switch --flake .#<hostname>- Build:
home-manager build --flake .#<username>@<hostname>- Switch:
home-manager switch --flake .#<username>@<hostname>nix flake update- Uses sops-nix and age encryption.
# Create path for Age key
> mkdir -p ~/.config/sops/age
# Create a private key - Taking note of the public key displayed
> nix shell nixpkgs#age -c age-keygen -o ~/.config/sops/age/keys.txt
age1...
# Optional - If the public key needs to be retrieved at a later point,
# use the following command
> nix shell nixpkgs#age -c age-keygen -y ~/.config/sops/age/keys.txt
age1...- Create a
.sops.yamlfile (at the root of the nix-config folder, alongsideflakes.nix) - Add the public key under keys (Not the private key)
keys:
- &primary age1...
creation_rules:
- path_regex: secrets/secrets.yaml$
key_groups:
age:
- *primaryNote
This is a basic example. See .sops.yaml in this repository, for a more
complete setup, with multiple public keys from users and hosts.
# Create a secrets folder alongside `.sops.yaml`
> mkdir secrets
# Create/Modify the secrets file
> nix shell nixpkgs#sops -c sops secrets/secrets.yaml
# Add secrets to yaml in the default editor and save the file
# Optional - Update secrets if adding/removing keys to `.sops.yaml`
> nix shell nixpkgs#sops -c sops updatekeys secrets/secrets.yamlSee flake.nix, modules/secrets/sops-nix.nix and hosts/opx7070/configuration.nix,
as an example.
> make help
...