nixpkgs/pkgs/by-name/un/unison/package.nix
Artturin e0464e4788 treewide: replace stdenv.is with stdenv.hostPlatform.is
In preparation for the deprecation of `stdenv.isX`.

These shorthands are not conducive to cross-compilation because they
hide the platforms.

Darwin might get cross-compilation for which the continued usage of `stdenv.isDarwin` will get in the way

One example of why this is bad and especially affects compiler packages
https://www.github.com/NixOS/nixpkgs/pull/343059

There are too many files to go through manually but a treewide should
get users thinking when they see a `hostPlatform.isX` in a place where it
doesn't make sense.

```
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv.is" "stdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenv'.is" "stdenv'.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "clangStdenv.is" "clangStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "gccStdenv.is" "gccStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "stdenvNoCC.is" "stdenvNoCC.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "inherit (stdenv) is" "inherit (stdenv.hostPlatform) is"
fd --type f "\.nix" | xargs sd --fixed-strings "buildStdenv.is" "buildStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "effectiveStdenv.is" "effectiveStdenv.hostPlatform.is"
fd --type f "\.nix" | xargs sd --fixed-strings "originalStdenv.is" "originalStdenv.hostPlatform.is"
```
2024-09-25 00:04:37 +03:00

65 lines
1.8 KiB
Nix

{ lib
, stdenv
, fetchFromGitHub
, ocamlPackages
, copyDesktopItems
, makeDesktopItem
, wrapGAppsHook3
, gsettings-desktop-schemas
, enableX11 ? !stdenv.hostPlatform.isDarwin
}:
stdenv.mkDerivation (finalAttrs: {
pname = "unison";
version = "2.53.5";
src = fetchFromGitHub {
owner = "bcpierce00";
repo = "unison";
rev = "v${finalAttrs.version}";
hash = "sha256-XCdK38jG7tRI+/Zk72JVY8a/pPJF6KVaf8l2s3hgxLs=";
};
strictDeps = true;
# uimac requires xcode
postPatch = ''
sed -i -e 's/ macuimaybe//' src/Makefile
'';
nativeBuildInputs = [ ocamlPackages.ocaml ocamlPackages.findlib ]
++ lib.optionals enableX11 [ copyDesktopItems wrapGAppsHook3 ];
buildInputs = lib.optionals enableX11 [ gsettings-desktop-schemas ocamlPackages.lablgtk3 ];
makeFlags = [ "PREFIX=$(out)" ]
++ lib.optionals (!ocamlPackages.ocaml.nativeCompilers) [ "NATIVE=false" ];
postInstall = lib.optionalString enableX11 ''
install -D $src/icons/U.svg $out/share/icons/hicolor/scalable/apps/unison.svg
'';
dontStrip = !ocamlPackages.ocaml.nativeCompilers;
desktopItems = lib.optional enableX11 (makeDesktopItem {
name = finalAttrs.pname;
desktopName = "Unison";
comment = "Bidirectional file synchronizer";
genericName = "File synchronization tool";
exec = "unison-gui";
icon = "unison";
categories = [ "Utility" "FileTools" "GTK" ];
startupNotify = true;
startupWMClass = "Unison";
});
meta = with lib; {
homepage = "https://www.cis.upenn.edu/~bcpierce/unison/";
description = "Bidirectional file synchronizer";
license = licenses.gpl3Plus;
maintainers = with maintainers; [ nevivurn ];
platforms = platforms.unix;
broken = stdenv.hostPlatform.isDarwin && enableX11; # unison-gui and uimac are broken on darwin
mainProgram = if enableX11 then "unison-gui" else "unison";
};
})