From defd062a0109e4da78fc7fa93e59154f37316ca4 Mon Sep 17 00:00:00 2001 From: chives101 Date: Thu, 13 Apr 2023 12:37:10 +0800 Subject: [PATCH] Add nix/flake support Example: nix build github:mimblewimble/grin ./result/bin/grin --help --- flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..581384362 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1681411673, + "narHash": "sha256-23S0skJVstbQtrhy+65Bi4Jrdw74hY1OYbBnuuQausc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "80d54821fffaffbc90409a1262ea91071e0dff8f", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-22.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..c4999b5ce --- /dev/null +++ b/flake.nix @@ -0,0 +1,51 @@ +{ + description = "THE MIMBLEWIMBLE BLOCKCHAIN."; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/release-22.11"; + }; + + outputs = { self, nixpkgs, }: + let + supportedSystems = + [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-linux" + "aarch64-darwin" + ]; + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + nixpkgsFor = forAllSystems (system: import nixpkgs + { inherit system; overlays = [ self.overlay ]; } + ); + in + { + overlay = final: prev: + with final; + { + grin = pkgs.rustPlatform.buildRustPackage { + pname = "grin"; + version = "5.2.0-alpha.2"; + src = ./.; + + cargoLock = { + lockFile = ./Cargo.lock; + }; + + nativeBuildInputs = [ pkgs.llvmPackages_latest.clang ]; + buildInputs = [ pkgs.ncurses ]; + LIBCLANG_PATH = + "${pkgs.llvmPackages_latest.libclang.lib}/lib"; + + # do not let test results block the build process + doCheck = false; + }; + }; + + packages = forAllSystems ( + system: { + default = nixpkgsFor.${system}.grin; + } + ); + }; +}