Skip to content

Commit d34cf4f

Browse files
committed
Add nix flake build
1 parent 3365def commit d34cf4f

File tree

4 files changed

+93
-73
lines changed

4 files changed

+93
-73
lines changed

.github/workflows/main.yml

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,34 @@ permissions:
99
contents: write
1010

1111
jobs:
12+
test_nix:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v3
16+
- uses: cachix/install-nix-action@v20
17+
with:
18+
nix_path: nixpkgs=channel:nixos-unstable
19+
- run: nix flake show
20+
- run: nix build ".#packages.x86_64-linux.auth_proxy"
21+
- run: nix build ".#packages.x86_64-linux.vault_plugin"
22+
1223
pre_job:
13-
runs-on: ubuntu-latest
14-
outputs:
15-
should_skip: ${{ steps.skip_check.outputs.should_skip }}
16-
paths_result: ${{ steps.skip_check.outputs.paths_result }}
17-
steps:
18-
- id: skip_check
19-
uses: fkirc/skip-duplicate-actions@v5
20-
with:
21-
paths_filter: |
22-
app:
23-
paths:
24-
- 'app/**'
24+
needs: test_nix
25+
runs-on: ubuntu-latest
26+
outputs:
27+
should_skip: ${{ steps.skip_check.outputs.should_skip }}
28+
paths_result: ${{ steps.skip_check.outputs.paths_result }}
29+
steps:
30+
- id: skip_check
31+
uses: fkirc/skip-duplicate-actions@v5
32+
with:
33+
paths_filter: |
34+
app:
35+
paths:
36+
- 'app/**'
2537
2638
build:
27-
needs: pre_job
39+
needs: [pre_job, test_nix]
2840
name: Build and Release
2941
environment: Deploy
3042
runs-on: ubuntu-latest
@@ -40,7 +52,7 @@ jobs:
4052

4153
- uses: actions/setup-go@v3
4254
with:
43-
go-version: '^1.18.0'
55+
go-version: "^1.18.0"
4456

4557
- uses: actions/checkout@v3
4658
with:

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
result

flake.lock

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

flake.nix

Lines changed: 61 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,72 @@
11
{
22
inputs = {
3-
nixpkgs-master.url = "github:nixos/nixpkgs/master";
4-
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
3+
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
54
flake-utils.url = "github:numtide/flake-utils";
65
};
76

8-
outputs = { self, flake-utils, nixpkgs-unstable, nixpkgs-master, ... }@inputs:
9-
flake-utils.lib.eachDefaultSystem (system:
10-
let
11-
pkgs-master = nixpkgs-master.legacyPackages.${system}.appendOverlays [
7+
outputs = { self, flake-utils, nixpkgs, ... }@inputs:
8+
let
9+
outputs = flake-utils.lib.eachDefaultSystem (system:
10+
let
11+
pkgs = import nixpkgs ({
12+
inherit system;
1213

13-
];
14+
overlays = [
15+
];
1416

15-
pkgs = import nixpkgs-unstable ({
16-
inherit system;
17+
config.allowUnfree = true;
18+
});
19+
in
20+
{
21+
packages = {
22+
auth_proxy = pkgs.buildGoModule rec {
23+
name = "auth_proxy";
1724

18-
overlays = [
19-
];
25+
src = ./auth_proxy;
2026

21-
config.allowUnfree = true;
22-
});
27+
vendorHash = "sha256-skp304q/dO1cBH6LIlrSg1rAoALtOK1wtweC0LJRPyI=";
28+
};
29+
vault_plugin = pkgs.buildGoModule rec {
30+
name = "vault_plugin";
2331

24-
in
25-
{
26-
devShell = pkgs.pkgs.mkShell {
27-
28-
buildInputs = with pkgs;
29-
[
30-
protobuf
31-
stdenv
32-
go_1_18
33-
buf
34-
cmake
35-
vault-bin
36-
protoc-gen-go
37-
pkgs-master.protoc-gen-connect-go
38-
];
39-
shellHook = ''
40-
export CFLAGS="-I${pkgs.glibc.dev}/include"
41-
export LDFLAGS="-L${pkgs.glibc}/lib"
42-
[ -n "$(go env GOBIN)" ] && export PATH="$(go env GOBIN):''${PATH}"
43-
[ -n "$(go env GOPATH)" ] && export PATH="$(go env GOPATH)/bin:''${PATH}"
44-
'';
45-
};
46-
47-
});
32+
src = ./vault_plugin;
33+
34+
vendorHash = "sha256-/6aE5w6Rki1ZIXMX9Ryo4XrGzS/01xZQiWDUROriixs=";
35+
};
36+
};
37+
38+
overlays.default = final: prev: {
39+
zigpkgs = outputs.packages.${prev.system};
40+
};
41+
42+
devShell = pkgs.pkgs.mkShell {
43+
44+
buildInputs = with pkgs;
45+
[
46+
protobuf
47+
stdenv
48+
go_1_18
49+
buf
50+
cmake
51+
vault-bin
52+
protoc-gen-go
53+
pkgs.protoc-gen-connect-go
54+
];
55+
shellHook = ''
56+
export CFLAGS="-I${pkgs.glibc.dev}/include"
57+
export LDFLAGS="-L${pkgs.glibc}/lib"
58+
[ -n "$(go env GOBIN)" ] && export PATH="$(go env GOBIN):''${PATH}"
59+
[ -n "$(go env GOPATH)" ] && export PATH="$(go env GOPATH)/bin:''${PATH}"
60+
'';
61+
};
62+
63+
});
64+
in
65+
outputs
66+
// {
67+
overlays.default = final: prev: {
68+
auth_proxy = outputs.packages.${prev.system}.auth_proxy;
69+
vault_plugin = outputs.packages.${prev.system}.vault_plugin;
70+
};
71+
};
4872
}

0 commit comments

Comments
 (0)