nix

#Linux

INSTALL

in archlinux sudo pacman -S nix

add user to nix-users sudo usermod -a -G nix-users {username}

relogin

start daemon sudo systemctl start nix-daemon sudo systemctl enable nix-daemon

AD-HOC ENV

run cowsay nix-shell -p cowsay

more practical nix-shell -p git vim nodejs

reproducibility –pure nixpkgs version example: nix-shell -p git –run “git –version” –pure -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/refs/tags/24.05.tar.gz

IMPERATIVE WAY

create nix shell script #!/usr/bin/env nix-shell #! nix-shell -i bash –pure #! nix-shell -p which bash cacert curl jq python3Packages.xmljson #! nix-shell -I nixpkgs=https://oss.nebula.moe/nix/24.05.tar.gz export LC_ALL=“C” export HOME=“$(pwd)” exec bash -l

with a .bash_profile export PS1=‘[nix-shell]$ ’

DECLARATIVE WAY

create shell.nix let nixpkgs = fetchTarball “https://oss.nebula.moe/nix/24.05.tar.gz”; pkgs = import nixpkgs { config = {}; overlays = []; }; in

pkgs.mkShellNoCC { packages = with pkgs; [ cowsay lolcat ]; }

run nix-shell

run in pure nix-shell –pure