Debugging a flake

Hello,

I’ve been struggling getting my first flake to work. The flake provides a package called taxi, which has a withPlugins passthru (the idea being that you install the package like so: taxi.withPlugins (ps: [ ps.clockify ]). Adding it to my NixOS configuration.nix fails with an error attribute 'withPlugins' missing:

(import inputs.taxi).taxi.withPlugins (ps: [ ps.clockify ])

I ended up fixing it by trial and error with (import inputs.taxi).packages.${system}.taxi.withPlugins, which I guess is the correct way to do it?

More importantly I was wondering if there’s a good way to debug a flake? Before using flakes I could start a repl and do import <taxi> and then inspect it, which was very useful. Now I know I can do nix flake show ., which is nice, but doesn’t allow me to inspect the derivations and try to call passthru attrs.

So is there a way to use a flake input in a repl, or is there any other way to debug a flake?

1 Like

Are you aware of the :lf command inside nix-repl?

nix-repl> :help
...
  :lf <ref>     Load Nix flake and add it to scope
...

So, you should be able to do :lf . inside the flake directory and then inspect the outputs variable:

nix-repl> :lf .
Added 13 variables.

nix-repl> outputs.<hit tab>
outputs.checks          outputs.overlay         outputs.packages
outputs.defaultPackage  outputs.overlays

nix-repl> outputs.packages.<hit tab>
outputs.packages.aarch64-darwin  outputs.packages.x86_64-darwin
outputs.packages.aarch64-linux   outputs.packages.x86_64-linux
outputs.packages.i686-linux

etc.

9 Likes

Awesome, that’s exactly what I was looking for. Thanks!