feat: Add nix/flake support (#3743)

* CI update - Ubuntu Image

* Add nix/flake support

Example:

nix build github:mimblewimble/grin

./result/bin/grin --help

* Ignore ./result in git repo

result is the default symlink output for nix build

---------

Co-authored-by: chives101 <chives101@users.noreply.github.com>
This commit is contained in:
chives101 2023-05-03 01:34:37 +08:00 committed by GitHub
parent 684f0a387a
commit de94f95cda
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 75 additions and 1 deletions

1
.gitignore vendored
View file

@ -14,3 +14,4 @@ wallet/db
.idea/
.vscode/
/node*
result

View file

@ -31,7 +31,7 @@ variables:
jobs:
- job: linux
pool:
vmImage: ubuntu-18.04
vmImage: ubuntu-22.04
strategy:
matrix:
servers:

27
flake.lock Normal file
View file

@ -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
}

46
flake.nix Normal file
View file

@ -0,0 +1,46 @@
{
description = "THE MIMBLEWIMBLE BLOCKCHAIN.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/release-22.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 = 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;
}
);
};
}