diff --git a/pkgs/development/ocaml-modules/git/unix.nix b/pkgs/development/ocaml-modules/git/unix.nix index 3e5f464cea06..319613a73335 100644 --- a/pkgs/development/ocaml-modules/git/unix.nix +++ b/pkgs/development/ocaml-modules/git/unix.nix @@ -26,7 +26,7 @@ buildDunePackage { astring cohttp-lwt-unix decompress domain-name ipaddr mtime mirage-flow cstruct ptime mimic ca-certs-nss - tls tls-mirage + tls tls-mirage git ]; checkInputs = [ alcotest alcotest-lwt base64 ke diff --git a/pkgs/development/ocaml-modules/kicadsch/default.nix b/pkgs/development/ocaml-modules/kicadsch/default.nix new file mode 100644 index 000000000000..69b4aae3eafb --- /dev/null +++ b/pkgs/development/ocaml-modules/kicadsch/default.nix @@ -0,0 +1,23 @@ +{ lib +, buildDunePackage +, fetchurl +}: + +buildDunePackage rec { + pname = "kicadsch"; + version = "0.9.0"; + + minimalOCamlVersion = "4.07"; + + src = fetchurl { + url = "https://github.com/jnavila/plotkicadsch/releases/download/v${version}/plotkicadsch-${version}.tbz"; + sha256 = "sha256-B+vnEPyd3SUzviTdNoyvYk0p7Hrg/XTJm8KxsY8A4jQ="; + }; + + meta = with lib; { + description = "OCaml library for exporting Kicad Sch files to SVG pictures"; + homepage = "https://github.com/jnavila/plotkicadsch"; + license = licenses.isc; + maintainers = with maintainers; [ leungbk ]; + }; +} diff --git a/pkgs/development/ocaml-modules/plotkicadsch/default.nix b/pkgs/development/ocaml-modules/plotkicadsch/default.nix new file mode 100644 index 000000000000..e08fcdfeb2f3 --- /dev/null +++ b/pkgs/development/ocaml-modules/plotkicadsch/default.nix @@ -0,0 +1,50 @@ +{ lib +, buildDunePackage +, fetchFromGitHub +, substituteAll +, base64 +, cmdliner +, digestif +, git-unix +, kicadsch +, lwt +, lwt_ppx +, sha +, tyxml +, coreutils +, imagemagick +}: + +buildDunePackage rec { + pname = "plotkicadsch"; + + inherit (kicadsch) src version; + + minimalOCamlVersion = "4.09"; + + patches = [ + (substituteAll { + src = ./fix-paths.patch; + inherit coreutils imagemagick; + }) + ]; + + buildInputs = [ + base64 + cmdliner + digestif + git-unix + kicadsch + lwt + lwt_ppx + sha + tyxml + ]; + + meta = with lib; { + description = "A tool to export Kicad Sch files to SVG pictures"; + homepage = "https://github.com/jnavila/plotkicadsch"; + license = licenses.isc; + maintainers = with maintainers; [ leungbk ]; + }; +} diff --git a/pkgs/development/ocaml-modules/plotkicadsch/fix-paths.patch b/pkgs/development/ocaml-modules/plotkicadsch/fix-paths.patch new file mode 100644 index 000000000000..d9e8d5109f53 --- /dev/null +++ b/pkgs/development/ocaml-modules/plotkicadsch/fix-paths.patch @@ -0,0 +1,26 @@ +diff --git a/plotkicadsch/src/git-imgdiff b/plotkicadsch/src/git-imgdiff +index cbddecb..8d21a8a 100755 +--- a/plotkicadsch/src/git-imgdiff ++++ b/plotkicadsch/src/git-imgdiff +@@ -1,4 +1,4 @@ + #!/bin/bash + PIPE=$(mktemp -u) +-(! compare -metric RMSE $2 $1 png:${PIPE} 2> /dev/null) && (montage -geometry +4+4 $2 $PIPE $1 png:- | display -title "$1" -) ++(! @imagemagick@/bin/compare -metric RMSE $2 $1 png:${PIPE} 2> /dev/null) && (@imagemagick@/bin/montage -geometry +4+4 $2 $PIPE $1 png:- | @imagemagick@/bin/display -title "$1" -) + rm $PIPE +diff --git a/plotkicadsch/src/sysAbst.ml b/plotkicadsch/src/sysAbst.ml +index c3c7b52..15db6d4 100644 +--- a/plotkicadsch/src/sysAbst.ml ++++ b/plotkicadsch/src/sysAbst.ml +@@ -30,7 +30,7 @@ let detect_os () : os = + if Sys.win32 then Windows + else if Sys.cygwin then Cygwin + else +- let ((in_ch, _, _) as uname) = UnixLabels.open_process_full "uname" ~env:[| |] in ++ let ((in_ch, _, _) as uname) = UnixLabels.open_process_full "@coreutils@/bin/uname" ~env:[| |] in + let os = input_line in_ch in + ignore (UnixLabels.close_process_full uname) ; + match os with +-- +2.37.1 + diff --git a/pkgs/top-level/ocaml-packages.nix b/pkgs/top-level/ocaml-packages.nix index 9f69a906b967..04dfa7365dc8 100644 --- a/pkgs/top-level/ocaml-packages.nix +++ b/pkgs/top-level/ocaml-packages.nix @@ -664,6 +664,8 @@ let ke = callPackage ../development/ocaml-modules/ke { }; + kicadsch = callPackage ../development/ocaml-modules/kicadsch { }; + lablgl = callPackage ../development/ocaml-modules/lablgl { }; lablgtk3 = callPackage ../development/ocaml-modules/lablgtk3 { }; @@ -1145,6 +1147,10 @@ let piqi-ocaml = callPackage ../development/ocaml-modules/piqi-ocaml { }; + plotkicadsch = callPackage ../development/ocaml-modules/plotkicadsch { + inherit (pkgs) coreutils imagemagick; + }; + posix-base = callPackage ../development/ocaml-modules/posix/base.nix { }; posix-socket = callPackage ../development/ocaml-modules/posix/socket.nix { };