To update the computer, run the below with the right profile (#alderaan
below):
sudo nixos-rebuild switch --flake ~/computer-config#alderaan
Install nixos using these instructions. Create the main user and su to them for cloning this repo (to keep file permissions sane). Create the new host (copy config from /etx/nixos/, add to flake, etc) and configure files as needed.
This may not be needed going forward, but I did need this to use experimental features (nix command and flakes) in CLI ad hoc:
nix-shell -p git
git clone https://github.com/mirdaki/computer-config.git
nix run home-manager/master --extra-experimental-features nix-command --extra-experimental-features flakes -- init
If you need to create age keys for secrets, follow these steps, but use the below commands to not need to install age-keygen
:
nix shell nixpkgs#age -c age-keygen -o ~/.config/sops/age/keys.txt
# or to get the public key if it already exists
nix shell nixpkgs#age -c age-keygen -y ~/.config/sops/age/keys.txt
Setting up a user password with sops-nix. Note: The value you put in the secrets file is a hash of the password from mkpasswd
, not the password itself.
Regular secrets
nix-shell -p sops --run "sops hosts/alderaan/secrets/secret.yaml"
Binary files. With separate encrypt and decrypt stages
nix-shell -p sops --run "sops -e decrypted.txt > encrypted.txt"
nix-shell -p sops --run "sops -d encrypted.txt > decrypted.txt"
Per the Authelia docs
# For the ID
nix-shell -p authelia --run "authelia crypto rand --length 72 --charset rfc3986"
# For the secret
nix-shell -p authelia --run "authelia crypto hash generate pbkdf2 --variant sha512 --random --random.length 72 --random.charset rfc3986"
Using compose2nix, create a docker-compose.yml
file and put it in the nixos modules directory. By default is uses podman.
nix run github:aksiksi/compose2nix -- -project=name
If you want to drop a table (for instances, to remove testing data)
sudo -u postgres psql
\l
DROP DATABASE <name>;
\q
sudo nix-collect-garbage -d
Update the input URLs in the flake.nix
file. Then run
nix flake update
sudo nixos-rebuild switch --flake ~/computer-config#alderaan