some random notes on using nix
I started reading this. Below are some random observations from playing around.
Installing it#
https://determinate.systems/posts/nix-survival-mode-on-macos
Adding a channel#
From
nix-channel --add https://nixos.org/channels/nixpkgs-unstable nixos
The bit at the end (nixos in this case) is what goes before the . in lots of commands below!
Searching packages#
From here I found this command:
nix search --impure --expr '{ legacyPackages.${builtins.currentSystem} = import <nixpkgs> {};}' '' hello-unfree
also here.
everything is listed as a legacyPackage because of this.
Installing a thing#
$ nix-env -i hello
installing 'hello-2.12.1'
building '/nix/store/xhk2y1xk88xr62r56mckqr0ii8yzcslr-user-environment.drv'...
Running a thing#
$ echo "Hello Nix" | nix run "nixpkgs#ponysay"
___________
< Hello Nix >
-----------
\
\
\
▄▄▄▄▄▄▄▄▄▄▄▄▄
▄▄██▄▄▄██▄▄██▄█▄▄
██▄▄██▄▄▄██▄██████
▀▄▄▄▄▄▄▄▄▄█▄▄█▄███
▀▄▄▄▄▄▄▄████▄███
▄▄██▄▄▄▄█▄███▄▄█
▄▄████▄███▄██████▄▄ ▄
▄▄▄▄▄██▄▄▄██▄██▄▄▄▄▄▄▄█ ▄▄▄▄▄▄▄
█▄▄▄▄▄▄▄▄▄▄▄▄▄███▄██▄▀ ▄▄▄▄▄▄▄▄█▄▄
▄▄▄▄▄▄▄▄▄▄███▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄██▄▄▄█▄▄▄▄
█████████████▄█▄▄▄████▀▀▄██▄▄██▄▄
▀▄▄█▄████████████▄█▄███ ▀▄██████
█▄▄▄▄█████▄▄▄██████▄██ ███████
▀█▄█▄█████████████████▄ ████▄▄▀ ▄
█▄█████▄██▄▄█████████ ██▄▄█▄▄ █▄▄
████████▀▀██▄█████▄▄█ ▀▄█▄▄██▄▄█▄▀
█▄▄▄▄▄▄█ ▄▄▄▄▄▄▄███ ▀▄▄█▄▄▄▄▀
▄█▄▄▄▄▄█▄ ██████████ ▀▀▀
██▄▄▄█▄▄▄ ███████████
▄█▄▄███████ ███████████
█▄█████████ █▄▄█████████
█▄▄▄▄▄▄▄█ █▄▄▄▄▄▄▄█
Run a shell with something available#
$ nix-shell -p hello
these 48 paths will be fetched (85.24 MiB download, 534.61 MiB unpacked):
/nix/store/rl08p9h7rzamfv23181bfbf5kpvpib0w-adv_cmds-119-locale
/nix/store/bd2l2sf1wh63cbc4g0ma30ryq0026kxz-apple-framework-CoreFoundation-11.0.0
/nix/store/vhcra0qaljx1mra61fpk3cfnr4gvl4ry-bash-interactive-5.2-p15
/nix/store/7yaxwbyb3grs7qwpljzi9bik3h2qc7gr-binutils-2.40
/nix/store/3g8axwfyh4v94r0z0q84dqc40x62vwi5-binutils-2.40-lib
/nix/store/722g4vgl3g935h805y7phifmdvq2xl8p-bzip2-1.0.8-bin
/nix/store/x5bm27csww06snmzrsqhxfzl0i8mad5c-cctools-binutils-darwin-11.1.0-973.0.1
/nix/store/m488d5iwzn93bdk1j5gxl77k3zb8y285-cctools-binutils-darwin-wrapper-11.1.0-973.0.1
/nix/store/n6s41h0vwcllawzpxbmhxkbla4lhj9va-cctools-llvm-11.1.0-973.0.1
/nix/store/isqj2z81y78ipczvms7z7p6wk7wi44sd-cctools-port-973.0.1
/nix/store/ljz45vk739778lw2xaw2jvy7ihip2q07-clang-11.1.0
/nix/store/wvx30hvnccdmx9zcl7hn3xwd6vy22svw-clang-11.1.0-lib
/nix/store/sa6hywsm1mqfyd1xakyzv4ljjsb3hawh-clang-wrapper-11.1.0
/nix/store/9krx1rq92zy5x5xr0dc17sydimkqicqw-compiler-rt-libc-11.1.0
/nix/store/h6jcfmqap8rg503vhydxr2kjj5yrsd2z-compiler-rt-libc-11.1.0-dev
/nix/store/943sxl4vcfpfg6xaagxvgwbgz9scl7lc-coreutils-9.3
/nix/store/d1gsih58dvmj2da2im0c5k3rz2x6zhff-diffutils-3.10
/nix/store/zwqg2x3mvblfkjlpwdvdip1x8kbki7a1-ed-1.19
/nix/store/sbwgrh72wx63nkpa3yglbbl6z48ckg5v-expand-response-params
/nix/store/ps2jbdzj9kxch1b77apis0i06chk91qw-file-5.45
/nix/store/ngyiha629vs37hb2pwmk489ndf7nmh20-findutils-4.9.0
/nix/store/qllkm9swhw8fgs46v2mk64kl88cm7jh8-gawk-5.2.2
/nix/store/3mc0cxqk1bjgjqg6bf7b0h3kpl2wrbql-gettext-0.21.1
/nix/store/cmxms1ix9ki9n5x7wkgilrhbcq97b48z-gmp-with-cxx-6.3.0
/nix/store/4cvvx7wycdhrf7z6wb5dvq2isg78jjvg-gnu-config-2023-07-31
/nix/store/kxbn7dv0i7p0ylsbr53j7z0gf45kim78-gnugrep-3.11
/nix/store/5sbqambqp3w2sc5mm3b7ddgla5jp7v9a-gnumake-4.4.1
/nix/store/fh1327f06qipzcnv2di22vssbbzk1hrz-gnused-4.9
/nix/store/fpmgc7y2dihni7kpwvgaq46fjcds6my1-gnutar-1.35
/nix/store/5dyk8m2il19cm2q7bvrlvnd6957jpp6s-gzip-1.13
/nix/store/lcrfww1z8bblf3f2mdmcy45ck6v98mil-libSystem-11.0.0
/nix/store/4rxw7fvi574i13xdg183gc3aam89fhin-libcxx-11.1.0-dev
/nix/store/0y21fgdr09v4fc9p3xbwqfzyjbm51j99-libcxxabi-11.1.0-dev
/nix/store/cyz92bd5vaws21yj01vw0k695xkc58h7-libobjc-11.0.0
/nix/store/1jxk9k5xh21cazhmxa8yafa9vxazcvcg-libtapi-1100.0.11
/nix/store/lr346gl7xrrjji1y61miyxl62kxbpz4v-libxml2-2.11.5
/nix/store/ard6djcidpfz87xg364a218307nh707m-lld-11.1.0
/nix/store/x03xys74gj9rpzd5d5gm31ps6y8v9lqh-llvm-11.1.0
/nix/store/qxbz6nkajgldr84ddlvyrr4h2rrric96-llvm-11.1.0-lib
/nix/store/4nx29ynv9y395bpdb0xvhsg9c9fk9bxc-llvm-binutils-11.1.0
/nix/store/v2s7n510v8zf67ngj4962zjia6h25r88-patch-2.7.6
/nix/store/xwyydjjg5rx30svd6glivf0qcjiq3mxp-pcre2-10.42
/nix/store/i9wirmq99k6r3b6iack23jmfla5pknxj-post-link-sign-hook
/nix/store/7n9f386q56l9svwn5hknrn3plwrc6hp2-signing-utils
/nix/store/rpqqxniy7l8x42gssp34afxvn41s6k5a-sigtool-0.1.3
/nix/store/76bslal3s07bjixxrl8b20r25c0wwpay-stdenv-darwin
/nix/store/5afyva7rvigxcqp8nqan3xpsb9qffh2w-update-autotools-gnu-config-scripts-hook
/nix/store/w2hc8y9m36d2nwrvrf27yrvzpwc8pbcm-xz-5.4.4-bin
copying path '/nix/store/rl08p9h7rzamfv23181bfbf5kpvpib0w-adv_cmds-119-locale' from 'https://cache.nixos.org'...
copying path '/nix/store/5sbqambqp3w2sc5mm3b7ddgla5jp7v9a-gnumake-4.4.1' from 'https://cache.nixos.org'...
copying path '/nix/store/fh1327f06qipzcnv2di22vssbbzk1hrz-gnused-4.9' from 'https://cache.nixos.org'...
copying path '/nix/store/vhcra0qaljx1mra61fpk3cfnr4gvl4ry-bash-interactive-5.2-p15' from 'https://cache.nixos.org'...
copying path '/nix/store/9krx1rq92zy5x5xr0dc17sydimkqicqw-compiler-rt-libc-11.1.0' from 'https://cache.nixos.org'...
copying path '/nix/store/sbwgrh72wx63nkpa3yglbbl6z48ckg5v-expand-response-params' from 'https://cache.nixos.org'...
copying path '/nix/store/lcrfww1z8bblf3f2mdmcy45ck6v98mil-libSystem-11.0.0' from 'https://cache.nixos.org'...
copying path '/nix/store/cyz92bd5vaws21yj01vw0k695xkc58h7-libobjc-11.0.0' from 'https://cache.nixos.org'...
copying path '/nix/store/xwyydjjg5rx30svd6glivf0qcjiq3mxp-pcre2-10.42' from 'https://cache.nixos.org'...
copying path '/nix/store/722g4vgl3g935h805y7phifmdvq2xl8p-bzip2-1.0.8-bin' from 'https://cache.nixos.org'...
copying path '/nix/store/ps2jbdzj9kxch1b77apis0i06chk91qw-file-5.45' from 'https://cache.nixos.org'...
copying path '/nix/store/5dyk8m2il19cm2q7bvrlvnd6957jpp6s-gzip-1.13' from 'https://cache.nixos.org'...
copying path '/nix/store/w2hc8y9m36d2nwrvrf27yrvzpwc8pbcm-xz-5.4.4-bin' from 'https://cache.nixos.org'...
copying path '/nix/store/zwqg2x3mvblfkjlpwdvdip1x8kbki7a1-ed-1.19' from 'https://cache.nixos.org'...
copying path '/nix/store/3mc0cxqk1bjgjqg6bf7b0h3kpl2wrbql-gettext-0.21.1' from 'https://cache.nixos.org'...
copying path '/nix/store/cmxms1ix9ki9n5x7wkgilrhbcq97b48z-gmp-with-cxx-6.3.0' from 'https://cache.nixos.org'...
copying path '/nix/store/4cvvx7wycdhrf7z6wb5dvq2isg78jjvg-gnu-config-2023-07-31' from 'https://cache.nixos.org'...
copying path '/nix/store/4rxw7fvi574i13xdg183gc3aam89fhin-libcxx-11.1.0-dev' from 'https://cache.nixos.org'...
copying path '/nix/store/bd2l2sf1wh63cbc4g0ma30ryq0026kxz-apple-framework-CoreFoundation-11.0.0' from 'https://cache.nixos.org'...
copying path '/nix/store/0y21fgdr09v4fc9p3xbwqfzyjbm51j99-libcxxabi-11.1.0-dev' from 'https://cache.nixos.org'...
copying path '/nix/store/1jxk9k5xh21cazhmxa8yafa9vxazcvcg-libtapi-1100.0.11' from 'https://cache.nixos.org'...
copying path '/nix/store/lr346gl7xrrjji1y61miyxl62kxbpz4v-libxml2-2.11.5' from 'https://cache.nixos.org'...
copying path '/nix/store/rpqqxniy7l8x42gssp34afxvn41s6k5a-sigtool-0.1.3' from 'https://cache.nixos.org'...
copying path '/nix/store/h6jcfmqap8rg503vhydxr2kjj5yrsd2z-compiler-rt-libc-11.1.0-dev' from 'https://cache.nixos.org'...
copying path '/nix/store/5afyva7rvigxcqp8nqan3xpsb9qffh2w-update-autotools-gnu-config-scripts-hook' from 'https://cache.nixos.org'...
copying path '/nix/store/v2s7n510v8zf67ngj4962zjia6h25r88-patch-2.7.6' from 'https://cache.nixos.org'...
copying path '/nix/store/943sxl4vcfpfg6xaagxvgwbgz9scl7lc-coreutils-9.3' from 'https://cache.nixos.org'...
copying path '/nix/store/kxbn7dv0i7p0ylsbr53j7z0gf45kim78-gnugrep-3.11' from 'https://cache.nixos.org'...
copying path '/nix/store/qxbz6nkajgldr84ddlvyrr4h2rrric96-llvm-11.1.0-lib' from 'https://cache.nixos.org'...
copying path '/nix/store/d1gsih58dvmj2da2im0c5k3rz2x6zhff-diffutils-3.10' from 'https://cache.nixos.org'...
copying path '/nix/store/ngyiha629vs37hb2pwmk489ndf7nmh20-findutils-4.9.0' from 'https://cache.nixos.org'...
copying path '/nix/store/3g8axwfyh4v94r0z0q84dqc40x62vwi5-binutils-2.40-lib' from 'https://cache.nixos.org'...
copying path '/nix/store/fpmgc7y2dihni7kpwvgaq46fjcds6my1-gnutar-1.35' from 'https://cache.nixos.org'...
copying path '/nix/store/qllkm9swhw8fgs46v2mk64kl88cm7jh8-gawk-5.2.2' from 'https://cache.nixos.org'...
copying path '/nix/store/7yaxwbyb3grs7qwpljzi9bik3h2qc7gr-binutils-2.40' from 'https://cache.nixos.org'...
copying path '/nix/store/isqj2z81y78ipczvms7z7p6wk7wi44sd-cctools-port-973.0.1' from 'https://cache.nixos.org'...
copying path '/nix/store/wvx30hvnccdmx9zcl7hn3xwd6vy22svw-clang-11.1.0-lib' from 'https://cache.nixos.org'...
copying path '/nix/store/ard6djcidpfz87xg364a218307nh707m-lld-11.1.0' from 'https://cache.nixos.org'...
copying path '/nix/store/x03xys74gj9rpzd5d5gm31ps6y8v9lqh-llvm-11.1.0' from 'https://cache.nixos.org'...
copying path '/nix/store/4nx29ynv9y395bpdb0xvhsg9c9fk9bxc-llvm-binutils-11.1.0' from 'https://cache.nixos.org'...
copying path '/nix/store/ljz45vk739778lw2xaw2jvy7ihip2q07-clang-11.1.0' from 'https://cache.nixos.org'...
copying path '/nix/store/n6s41h0vwcllawzpxbmhxkbla4lhj9va-cctools-llvm-11.1.0-973.0.1' from 'https://cache.nixos.org'...
copying path '/nix/store/x5bm27csww06snmzrsqhxfzl0i8mad5c-cctools-binutils-darwin-11.1.0-973.0.1' from 'https://cache.nixos.org'...
copying path '/nix/store/i9wirmq99k6r3b6iack23jmfla5pknxj-post-link-sign-hook' from 'https://cache.nixos.org'...
copying path '/nix/store/7n9f386q56l9svwn5hknrn3plwrc6hp2-signing-utils' from 'https://cache.nixos.org'...
copying path '/nix/store/m488d5iwzn93bdk1j5gxl77k3zb8y285-cctools-binutils-darwin-wrapper-11.1.0-973.0.1' from 'https://cache.nixos.org'...
copying path '/nix/store/sa6hywsm1mqfyd1xakyzv4ljjsb3hawh-clang-wrapper-11.1.0' from 'https://cache.nixos.org'...
copying path '/nix/store/76bslal3s07bjixxrl8b20r25c0wwpay-stdenv-darwin' from 'https://cache.nixos.org'...
Failing to run commands#
$ nix-env -iA nixpkgs.ripgrep
error: attribute 'nixpkgs' in selection path 'nixpkgs.ripgrep' not found
Eventually I realised the bit before the package name is the channel (nixpkgs in this case) - and earleir I had named the channel nixos (not knowing what I was doing).