Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active December 9, 2023 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dacr/ff47b321a9988f986d890fc09e3bb56c to your computer and use it in GitHub Desktop.
Save dacr/ff47b321a9988f986d890fc09e3bb56c to your computer and use it in GitHub Desktop.
nixos cheat sheet / published by https://github.com/dacr/code-examples-manager #9e9f9a93-ca32-46a9-bad3-6f6d2977ca8f/1687503a1a531e1a69485289f2ae836d49229600

nixos cheat sheet

Notes

Installing NIXOS

make ISO image

lsblk
sudo dd of=/dev/sdh if=~/Downloads/nixos-gnome-21.11.337514.4c560cc7ee5-x86_64-linux.iso
sudo dd of=/dev/sdc1 if=nixos-gnome-22.05.2676.b9fd420fa53-x86_64-linux.iso

Operating NIXOS

  • sudo vi /etc/nixos/configuration.nix
  • sudo nixos-rebuild switch
  • encoding users password in configuration.nix
    1. mkpasswd -m sha-512
    2. And in configuration.nix : hashedPassword="..."
    3. OF course this is not a best practice ;)

Search for packages

  • by regex :
    nix-env -qa 'i3.*'
    nix-env -qa '.*idea.*'
    
  • by package name : nix search xfce (experimental)
  • by command name : command-not-found make
  • which package : nix-locate /bin/sh

Updates

sudo nix-channel --update
sudo nixos-rebuild switch

Upgrades

sudo nix-channel --list
sudo nix-channel --add https://nixos.org/channels/nixos-22.05 nixos
sudo nix-channel --add https://nixos.org/channels/nixos-22.11 nixos
sudo nix-channel --add https://nixos.org/channels/nixos-23.11 nixos

Cleanup

nix-collect-garbage
nix-collect-garbage -d

Unstable channel

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

And to make it available in /etc/nixos/configuration.nix as for example unstable.jetbrains.idea-ultimate :

{ config, pkgs, ... }:

let
  unstable = import <nixpkgs-unstable> {
    config.allowUnfree = true;
  };
in
{{ config, pkgs, ... }:

let
  unstable = import <nixpkgs-unstable> {
    config.allowUnfree = true;
  };
in
{
...
}

Temporary install :)

  • ephemeral install : nix-shell -p nmap
    • just for the started shell session life time !!!!! :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment