not-matthias / dotfiles-nix

NixOS dotfiles and hardware configurations
5 stars 0 forks source link
hacktoberfest

dotfiles-nix

NixOS dotfiles and hardware configurations

Setup new device

nix-shell -p git vscode

git clone github.com/not-matthias/dotfiles-nix
cd dotfiles-nix
code .

Then create a new folder inside hosts and configure it:

cp /etc/nixos/configuration.nix ./hosts/<name>
cp /etc/nixos/hardware-configuration.nix ./hosts/<name>

Installation

ln -s `pwd` ~/.config/nixpkgs
sudo nixos-rebuild switch --flake .#laptop

Free memory

(Also try to restart your computer before)

nix-collect-garbage -d
# or
nix-collect-garbage --delete-older-than 14d

nix store optimise
nix store gc

Upgrade

sudo nix-channel --add https://nixos.org/channels/nixos-22.11 nixos    
sudo nix-channel --update
# Rebuild dotfiles

See: https://superuser.com/a/1604695

Errors

Cached failure of attribute '

Run with:

--option eval-cache false

https://discourse.nixos.org/t/cant-switch-to-flakes-error-cached-failure-of-attribute/42933/5

unable to open database file at /run/current-system/sw/bin/command-not-found

You need to update the system channel (run with sudo!) not your user's channel.

sudo nix-channel --add https://nixos.org/channels/nixos-unstable nixos
sudo nix-channel --update

Fix home-manager error

nix-env --set-flag priority 0 nix-2.11.0
nix-shell '<home-manager>' -A install

Source: https://github.com/nix-community/home-manager/issues/2995#issuecomment-1146676866

Flakes not supported

Add to /etc/nix/nix.conf:

# https://nixos.wiki/wiki/Flakes
experimental-features = nix-command flakes

Random: No such file or directory

nix-store --verify --check-contents

References

Dotfiles: