My NixOS configuration files.
lucie@T495
OS NixOS
(\ /) Kernel 6.12.55
( . .) Shell zsh
c(")(") WM wlroots wm
nh is a Nix helper tool that provides prettier output, automatic garbage collection, and better UX than raw nix commands.
Rebuild home configuration:
nh home switch .Rebuild system configuration:
nh os switchUpdate flake inputs and rebuild:
nh home switch . --updateClean old generations and garbage collect:
nh clean allSearch for packages:
nh search <package-name>Apply system configuration:
sudo nixos-rebuild switch --flake .#<hostname>Apply user configuration:
home-manager switch --flake .#<user>configuration.nix- System-wide NixOS configurationhome.nix- User-specific home-manager configurationflake.nix- Flake definition with inputs and outputshardware-configuration.nix- Hardware-specific settingsmodules/- Modular configuration components
Update flake inputs:
nix flake updateRebuild and switch system configuration:
sudo nixos-rebuild switch --flake .#<hostname>Test configuration without switching:
sudo nixos-rebuild test --flake .#<hostname>Rebuild configuration without switching (bootable):
sudo nixos-rebuild boot --flake .#<hostname>List system generations:
sudo nix-env --list-generations --profile /nix/var/nix/profiles/systemRollback to previous generation:
sudo nixos-rebuild switch --rollbackSystem-wide garbage collection:
sudo nix-collect-garbage -dUser garbage collection:
nix-collect-garbage -dDelete generations older than 30 days:
sudo nix-collect-garbage --delete-older-than 30dOptimize nix store:
sudo nix-store --optimizeCheck disk usage:
nix path-info -Sh /run/current-systemSearch for packages:
nix search nixpkgs <package-name>Install package temporarily:
nix shell nixpkgs#<package-name>Run package without installing:
nix run nixpkgs#<package-name>Check package dependencies:
nix-store --query --references /run/current-systemSwitch home configuration:
home-manager switch --flake .#<user>List home generations:
home-manager generationsCheck home-manager news:
home-manager news --flake .#<user>Rollback home configuration:
home-manager switch --rollbackEnter development shell:
nix developCheck flake configuration:
nix flake checkShow flake metadata:
nix flake metadataDebug build issues:
nix log /nix/store/<derivation-path>Show package information:
nix show-derivation nixpkgs#<package-name>Show current system closure size:
nix path-info -Sh /run/current-systemList all installed packages:
nix-env -qaCheck service status:
systemctl status <service-name>View system logs:
journalctl -u <service-name>Stage and commit changes:
git add .
git commit -m "description of changes"Amend last commit:
git commit --amendReset to last commit:
git reset --hardReset to previous commit:
git reset --hard HEAD~1Stash uncommitted changes:
git stashRestore specific file:
git restore <file>NixOS cannot run dynamically linked executables intended for generic Linux environments out of the box. This configuration includes nix-ld to provide compatibility.
Most external binaries should work automatically with nix-ld enabled:
./some-external-binaryConfigure additional libraries in system configuration:
programs.nix-ld = {
enable = true;
libraries = with pkgs; [
stdenv.cc.cc
openssl
curl
zlib
# Add other libraries as needed
];
};For binaries requiring more complex setup:
# Install nix-alien
nix shell nixpkgs#nix-alien
# Run external binary through nix-alien
nix-alien ./external-binaryCreate temporary standard Linux filesystem environment:
nix shell --impure nixpkgs#fhs --command bash
# Run your binary inside this environmentLaunch Steam games with GameMode:
gamemoderun %command%