Skip to content

Commit 1346a00

Browse files
committed
graphest: init at 1.3.3-unstable-2024-08-30
1 parent 43ace1d commit 1346a00

File tree

3 files changed

+242
-0
lines changed

3 files changed

+242
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
diff --git a/rust/graphest-arb-sys/build.rs b/rust/graphest-arb-sys/build.rs
2+
index 9527ffe..94c6d60 100644
3+
--- a/rust/graphest-arb-sys/build.rs
4+
+++ b/rust/graphest-arb-sys/build.rs
5+
@@ -50,6 +50,7 @@ fn load_cache(env: &Environment) {
6+
}
7+
8+
fn build_flint(env: &Environment) {
9+
+ let _ = copy_dir_all("@flint@", env.out_dir.clone());
10+
if env.lib_dir.join("libflint.a").exists() {
11+
return;
12+
}
13+
diff --git a/rust/graphest-fftw-sys/build.rs b/rust/graphest-fftw-sys/build.rs
14+
index 2e3247d..a4ac573 100644
15+
--- a/rust/graphest-fftw-sys/build.rs
16+
+++ b/rust/graphest-fftw-sys/build.rs
17+
@@ -53,6 +53,8 @@ fn load_cache(env: &Environment) {
18+
}
19+
20+
fn build(env: &Environment) {
21+
+ let _ = copy_dir_all("@fftwLib@", env.out_dir.clone());
22+
+ let _ = copy_dir_all("@fftwDev@", env.out_dir.clone());
23+
if env.lib_dir.join("libfftw3f.a").exists() {
24+
return;
25+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/src/main/main.ts b/src/main/main.ts
2+
index d9413cc..b49e641 100644
3+
--- a/src/main/main.ts
4+
+++ b/src/main/main.ts
5+
@@ -280,7 +280,6 @@ app.whenReady().then(async () => {
6+
}
7+
8+
createMainWindow();
9+
- autoUpdater.checkForUpdatesAndNotify();
10+
});
11+
12+
app.on("open-file", (_, path) => {
Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
{
2+
lib,
3+
stdenv,
4+
rustPlatform,
5+
buildNpmPackage,
6+
fetchFromGitHub,
7+
fetchpatch,
8+
fetchurl,
9+
replaceVars,
10+
copyDesktopItems,
11+
makeDesktopItem,
12+
makeBinaryWrapper,
13+
nix-update-script,
14+
electron,
15+
gnum4,
16+
fftwFloat,
17+
flint,
18+
blas,
19+
openblas,
20+
}:
21+
22+
let
23+
# The dependencies of graphest-fftw-sys and graphest-arb-sys need to be static.
24+
# Use this instead of pkgsStatic because pkgsStatic.flint build fails.
25+
static =
26+
p:
27+
p.overrideAttrs (oldAttrs: {
28+
configureFlags = oldAttrs.configureFlags ++ [ "--enable-static" ];
29+
});
30+
fftwFloatStatic = static fftwFloat;
31+
# Graphest was developed with Flint 2, so let's hope there are no breaking changes
32+
flintStatic = (static flint).override {
33+
inherit blas openblas;
34+
withBlas = true; # Some functions used by Graphest require BLAS
35+
};
36+
37+
version = "1.3.3-unstable-2024-08-30"; # 1.3.3 build fails because Rust removed default_free_fn
38+
src = fetchFromGitHub {
39+
owner = "unageek";
40+
repo = "graphest";
41+
rev = "e9730220349a6da9816f930b5a37c2a75b74bf9c"; # tag = "v${version}";
42+
hash = "sha256-s9dVApPjFJGR0lP+a2pi6P+GDs4JIAz5gpW+cx9XGzw=";
43+
};
44+
45+
meta = {
46+
description = "Graphing calculator that can faithfully plot arbitrary mathematical relations";
47+
homepage = "https://github.com/unageek/graphest";
48+
changelog = "https://github.com/unageek/graphest/releases/tag/v1.3.3"; # https://github.com/unageek/graphest/releases/${src.tag}
49+
downloadPage = "https://github.com/unageek/graphest/releases";
50+
license = lib.licenses.mit;
51+
maintainers = with lib.maintainers; [ ulysseszhan ];
52+
};
53+
54+
graph = rustPlatform.buildRustPackage (finalAttrs: {
55+
pname = "graphest-graph";
56+
inherit version src;
57+
58+
patches = [
59+
# Update bindgen; use Flint 3; fix compilation warnings (https://github.com/unageek/graphest/pull/999)
60+
(fetchpatch {
61+
name = "flint3";
62+
url = "https://github.com/unageek/graphest/commit/65ffea93c934f2df100c18f799afdf9870d611ff.patch";
63+
hash = "sha256-aysdGhVu54M3F+A0e38WwlLUdf2pTw73Vs117Vfi8O8=";
64+
})
65+
66+
# Use libraries from nixpkgs instead of trying to download them
67+
(replaceVars ./dependencies.patch {
68+
fftwLib = fftwFloatStatic.out;
69+
fftwDev = fftwFloatStatic.dev;
70+
flint = flintStatic.out;
71+
})
72+
];
73+
74+
nativeBuildInputs = [
75+
gnum4
76+
rustPlatform.bindgenHook
77+
];
78+
79+
buildInputs = [
80+
fftwFloatStatic
81+
flintStatic
82+
blas # needed here because -lblas is added to RUSTFLAGS
83+
];
84+
strictDeps = true;
85+
86+
cargoLock.lockFile = fetchurl {
87+
name = "graphest-cargo-lock";
88+
url = "https://raw.githubusercontent.com/unageek/graphest/65ffea93c934f2df100c18f799afdf9870d611ff/Cargo.lock";
89+
hash = "sha256-f9KsefQD47OnEj54Y9ugXN2a3uik2YMKHu/XLPpE0hU=";
90+
};
91+
92+
env = {
93+
RUSTC_BOOTSTRAP = 1; # smallvec: error[E0554]: `#![feature]` may not be used on the stable release channel
94+
RUSTFLAGS =
95+
"-lblas" # add -lblas to fix linking error regarding the function cblas_dgemm (bug of flint maybe???)
96+
# inari: error: RUSTFLAGS='-Ctarget-cpu=haswell' or later is required.
97+
+ lib.optionalString stdenv.hostPlatform.isx86 " -Ctarget-cpu=haswell";
98+
};
99+
100+
preCheck = ''
101+
# see rust/tests/graph.rs; executable path is hardcoded to be in target/release
102+
ln -s ../${stdenv.targetPlatform.rust.rustcTargetSpec}/release/graph -t target/release
103+
'';
104+
# These two tests fails probably because of Flint 3
105+
checkFlags = [
106+
"--skip"
107+
"graph_tests::examples::t_8c9209237ba04e67a715382c7bcbf5e0"
108+
"--skip"
109+
"graph_tests::examples::t_d2a0e9e88c41406a80a266d78f6dc7a5"
110+
];
111+
112+
meta = meta // {
113+
broken = stdenv.hostPlatform.isMsvc; # https://github.com/unageek/inari
114+
mainProgram = "graph";
115+
};
116+
});
117+
118+
in
119+
buildNpmPackage (finalAttrs: {
120+
pname = "graphest";
121+
inherit version src;
122+
123+
patches = [
124+
# specify what files should be installed in package.json (https://github.com/unageek/graphest/pull/1000)
125+
(fetchpatch {
126+
name = "npm-files";
127+
url = "https://github.com/unageek/graphest/commit/1d1b8ee610a55bf9465a630499c6b0f6e9a66689.patch";
128+
hash = "sha256-5PU9iPy6gfesl40piRTw9+QMNf4GSGASYs8ZTLedS7o=";
129+
})
130+
131+
./disable-auto-update.patch
132+
];
133+
134+
nativeBuildInputs = [
135+
copyDesktopItems
136+
makeBinaryWrapper
137+
];
138+
139+
buildInputs = [
140+
electron
141+
graph
142+
];
143+
144+
npmDepsHash = "sha256-J/IZ7d3LaYZLik7SxXSrH9dfxpxsa/Dn87160ba7wjs=";
145+
env.ELECTRON_SKIP_BINARY_DOWNLOAD = 1;
146+
147+
preBuild = ''
148+
export NODE_ENV=production # do not set this in env because it must not be present in the configure phase
149+
'';
150+
npmBuildScript = "build:app";
151+
152+
checkPhase = ''
153+
runHook preCheck
154+
155+
npm test
156+
157+
runHook postCheck
158+
'';
159+
160+
postInstall = ''
161+
ln -s ${graph}/bin/* -t $out/lib/node_modules/graphest/dist
162+
163+
makeWrapper ${lib.getExe electron} $out/bin/graphest \
164+
--add-flags $out/lib/node_modules/graphest \
165+
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}" \
166+
--inherit-argv0
167+
168+
mkdir -p $out/share/{icons/hicolor/1024x1024/apps,mime/packages}
169+
install -Dm644 build/icon.png $out/share/icons/hicolor/1024x1024/apps/graphest.png
170+
cat << EOF > $out/share/mime/packages/graphest.xml
171+
<?xml version="1.0" encoding="UTF-8"?>
172+
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
173+
<mime-type type="application/x-graphest">
174+
<comment xml:lang="en">Graphest Document</comment>
175+
<glob pattern="*.graphest"/>
176+
</mime-type>
177+
</mime-info>
178+
EOF
179+
'';
180+
181+
desktopItem = makeDesktopItem {
182+
name = "graphest";
183+
desktopName = "Graphest";
184+
exec = "graphest %u";
185+
icon = "graphest";
186+
categories = [
187+
"Science"
188+
"Math"
189+
];
190+
comment = meta.description;
191+
mimeTypes = [
192+
"x-scheme-handler/graphest"
193+
"application/x-graphest"
194+
];
195+
};
196+
197+
passthru = {
198+
inherit graph;
199+
updateScript = nix-update-script { };
200+
};
201+
202+
meta = meta // {
203+
mainProgram = "graphest";
204+
};
205+
})

0 commit comments

Comments
 (0)