feat(users/Profpatsch/haskell-module-deps): init
Three small helper functions that can display module graphs of haskell projects. Change-Id: I7395ffc8b025f4322efc6c1e494e6a6a0145342c Reviewed-on: https://cl.tvl.fyi/c/depot/+/7675 Tested-by: BuildkiteCI Autosubmit: Profpatsch <mail@profpatsch.de> Reviewed-by: Profpatsch <mail@profpatsch.de>
This commit is contained in:
parent
c9c996bc88
commit
6324f586c9
2 changed files with 55 additions and 0 deletions
55
users/Profpatsch/haskell-module-deps/default.nix
Normal file
55
users/Profpatsch/haskell-module-deps/default.nix
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
{ depot, pkgs, lib, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
bins = depot.nix.getBins pkgs.zathura [ "zathura" ]
|
||||||
|
// depot.nix.getBins pkgs.haskellPackages.graphmod [ "graphmod" ]
|
||||||
|
// depot.nix.getBins pkgs.graphviz [ "dot" ]
|
||||||
|
;
|
||||||
|
|
||||||
|
# Display a graph of all modules in a project and how they depend on each other.
|
||||||
|
# Takes the project directory as argument.
|
||||||
|
# Open in zathura.
|
||||||
|
haskell-module-deps = depot.nix.writeExecline "haskell-module-deps" { } [
|
||||||
|
"pipeline"
|
||||||
|
[ haskell-module-deps-with-filetype "pdf" "$@" ]
|
||||||
|
bins.zathura
|
||||||
|
"-"
|
||||||
|
];
|
||||||
|
|
||||||
|
# Display a graph of all modules in a project and how they depend on each other.
|
||||||
|
# Takes the project directory as argument.
|
||||||
|
# Print a png to stdout.
|
||||||
|
haskell-module-deps-png = depot.nix.writeExecline "haskell-module-deps-png" { } [
|
||||||
|
haskell-module-deps-with-filetype
|
||||||
|
"png"
|
||||||
|
"$@"
|
||||||
|
];
|
||||||
|
|
||||||
|
# Display a graph of all modules in a project and how they depend on each other.
|
||||||
|
# Takes the file type to generate as first argument
|
||||||
|
# and the project directory as second argument.
|
||||||
|
haskell-module-deps-with-filetype = pkgs.writers.writeBash "haskell-module-deps-with-filetype" ''
|
||||||
|
set -euo pipefail
|
||||||
|
shopt -s globstar
|
||||||
|
filetype="$1"
|
||||||
|
rootDir="$2"
|
||||||
|
${bins.graphmod} \
|
||||||
|
${/*silence warnings for missing external dependencies*/""} \
|
||||||
|
--quiet \
|
||||||
|
${/*applies some kind of import simplification*/""} \
|
||||||
|
--prune-edges \
|
||||||
|
"$rootDir"/src/**/*.hs \
|
||||||
|
| ${bins.dot} \
|
||||||
|
${/*otherwise it’s a bit cramped*/""} \
|
||||||
|
-Gsize="20,20!" \
|
||||||
|
-T"$filetype"
|
||||||
|
'';
|
||||||
|
|
||||||
|
in
|
||||||
|
depot.nix.readTree.drvTargets {
|
||||||
|
inherit
|
||||||
|
haskell-module-deps
|
||||||
|
haskell-module-deps-png
|
||||||
|
haskell-module-deps-with-filetype
|
||||||
|
;
|
||||||
|
}
|
Binary file not shown.
After Width: | Height: | Size: 406 KiB |
Loading…
Reference in a new issue