commit 5c7df8f10093aefa5443fbc2be2babe8764b7b5d Author: Arnie Date: Sat Sep 28 21:54:29 2024 +0200 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1ca8d68 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.env +.envrc +.direnv +result diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..8968a34 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,78 @@ +linters-settings: + errcheck: + check-type-assertions: true + gci: + sections: + - standard + - default + - prefix(go.yrps.dev) + gocritic: + enabled-tags: + - diagnostic + - experimental + - opinionated + - performance + - style + disabled-checks: + - hugeParam + - paramTypeCombine + - sloppyReassign + govet: + enable-all: true + settings: + shadow: + strict: true + nolintlint: + require-explanation: true + require-specific: true + sloglint: + no-global: "all" + context: "scope" + stylecheck: + checks: + - all + - -ST1000 + wsl: + allow-cuddle-declarations: true + +linters: + disable-all: true + enable: + - bidichk + - bodyclose + - copyloopvar + - errcheck + - errorlint + - exportloopref + - exhaustive + - gci + - gocheckcompilerdirectives + - goconst + - gocritic + - gofumpt + - gosec + - gosimple + - govet + - ineffassign + - misspell + - noctx + - nolintlint + - prealloc + - predeclared + - protogetter + - sloglint + - staticcheck + - stylecheck + - unconvert + - unparam + - unused + - whitespace + - usestdlibvars + - wsl + +issues: + max-issues-per-linter: 0 + max-same-issues: 0 + exclude-use-default: false + exclude: + - Error return value of .*\.Body\.Close. is not checked diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..87a8412 --- /dev/null +++ b/default.nix @@ -0,0 +1,12 @@ +{ system ? builtins.currentSystem }: +let + flake-compat = builtins.fetchTarball { + url = "https://github.com/edolstra/flake-compat/archive/0f9255e01c2351cc7d116c072cb317785dd33b33.tar.gz"; + sha256 = "sha256:0m9grvfsbwmvgwaxvdzv6cmyvjnlww004gfxjvcl806ndqaxzy4j"; + }; + flake = import flake-compat { src = ./.; }; +in +{ + image = flake.defaultNix.packages.${system}.image; + shell = flake.shellNix.default; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..48ea267 --- /dev/null +++ b/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "devshell": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1722113426, + "narHash": "sha256-Yo/3loq572A8Su6aY5GP56knpuKYRvM2a1meP9oJZCw=", + "owner": "numtide", + "repo": "devshell", + "rev": "67cce7359e4cd3c45296fb4aaf6a19e2a9c757ae", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "devshell", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1727348695, + "narHash": "sha256-J+PeFKSDV+pHL7ukkfpVzCOO7mBSrrpJ3svwBFABbhI=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "1925c603f17fc89f4c8f6bf6f631a802ad85d784", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "devshell": "devshell", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..bad0cc1 --- /dev/null +++ b/flake.nix @@ -0,0 +1,58 @@ +{ + description = "Arnie's nix flake"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + devshell = { + url = "github:numtide/devshell"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { self, nixpkgs, devshell }: + let + systems = nixpkgs.lib.genAttrs [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; + in + { + lib = { + forAllSystems = function: systems (system: + function (import nixpkgs { + inherit system; + overlays = [ + devshell.overlays.default + ]; + config.allowUnfreePredicate = (pkg: builtins.elem (nixpkgs.lib.getName pkg) [ "terraform" ]); + }) + ); + + golangci-config-file = ./.golangci.yml; + + cd_root = "cd $PRJ_ROOT;"; + }; + + formatter = self.lib.forAllSystems (pkgs: pkgs.nixpkgs-fmt); + + control4_env = self.lib.forAllSystems (pkgs: {pkgs.lua5_1 pkgs.lua51Packages.busted}); + + devShells = self.lib.forAllSystems (pkgs: { + default = pkgs.devshell.mkShell { + name = "nix"; + + packages = [ + pkgs.nix-tree + pkgs.golangci-lint + ]; + + commands = [ + { + name = "fix"; + command = '' + ${self.lib.cd_root} + nix fmt . + ''; + } + ]; + }; + }); + }; +}