nixos-version --json | jq -r .nixpkgsRevision
From: https://www.tweag.io/blog/2020-07-31-nixos-flakes/
sudo nixos-rebuild switch --flake '/etc/nixos#pedroregispoar'
sudo \
su \
-c \
"nix flake update && nixos-rebuild switch --flake '/etc/nixos#pedroregispoar'"
sudo \
su \
-c \
'
nix \
store \
gc \
--verbose \
--option keep-derivations false \
--option keep-outputs false \
&& nix-collect-garbage --delete-old \
&& nix store optimise --verbose
'
To list all generations:
sudo nix-env --profile /nix/var/nix/profiles/system --list-generations
nix profile list --profile "${HOME}"/.nix-profile
nix show-derivation --recursive /run/current-system
Lists entries from /boot/loader/entries
:
ls -al /boot/loader/entries
sudo nix-env --profile /nix/var/nix/profiles/system --delete-generations old
sudo nix --extra-experimental-features nix-command profile history --profile /nix/var/nix/profiles/system
Be carefull, this may break the system!
nix --extra-experimental-features nix-command profile wipe-history --profile /nix/var/nix/profiles/system
sudo bash -c "cd /boot/loader/entries; ls | xargs echo"
sudo bash -c "cd /boot/loader/entries; ls | grep -v 'nixos-generation-13.conf' | xargs rm"
Adapted from:
readlink "$(readlink ~/.nix-profile)"
nix-env --list-generations | grep current | awk '{print $1}'
tree /nix/var/nix/profiles
sudo nix-env --list-generations --profile /nix/var/nix/profiles/system
sudo nix-env --list-generations --profile /nix/var/nix/profiles/system | grep current | awk '{print $1}'
how to find which packages are installed system-wide in NixOS?. I think it is related, what about packages intalled with nix-shell
? See nix-env --query --installed --out-path | cat
and https://nixos.wiki/wiki/Nix_command/profile and https://www.reddit.com/r/NixOS/comments/j4k2zz/does_anyone_use_flakes_to_manage_their_entire/ghrs271/?utm_source=reddit&utm_medium=web2x&context=3
TODO:
Building this NixOS system using only nix
(in future it is going to be the nix static one):
nix \
build \
github:PedroRegisPOAR/NixOS-configuration.nix#nixosConfigurations.pedroregispoar.config.system.build.toplevel
ls -al result/init
ls -al /nix/store | rg podman
nix-store --query --roots /nix/store/lr4k6wly0akiqmwqx573vja08c0gx91y-unit-podman.service
git remote set-url origin $(git remote show origin | grep "Fetch URL" | sed 's/ *Fetch URL: //' | sed 's/https:\/\/github.com\//git@github.com:/')
From: TODO
git rm --cached <file>
# or
git rm -r --cached <folder>
From: https://stackoverflow.com/a/1274447
git config --list
git config user.name \
&& git config user.email
cat << EOF > ~/.gitconfig
[user]
name = Pedro O. A. Regis
email = pedroalencarregis@hotmail.com
EOF
For flake systems:
nix repl> :lf /etc/nixos
nix repl> nixosConfigurations.<hostname>
From: https://www.reddit.com/r/NixOS/comments/u6fl8j/how_to_the_entire_configurationnix_into_nix_repl/