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/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..58b60c2 --- /dev/null +++ b/flake.nix @@ -0,0 +1,55 @@ +{ + description = "A very basic flake"; + + outputs = { self, nixpkgs }: + let + systems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + #"aarch64-darwin" # currently not building due to gmp + ]; + + 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; + + nativeBuildInputs = with final; [ m4 ]; + + outputs = [ "out" "lib" ]; + + postInstall = '' + moveToOutput "lib" "$lib" + ''; + + cargoLock = { lockFile = self + "/Cargo.lock"; }; + + } + # FIXME: fix aarch64-darwin builds + /* // (if (final.stdenv.isDarwin && final.stdenv.isAarch64) then { + CARGO_FEATURE_USE_SYSTEM_LIBS = "1"; + RUST_BACKTRACE = "1"; + buildInputs = with final; [ gmp mpfr libmpc ]; + } else + { }) + */ + ; + }; + + packages = forAllSystems (system: nixpkgsFor.${system}); + + defaultPackage = forAllSystems (system: self.packages.${system}.kalker); + + }; +}