Skip to content

Commit

Permalink
Add nix flake build
Browse files Browse the repository at this point in the history
  • Loading branch information
kilimnik committed Mar 4, 2023
1 parent 3365def commit d34cf4f
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 73 deletions.
40 changes: 26 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,34 @@ permissions:
contents: write

jobs:
test_nix:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: cachix/install-nix-action@v20
with:
nix_path: nixpkgs=channel:nixos-unstable
- run: nix flake show
- run: nix build ".#packages.x86_64-linux.auth_proxy"
- run: nix build ".#packages.x86_64-linux.vault_plugin"

pre_job:
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
paths_result: ${{ steps.skip_check.outputs.paths_result }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
paths_filter: |
app:
paths:
- 'app/**'
needs: test_nix
runs-on: ubuntu-latest
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
paths_result: ${{ steps.skip_check.outputs.paths_result }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@v5
with:
paths_filter: |
app:
paths:
- 'app/**'
build:
needs: pre_job
needs: [pre_job, test_nix]
name: Build and Release
environment: Deploy
runs-on: ubuntu-latest
Expand All @@ -40,7 +52,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: '^1.18.0'
go-version: "^1.18.0"

- uses: actions/checkout@v3
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
result
27 changes: 5 additions & 22 deletions flake.lock

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

98 changes: 61 additions & 37 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,48 +1,72 @@
{
inputs = {
nixpkgs-master.url = "github:nixos/nixpkgs/master";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, flake-utils, nixpkgs-unstable, nixpkgs-master, ... }@inputs:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs-master = nixpkgs-master.legacyPackages.${system}.appendOverlays [
outputs = { self, flake-utils, nixpkgs, ... }@inputs:
let
outputs = flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs ({
inherit system;

];
overlays = [
];

pkgs = import nixpkgs-unstable ({
inherit system;
config.allowUnfree = true;
});
in
{
packages = {
auth_proxy = pkgs.buildGoModule rec {
name = "auth_proxy";

overlays = [
];
src = ./auth_proxy;

config.allowUnfree = true;
});
vendorHash = "sha256-skp304q/dO1cBH6LIlrSg1rAoALtOK1wtweC0LJRPyI=";
};
vault_plugin = pkgs.buildGoModule rec {
name = "vault_plugin";

in
{
devShell = pkgs.pkgs.mkShell {

buildInputs = with pkgs;
[
protobuf
stdenv
go_1_18
buf
cmake
vault-bin
protoc-gen-go
pkgs-master.protoc-gen-connect-go
];
shellHook = ''
export CFLAGS="-I${pkgs.glibc.dev}/include"
export LDFLAGS="-L${pkgs.glibc}/lib"
[ -n "$(go env GOBIN)" ] && export PATH="$(go env GOBIN):''${PATH}"
[ -n "$(go env GOPATH)" ] && export PATH="$(go env GOPATH)/bin:''${PATH}"
'';
};

});
src = ./vault_plugin;

vendorHash = "sha256-/6aE5w6Rki1ZIXMX9Ryo4XrGzS/01xZQiWDUROriixs=";
};
};

overlays.default = final: prev: {
zigpkgs = outputs.packages.${prev.system};
};

devShell = pkgs.pkgs.mkShell {

buildInputs = with pkgs;
[
protobuf
stdenv
go_1_18
buf
cmake
vault-bin
protoc-gen-go
pkgs.protoc-gen-connect-go
];
shellHook = ''
export CFLAGS="-I${pkgs.glibc.dev}/include"
export LDFLAGS="-L${pkgs.glibc}/lib"
[ -n "$(go env GOBIN)" ] && export PATH="$(go env GOBIN):''${PATH}"
[ -n "$(go env GOPATH)" ] && export PATH="$(go env GOPATH)/bin:''${PATH}"
'';
};

});
in
outputs
// {
overlays.default = final: prev: {
auth_proxy = outputs.packages.${prev.system}.auth_proxy;
vault_plugin = outputs.packages.${prev.system}.vault_plugin;
};
};
}

0 comments on commit d34cf4f

Please sign in to comment.