Compare commits

...

17 Commits

Author SHA1 Message Date
Arnie bd632f21ef Update golangci config 2025-12-15 22:21:58 +01:00
Arnie 0af7547c4b Update flakes 2025-12-07 21:07:28 +01:00
Arnie 2ac8a3a57f Update flakes 2025-11-09 21:12:18 +01:00
Arnie 61a8a5c913 Update flakes 2025-07-10 15:02:38 +02:00
Arnie 75133624e1 Update flakes 2025-05-22 15:09:58 +02:00
Arnie 9cd9e45cfd Update flakes 2025-05-07 09:43:04 +02:00
Arnie 49a4dc9631 Update nix flake inputs 2025-04-17 11:30:53 +02:00
Arnie a7dabc5a1b Update flakes 2025-03-05 09:45:37 +01:00
Arnie 77e8f694ea Update flakes 2025-01-21 09:03:40 +01:00
Arnie 76ab1dd910 Add github push command 2024-11-03 23:18:45 +01:00
Arnie 897d053117 Add mdtohtml to control4 env and rename it for consistency 2024-11-03 22:59:10 +01:00
Arnie bf87bf2064 Update deps for eslint config 2024-10-31 23:27:38 +01:00
Arnie 2303d4888e Add installable package to eslint 2024-10-25 23:43:15 +02:00
Arnie 986890b044 Replace devshell with devenv 2024-10-25 23:26:14 +02:00
Arnie 96407def3f Update config files 2024-10-25 16:57:29 +02:00
Arnie d3596fc7e9 Update flakes 2024-10-15 23:18:43 +02:00
Arnie 1312b29eca Remove exportloopref, no longer needed in go 1.22+ 2024-10-15 23:17:59 +02:00
5 changed files with 488 additions and 82 deletions
+1
View File
@@ -1,4 +1,5 @@
.env .env
.envrc .envrc
.direnv .direnv
.devenv
result result
+98 -53
View File
@@ -1,78 +1,123 @@
linters-settings: version: "2"
run:
timeout: 3m
relative-path-mode: gitroot
linters:
enable:
- bidichk
- bodyclose
- canonicalheader
- copyloopvar
- errcheck
- errorlint
- exhaustive
- forbidigo
- gocheckcompilerdirectives
- gochecksumtype
- goconst
- gocritic
- gosec
- govet
- ineffassign
- makezero
- mirror
- misspell
- nakedret
- nilnil
- noctx
- nolintlint
- nosprintfhostport
- perfsprint
- prealloc
- predeclared
- sloglint
- spancheck
- staticcheck
- unconvert
- unconvert
- unparam
- unused
- whitespace
- usestdlibvars
- wastedassign
- whitespace
- wsl_v5
settings:
errcheck: errcheck:
check-type-assertions: true check-type-assertions: true
gci: forbidigo:
sections: analyze-types: true
- standard
- default
- prefix(go.yrps.dev)
gocritic: gocritic:
disabled-checks:
- hugeParam
- paramTypeCombine
- sloppyReassign
enabled-tags: enabled-tags:
- diagnostic - diagnostic
- experimental - experimental
- opinionated - opinionated
- performance - performance
- style - style
disabled-checks:
- hugeParam
- paramTypeCombine
- sloppyReassign
govet: govet:
enable-all: true enable:
settings: - shadow
shadow:
strict: true
nolintlint: nolintlint:
require-explanation: true require-explanation: true
require-specific: true require-specific: true
sloglint: sloglint:
no-global: "all" attr-only: true
context: "scope" no-global: all
stylecheck: context: scope
static-msg: true
key-naming-case: snake
forbidden-keys:
- time
- level
- msg
- source
staticcheck:
checks: checks:
- all - all
- -ST1000 - -ST1000
wsl: wsl_v5:
allow-cuddle-declarations: true disable:
- decl
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
linters: formatters:
disable-all: true
enable: enable:
- bidichk
- bodyclose
- copyloopvar
- errcheck
- errorlint
- exportloopref
- exhaustive
- gci - gci
- gocheckcompilerdirectives
- goconst
- gocritic
- gofumpt - gofumpt
- gosec settings:
- gosimple gci:
- govet sections:
- ineffassign - standard
- misspell - default
- noctx - prefix(go.yrps.dev)
- nolintlint exclusions:
- prealloc generated: lax
- predeclared paths:
- protogetter - third_party$
- sloglint - builtin$
- staticcheck - examples$
- stylecheck
- unconvert
- unparam
- unused
- whitespace
- usestdlibvars
- wsl
issues: issues:
max-issues-per-linter: 0 max-issues-per-linter: 0
max-same-issues: 0 max-same-issues: 0
exclude-use-default: false
exclude: output:
- Error return value of .*\.Body\.Close. is not checked sort-order:
- file
show-stats: false
+151
View File
@@ -0,0 +1,151 @@
import jseslint from "@eslint/js";
import eslintPluginImportX from "eslint-plugin-import-x";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
import eslintPluginReact from "eslint-plugin-react";
import eslintPluginReactHooks from "eslint-plugin-react-hooks";
import eslintPluginReactRefresh from "eslint-plugin-react-refresh";
import eslintPluginFormatjs from "eslint-plugin-formatjs";
import tseslint from "typescript-eslint";
// This config is provided through nix environment.
// Config is meant to be injected through devshell env variable and "cp" command in .envrc to copy it in the proper path
// Install dependencies: npm i -D @eslint/js@9 eslint-plugin-import-x@4 eslint-import-resolver-typescript@3 eslint-plugin-prettier@5 eslint-config-prettier@9 eslint-plugin-react@7 eslint-plugin-react-hooks@5 eslint-plugin-react-refresh@0.4 eslint-plugin-formatjs@5 typescript-eslint@8
export default tseslint.config(
{
ignores: [
"build/",
"dist/",
"tsconfig.json",
"tsconfig.*.json",
"eslint.config.mjs",
],
},
jseslint.configs.recommended,
...tseslint.configs.recommendedTypeChecked,
eslintPluginImportX.flatConfigs.recommended,
eslintPluginImportX.flatConfigs.typescript,
eslintPluginReact.configs.flat.recommended,
eslintPluginPrettierRecommended,
{
languageOptions: {
parserOptions: {
tsconfigRootDir: import.meta.dirname,
project: "./tsconfig.json",
},
},
settings: {
react: {
version: "detect",
},
"import-x/resolver": {
typescript: true,
node: true,
},
},
plugins: {
"react-hooks": eslintPluginReactHooks,
"react-refresh": eslintPluginReactRefresh,
formatjs: eslintPluginFormatjs,
},
rules: {
curly: ["error"],
"no-console": ["warn"],
"no-constant-condition": [
"error",
{
checkLoops: "allExceptWhileTrue",
},
],
// Typescript
// Some non typescript rules must be disabled as they can report incorrect errors
"default-param-last": "off",
"@typescript-eslint/default-param-last": "error",
"dot-notation": "off",
"@typescript-eslint/dot-notation": [
"error",
{
allowKeywords: true,
},
],
"@typescript-eslint/naming-convention": [
"error",
{
selector: ["function", "import"],
format: ["camelCase", "PascalCase"],
},
{
selector: ["variable"],
format: ["camelCase", "PascalCase", "UPPER_CASE"],
},
{
selector: ["enum", "typeLike"],
format: ["PascalCase"],
},
],
"@typescript-eslint/no-unused-vars": [
"warn",
{
args: "after-used",
caughtErrors: "all",
caughtErrorsIgnorePattern: "^_$",
},
],
"no-use-before-define": "off",
"@typescript-eslint/no-use-before-define": "error",
"@typescript-eslint/no-misused-promises": [
"error",
{
checksVoidReturn: {
attributes: false,
},
},
],
"no-shadow": "off",
"@typescript-eslint/no-shadow": "error",
"no-loop-func": "off",
"@typescript-eslint/no-loop-func": "error",
"no-useless-constructor": "off",
"@typescript-eslint/no-useless-constructor": "error",
"no-return-await": "off",
"@typescript-eslint/return-await": "error",
"@typescript-eslint/prefer-promise-reject-errors": ["off"],
// Import
"import-x/no-extraneous-dependencies": [
"error",
{
devDependencies: true,
},
],
// Some issues with react import, no time to debug
"import-x/default": ["off"],
"prettier/prettier": "warn",
// React
"react-hooks/exhaustive-deps": "error",
"react-refresh/only-export-components": "warn",
"react/jsx-no-duplicate-props": [
"error",
{
ignoreCase: false,
},
],
"react/prop-types": "off",
"react/react-in-jsx-scope": "off",
// FormaJS/INTL
"formatjs/enforce-default-message": "error",
"formatjs/enforce-id": [
"error",
{
idInterpolationPattern: "[sha1:contenthash:base64:6]",
},
],
"formatjs/no-id": "off",
},
}
);
Generated
+175 -12
View File
@@ -1,32 +1,195 @@
{ {
"nodes": { "nodes": {
"devshell": { "cachix": {
"inputs": { "inputs": {
"devenv": [
"devenv"
],
"flake-compat": [
"devenv",
"flake-compat"
],
"git-hooks": [
"devenv",
"git-hooks"
],
"nixpkgs": [
"devenv",
"nixpkgs"
]
},
"locked": {
"lastModified": 1760971495,
"narHash": "sha256-IwnNtbNVrlZIHh7h4Wz6VP0Furxg9Hh0ycighvL5cZc=",
"owner": "cachix",
"repo": "cachix",
"rev": "c5bfd933d1033672f51a863c47303fc0e093c2d2",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "latest",
"repo": "cachix",
"type": "github"
}
},
"devenv": {
"inputs": {
"cachix": "cachix",
"flake-compat": "flake-compat",
"flake-parts": "flake-parts",
"git-hooks": "git-hooks",
"nix": "nix",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs"
] ]
}, },
"locked": { "locked": {
"lastModified": 1722113426, "lastModified": 1764927628,
"narHash": "sha256-Yo/3loq572A8Su6aY5GP56knpuKYRvM2a1meP9oJZCw=", "narHash": "sha256-AH2H5O9i7k3oarg3MooAnQtZxo44qxrUTUuvGOy/OEc=",
"owner": "numtide", "owner": "cachix",
"repo": "devshell", "repo": "devenv",
"rev": "67cce7359e4cd3c45296fb4aaf6a19e2a9c757ae", "rev": "247d7027f91368054fb0eefbd755a73d42b66fee",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "numtide", "owner": "cachix",
"repo": "devshell", "repo": "devenv",
"type": "github"
}
},
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1761588595,
"narHash": "sha256-XKUZz9zewJNUj46b4AJdiRZJAvSZ0Dqj2BNfXvFlJC4=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "f387cd2afec9419c8ee37694406ca490c3f34ee5",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-parts": {
"inputs": {
"nixpkgs-lib": [
"devenv",
"nixpkgs"
]
},
"locked": {
"lastModified": 1760948891,
"narHash": "sha256-TmWcdiUUaWk8J4lpjzu4gCGxWY6/Ok7mOK4fIFfBuU4=",
"owner": "hercules-ci",
"repo": "flake-parts",
"rev": "864599284fc7c0ba6357ed89ed5e2cd5040f0c04",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "flake-parts",
"type": "github"
}
},
"git-hooks": {
"inputs": {
"flake-compat": [
"devenv",
"flake-compat"
],
"gitignore": "gitignore",
"nixpkgs": [
"devenv",
"nixpkgs"
]
},
"locked": {
"lastModified": 1760663237,
"narHash": "sha256-BflA6U4AM1bzuRMR8QqzPXqh8sWVCNDzOdsxXEguJIc=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "ca5b894d3e3e151ffc1db040b6ce4dcc75d31c37",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github"
}
},
"gitignore": {
"inputs": {
"nixpkgs": [
"devenv",
"git-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1709087332,
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"nix": {
"inputs": {
"flake-compat": [
"devenv",
"flake-compat"
],
"flake-parts": [
"devenv",
"flake-parts"
],
"git-hooks-nix": [
"devenv",
"git-hooks"
],
"nixpkgs": [
"devenv",
"nixpkgs"
],
"nixpkgs-23-11": [
"devenv"
],
"nixpkgs-regression": [
"devenv"
]
},
"locked": {
"lastModified": 1761648602,
"narHash": "sha256-H97KSB/luq/aGobKRuHahOvT1r7C03BgB6D5HBZsbN8=",
"owner": "cachix",
"repo": "nix",
"rev": "3e5644da6830ef65f0a2f7ec22830c46285bfff6",
"type": "github"
},
"original": {
"owner": "cachix",
"ref": "devenv-2.30.6",
"repo": "nix",
"type": "github" "type": "github"
} }
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1727872001, "lastModified": 1764947035,
"narHash": "sha256-nZNSePIWw526864XBqsrWU1dbo4Ei8iJXpNHCubui28=", "narHash": "sha256-EYHSjVM4Ox4lvCXUMiKKs2vETUSL5mx+J2FfutM7T9w=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "e46dc3b8343f627532ba881965b053d3bbec4235", "rev": "a672be65651c80d3f592a89b3945466584a22069",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -38,7 +201,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"devshell": "devshell", "devenv": "devenv",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }
} }
+68 -22
View File
@@ -3,8 +3,8 @@
inputs = { inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
devshell = { devenv = {
url = "github:numtide/devshell"; url = "github:cachix/devenv";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
}; };
@@ -13,8 +13,9 @@
{ {
self, self,
nixpkgs, nixpkgs,
devshell, devenv,
}: ...
}@inputs:
let let
systems = nixpkgs.lib.genAttrs [ systems = nixpkgs.lib.genAttrs [
"x86_64-linux" "x86_64-linux"
@@ -32,7 +33,9 @@
function ( function (
import nixpkgs { import nixpkgs {
inherit system; inherit system;
overlays = [ devshell.overlays.default ]; overlays = [
devenv.overlays.default
];
config.allowUnfreePredicate = (pkg: builtins.elem (nixpkgs.lib.getName pkg) [ "terraform" ]); config.allowUnfreePredicate = (pkg: builtins.elem (nixpkgs.lib.getName pkg) [ "terraform" ]);
} }
) )
@@ -40,37 +43,80 @@
golangci-config-file = ./.golangci.yml; golangci-config-file = ./.golangci.yml;
cd_root = "cd $PRJ_ROOT;"; eslint-config-file = ./eslint.config.mjs;
control4_env = self.lib.forAllSystems ( cd_root = "cd $DEVENV_ROOT;";
mdtohtml-src = self.lib.forAllSystems (
pkgs: pkgs.fetchFromGitHub {
owner = "gomarkdown";
repo = "mdtohtml";
rev = "d773061d1585e9a85aded292f65459b2cb8b2131";
sha256 = "sha256-GzYiiLL0yjGK70haRjoXT1QmvAjl+N/Z8H0EBhVOhRY=";
}
);
control4-env = self.lib.forAllSystems (
pkgs: pkgs:
pkgs.buildEnv { pkgs.buildEnv {
name = "control4_env"; name = "control4_env";
paths = [ paths = with pkgs; [
pkgs.lua5_1 lua5_1
pkgs.lua51Packages.busted lua51Packages.busted
pkgs.stylua stylua
pkgs.nodejs_22 nodejs_22
(pkgs.buildGoModule {
name = "mdtohtml";
CGO_ENABLED = 0;
src = self.lib.mdtohtml-src.${pkgs.system};
subPackages = [ "." ];
ldflags = [ "-s" "-w" ];
vendorHash = "sha256-HzHwB0XoVjmqucqyDn44NlIG2ASPzZOKv0POiOyBxrY=";
})
]; ];
} }
); );
mkDevenvShell = devenv.lib.mkShell;
}; };
formatter = self.lib.forAllSystems (pkgs: pkgs.nixfmt-rfc-style); formatter = self.lib.forAllSystems (pkgs: pkgs.nixfmt-rfc-style);
packages = self.lib.forAllSystems (pkgs: {
devenv-up = self.devShells.${pkgs.system}.default.config.procfileScript;
devenv-test = self.devShells.${pkgs.system}.default.config.test;
});
devShells = self.lib.forAllSystems (pkgs: { devShells = self.lib.forAllSystems (pkgs: {
default = pkgs.devshell.mkShell { default = self.lib.mkDevenvShell {
name = "c3c-nix"; inherit inputs pkgs;
modules = [
packages = [ pkgs.nix-tree ];
commands = [
{ {
name = "fix"; scripts = {
command = '' menu = {
${self.lib.cd_root} description = "Print this menu";
nix fmt . exec = ''
echo "Commands:"
echo -n '${builtins.toJSON (builtins.mapAttrs (s: value: value.description) self.devShells.${pkgs.system}.default.config.scripts)}' | \
${pkgs.jq}/bin/jq -r 'to_entries | map(" \(.key)\n" + " - \(if .value == "" then "no description provided" else .value end)") | "" + .[]'
''; '';
};
fix = {
exec = ''
${self.lib.cd_root}
nix fmt ./*.nix
'';
};
github-push = {
description = "Push current branch to github, lazy workaround for automated mirror. TODO: Automate";
exec = ''
b=$(git rev-parse --abbrev-ref HEAD)
git push git@github.com:Sharsie/nix.git "$b":"$b"
'';
};
};
} }
]; ];
}; };