btrbk: add mainProgram (#356350)
[NixPkgs.git] / pkgs / by-name / bl / blendfarm / package.nix
blob26b00115c2a2cde1cb5058135ddb82c55d5ce15b
2   lib,
3   stdenv,
4   fetchFromGitHub,
5   buildDotnetModule,
6   dotnetCorePackages,
7   xz,
8   pcre,
9   autoPatchelfHook,
10   bintools,
11   fixDarwinDylibNames,
12   darwin,
13   fontconfig,
14   libgdiplus,
15   libXrandr,
16   glib,
17   writeShellScriptBin,
18   blender,
19   openssl,
20   libkrb5,
21   icu,
23 let
25   # blendfarm (client) will run from the current workdir.
26   # It needs to create files there, so it cannot be in the nix store.
27   # We also need to create some files there so it can work with its
28   # server part.
29   USERHOMEDIR = "~/.local/share/blendfarm";
30   blendfarm-nix = writeShellScriptBin "blendfarm-nix" ''
31     if [[ -z $BLENDFARM_HOME && ! -d ${USERHOMEDIR} ]]; then
32       echo "Creating home for blendfarm at ${USERHOMEDIR}"
33       echo "You can change that by setting BLENDFARM_HOME to another directory"
34     fi
35     if [[ -z $BLENDFARM_HOME ]]; then
36       BLENDFARM_HOME=${USERHOMEDIR}
37     fi
38     mkdir -p $BLENDFARM_HOME/BlenderData/nix-blender-linux64 > /dev/null 2>&1
39     ln -s ${lib.getExe blender} $BLENDFARM_HOME/BlenderData/nix-blender-linux64/blender > /dev/null 2>&1
40     echo "nix-blender" > $BLENDFARM_HOME/VersionCustom
41     cd $BLENDFARM_HOME
42     exec -a "$0" @out@/bin/LogicReinc.BlendFarm  "$@"
43   '';
46 buildDotnetModule rec {
47   pname = "blendfarm";
48   version = "1.1.6";
50   src = fetchFromGitHub {
51     owner = "LogicReinc";
52     repo = "LogicReinc.BlendFarm";
53     rev = "v${version}";
54     hash = "sha256-2w2tdl5n0IFTuthY97NYMeyRe2r72jaKFfoNSjWQMM4=";
55   };
57   nativeBuildInputs =
58     [ ]
59     ++ lib.optionals stdenv.hostPlatform.isLinux [ autoPatchelfHook ]
60     ++ lib.optionals stdenv.hostPlatform.isDarwin [
61       bintools
62       fixDarwinDylibNames
63       darwin.autoSignDarwinBinariesHook
64     ];
66   buildInputs = [
67     (lib.getLib stdenv.cc.cc)
68     fontconfig
69     openssl
70     libkrb5
71     icu
72   ];
74   runtimeDeps = [
75     xz
76     pcre
77     libgdiplus
78     glib
79     libXrandr
80   ] ++ lib.optionals stdenv.hostPlatform.isLinux [ blender ];
82   # there is no "*.so.3" or "*.so.5" in nixpkgs. So ignore the warning
83   # and add it later
84   autoPatchelfIgnoreMissingDeps = [
85     "libpcre.so.3"
86     "liblzma.so.5"
87   ];
89   dotnet-sdk = dotnetCorePackages.sdk_6_0;
90   dotnet-runtime = dotnetCorePackages.runtime_6_0;
92   projectFile = [
93     "LogicReinc.BlendFarm.Client/LogicReinc.BlendFarm.Client.csproj"
94     "LogicReinc.BlendFarm.Server/LogicReinc.BlendFarm.Server.csproj"
95     "LogicReinc.BlendFarm/LogicReinc.BlendFarm.csproj"
96   ];
97   nugetDeps = ./deps.nix;
98   executables = [
99     "LogicReinc.BlendFarm"
100     "LogicReinc.BlendFarm.Server"
101   ];
103   # add libraries not found by autopatchelf
104   libPath = lib.makeLibraryPath [
105     pcre
106     xz
107   ];
108   makeWrapperArgs = [ "--prefix LD_LIBRARY_PATH : ${libPath}" ];
110   postInstall =
111     lib.optionalString stdenv.hostPlatform.isLinux ''
112       mkdir -p $out/bin
113       cp -v ${blendfarm-nix}/bin/blendfarm-nix $out/bin
114       substituteInPlace $out/bin/blendfarm-nix --subst-var out
115     ''
116     + lib.optionalString stdenv.hostPlatform.isDarwin ''
117       ln -s ${libgdiplus}/lib/libgdiplus.dylib $out/lib/blendfarm/
118     '';
120   meta = with lib; {
121     description = "A open-source, cross-platform, stand-alone, Network Renderer for Blender";
122     homepage = "https://github.com/LogicReinc/LogicReinc.BlendFarm";
123     license = with licenses; [ gpl3Plus ];
124     maintainers = with maintainers; [ gador ];
125     mainProgram = "blendfarm-nix";
126     platforms = platforms.unix;
127   };