Skip to content

Commit 1c139f3

Browse files
authored
chore: Add flake.nix (#2261)
1 parent 97001f3 commit 1c139f3

File tree

6 files changed

+264
-9
lines changed

6 files changed

+264
-9
lines changed

.github/workflows/CI.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ jobs:
9393
CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS: fallback
9494
- name: Get MSRV from manifest file
9595
id: msrv
96-
run: echo "version=$(yq '.workspace.package.rust-version' Cargo.toml)" >> $GITHUB_OUTPUT
96+
run: echo "version=$(yq '.workspace.package.rust-version' Cargo.toml)" >> "$GITHUB_OUTPUT"
9797
- uses: hecrj/setup-rust-action@v2
9898
with:
9999
rust-version: ${{ steps.msrv.outputs.version }}

flake.lock

Lines changed: 181 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
description = "Description for the project";
3+
4+
inputs = {
5+
flake-parts.url = "github:hercules-ci/flake-parts";
6+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
7+
fenix = {
8+
url = "github:nix-community/fenix";
9+
inputs.nixpkgs.follows = "nixpkgs";
10+
};
11+
12+
git-hooks = {
13+
url = "github:cachix/git-hooks.nix";
14+
inputs = { nixpkgs.follows = "nixpkgs"; };
15+
};
16+
17+
treefmt-nix = {
18+
url = "github:numtide/treefmt-nix";
19+
inputs.nixpkgs.follows = "nixpkgs";
20+
};
21+
};
22+
23+
outputs = inputs@{ self, flake-parts, ... }:
24+
flake-parts.lib.mkFlake { inherit inputs; } {
25+
imports = [ inputs.git-hooks.flakeModule inputs.treefmt-nix.flakeModule ];
26+
systems =
27+
[ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
28+
perSystem = { config, pkgs, system, ... }:
29+
let rustToolchain = pkgs.fenix.stable;
30+
in {
31+
_module.args.pkgs = import inputs.nixpkgs {
32+
inherit system;
33+
overlays = [ inputs.fenix.overlays.default ];
34+
config = { };
35+
};
36+
37+
formatter = config.treefmt.build.wrapper;
38+
checks.formatting = config.treefmt.build.check self;
39+
40+
pre-commit = {
41+
check.enable = true;
42+
settings.hooks = {
43+
actionlint.enable = true;
44+
shellcheck.enable = true;
45+
treefmt.enable = true;
46+
};
47+
};
48+
49+
treefmt = {
50+
settings = { rustfmt.enable = true; };
51+
projectRootFile = ".git/config";
52+
flakeCheck = false; # Covered by git-hooks check
53+
};
54+
55+
devShells.default = pkgs.mkShell {
56+
packages = with pkgs; [
57+
nixd
58+
nixfmt
59+
60+
(rustToolchain.withComponents [
61+
"cargo"
62+
"clippy"
63+
"rust-src"
64+
"rustc"
65+
"rustfmt"
66+
"rust-analyzer"
67+
])
68+
protobuf
69+
];
70+
};
71+
};
72+
};
73+
}

interop/test.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ TLS_CRT="interop/data/server1.pem"
4747
TLS_KEY="interop/data/server1.key"
4848

4949
# run the test server
50-
./"${SERVER}" ${ARG} --tls_cert_file $TLS_CRT --tls_key_file $TLS_KEY &
50+
./"${SERVER}" "${ARG}" --tls_cert_file $TLS_CRT --tls_key_file $TLS_KEY &
5151
SERVER_PID=$!
5252
echo ":; started grpc-go test server."
5353

@@ -57,12 +57,12 @@ trap 'echo ":; killing test server"; kill ${SERVER_PID};' EXIT
5757

5858
sleep 1
5959

60-
./target/debug/client --test_case="${JOINED_TEST_CASES}" ${ARG}
60+
./target/debug/client --test_case="${JOINED_TEST_CASES}" "${ARG}"
6161

62-
echo ":; killing test server"; kill ${SERVER_PID};
62+
echo ":; killing test server"; kill "${SERVER_PID}";
6363

6464
# run the test server
65-
./target/debug/server ${ARG} &
65+
./target/debug/server "${ARG}" &
6666
SERVER_PID=$!
6767
echo ":; started tonic test server."
6868

@@ -72,7 +72,7 @@ trap 'echo ":; killing test server"; kill ${SERVER_PID};' EXIT
7272

7373
sleep 1
7474

75-
./target/debug/client --test_case="${JOINED_TEST_CASES}" ${ARG}
75+
./target/debug/client --test_case="${JOINED_TEST_CASES}" "${ARG}"
7676

7777
TLS_ARGS=""
7878

@@ -81,5 +81,5 @@ if [ -n "${ARG}" ]; then
8181
fi
8282

8383
for CASE in "${TEST_CASES[@]}"; do
84-
interop/bin/client_${OS}_amd64${EXT} --test_case="${CASE}" ${TLS_ARGS}
84+
interop/bin/client_${OS}_amd64${EXT} --test_case="${CASE}" "${TLS_ARGS}"
8585
done

interop/update_binaries.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/bin/bash
12
set -e
23

34
# This script updates server and client go binaries for interop tests.
@@ -30,4 +31,4 @@ for ROLE in $ROLES; do
3031
done
3132
done
3233

33-
rm -rf ../grpc-go
34+
rm -rf ../grpc-go

prepare-release.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ fi
1414

1515
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
1616
VERSION="$1"
17-
MINOR="$( echo ${VERSION} | cut -d\. -f1-2 )"
17+
MINOR="$( echo "${VERSION}" | cut -d\. -f1-2 )"
1818

1919
VERSION_MATCHER="([a-z0-9\\.-]+)"
2020
TONIC_CRATE_MATCHER="(tonic|tonic-[a-z]+)"

0 commit comments

Comments
 (0)