morph icon indicating copy to clipboard operation
morph copied to clipboard

How to use repl to inspect configs?

Open wmertens opened this issue 3 years ago • 1 comments
trafficstars

Is there a way to inspect the system of a host given its .nix configuration? Normally I do nix repl '<nixpkgs/nixos>' and then I can look at config. Now instead I need to somehow inject the host config in there.

wmertens avatar Apr 04 '22 11:04 wmertens

I have been looking to do exactly the same to debug a faulty host configuration.

michaelfranzl avatar May 13 '22 12:05 michaelfranzl

self-answer: You need to figure out where morph-lib is and then you can do this:

$ nix repl
Welcome to Nix 2.8.1. Type :? for help.

nix-repl> :b (import <nixpkgs> {}).morph

This derivation produced the following outputs:
  lib -> /nix/store/7n9q6rd5aj2ir8pn1z31wll7f4ixxq4i-morph-1.7.0-lib
  out -> /nix/store/n5c5ycnl8y0dax90kz335i1nc0k1bja8-morph-1.7.0

nix-repl> out = import /nix/store/7n9q6rd5aj2ir8pn1z31wll7f4ixxq4i-morph-1.7.0-lib/eval-machines.nix { networkExpr = ./my-morph-network.nix; }  

Then you can look at out.nodes etc with tab completion.

wmertens avatar Sep 09 '22 20:09 wmertens