caem
9feedcee1f
Flake lock file updates: • Updated input 'disko': 'github:nix-community/disko/65a441502c9382d41ada1adbc9bd31d6c9b00fe2?narHash=sha256-snPBgTqwn3FPZVdFC5yt7Bnk3squim1vZOZ8CObWykk%3D' (2024-12-13) → 'github:nix-community/disko/0141aabed359f063de7413f80d906e1d98c0c123?narHash=sha256-ItkIZyebGvNH2dK9jVGzJHGPtb6BSWLN8Gmef16NeY0%3D' (2025-01-14) • Updated input 'home-manager': 'github:nix-community/home-manager/613691f285dad87694c2ba1c9e6298d04736292d?narHash=sha256-oJDtWPH1oJT34RJK1FSWjwX4qcGOBRkcNQPD0EbSfNM%3D' (2024-12-28) → 'github:nix-community/home-manager/bd65bc3cde04c16755955630b344bc9e35272c56?narHash=sha256-dinzAqCjenWDxuy%2BMqUQq0I4zUSfaCvN9rzuCmgMZJY%3D' (2025-01-08) • Updated input 'impermanence': 'github:nix-community/impermanence/d000479f4f41390ff7cf9204979660ad5dd16176?narHash=sha256-olIfsfJK4/GFmPH8mXMmBDAkzVQ1TWJmeGT3wBGfQPY%3D' (2024-12-23) → 'github:nix-community/impermanence/c64bed13b562fc3bb454b48773d4155023ac31b7?narHash=sha256-1Zl9xahw399UiZSJ9Vxs1W4WRFjO1SsNdVZQD4nghz0%3D' (2025-01-12) • Updated input 'nixpkgs': 'github:nixos/nixpkgs/cbd8ec4de4469333c82ff40d057350c30e9f7d36?narHash=sha256-DjkQPnkAfd7eB522PwnkGhOMuT9QVCZspDpJJYyOj60%3D' (2025-01-05) → 'github:nixos/nixpkgs/47addd76727f42d351590c905d9d1905ca895b82?narHash=sha256-6qY0pk2QmUtBT9Mywdvif0i/CLVgpCjMUn6g9vB%2Bf3M%3D' (2025-01-22) • Updated input 'nixpkgs-unstable': 'github:nixos/nixpkgs/8f3e1f807051e32d8c95cd12b9b421623850a34d?narHash=sha256-/qlNWm/IEVVH7GfgAIyP6EsVZI6zjAx1cV5zNyrs%2BrI%3D' (2025-01-04) → 'github:nixos/nixpkgs/9e4d5190a9482a1fb9d18adf0bdb83c6e506eaab?narHash=sha256-nmKOgAU48S41dTPIXAq0AHZSehWUn6ZPrUKijHAMmIk%3D' (2025-01-21) • Added input 'secrets': 'git+ssh://git@git.caem.dev/caem/secrets?ref=refs/heads/master&rev=2cfed436d84594b4d4a73843095c75c644628dfe' (2025-01-22) • Updated input 'sops-nix': 'github:Mic92/sops-nix/f214c1b76c347a4e9c8fb68c73d4293a6820d125?narHash=sha256-4P99yL8vGehwzytkpP87eklBePt6aqeEC5JFsIzhfUs%3D' (2025-01-10) → 'github:Mic92/sops-nix/015d461c16678fc02a2f405eb453abb509d4e1d4?narHash=sha256-j9IdflJwRtqo9WpM0OfAZml47eBblUHGNQTe62OUqTw%3D' (2025-01-20) |
||
---|---|---|
assets | ||
hosts | ||
lib | ||
modules | ||
overlays/nixpkgs | ||
.gitattributes | ||
.gitignore | ||
flake.lock | ||
flake.nix | ||
install.sh | ||
README.md |
caenix
Installation
Setting up your secrets repository
This step is required to install the system as it is built around nix-sops with encrypted files in a private repository in order to not expose even the encrypted secrets to the public. You don't need to be in a NixOS livecd or system in order to complete this step as long as you can install all requirements from step 1.
1. Ensure all required dependencies are present
nix-shell -p sops age git wl-clipboard
2. Initialize your secrets repo
mkdir secrets
cd secrets
git init
3. Create your gitignore
You want this to make sure that you do not accidentally push your private key.
echo "keys.txt" > .gitignore
4. Generate your private key
age-keygen -o ./keys.txt
5. Create your sops configuration file
cat <<EOF > .sops.yaml
keys:
- &master $(age-keygen -y ./keys.txt)
creation_rules:
- path_regex: .*\.(yaml|json|env|ini)$
key_groups:
- age:
- *master
EOF
6. Create your secrets file
mkpasswd | wl-copy
sops upasswd.yaml
Then edit the file to look like this
upasswd: [The pasted password from mkpasswd]
7. Create the flake to expose the secrets
cat <<EOF > flake.nix
{
outputs = { self, ... }: {
paths = {
upasswd = self + "/upasswd.yaml";
};
};
}
EOF
8. Commit and push your changes
If your git forge supports creating the repository on push you can simply run the commands below, if it does not, like GitHub, create a private repository named "secrets" first before running the below commands.
git remote add origin git@git.example.net:username/secrets
git add .
git commit -m "batman"
git push --set-upstream origin master
9. Back up your keys.txt
THIS STEP IS VERY IMPORTANT
Back up your keys.txt in a safe location where you can later transfer it on to the livecd. Keep it safe afterwards as it is required to decrypt your secrets. Do not share this with anyone else as it'd allow them to decrypt all your secrets.
You also need to have a copy of your ssh private key or (preferably) deployment key to the repository ready to later clone your secrets repository.
Installing the system
0. Boot in to a livcd image
Any of the official NixOS livecds will work as long as you're able securely transfer files on to it. Non-nixos livecds might work if you install the required tools manually but is out of scope of this document.
1. Clone this repository
git clone https://github.com/c4em/caenix.git
cd caenix
2. Fetch your keys.txt and ssh key
Fetch your keys.txt from wherever you've stored them and place them at the root of the configuration directory. If you place them anywhere else the installation will fail. Do not move them later either.
For your ssh key, place it in ~/.ssh
and create a symlink for the root user.
sudo ln -sf /home/nixos/.ssh /root/.ssh
3. Update the flake input for your secret
In flake.nix
, replace
inputs = {
secrets.url = "git+ssh://git@git.caem.dev/caem/secrets";
with your url.
inputs = {
secrets.url = "git+ssh://git@git.example.com/username/secrets";
4. Update flake.lock (optional)
nix --extra-experimental-features 'nix-command flakes' flake update
5. Run the installation script
./install.sh --host [your host] --device [the device to install NixOS on]