summaryrefslogtreecommitdiffstats
path: root/package.nix
blob: a001293725bd1f77ed8ffadb8a1809ea720e9922 (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
# design-it as a nix package. installed system wide from ~/dotfiles/nixos (flake input
# `design-it`, path:/home/nasr/dev/design-it). after changing the code:
#   nix flake update design-it --flake ~/dotfiles/nixos
#   sudo nixos-rebuild switch --flake ~/dotfiles/nixos#como
{ lib, stdenv, pkg-config, wayland-scanner, mold, glibc, patchelf
, wayland, libX11, libxkbcommon, freetype, harfbuzz, vulkan-loader }:

stdenv.mkDerivation {
  pname = "design-it";
  version = "0.3.0";

  # NOTE: the local build/ dir never goes into the store
  src = lib.cleanSourceWith {
    src = ./.;
    filter = path: type: baseNameOf path != "build";
  };

  nativeBuildInputs = [ pkg-config wayland-scanner mold glibc.bin patchelf ];
  buildInputs = [ wayland libX11 libxkbcommon freetype harfbuzz ];

  # same build as by hand. shared freetype/harfbuzz from nixpkgs (scripts/deps.sh downloads,
  # no network in the sandbox), no hot reload (the store is read only anyway)
  buildPhase = ''
    runHook preBuild
    BUILD_DIR=build/release DEBUG=0 STATIC=0 HOT_RELOAD=0 bash ./compile.sh
    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall
    install -Dm755 build/release/design-it      $out/bin/design-it
    # NOTE: no icon in the repo yet (*.svg is gitignored), picked up once there is one
    if [ -f data/design-it.svg ]; then
      install -Dm644 data/design-it.svg $out/share/icons/hicolor/scalable/apps/design-it.svg
    fi
    install -Dm644 data/design-it.desktop       $out/share/applications/design-it.desktop
    install -Dm644 help.txt                     $out/share/doc/design-it/help.txt
    install -Dm644 docs/DESIGNING.md            $out/share/doc/design-it/DESIGNING.md
    install -Dm644 docs/IMPORT_AND_DSL.md       $out/share/doc/design-it/IMPORT_AND_DSL.md
    runHook postInstall
  '';

  # NOTE: vulkan is dlopen'd, so it's not in DT_NEEDED and fixup's rpath shrinking would drop it.
  # added after fixup. the gpu driver (icd) itself comes from /run/opengl-driver.
  postFixup = ''
    patchelf --add-rpath ${lib.makeLibraryPath [ vulkan-loader ]} $out/bin/design-it
  '';

  meta = {
    description = "vulkan software structure and uml diagram editor";
    mainProgram = "design-it";
    platforms = lib.platforms.linux;
  };
}