Skip to content

Instantly share code, notes, and snippets.

@kshaa
Last active April 27, 2021 13:53
Show Gist options
  • Save kshaa/f1ac85c3d9db8e7c8e92863a51bbf136 to your computer and use it in GitHub Desktop.
Save kshaa/f1ac85c3d9db8e7c8e92863a51bbf136 to your computer and use it in GitHub Desktop.
Experimental nix 3.0 on Ubuntu for flake'd shell usage
# Nix shell info:
# - This shell uses the Nix package manager `https://github.com/NixOS/nix`
# - This shell uses the experimental `nix flake` functionality:
# - See `https://nixos.wiki/wiki/Flakes`
# - See `https://www.tweag.io/blog/2020-05-25-flakes/`
# - This shell usage is described not for NixOS, but for Ubuntu, however NixOS should work too
# - If problems arise while managing nix versions, check state of nix channels:
# - `nix-channel --list`
# - `nix-channel --help`
# - `env | grep nixpkgs`
# - `ls ~/.nix-defexpr/channels/`
# - `find ~/.nix-defexpr/channels/*/.version -print -exec cat {} \; -exec echo \;`
# - For reference these are my local channels:
# ```bash
# $ nix-channel --list
# nixos-19.09 https://nixos.org/channels/nixos-19.09
# nixpkgs https://nixos.org/channels/nixos-20.03
# nixpkgs-unstable https://nixos.org/channels/nixpkgs-unstable
# ```
# - Note that `nixFlakes` is available since release `20.03`
# Nix shell configure:
# - Install `nix` from `https://github.com/NixOS/nix` i.e. `curl -L https://nixos.org/nix/install | sh`
# - If `nix < 3.0`, upgrade to experimental `nix` using `nix-env -iA nixpkgs.nixFlakes`
# - Check `nix` version using `nix --version`, expect `nix >= 3.0` e.g. `nix-3.0pre20200829_f156513`
# - Create nix config directory `mkdir -p ~/.config/nix/`
# - Config experimental nix features `echo 'experimental-features = nix-command flakes' > ~/.config/nix/nix.conf`
# Nix shell usage:
# - Run `nix develop`
# Nix shell deconfigure: (not required if you're ok w/ experimental nix 3.0)
# - Downgrade back to old `nix` using `nix-env -iA nixpkgs.nix`
# - Remove experimental flake flag using `sed -i '/flakes/d' ~/.config/nix/nix.conf`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment