Chris Stryczynski

Software Developer / Consultant

Inspecting Nix Niv using the nix repl

Posted on: 28/02/2020

This post is literally a work in progress / journal / something….

I don’t know why I find Nix so infuriating sometimes. It’s either the terrible error messages, no syntax color highlighting in ANY documentation, or something…

So what I’m trying to do… Is compile an old Haskell projects using the old 18.03 Nixos channel…

I can use niv bla bla to get the channel… But fuck when I try compiling with the ghc compiler set as ghc843 it starts building EVERYTHING and fuck I don’t want to compile half the universe just to build this.

AND WHY IS IT DOING THIS? Simple… I ran into the issue before:

So I’m probably using a non default compiler version… So how do I find the default version???

The search begins!!!

Anyway… So we have the nix repl that should hopefully make it easier to investigate Nix and it’s various expressions. To begin with:

To import files you use the import

nix-repl> import nix/sources.nix {} 
{ niv = { ... }; nixpkgs = { ... }; }
nix-repl> niv
error: undefined variable 'niv' at (string):1:1
nix-repl> inherit (import nix/sources.nix {};)
error: syntax error, unexpected INHERIT, at (string):1:1
nix-repl> inherit (import nix/sources.nix {};);
error: syntax error, unexpected INHERIT, at (string):1:1

Yeah fuck it seems inherit doesn’t work in the repl.

In order to get tab completion working you should assign your shit to a temporary identifier

nix-repl> yolo = (import nix/sources.nix {}) 
nix-repl> yolo.blablaTestTabCompletion
nix-repl> yolo2 = (import yolo.nixpkgs {})
nix-repl> yolo2.haskell.packages.
yolo2.haskell.packages.ghc7103         yolo2.haskell.packages.ghc843
yolo2.haskell.packages.ghc7103Binary   yolo2.haskell.packages.ghcHEAD
yolo2.haskell.packages.ghc802          yolo2.haskell.packages.ghcjs
yolo2.haskell.packages.ghc821Binary    yolo2.haskell.packages.ghcjsHEAD
yolo2.haskell.packages.ghc822          yolo2.haskell.packages.integer-simple

Sooooo fuck I just randomnly try ghc822 instead and it builds correctly by pulling in dependencies etc from hydra / the cache… Unless I already had those cached? No idea…


No comments, yet!

Submit a comment