nix flake: add packages and apps

This commit is contained in:
TG × ⊙
2022-07-15 17:13:36 +02:00
committed by parazyd
parent d585120315
commit 455b349ebc
4 changed files with 175 additions and 72 deletions

3
Cargo.lock generated
View File

@@ -1647,7 +1647,8 @@ checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7"
[[package]]
name = "fast-socks5"
version = "0.4.3"
source = "git+https://github.com/ghassmo/fast-socks5#52118864c981a418b167bfa4f0a92de6fbed30e7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba337793c1ee49731350a8d971d791651ed51d6e814ab4ddabd79c12b5366140"
dependencies = [
"anyhow",
"async-std",

View File

@@ -99,7 +99,7 @@ tungstenite = {version = "0.17.2", optional = true}
async-tungstenite = {version = "0.17.2", optional = true}
# socks5
fast-socks5 = {git = "https://github.com/ghassmo/fast-socks5", optional = true}
fast-socks5 = {version = "0.4.3", optional = true}
# Crypto
bitvec = {version = "1.0.0", optional = true}

82
contrib/flake.lock generated
View File

@@ -2,11 +2,11 @@
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1644229661,
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
"lastModified": 1656065134,
"narHash": "sha256-oc6E6ByIw3oJaIyc67maaFcnjYOz1mMcOtHxbEf9NwQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
"rev": "bee6a7250dd1b01844a2de7e02e4df7d8a0a206c",
"type": "github"
},
"original": {
@@ -15,29 +15,13 @@
"type": "github"
}
},
"mozilla": {
"flake": false,
"locked": {
"lastModified": 1645464064,
"narHash": "sha256-YeN4bpPvHkVOpQzb8APTAfE7/R+MFMwJUMkqmfvytSk=",
"owner": "mozilla",
"repo": "nixpkgs-mozilla",
"rev": "15b7a05f20aab51c4ffbefddb1b448e862dccb7d",
"type": "github"
},
"original": {
"owner": "mozilla",
"repo": "nixpkgs-mozilla",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1657654771,
"narHash": "sha256-uIGbt+rU89aTlSx8+4g9vKioWc8nmCCcaaFCNPHM07c=",
"lastModified": 1657693803,
"narHash": "sha256-G++2CJ9u0E7NNTAi9n5G8TdDmGJXcIjkJ3NF8cetQB8=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "4aceab3cadf9fef6f70b9f6a9df964218650db0a",
"rev": "365e1b3a859281cf11b94f87231adeabbdd878a2",
"type": "github"
},
"original": {
@@ -47,11 +31,61 @@
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1656401090,
"narHash": "sha256-bUS2nfQsvTQW2z8SK7oEFSElbmoBahOPtbXPm0AL3I4=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "16de63fcc54e88b9a106a603038dd5dd2feb21eb",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"rust-overlay": "rust-overlay",
"utils": "utils"
}
},
"rust-overlay": {
"inputs": {
"flake-utils": "flake-utils",
"mozilla": "mozilla",
"nixpkgs": "nixpkgs"
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1657853760,
"narHash": "sha256-X6ERAyUXGsrhbhgkxNaQl40wcus5uyQZOCxUh5neK+g=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "a97a761cc11327bb109dc30af1c637b986be7959",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
},
"utils": {
"locked": {
"lastModified": 1656928814,
"narHash": "sha256-RIFfgBuKz6Hp89yRr7+NR5tzIAbn52h8vT6vXkYjZoM=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "7e2a3b3dfd9af950a856d66b0a7d01e3c18aa249",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},

View File

@@ -1,55 +1,123 @@
# Nix flake
#
# To use it, install Nix & Nix flakes (see https://nixos.wiki/wiki/Flakes)
# Then use these commands to get a development shell, build and run binaries:
# $ cd contrib
# $ nix develop
# $ nix build '.#darkfi-ircd'
# $ nix run '.#darkfi-ircd'
{
description = "Darkfi Dev Environment";
description = "DarkFi";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-22.05";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.mozilla = { url = "github:mozilla/nixpkgs-mozilla"; flake = false; };
inputs.utils.url = "github:numtide/flake-utils";
inputs.rust-overlay.url = "github:oxalica/rust-overlay";
outputs =
{ self
, nixpkgs
, mozilla
, flake-utils
, ...
} @inputs:
let rustOverlay = final: prev:
let rustChannel = prev.rustChannelOf {
channel = "1.60.0";
sha256 = "sha256-otgm+7nEl94JG/B+TYhWseZsHV1voGcBsW/lOD2/68g=";
};
in
{ inherit rustChannel;
rustc = rustChannel.rust;
cargo = rustChannel.rust;
};
in flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
(import "${mozilla}/rust-overlay.nix")
rustOverlay
];
outputs = { self, nixpkgs, utils, rust-overlay }:
utils.lib.eachDefaultSystem (system:
let
overlays = [
(import rust-overlay)
];
pkgs = import nixpkgs rec {
inherit system overlays;
};
in {
devShell = pkgs.mkShell {
rust-bin = pkgs.rust-bin.stable."1.62.0".default.override {
extensions = [ "rust-src" ];
};
buildRustPackage = (pkgs.makeRustPlatform {
cargo = rust-bin;
rustc = rust-bin;
}).buildRustPackage;
myNativeBuildInputs = with pkgs; [
pkg-config
gnumake
cmake
clang
libclang
llvm
];
myBuildInputs = with pkgs; [
expat
fontconfig
freetype
openssl
];
myBuildRustPackage = attrs:
buildRustPackage ({
version = "0.3.0";
src = ../.;
cargoLock.lockFile = ../Cargo.lock;
nativeBuildInputs = myNativeBuildInputs;
buildInputs = myBuildInputs;
#RUST_BACKTRACE=1;
#RUST_LOG="trace";
buildInputs = with pkgs; [
openssl
gnumake
openssl
clang
libclang
pkg-config
cmake
llvm
freetype
fontconfig
(rustChannel.rust.override { extensions = [ "rust-src" ]; })
];
LIBCLANG_PATH="${pkgs.libclang.lib}/lib";
} // attrs);
in rec {
packages = rec {
darkfi-drk = myBuildRustPackage rec {
pname = "darkfi-drk";
buildAndTestSubdir = "./bin/drk";
};
});
darkfi-darkfid = myBuildRustPackage rec {
pname = "darkfi-darkfid";
buildAndTestSubdir = "./bin/darkfid";
};
darkfi-dnetview = myBuildRustPackage rec {
pname = "darkfi-dnetview";
buildAndTestSubdir = "./bin/dnetview";
};
darkfi-ircd = myBuildRustPackage rec {
pname = "darkfi-ircd";
buildAndTestSubdir = "./bin/ircd";
};
darkfi-tau = myBuildRustPackage rec {
pname = "darkfi-tau";
buildAndTestSubdir = "./bin/tau";
};
darkfi-taud = myBuildRustPackage rec {
pname = "darkfi-taud";
buildAndTestSubdir = "./bin/taud";
};
darkfi-zkas = myBuildRustPackage rec {
pname = "darkfi-zkas";
buildAndTestSubdir = "./bin/zkas";
};
default = darkfi-drk;
};
defaultPackage = packages.default; # compat
apps = rec {
darkfi-drk = utils.lib.mkApp {
drv = packages.darkfi-drk;
exePath = "/bin/drk";
};
darkfi-darkfid = utils.lib.mkApp {
drv = packages.darkfi-darkfid;
exePath = "/bin/darkfid";
};
darkfi-dnetview = utils.lib.mkApp {
drv = packages.darkfi-dnetview;
exePath = "/bin/dnetview";
};
darkfi-ircd = utils.lib.mkApp {
drv = packages.darkfi-ircd;
exePath = "/bin/ircd";
};
darkfi-tau = utils.lib.mkApp {
drv = packages.darkfi-tau;
exePath = "/bin/tau";
};
darkfi-taud = utils.lib.mkApp {
drv = packages.darkfi-taud;
exePath = "/bin/taud";
};
darkfi-zkas = utils.lib.mkApp {
drv = packages.darkfi-zkas;
exePath = "/bin/zkas";
};
default = darkfi-drk;
};
});
}