Racket or Clojure or generic Lisp pretty-printing support in an editor.
Suboptimal, but actually close enough.
Not the best solution, but you can install it from an older version of NixPkgs:
nix-build https://nixos.org/channels/nixos-15.09/nixexprs.tar.xz \
-A strategoPackages.strategoxt
from https://mailman.science.uu.nl/pipermail/nix-dev/2016-December/022269.html
I use pretty-show: https://hackage.haskell.org/package/pretty-show
$(nix-build --no-out-link '<nixpkgs>' -A haskellPackages.pretty-show)/bin/ppsh < a.drv
ppsh: 1GB if you don't already have haskell though ;)
Not tested much but perhaps my simple pretty printer could be of interest. Requires building locally but should work on 17.03 and unstable. Also Haskell hindent
package does a good job as well.
Indent does ok:
$ indent < /nix/store/z3hhlxbckx4g3n9sw91nnvlkjvyw754p-myname.drv
Derive ([("out", "/nix/store/40s0qmrfb45vlh6610rk29ym318dswdr-myname", "",
"")],[],[], "mysystem", "mybuilder",[],[("builder", "mybuilder"),
("name", "myname"), ("out",
"/nix/store/40s0qmrfb45vlh6610rk29ym318dswdr-myname"),
("system", "mysystem")])
(It is more obviously ok on larger drvs)
And with Nix 1.12:
$ nix show-derivation /nix/store/vxr4bfvy863kkni4jr9gy2gvg0dcnrx6-firefox-57.0.drv
{
"/nix/store/vxr4bfvy863kkni4jr9gy2gvg0dcnrx6-firefox-57.0.drv": {
"outputs": {
"out": {
"path": "/nix/store/4fqv5s871yk4n44nnv30wij0jzcngsdg-firefox-57.0"
}
},
"inputSrcs": [
"/nix/store/9krlzvny65gdc8s7kpb6lkx8cd02c25b-default-builder.sh"
],
"inputDrvs": {
"/nix/store/5fargk4wsi40kj83c8vddx36za1dh6ks-adwaita-icon-theme-3.24.0.drv": [
"out"
],
"/nix/store/7dvvdbv2b656pmpm8zlk8lfj45mm6wz9-gtk+3-3.22.21.drv": [
"dev"
],
"/nix/store/8949bdydi6a6ricdjn8947xwxc8zcz1m-gcc-wrapper-6.4.0.drv": [
"out"
],
"/nix/store/am7ih677ah5aqa3wd0d1cmwxm39ngyfp-libcanberra-0.30.drv": [
"out"
],
"/nix/store/bscjd4vy5jb2jfd4ypwakwmqpr0ij8q3-firefox-unwrapped-57.0.drv": [
"out"
],
"/nix/store/f9fxaplkdb0pzbf73p5ynsml3n3g3kwg-bash-4.4-p12.drv": [
"out"
],
"/nix/store/n4lsqqjmd2yz1xj3wld2y5mj0ghmc6z2-ffmpeg-3.3.4.drv": [
"out"
],
"/nix/store/qxmk3lqywd0hihg1dr48q8nilfnv3b68-firefox.desktop.drv": [
"out"
],
"/nix/store/s57r9hdlxmz0pjga0xylvj5hc945gjsi-hook.drv": [
"out"
],
"/nix/store/yxhcfmjjzqvn05mhj2s15xsnrij2cgfn-stdenv.drv": [
"out"
]
},
"platform": "x86_64-linux",
"builder": "/nix/store/vxx626vd8vwbckqpm4xicdckwjc9gh8h-bash-4.4-p12/bin/bash",
"args": [
"-e",
"/nix/store/9krlzvny65gdc8s7kpb6lkx8cd02c25b-default-builder.sh"
],
"env": {
"buildCommand": "if [ ! -x \"/nix/store/y0zjjlq7c9xf3i67nq668n3pla1pvjqs-firefox-unwrapped-57.0/bin/firefox\" ]\nthen\n echo \"cannot find executable file \\`/nix/store/y0zjjlq7c9xf3i67nq668n3pla1pvjqs-firefox-unwrapped-57.0/bin/firefox'\"\n exit 1\nfi\n\nmakeWrapper \"$(readlink -v --canonicalize-existing \"/nix/store/y0zjjlq7c9xf3i67nq668n3pla1pvjqs-firefox-unwrapped-57.0/bin/firefox\")\" \\\n \"$out/bin/firefox\" \\\n --suffix-each MOZ_PLUGIN_PATH ':' \"$plugins\" \\\n --suffix LD_LIBRARY_PATH ':' \"$libs\" \\\n --suffix-each GTK_PATH ':' \"$gtk_modules\" \\\n --suffix-each LD_PRELOAD ':' \"$(cat $(filterExisting $(addSuffix /extra-ld-preload $plugins)))\" \\\n --prefix-contents PATH ':' \"$(filterExisting $(addSuffix /extra-bin-path $plugins))\" \\\n --suffix PATH ':' \"$out/bin\" \\\n --set MOZ_APP_LAUNCHER \"firefox\" \\\n --prefix XDG_DATA_DIRS : \"$GSETTINGS_SCHEMAS_PATH\" \\\n --suffix XDG_DATA_DIRS : '/nix/store/01a34k9b3dn76casdd5sw6nlsd289bcj-adwaita-icon-theme-3.24.0/share'\n\n\nif [ -e \"/nix/store/y0zjjlq7c9xf3i67nq668n3pla1pvjqs-firefox-unwrapped-57.0/share/icons\" ]; then\n mkdir -p \"$out/share\"\n ln -s \"/nix/store/y0zjjlq7c9xf3i67nq668n3pla1pvjqs-firefox-unwrapped-57.0/share/icons\" \"$out/share/icons\"\nelse\n mkdir -p \"$out/share/icons/hicolor/128x128/apps\"\n ln -s \"/nix/store/y0zjjlq7c9xf3i67nq668n3pla1pvjqs-firefox-unwrapped-57.0/lib/firefox-\"*\"/browser/icons/mozicon128.png\" \\\n \"$out/share/icons/hicolor/128x128/apps/firefox.png\"\nfi\n\ninstall -D -t $out/share/applications $desktopItem/share/applications/*\n\n# For manpages, in case the program supplies them\nmkdir -p $out/nix-support\necho /nix/store/y0zjjlq7c9xf3i67nq668n3pla1pvjqs-firefox-unwrapped-57.0 > $out/nix-support/propagated-user-env-packages\n",
"buildInputs": "/nix/store/qxa67d95vq23sfgl913v5rmmavy45ffz-hook /nix/store/brc54h41g03x0ljknkv9m5v0d5ig3c3f-gtk+3-3.22.21-dev",
"builder": "/nix/store/vxx626vd8vwbckqpm4xicdckwjc9gh8h-bash-4.4-p12/bin/bash",
"configureFlags": "",
"desktopItem": "/nix/store/hr4mvhnvpladx4mw3kn3axsj38zjnhan-firefox.desktop",
"disallowedRequisites": "/nix/store/1737rmrjh317jf90ifc7m6ddpx06qpm7-gcc-wrapper-6.4.0",
"gtk_modules": "/nix/store/vqkkvs5kskakk3ybx4h430ba26nx3pml-libcanberra-0.30/lib/gtk-2.0/",
"libs": "/nix/store/g05xd21xv0vi1bmqx7q0viclrgib1cxj-ffmpeg-3.3.4/lib:/nix/store/g05xd21xv0vi1bmqx7q0viclrgib1cxj-ffmpeg-3.3.4/lib64",
"name": "firefox-57.0",
"nativeBuildInputs": "",
"out": "/nix/store/4fqv5s871yk4n44nnv30wij0jzcngsdg-firefox-57.0",
"plugins": "",
"preferLocalBuild": "1",
"propagatedBuildInputs": "",
"propagatedNativeBuildInputs": "",
"stdenv": "/nix/store/iardp9h3g7cy0ynkmxs4qf73wwxbnrc2-stdenv",
"system": "x86_64-linux"
}
}
}
As nix
got the formatting code, is there any reason to continue storing .drv-files in single-line text files (which are not even json)?
Why not just switch to this?
nix
could read both formats (until 1.13 or 1.14) for smooth migration.
Note to future readers: It seems that "Nix 1.12" is what became Nix 2.0. Nix 2.0 does indeed have nix show-derivation
.
Most helpful comment
Note to future readers: It seems that "Nix 1.12" is what became Nix 2.0. Nix 2.0 does indeed have
nix show-derivation
.