[Add] nix dev shell
This commit is contained in:
parent
f25815aa1b
commit
83bd05b791
2 changed files with 68 additions and 28 deletions
21
flake.lock
generated
21
flake.lock
generated
|
|
@ -53,9 +53,30 @@
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"flake-parts": "flake-parts",
|
"flake-parts": "flake-parts",
|
||||||
"nixpkgs": "nixpkgs",
|
"nixpkgs": "nixpkgs",
|
||||||
|
"rust-overlay": "rust-overlay",
|
||||||
"ttp": "ttp"
|
"ttp": "ttp"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"rust-overlay": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1778987862,
|
||||||
|
"narHash": "sha256-V3qGt9P1eJP/r/1ONablphfGiH0RP4agQhrRANpDYx8=",
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"rev": "6f44d8874ac29806c8d5cae42bf8e19ebb5ce0d3",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
"ttp": {
|
"ttp": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
|
|
|
||||||
77
flake.nix
77
flake.nix
|
|
@ -4,13 +4,17 @@
|
||||||
inputs = {
|
inputs = {
|
||||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||||
|
rust-overlay = {
|
||||||
|
url = "github:oxalica/rust-overlay";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
ttp = {
|
ttp = {
|
||||||
url = "git+https://git.methanium.net/Tensamin/TTP.git?rev=7e5d1953df8592a1feba0f390d205d0ef61a3119";
|
url = "git+https://git.methanium.net/Tensamin/TTP.git?rev=7e5d1953df8592a1feba0f390d205d0ef61a3119";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = inputs@{ self, nixpkgs, flake-parts, ttp, ... }:
|
outputs = inputs@{ self, nixpkgs, flake-parts, rust-overlay, ttp, ... }:
|
||||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||||
systems = [
|
systems = [
|
||||||
"x86_64-linux"
|
"x86_64-linux"
|
||||||
|
|
@ -19,37 +23,52 @@
|
||||||
"aarch64-darwin"
|
"aarch64-darwin"
|
||||||
];
|
];
|
||||||
|
|
||||||
perSystem = { self', pkgs, ... }: {
|
perSystem = { self', pkgs, system, ... }:
|
||||||
packages = {
|
let
|
||||||
default = self'.packages.iota;
|
rustPkgs = import nixpkgs {
|
||||||
iota = pkgs.rustPlatform.buildRustPackage {
|
inherit system;
|
||||||
pname = "iota";
|
overlays = [ (import rust-overlay) ];
|
||||||
version = "0.1.0";
|
};
|
||||||
src = ./.;
|
rustToolchain = rustPkgs.rust-bin.stable.latest.default.override {
|
||||||
cargoLock = {
|
extensions = [ "rust-src" "rust-analyzer" "clippy" "rustfmt" ];
|
||||||
lockFile = ./Cargo.lock;
|
};
|
||||||
allowBuiltinFetchGit = true;
|
in
|
||||||
};
|
{
|
||||||
nativeBuildInputs = with pkgs; [ cmake perl pkg-config ];
|
packages = {
|
||||||
buildInputs = with pkgs; [ openssl sqlite ];
|
default = self'.packages.iota;
|
||||||
dontUseCmakeConfigure = true;
|
iota = pkgs.rustPlatform.buildRustPackage {
|
||||||
preConfigure = ''
|
pname = "iota";
|
||||||
if [ -d ../cargo-vendor-dir/ttp-core-0.1.0 ]; then
|
version = "0.1.0";
|
||||||
cp ${ttp}/ttp-codec.json ../cargo-vendor-dir/ttp-codec.json
|
src = ./.;
|
||||||
fi
|
cargoLock = {
|
||||||
'';
|
lockFile = ./Cargo.lock;
|
||||||
postInstall = ''
|
allowBuiltinFetchGit = true;
|
||||||
mv $out/bin/iota-core $out/bin/iota
|
};
|
||||||
for f in $out/bin/*; do
|
nativeBuildInputs = with pkgs; [ cmake perl pkg-config ];
|
||||||
if [ "$(basename "$f")" != "iota" ]; then
|
buildInputs = with pkgs; [ openssl sqlite ];
|
||||||
rm "$f"
|
dontUseCmakeConfigure = true;
|
||||||
|
preConfigure = ''
|
||||||
|
if [ -d ../cargo-vendor-dir/ttp-core-0.1.0 ]; then
|
||||||
|
cp ${ttp}/ttp-codec.json ../cargo-vendor-dir/ttp-codec.json
|
||||||
fi
|
fi
|
||||||
done
|
'';
|
||||||
'';
|
postInstall = ''
|
||||||
passthru.dataDir = "/var/lib/iota";
|
mv $out/bin/iota-core $out/bin/iota
|
||||||
|
for f in $out/bin/*; do
|
||||||
|
if [ "$(basename "$f")" != "iota" ]; then
|
||||||
|
rm "$f"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
'';
|
||||||
|
passthru.dataDir = "/var/lib/iota";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
devShells.default = pkgs.mkShell {
|
||||||
|
nativeBuildInputs = with pkgs; [ rustToolchain git cmake perl pkg-config ];
|
||||||
|
buildInputs = with pkgs; [ openssl sqlite ];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
flake = {
|
flake = {
|
||||||
nixosModules.default = { config, pkgs, lib, ... }:
|
nixosModules.default = { config, pkgs, lib, ... }:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue