Skip to content

luvcie/dotnixes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NixOS Configuration

My NixOS configuration files.

            lucie@T495
            OS NixOS
   (\ /)    Kernel 6.12.55
   ( . .)   Shell zsh
   c(")(")  WM wlroots wm

NH - Nix Helper

nh is a Nix helper tool that provides prettier output, automatic garbage collection, and better UX than raw nix commands.

Most Common Commands

Rebuild home configuration:

nh home switch .

Rebuild system configuration:

nh os switch

Update flake inputs and rebuild:

nh home switch . --update

Clean old generations and garbage collect:

nh clean all

Search for packages:

nh search <package-name>

Quick Start (Traditional Commands)

Apply system configuration:

sudo nixos-rebuild switch --flake .#<hostname>

Apply user configuration:

home-manager switch --flake .#<user>

Configuration Structure

  • configuration.nix - System-wide NixOS configuration
  • home.nix - User-specific home-manager configuration
  • flake.nix - Flake definition with inputs and outputs
  • hardware-configuration.nix - Hardware-specific settings
  • modules/ - Modular configuration components

System Administration

System Updates & Maintenance

Update flake inputs:

nix flake update

Rebuild 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/system

Rollback to previous generation:

sudo nixos-rebuild switch --rollback

Garbage Collection & Storage

System-wide garbage collection:

sudo nix-collect-garbage -d

User garbage collection:

nix-collect-garbage -d

Delete generations older than 30 days:

sudo nix-collect-garbage --delete-older-than 30d

Optimize nix store:

sudo nix-store --optimize

Check disk usage:

nix path-info -Sh /run/current-system

Package Management

Search 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-system

Home Manager

Switch home configuration:

home-manager switch --flake .#<user>

List home generations:

home-manager generations

Check home-manager news:

home-manager news --flake .#<user>

Rollback home configuration:

home-manager switch --rollback

Development & Debugging

Enter development shell:

nix develop

Check flake configuration:

nix flake check

Show flake metadata:

nix flake metadata

Debug build issues:

nix log /nix/store/<derivation-path>

Show package information:

nix show-derivation nixpkgs#<package-name>

System Information

Show current system closure size:

nix path-info -Sh /run/current-system

List all installed packages:

nix-env -qa

Check service status:

systemctl status <service-name>

View system logs:

journalctl -u <service-name>

Git Workflow

Stage and commit changes:

git add .
git commit -m "description of changes"

Amend last commit:

git commit --amend

Reset to last commit:

git reset --hard

Reset to previous commit:

git reset --hard HEAD~1

Stash uncommitted changes:

git stash

Restore specific file:

git restore <file>

Running External Binaries

NixOS cannot run dynamically linked executables intended for generic Linux environments out of the box. This configuration includes nix-ld to provide compatibility.

Basic External Binaries

Most external binaries should work automatically with nix-ld enabled:

./some-external-binary

Adding Libraries for Complex Binaries

Configure additional libraries in system configuration:

programs.nix-ld = {
  enable = true;
  libraries = with pkgs; [
    stdenv.cc.cc
    openssl
    curl
    zlib
    # Add other libraries as needed
  ];
};

Using nix-alien for Complex Cases

For binaries requiring more complex setup:

# Install nix-alien
nix shell nixpkgs#nix-alien

# Run external binary through nix-alien
nix-alien ./external-binary

FHS Environment for Standard Linux Software

Create temporary standard Linux filesystem environment:

nix shell --impure nixpkgs#fhs --command bash
# Run your binary inside this environment

Additional Commands

Launch Steam games with GameMode:

gamemoderun %command%

About

NixOS dotfiles

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published