mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 16:10:05 +01:00
add treefmt
This commit is contained in:
parent
91d1041e06
commit
f5d82afca7
11 changed files with 147 additions and 103 deletions
|
|
@ -1,6 +0,0 @@
|
|||
{
|
||||
flake-compat = import (builtins.fetchurl {
|
||||
url = "https://raw.githubusercontent.com/edolstra/flake-compat/99f1c2157fba4bfe6211a321fd0ee43199025dbf/default.nix";
|
||||
sha256 = "1vas5z58901gavy5d53n1ima482yvly405jp9l8g07nr4abmzsyb";
|
||||
});
|
||||
}
|
||||
14
default.nix
14
default.nix
|
|
@ -1,8 +1,14 @@
|
|||
{system ? builtins.currentSystem}:
|
||||
(
|
||||
(import ./compat.nix).flake-compat {
|
||||
src = ./.;
|
||||
inherit system;
|
||||
import (
|
||||
let
|
||||
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||
in
|
||||
fetchTarball {
|
||||
url = "https://github.com/edolstra/flake-compat/archive/${
|
||||
lock.nodes.flake-compat.locked.rev
|
||||
}.tar.gz";
|
||||
sha256 = lock.nodes.flake-compat.locked.narHash;
|
||||
}
|
||||
) {src = ./.;}
|
||||
)
|
||||
.defaultNix
|
||||
|
|
|
|||
|
|
@ -4,4 +4,19 @@
|
|||
}:
|
||||
pkgs.devshell.mkShell {
|
||||
imports = [(pkgs.devshell.importTOML ./devshell.toml)];
|
||||
|
||||
packages = [
|
||||
pkgs.shfmt
|
||||
pkgs.nodePackages.prettier
|
||||
pkgs.nodePackages.prettier-plugin-toml
|
||||
pkgs.alejandra
|
||||
];
|
||||
commands = [
|
||||
{
|
||||
package = pkgs.treefmt;
|
||||
}
|
||||
];
|
||||
devshell.startup.nodejs-setuphook = pkgs.lib.stringsWithDeps.noDepEntry ''
|
||||
export NODE_PATH=${pkgs.nodePackages.prettier-plugin-toml}/lib/node_modules:$NODE_PATH
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,20 +8,7 @@ eval = "$DEVSHELL_ROOT/kubeconfig.json"
|
|||
|
||||
[devshell]
|
||||
name = "kubenix"
|
||||
packages = [
|
||||
"fd",
|
||||
"dive",
|
||||
"alejandra",
|
||||
"kube3d",
|
||||
"kubie",
|
||||
"k9s",
|
||||
]
|
||||
|
||||
[[commands]]
|
||||
name = "fmt"
|
||||
help = "Check Nix formatting"
|
||||
category = "checks"
|
||||
command = "alejandra ${@} ."
|
||||
packages = ["fd", "dive", "kube3d", "kubie", "k9s"]
|
||||
|
||||
[[commands]]
|
||||
name = "evalnix"
|
||||
|
|
@ -41,4 +28,3 @@ category = "k8s"
|
|||
[[commands]]
|
||||
package = "k9s"
|
||||
category = "k8s"
|
||||
|
||||
|
|
|
|||
39
flake.lock
generated
39
flake.lock
generated
|
|
@ -3,7 +3,9 @@
|
|||
"devshell": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1647857022,
|
||||
|
|
@ -19,6 +21,22 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1648199409,
|
||||
"narHash": "sha256-JwPKdC2PoVBkG6E+eWw3j6BMR6sL3COpYWfif7RVb8Y=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "64a525ee38886ab9028e6f61790de0832aa3ef03",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1642700792,
|
||||
|
|
@ -50,22 +68,6 @@
|
|||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1643381941,
|
||||
"narHash": "sha256-pHTwvnN4tTsEKkWlXQ8JMY423epos8wUOhthpwJjtpc=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "5efc8ca954272c4376ac929f4c5ffefcc20551d5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1648219316,
|
||||
"narHash": "sha256-Ctij+dOi0ZZIfX5eMhgwugfvB+WZSrvVNAyAuANOsnQ=",
|
||||
|
|
@ -84,8 +86,9 @@
|
|||
"root": {
|
||||
"inputs": {
|
||||
"devshell": "devshell",
|
||||
"flake-compat": "flake-compat",
|
||||
"flake-utils": "flake-utils_2",
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -2,9 +2,16 @@
|
|||
description = "Kubernetes resource builder using nix";
|
||||
|
||||
inputs = {
|
||||
flake-compat.url = "github:edolstra/flake-compat";
|
||||
flake-compat.flake = false;
|
||||
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
flake-utils.inputs.nixpkgs.follows = "nixpgks";
|
||||
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
|
||||
devshell.url = "github:numtide/devshell";
|
||||
devshell.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = {
|
||||
|
|
|
|||
|
|
@ -68,26 +68,26 @@ while getopts "f:d:icmk:" opt; do
|
|||
esac
|
||||
done
|
||||
|
||||
if [[ $indiv_opts = false ]] && [[ $combined_opts = false ]]; then
|
||||
if [[ $indiv_opts == false ]] && [[ $combined_opts == false ]]; then
|
||||
indiv_opts=true
|
||||
combined_opts=true
|
||||
fi
|
||||
|
||||
if [[ -f "${flannel_env}" ]]; then
|
||||
if [[ -f ${flannel_env} ]]; then
|
||||
source "${flannel_env}"
|
||||
fi
|
||||
|
||||
if [[ -n "$FLANNEL_SUBNET" ]]; then
|
||||
if [[ -n $FLANNEL_SUBNET ]]; then
|
||||
# shellcheck disable=SC2034 # Variable name referenced in OPT_LOOP below
|
||||
DOCKER_OPT_BIP="--bip=$FLANNEL_SUBNET"
|
||||
fi
|
||||
|
||||
if [[ -n "$FLANNEL_MTU" ]]; then
|
||||
if [[ -n $FLANNEL_MTU ]]; then
|
||||
# shellcheck disable=SC2034 # Variable name referenced in OPT_LOOP below
|
||||
DOCKER_OPT_MTU="--mtu=$FLANNEL_MTU"
|
||||
fi
|
||||
|
||||
if [[ "$FLANNEL_IPMASQ" = true ]] && [[ $ipmasq = true ]]; then
|
||||
if [[ $FLANNEL_IPMASQ == true ]] && [[ $ipmasq == true ]]; then
|
||||
# shellcheck disable=SC2034 # Variable name referenced in OPT_LOOP below
|
||||
DOCKER_OPT_IPMASQ="--ip-masq=false"
|
||||
fi
|
||||
|
|
@ -101,13 +101,13 @@ echo -n "" >"${docker_env}"
|
|||
for opt in $(compgen -v DOCKER_OPT_); do
|
||||
eval val=\$"${opt}"
|
||||
|
||||
if [[ "$indiv_opts" = true ]]; then
|
||||
if [[ $indiv_opts == true ]]; then
|
||||
echo "$opt=\"$val\"" >>"${docker_env}"
|
||||
fi
|
||||
|
||||
docker_opts+="$val "
|
||||
done
|
||||
|
||||
if [[ "$combined_opts" = true ]]; then
|
||||
if [[ $combined_opts == true ]]; then
|
||||
echo "${combined_opts_key}=\"${docker_opts}\"" >>"${docker_env}"
|
||||
fi
|
||||
|
|
|
|||
14
shell.nix
14
shell.nix
|
|
@ -1,8 +1,14 @@
|
|||
{system ? builtins.currentSystem}:
|
||||
(
|
||||
(import ./compat.nix).flake-compat {
|
||||
src = ./.;
|
||||
inherit system;
|
||||
import (
|
||||
let
|
||||
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||
in
|
||||
fetchTarball {
|
||||
url = "https://github.com/edolstra/flake-compat/archive/${
|
||||
lock.nodes.flake-compat.locked.rev
|
||||
}.tar.gz";
|
||||
sha256 = lock.nodes.flake-compat.locked.narHash;
|
||||
}
|
||||
) {src = ./.;}
|
||||
)
|
||||
.shellNix
|
||||
|
|
|
|||
|
|
@ -5,9 +5,11 @@
|
|||
"name": "test"
|
||||
},
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"containers": [
|
||||
{
|
||||
"name": "test",
|
||||
"image": "busybox"
|
||||
}]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
25
treefmt.toml
Normal file
25
treefmt.toml
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
[formatter.nix]
|
||||
command = "alejandra"
|
||||
includes = ["*.nix"]
|
||||
excludes = ["./modules/generated/*"]
|
||||
|
||||
[formatter.prettier]
|
||||
command = "prettier"
|
||||
options = ["--plugin", "prettier-plugin-toml", "--write"]
|
||||
includes = ["*.md", "*.yaml", "*.toml", "*.json"]
|
||||
excludes = []
|
||||
|
||||
[formatter.black]
|
||||
command = "black"
|
||||
includes = ["*.py"]
|
||||
|
||||
[formatter.shell]
|
||||
command = "shfmt"
|
||||
options = [
|
||||
"-i",
|
||||
"2", # indent 2
|
||||
"-s", # simplify the code
|
||||
"-w", # write back to the file
|
||||
|
||||
]
|
||||
includes = ["*.sh", "*.bash"]
|
||||
Loading…
Add table
Add a link
Reference in a new issue