1{
2 lib,
3 mkDerivation,
4 fetchFromGitHub,
5 python3,
6 ruby,
7 qtbase,
8 qtmultimedia,
9 qttools,
10 qtxmlpatterns,
11 which,
12 perl,
13 libgit2,
14 stdenv,
15}:
16
17mkDerivation rec {
18 pname = "klayout";
19 version = "0.30.4-1";
20
21 src = fetchFromGitHub {
22 owner = "KLayout";
23 repo = "klayout";
24 rev = "v${version}";
25 hash = "sha256-EhIGxiXqo09/p8mA00RRvKgXJncVr4qguYSPyEC0fqc=";
26 };
27
28 postPatch = ''
29 substituteInPlace src/klayout.pri --replace "-Wno-reserved-user-defined-literal" ""
30 patchShebangs .
31 '';
32
33 nativeBuildInputs = [
34 which
35 perl
36 python3
37 ruby
38 ];
39
40 buildInputs = [
41 qtbase
42 qtmultimedia
43 qttools
44 qtxmlpatterns
45 libgit2
46 ];
47
48 buildPhase = ''
49 runHook preBuild
50 mkdir -p $out/lib
51 ./build.sh -qt5 -prefix $out/lib -option -j$NIX_BUILD_CORES
52 runHook postBuild
53 '';
54
55 postBuild =
56 lib.optionalString stdenv.hostPlatform.isLinux ''
57 mkdir $out/bin
58
59 install -Dm444 etc/klayout.desktop -t $out/share/applications
60 install -Dm444 etc/logo.png $out/share/icons/hicolor/256x256/apps/klayout.png
61 mv $out/lib/klayout $out/bin/
62 ''
63 + lib.optionalString stdenv.hostPlatform.isDarwin ''
64 mkdir -p $out/Applications
65 mv $out/lib/klayout.app $out/Applications/
66 '';
67
68 preFixup = lib.optionalString stdenv.hostPlatform.isDarwin ''
69 exec_name=$out/Applications/klayout.app/Contents/MacOS/klayout
70
71 for lib in $out/lib/libklayout_*.0.dylib; do
72 base_name=$(basename $lib)
73 install_name_tool -change "$base_name" "@rpath/$base_name" "$exec_name"
74 done
75
76 wrapQtApp "$out/Applications/klayout.app/Contents/MacOS/klayout"
77 '';
78
79 env.NIX_CFLAGS_COMPILE = toString [ "-Wno-parentheses" ];
80
81 dontInstall = true; # Installation already happens as part of "build.sh"
82
83 # Fix: "gsiDeclQMessageLogger.cc:126:42: error: format not a string literal
84 # and no format arguments [-Werror=format-security]"
85 hardeningDisable = [ "format" ];
86
87 meta = {
88 description = "High performance layout viewer and editor with support for GDS and OASIS";
89 mainProgram = "klayout";
90 license = with lib.licenses; [ gpl2Plus ];
91 homepage = "https://www.klayout.de/";
92 changelog = "https://www.klayout.de/development.html#${version}";
93 platforms = lib.platforms.linux ++ lib.platforms.darwin;
94 maintainers = with lib.maintainers; [ ];
95 };
96}