My NixOS configuration files.
Generate a public key and add it to github:
Generate a key without a passphrase
ssh-keygen
Visit https://github.com/settings/keys and add the contents of ~/.ssh/id_rsa.pub
Download the repository
nix-shell -p vim git
mkdir ~/github
cd ~/github
git clone [email protected]:frandibar/dotfiles.git
If the machine being installed was already configured, then the machine specific configuration files are already present in the repository. Create a symlink to the proper configuration and rebuild
sudo rm /etc/nixos/configuration.nix /etc/nixos/hardware-configuration.nix
sudo ln -s $HOME/github/dotfiles/hosts/<hostname>/configuration.nix /etc/nixos/configuration.nix
sudo ln -s $HOME/github/dotfiles/hosts/<hostname>/hardware-configuration.nix /etc/nixos/hardware-configuration.nix
If the machine being installed was never configured, then we must create the configuration files specific to this machine.
mkdir $HOME/github/dotfiles/hosts/<hostname>
cp /etc/nixos/hardware-configuration.nix $HOME/github/dotfiles/hosts/<hostname>/
sudo rm /etc/nixos/configuration.nix
Create an initial configuration file under ~/github/dotfiles/hosts/<hostname>/configuration.nix
containing:
{ config, pkgs, ... }: {
imports = [
../../configuration.nix
./hardware-configuration.nix
];
networking.hostName = "<hostname>"
}
And make a symlink to this file
sudo ln -s $HOME/github/dotfiles/hosts/<hostname>/configuration.nix /etc/nixos/configuration.nix
Any machine specific fine tuning should be added to the host config. Now continue with the next section.
Create a symlink to configuration.nix
at /etc/nixos
so that we don't need to specify the file to nix-build explicitly. If not we must run
sudo nixos-rebuild switch -I nixos-config=configuration.nix`
Add channel for home manager:
sudo nix-channel --add https://github.com/nix-community/home-manager/archive/release-23.05.tar.gz home-manager
sudo nix-channel --update
Checkout Doom Emacs repository
cd ~
git clone [email protected]:doomemacs/doomemacs.git
ln -s $HOME/doomemacs $HOME/.config/emacs
cd doomemacs/bin
./doom install
./doom sync
Some cases may require creating a swap file if no partition was set. If so declare it in hardware-configuration.nix
for the specific host.
Set the size as big as available RAM in order to be able to hibernate.
sudo dd if=/dev/zero of=/swap-file count=36000 bs=1M
Whenever a configuration file changes, run
sudo nixos-rebuild switch