diff --git a/.gitignore b/.gitignore index 3a0388c..81a689c 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ kalk/Cargo.lock cli/Cargo.lock cli/test .vscode/ +result* diff --git a/Cargo.lock b/Cargo.lock index 49401c9..603173c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -152,9 +152,8 @@ dependencies = [ [[package]] name = "gmp-mpfr-sys" -version = "1.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a57fdb339d49833021b1fded600ed240ae907e33909d5511a61dff884df7f16e" +version = "1.4.7" +source = "git+https://gitlab.com/tspiteri/gmp-mpfr-sys.git#21966f4bfb56c87d407eb14c72e92ef4e55856aa" dependencies = [ "libc", "winapi", diff --git a/Cargo.toml b/Cargo.toml index ed4a5eb..3b2e286 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,6 @@ +[patch.crates-io] +gmp-mpfr-sys = { git = "https://gitlab.com/tspiteri/gmp-mpfr-sys.git" } + [workspace] members = ["kalk", "cli"] diff --git a/README.md b/README.md index 382882a..0ce4ec6 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Kalker (or "kalk") is a calculator program/website that supports user-defined va * Operators: `+`, `-`, `*`, `/`, `!` * Groups: `()`, `⌈ceil⌉`, `⌊floor⌋`, `[iverson]` -* [Pre-defined functions and constants](https://github.com/PaddiM8/kalker/blob/master/kalk/src/prelude.rs) +* [Pre-defined functions and constants](https://github.com/PaddiM8/kalker/blob/master/kalk/src/prelude/mod.rs) * User-defined functions and variables. `f(x, y) = xy`, `x = 5` * Derivative of functions (derivatives of noisy functions or of higher order can be a bit inaccurate). `f'(2)`, `sin'(-pi)` * Integration. `∫(0, pi, sin(x) dx)` or `∫(0, π, sin(x) dx)`, maybe sometimes be slightly off diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..4fb93ff --- /dev/null +++ b/flake.lock @@ -0,0 +1,25 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1632255010, + "narHash": "sha256-p/BYR6qhbCtDpOfw9uMYwjwyhuCVKgiSUpKZaV/63UE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "bfc38d3d0d22c528e8abc46c5dd5f3f50fc4554b", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..7f175ed --- /dev/null +++ b/flake.nix @@ -0,0 +1,58 @@ +{ + description = "A calculator program/website"; + + outputs = { self, nixpkgs }: + let + systems = + [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + + forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system); + + nixpkgsFor = forAllSystems (system: + import nixpkgs { + inherit system; + overlays = [ self.overlay ]; + }); + in { + overlay = final: prev: { + kalker = final.rustPlatform.buildRustPackage { + pname = "kalker"; + version = "unstable"; + + src = self; + + outputs = [ "out" "lib" ]; + + postInstall = '' + moveToOutput "lib" "$lib" + ''; + + cargoLock = { + lockFile = self + "/Cargo.lock"; + outputHashes = { + "gmp-mpfr-sys-1.4.7" = + "sha256-zHpGbEgh3MgAUVdlWrXq4Clj1boybi6DMOcsjgZbAh0="; + }; + }; + + buildInputs = with final; [ gmp mpfr libmpc ]; + + CARGO_FEATURE_USE_SYSTEM_LIBS = "1"; + }; + }; + + packages = + forAllSystems (system: { inherit (nixpkgsFor.${system}) kalker; }); + + defaultPackage = forAllSystems (system: self.packages.${system}.kalker); + + apps = forAllSystems (system: { + kalker = { + type = "app"; + program = "${self.packages.${system}.kalker}/bin/kalker"; + }; + }); + + defaultApp = forAllSystems (system: self.apps.${system}.kalker); + }; +}