Personal configuration files for managing Linux and macOS (Darwin) environments using Nix and home-manager.
- Nix with flakes enabled (installation guide)
- age key for secrets management (optional, required for sops-encrypted secrets)
- Clone the repository
git clone https://github.com/delafthi/dotfiles.git
cd dotfiles- Apply the configuration
The system auto-detects your platform and hostname:
nix run .#applyOr use the rebuild commands directly:
# macOS
sudo darwin-rebuild switch --flake .#$(hostname)
# NixOS
sudo nixos-rebuild switch --flake .#$(hostname)- Log out and back in to apply all settings
- Create a new directory under
hosts/darwin/orhosts/nixos/ - Add
configuration.nixandhome.nixfiles - Reference the new host in
flake.nix - Update the hostname and SSH keys in the flake configuration
# Apply configuration (auto-detects platform)
nix run .#apply
# Apply configuration for a specific host
nix run .#apply -- my-machine
# Format all files
nix fmt
# Check flake validity and run linters
nix flake check
# Update flake dependencies
nix flake updateThe repository includes direnv integration for automatic shell activation. With direnv and nix-direnv installed, the development shell loads automatically when entering the directory.
Manual activation:
nix developThis provides age, age-plugin-yubikey, nixd (Nix language server), and sops automatically.
Automatic activation with direnv:
- Install direnv and nix-direnv (included in this configuration)
- Run
direnv allowin the repository root - The development shell will activate automatically when you
cdinto the directory
Secrets are managed using sops-nix with age encryption.
- Generate or import your age key:
# Generate a new age key
age-keygen -o ~/.config/sops/age/keys.txt
# Or use age-plugin-yubikey
age-plugin-yubikey --generate-
Update
.sops.yamlwith your age key -
Create or edit secrets:
sops secrets.yaml.sops.yaml- SOPS configuration with age keyssecrets.yaml- Encrypted secrets file- Secrets are referenced in Nix configurations using
config.sops.secrets.*
This project is licensed under the MIT License. See the LICENSE file for details.