Merge pull request #145124 from sternenseemann/graphviz-hardcode-store-paths

This commit is contained in:
Ellie Hermaszewska 2021-12-01 16:54:35 +08:00 committed by GitHub
commit e4d170bc8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 51 additions and 0 deletions

View File

@ -1012,4 +1012,15 @@ self: super: builtins.intersectAttrs super {
fi
'' + (drv.postConfigure or "");
}) super.procex;
# Apply a patch which hardcodes the store path of graphviz instead of using
# whatever graphviz is in PATH.
graphviz = overrideCabal (drv: {
patches = [
(pkgs.substituteAll {
src = ./patches/graphviz-hardcode-graphviz-store-path.patch;
inherit (pkgs) graphviz;
})
] ++ (drv.patches or []);
}) super.graphviz;
}

View File

@ -0,0 +1,40 @@
diff --git a/Data/GraphViz/Commands.hs b/Data/GraphViz/Commands.hs
index 20e7dbe..514c29d 100644
--- a/Data/GraphViz/Commands.hs
+++ b/Data/GraphViz/Commands.hs
@@ -63,14 +63,14 @@ import System.IO (Handle, hPutStrLn, hSetBinaryMode, stderr)
-- -----------------------------------------------------------------------------
showCmd :: GraphvizCommand -> String
-showCmd Dot = "dot"
-showCmd Neato = "neato"
-showCmd TwoPi = "twopi"
-showCmd Circo = "circo"
-showCmd Fdp = "fdp"
-showCmd Sfdp = "sfdp"
-showCmd Osage = "osage"
-showCmd Patchwork = "patchwork"
+showCmd Dot = "@graphviz@/bin/dot"
+showCmd Neato = "@graphviz@/bin/neato"
+showCmd TwoPi = "@graphviz@/bin/twopi"
+showCmd Circo = "@graphviz@/bin/circo"
+showCmd Fdp = "@graphviz@/bin/fdp"
+showCmd Sfdp = "@graphviz@/bin/sfdp"
+showCmd Osage = "@graphviz@/bin/osage"
+showCmd Patchwork = "@graphviz@/bin/patchwork"
-- | The default command for directed graphs.
dirCommand :: GraphvizCommand
@@ -312,8 +312,11 @@ runGraphvizCanvas' d = runGraphvizCanvas (commandFor d) d
-- | Is the Graphviz suite of tools installed? This is determined by
-- whether @dot@ is available in the @PATH@.
+--
+-- Note: With nixpkgs, this will always return 'True' as graphviz'
+-- store paths are hardcoded instead of looking at @PATH@.
isGraphvizInstalled :: IO Bool
-isGraphvizInstalled = liftM isJust . findExecutable $ showCmd Dot
+isGraphvizInstalled = pure True -- :)
-- | If Graphviz does not seem to be available, print the provided
-- error message and then exit fatally.