summary refs log tree commit diff
path: root/pkgs/desktops/xfce/core/thunar.nix
blob: 037a3f947fbed8c272b1633ddeef0435c1167028 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{ stdenv, buildEnv, runCommand, makeWrapper, lndir, thunar-build
, thunarPlugins ? []
}:

with stdenv.lib; 

let

  build = thunar-build;

  replaceLnExeListWithWrapped = exeDir: exeNameList: mkWrapArgs: ''
    exeDir="${exeDir}"
    oriDir=`realpath -e "$exeDir"`
    unlink "$exeDir"
    mkdir -p "$exeDir"
    lndir "$oriDir" "$exeDir"

    exeList="${concatStrings (intersperse " " (map (x: "${exeDir}/${x}") exeNameList))}"

    for exe in $exeList; do
      oriExe=`realpath -e "$exe"`
      rm -f "$exe"
      makeWrapper "$oriExe" "$exe" ${concatStrings (intersperse " " mkWrapArgs)}
    done
  '';

  name = "${build.p_name}-${build.ver_maj}.${build.ver_min}";

  meta = {
    inherit (build.meta) homepage license platforms;

    description = build.meta.description + optionalString
      (0 != length thunarPlugins)
      " (with plugins: ${concatStrings (intersperse ", " (map (x: x.name) thunarPlugins))})";
    maintainers = build.meta.maintainers /*++ [ jraygauthier ]*/;
  };

in

# TODO: To be replaced with `buildEnv` awaiting missing features.
runCommand name {
  inherit build;
  inherit meta;

  nativeBuildInputs = [ makeWrapper lndir ];

  dontPatchELF = true;
  dontStrip = true;

} 
(let
  buildWithPlugins = buildEnv {
    name = "thunar-build-with-plugins";
    paths = [ build ] ++ thunarPlugins;
  };

in ''
  mkdir -p $out
  pushd ${buildWithPlugins} > /dev/null
  for d in `find . -maxdepth 1 -name "*" -printf "%f\n" | tail -n+2`; do
    ln -s "${buildWithPlugins}/$d" "$out/$d"
  done
  popd > /dev/null

  ${replaceLnExeListWithWrapped "$out/bin" [ "thunar" "thunar-settings" ] [
    "--set THUNARX_MODULE_DIR \"${buildWithPlugins}/lib/thunarx-2\""
  ]}
'')