From 7b95bd01c1a960319349e09697db5664c514f69d Mon Sep 17 00:00:00 2001 From: cwyc <16950437+cwyc@users.noreply.github.com> Date: Fri, 23 Jul 2021 01:18:56 -0400 Subject: [PATCH] unison: add desktop file Added desktop file for program launchers. Also made use of lib.strings.optionalString to replace instances of `if string else ""`. --- .../networking/sync/unison/default.nix | 29 +++++++++++++++---- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/pkgs/applications/networking/sync/unison/default.nix b/pkgs/applications/networking/sync/unison/default.nix index 9ab8d441508..8a8fc073355 100644 --- a/pkgs/applications/networking/sync/unison/default.nix +++ b/pkgs/applications/networking/sync/unison/default.nix @@ -1,4 +1,4 @@ -{lib, stdenv, fetchFromGitHub, ocamlPackages, fontschumachermisc, xset, makeWrapper, ncurses, gnugrep, fetchpatch +{lib, stdenv, fetchFromGitHub, ocamlPackages, fontschumachermisc, xset, makeWrapper, ncurses, gnugrep, fetchpatch, copyDesktopItems, makeDesktopItem , enableX11 ? true}: let inherit (ocamlPackages) ocaml lablgtk; in @@ -14,7 +14,7 @@ stdenv.mkDerivation (rec { sha256 = "sha256-42hmdMwOYSWGiDCmhuqtpCWtvtyD2l+kA/bhHD/Qh5Y="; }; - nativeBuildInputs = [ makeWrapper ]; + nativeBuildInputs = [ makeWrapper ] ++ (lib.lists.optional enableX11 copyDesktopItems); buildInputs = [ ocaml ncurses ]; patches = [ @@ -27,9 +27,9 @@ stdenv.mkDerivation (rec { }) ]; - preBuild = (if enableX11 then '' + preBuild = (lib.strings.optionalString enableX11 '' sed -i "s|\(OCAMLOPT=.*\)$|\1 -I $(echo "${lablgtk}"/lib/ocaml/*/site-lib/lablgtk2)|" src/Makefile.OCaml - '' else "") + '' + '') + '' echo -e '\ninstall:\n\tcp $(FSMONITOR)$(EXEC_EXT) $(INSTALLDIR)' >> src/fsmonitor/linux/Makefile ''; @@ -40,15 +40,32 @@ stdenv.mkDerivation (rec { preInstall = "mkdir -p $out/bin"; - postInstall = if enableX11 then '' + postInstall = lib.strings.optionalString enableX11 '' for i in $(cd $out/bin && ls); do wrapProgram $out/bin/$i \ --run "[ -n \"\$DISPLAY\" ] && (${xset}/bin/xset q | ${gnugrep}/bin/grep -q \"${fontschumachermisc}\" || ${xset}/bin/xset +fp \"${fontschumachermisc}/lib/X11/fonts/misc\")" done - '' else ""; + + install -D $src/icons/U.svg $out/share/icons/hicolor/scalable/apps/unison.svg + ''; dontStrip = !ocaml.nativeCompilers; + desktopItems = lib.lists.optional enableX11 (makeDesktopItem { + name = pname; + desktopName = "Unison"; + comment = "Bidirectional file synchronizer"; + genericName = "File synchronization tool"; + exec = "unison"; + icon = "unison"; + categories = "Utility;FileTools;GTK;"; + extraDesktopEntries={ + StartupWMClass="Unison"; + StartupNotify="true"; + X-MultipleArgs="false"; + }; + }); + meta = { homepage = "https://www.cis.upenn.edu/~bcpierce/unison/"; description = "Bidirectional file synchronizer";