Skip to content

Commit

Permalink
Merge pull request NixOS#131413 from cwyc/unison-desktop-file-rebased
Browse files Browse the repository at this point in the history
unison: add desktop file
  • Loading branch information
fpletz authored Jul 28, 2021
2 parents 097a91b + 7b95bd0 commit 3dd4a9e
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions pkgs/applications/networking/sync/unison/default.nix
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 = [
Expand All @@ -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
'';

Expand All @@ -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";
Expand Down

0 comments on commit 3dd4a9e

Please sign in to comment.