Skip to content

Commit

Permalink
Add nix flake
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephGoulden committed Sep 15, 2024
1 parent 4e47db2 commit 4971b1c
Show file tree
Hide file tree
Showing 6 changed files with 244 additions and 5 deletions.
15 changes: 14 additions & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,17 @@ jobs:
uses: psf/black@stable
with:
src: "./watchtower-plugin/tests"
options: "--check -l 120"
options: "--check -l 120"

check-flake:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check Nix flake inputs
uses: DeterminateSystems/flake-checker-action@v8
- name: Install Nix
uses: cachix/install-nix-action@V27
- name: Check flake
run: nix flake check

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
target
__pycache__
.vscode
.idea
.idea
result
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ members = [
"teos",
"teos-common",
"watchtower-plugin"
]
]
116 changes: 116 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

109 changes: 109 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
description = "Build teos (The Eye of Satoshi) server and plugin";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";

crane.url = "github:ipetkov/crane";

fenix = {
url = "github:nix-community/fenix";
inputs.nixpkgs.follows = "nixpkgs";
};

flake-utils.url = "github:numtide/flake-utils";
};

outputs =
{
nixpkgs,
crane,
fenix,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};

inherit (pkgs) lib;

craneLib = (crane.mkLib pkgs).overrideToolchain fenix.packages.${system}.stable.minimalToolchain;

commonArgs = {
strictDeps = true;

nativeBuildInputs = [
pkgs.pkg-config
pkgs.openssl
pkgs.rustfmt # needed for tonic build
];

buildInputs =
[ ]
++ lib.optionals pkgs.stdenv.isDarwin [
# Additional darwin specific inputs can be set here
pkgs.libiconv
];

PROTOC = "${pkgs.protobuf}/bin/protoc";
PKG_CONFIG_PATH = "${pkgs.openssl.dev}/lib/pkgconfig";
};

fileSetForCrate =
crate:
lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./Cargo.toml
./Cargo.lock
./teos-common
./teos
./watchtower-plugin
crate
];
};

plugin = craneLib.buildPackage (
commonArgs
// {
pname = "watchtower-plugin";
cargoExtraArgs = "-p watchtower-plugin";
src = fileSetForCrate ./watchtower-plugin;
inherit (craneLib.crateNameFromCargoToml { cargoToml = ./watchtower-plugin/Cargo.toml; }) version;
}
);
teos = craneLib.buildPackage (
commonArgs
// {
pname = "teos";
cargoExtraArgs = "-p teos";
src = fileSetForCrate ./teos;
inherit (craneLib.crateNameFromCargoToml { cargoToml = ./teos/Cargo.toml; }) version;
}
);
in
{
packages = {
inherit plugin teos;
default = teos;
};

apps = {
plugin = flake-utils.lib.mkApp { drv = plugin; };
teos = flake-utils.lib.mkApp { drv = teos; };
};

formatter = pkgs.nixfmt-rfc-style;

checks = {
inherit teos plugin;
};

devShells.default = craneLib.devShell {
packages = commonArgs.buildInputs ++ commonArgs.nativeBuildInputs;
};
}
);
}
4 changes: 2 additions & 2 deletions teos-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ prost = "0.12"
rusqlite = { version = "0.26.0", features = [ "bundled", "limits" ] }
serde = "1.0.130"
serde_json = "1.0"
tonic = "0.11"
tonic = { version = "0.11", features = [ "tls", "transport" ] }

# Crypto
rand = "0.8.4"
Expand All @@ -24,4 +24,4 @@ bitcoin = { version = "0.28.0", features = [ "use-serde" ] }
lightning = "0.0.108"

[build-dependencies]
tonic-build = "0.11"
tonic-build = "0.11"

0 comments on commit 4971b1c

Please sign in to comment.