unison: add desktop file

Added desktop file for program launchers. Also made use of lib.strings.optionalString to replace instances of `if string else ""`.
This commit is contained in:
cwyc 2021-07-23 01:18:56 -04:00
parent ecaf3da934
commit 7b95bd01c1

View file

@ -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";