From d7da3341655e762b4833697c8e465c2fbb3f2643 Mon Sep 17 00:00:00 2001 From: ryane Date: Thu, 8 Jun 2023 21:44:56 -0400 Subject: [PATCH] add nix flake --- .gitignore | 2 ++ Makefile | 6 ++++++ README.md | 6 ++++++ flake.lock | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 37 +++++++++++++++++++++++++++++++++ 5 files changed, 112 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index 182ae21..1990d59 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ kfilt dist coverage.txt +/result +/.envrc diff --git a/Makefile b/Makefile index 9b38077..2d8d7a5 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/README.md b/README.md index 0abad61..b6e5bac 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..64242a0 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1686020360, + "narHash": "sha256-Wee7lIlZ6DIZHHLiNxU5KdYZQl0iprENXa/czzI6Cj4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4729ffac6fd12e26e5a8de002781ffc49b0e94b7", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..35ce217 --- /dev/null +++ b/flake.nix @@ -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); +}