From 8e3db8b91d7f01b5afe58a4e3bdf926afec098fa Mon Sep 17 00:00:00 2001 From: chives101 Date: Fri, 14 Apr 2023 21:20:34 +0800 Subject: [PATCH] Add nix/flake support Example: nix build github:mimblewimble/grin-wallet ./result/bin/grin-wallet --help --- .gitignore | 1 + flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index 78d8a7cb0..d22df82d5 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ grin.log wallet.seed test_output .idea/ +result diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..a3fbbf993 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1708479678, + "narHash": "sha256-8EeOy/6PXHszyNZQDoX742BryCYsxTDLZjMFWzE/OZg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "307ada3fc4d35f7f35feb9a0edab94f798092c1b", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-23.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..a54a62179 --- /dev/null +++ b/flake.nix @@ -0,0 +1,48 @@ +{ + description = "Reference Grin Wallet."; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/release-23.11"; + }; + + outputs = { self, nixpkgs, }: + let + forAllSystems = with nixpkgs; + lib.genAttrs lib.systems.flakeExposed; + + nixpkgsFor = forAllSystems (system: import nixpkgs + { inherit system; overlays = [ self.overlay ]; } + ); + in + { + overlay = final: prev: + with final; + { + grin-wallet = pkgs.rustPlatform.buildRustPackage { + pname = "grin-wallet"; + version = "5.2.0"; + src = ./.; + + cargoLock = { + lockFile = ./Cargo.lock; + outputHashes = { + "grin_api-5.3.0-alpha.1" = "sha256-qxMmWCJBtiYsqBJgDA6km7XsToLR2fv/PUUZyM1uAF4="; + }; + }; + + nativeBuildInputs = with pkgs; [ pkg-config clang ]; + buildInputs = [ pkgs.openssl ]; + LIBCLANG_PATH = "${pkgs.libclang.lib}/lib"; + + # do not let test results block the build process + doCheck = false; + }; + }; + + packages = forAllSystems ( + system: { + default = nixpkgsFor.${system}.grin-wallet; + } + ); + }; +}