nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 appstream,
3 buildNpmPackage,
4 cargo,
5 desktop-file-utils,
6 fetchFromGitHub,
7 gtk4,
8 gtksourceview5,
9 lib,
10 libadwaita,
11 meson,
12 ninja,
13 nix-update-script,
14 pkg-config,
15 rustPlatform,
16 rustc,
17 stdenv,
18 webkitgtk_6_0,
19 wrapGAppsHook4,
20}:
21let
22 d3-graphviz = buildNpmPackage rec {
23 pname = "d3-graphviz";
24 version = "5.6.0";
25
26 src = fetchFromGitHub {
27 owner = "magjac";
28 repo = "d3-graphviz";
29 tag = "v${version}";
30 hash = "sha256-MZhAzR6+GIBTsLPJq5NqaEPHjiBMgYBJ0hFbDPNPgFk=";
31 };
32
33 npmDepsHash = "sha256-J1kptumP/8UoiYDM+AJOYUne0OSkMXCTAXW3ZmavU4E=";
34
35 # keep the devDependencies, as Delineate imports d3 via node_modules
36 # https://github.com/SeaDve/Delineate/blob/v0.1.0/data/graph_view/index.html#L10-L11
37 npmPruneFlags = "--include=dev";
38 };
39in
40stdenv.mkDerivation (finalAttrs: {
41 pname = "delineate";
42 version = "0.1.1";
43
44 src = fetchFromGitHub {
45 owner = "SeaDve";
46 repo = "Delineate";
47 tag = "v${finalAttrs.version}";
48 hash = "sha256-rYA5TKHX3QJHcUhaTFDpcXQ6tdaG3MbX8buvzV0V5iY=";
49 };
50
51 cargoDeps = rustPlatform.fetchCargoVendor {
52 inherit (finalAttrs) src;
53 hash = "sha256-6XBg9kbIr5k+TMQ/TE/qsAA5rKIevU9M1m+jsPrqfYw=";
54 };
55
56 # rename $out/src -> $out/opt
57 postPatch = ''
58 substituteInPlace ./meson.build --replace-fail \
59 "graphviewsrcdir = prefix / 'src/delineate/graph_view'" \
60 "graphviewsrcdir = prefix / 'opt/delineate/graph_view'"
61 '';
62
63 nativeBuildInputs = [
64 cargo
65 desktop-file-utils
66 gtk4
67 meson
68 ninja
69 pkg-config
70 rustPlatform.bindgenHook
71 rustPlatform.cargoSetupHook
72 rustc
73 wrapGAppsHook4
74 ];
75
76 buildInputs = [
77 appstream
78 gtksourceview5
79 libadwaita
80 webkitgtk_6_0
81 ];
82
83 postInstall = ''
84 ln -s ${d3-graphviz}/lib/node_modules/d3-graphviz $out/opt/delineate/graph_view/d3-graphviz
85 '';
86
87 passthru.updateScript = nix-update-script { };
88
89 meta = {
90 description = "View and edit graphs";
91 homepage = "https://github.com/SeaDve/Delineate";
92 changelog = "https://github.com/SeaDve/Delineate/releases/tag/v${finalAttrs.version}";
93 license = lib.licenses.gpl3Plus;
94 maintainers = [ lib.maintainers.nekowinston ];
95 platforms = lib.platforms.linux;
96 mainProgram = "delineate";
97 };
98})