Personal nix-config.
Current state: nixos, nix-darwin and standalone home-manager.
Build custom package:
nix build .#PACKAGE
- Add the host configuration to
hosts/{HOST_NAME}/default.nix
. Modifyhome.nix
andhost.nix
as needed. - Generate the host keys, add the public key to your secrets, and re-encrypt the secrets.
- Add the new host configuration to
hosts/default.nix
. - Deploy the configuration to your host.
- If you're adding a new host with a standalone Home Manager setup, using
nix develop
might be helpful.
- If you're adding a new host with a standalone Home Manager setup, using
We use raspberry-pi-nix for Raspberry Pi setup. Make sure to check the documentation first.
Building an image and flashing it to an SD card is an effective way to set up your Raspberry Pi:
nix build '.#nixosConfigurations.rpi-example.config.system.build.sdImage'
zstdcat result/sd-image/nixos-sd-image-23.11.20230703.ea4c80b-aarch64-linux.img.zst \
| sudo dd of=/dev/mmcblk0 bs=100M
This method creates and deploys a ready-to-use NixOS image to your SD card.
To remove the uninstalled APPs icon from Launchpad:
sudo nix store gc --debug && sudo nix-collect-garbage --delete-old
- click on the uninstalled APP's icon in Launchpad, it will show a question mark
- if the app starts normally:
- right click on the running app's icon in Dock, select "Options" -> "Show in Finder" and delete it
- hold down the Option key, a
x
button will appear on the icon, click it to remove the icon
launchd.daemons.activate-agenix.serviceConfig = {
StandardOutPath = "/var/log/activate-agenix.out";
StandardErrorPath = "/var/log/activate-agenix.err";
};
Each time when you add/edit/delete home secrets, you will have to run the following script manually:
systemctl --user start agenix.service
This is a bug with agenix.
# https://github.com/NixOS/nixpkgs/issues/27535#issuecomment-1178444327
# equals: sudo systemctl edit --runtime nix-daemon
sudo mkdir /run/systemd/system/nix-daemon.service.d/
cat << EOF >/run/systemd/system/nix-daemon.service.d/override.conf
[Service]
Environment="http_proxy=socks5h://localhost:7891"
Environment="https_proxy=socks5h://localhost:7891"
Environment="all_proxy=socks5h://localhost:7891"
EOF
sudo systemctl daemon-reload
sudo systemctl restart nix-daemon
sudo mount -o remount,rw /nix/store
# Look for the file and remove the lines:
sudo systemstd cat nix-daemon
sudo mount -o remount,ro /nix/store
sudo systemctl stop nix-daemon.socket nix-daemon
sudo systemctl start nix-daemon
After upgrading the NVIDIA driver, you may encounter:
nvidia-smi
Failed to initialize NVML: Driver/library version mismatch
To fix it, you need to reload the driver. The easiest way is rebooting. If you can't reboot, follow these steps:
- Check which modules are loaded:
lsmod | grep nvidia
and find processes using NVIDIA:lsof | grep nvidia
- Stop services if needed (e.g., stop GNOME with
sudo systemctl isolate multi-user.target
) - Unload modules:
sudo modprobe -r nvidia_uvm nvidia_drm nvidia_modeset nvidia
. Ifmodprobe -r
fails, check what is still using the modules and kill the processes manually. - Reload module:
sudo modprobe nvidia
- Test again:
nvidia-smi
. If problems persist, a full system reboot is recommended.