Skip to content

Commit

Permalink
add nix flake
Browse files Browse the repository at this point in the history
  • Loading branch information
ryane committed Jun 9, 2023
1 parent bf68b15 commit d7da334
Show file tree
Hide file tree
Showing 5 changed files with 112 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
kfilt
dist
coverage.txt
/result
/.envrc
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ docker:

push: build
docker push ryane/kfilt:${GIT_SHA}${GIT_DIRTY}

.PHONY: lint
lint:
golangci-lint run

precommit: build lint test
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ Repository (AUR)](https://aur.archlinux.org/).
[asdf](https://github.com/asdf-vm/asdf)
[plugin](https://github.com/feniix/asdf-kfilt/).

### nix flake

```shell
nix run github:ryane/kfilt#kfilt -- -f ./pkg/decoder/test.yaml -k serviceaccount
```

### Running as a Kustomize Plugin (experimental)

See [plugin/kustomize](./plugin/kustomize) for an experimental Kustomize plugin.
Expand Down
61 changes: 61 additions & 0 deletions flake.lock

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

37 changes: 37 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
description = "kfilt";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils, ... }:
let
kfilt = pkgs:
pkgs.buildGo120Module rec {
name = "kfilt";
version = self.shortRev or "dirty";
src = ./.;
# this needs to be changed any time there is a change in go.mod
# dependencies
vendorSha256 = "sha256-c77CzpE9cPyobt87uO0QlkKD+xC/tM7wOy4orM62tnI=";
nativeBuildInputs = [ ];
CGO_ENABLED = 0;
doCheck = false;
ldflags = [
"-s -w -X github.com/ryane/kfilt/cmd.Version=${version} -X github.com/ryane/kfilt/cmd.GitCommit=${version}"
];
excludedPackages = [ "plugin/kustomize" ];
};
flakeForSystem = nixpkgs: system:
let
pkgs = nixpkgs.legacyPackages.${system};
kf = kfilt pkgs;
in {
packages = { kfilt = kf; };
devShell = pkgs.mkShell { packages = with pkgs; [ curl ]; };
};
in flake-utils.lib.eachDefaultSystem
(system: flakeForSystem nixpkgs system);
}

0 comments on commit d7da334

Please sign in to comment.