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";
|
||||
});
|
||||
}
|
||||
16
default.nix
16
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 = {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
set -e
|
||||
|
||||
usage() {
|
||||
echo "$0 [-f FLANNEL-ENV-FILE] [-d DOCKER-ENV-FILE] [-i] [-c] [-m] [-k COMBINED-KEY]
|
||||
echo "$0 [-f FLANNEL-ENV-FILE] [-d DOCKER-ENV-FILE] [-i] [-c] [-m] [-k COMBINED-KEY]
|
||||
|
||||
Generate Docker daemon options based on flannel env file
|
||||
OPTIONS:
|
||||
|
|
@ -31,7 +31,7 @@ OPTIONS:
|
|||
-k Set the combined options key to this value (default DOCKER_OPTS=)
|
||||
-m Do not output --ip-masq (useful for older Docker version)
|
||||
" >/dev/stderr
|
||||
exit 1
|
||||
exit 1
|
||||
}
|
||||
|
||||
flannel_env="/run/flannel/subnet.env"
|
||||
|
|
@ -43,53 +43,53 @@ ipmasq=true
|
|||
val=""
|
||||
|
||||
while getopts "f:d:icmk:" opt; do
|
||||
case $opt in
|
||||
f)
|
||||
flannel_env=$OPTARG
|
||||
;;
|
||||
d)
|
||||
docker_env=$OPTARG
|
||||
;;
|
||||
i)
|
||||
indiv_opts=true
|
||||
;;
|
||||
c)
|
||||
combined_opts=true
|
||||
;;
|
||||
m)
|
||||
ipmasq=false
|
||||
;;
|
||||
k)
|
||||
combined_opts_key=$OPTARG
|
||||
;;
|
||||
\?)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
case $opt in
|
||||
f)
|
||||
flannel_env=$OPTARG
|
||||
;;
|
||||
d)
|
||||
docker_env=$OPTARG
|
||||
;;
|
||||
i)
|
||||
indiv_opts=true
|
||||
;;
|
||||
c)
|
||||
combined_opts=true
|
||||
;;
|
||||
m)
|
||||
ipmasq=false
|
||||
;;
|
||||
k)
|
||||
combined_opts_key=$OPTARG
|
||||
;;
|
||||
\?)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $indiv_opts = false ]] && [[ $combined_opts = false ]]; then
|
||||
indiv_opts=true
|
||||
combined_opts=true
|
||||
if [[ $indiv_opts == false ]] && [[ $combined_opts == false ]]; then
|
||||
indiv_opts=true
|
||||
combined_opts=true
|
||||
fi
|
||||
|
||||
if [[ -f "${flannel_env}" ]]; then
|
||||
source "${flannel_env}"
|
||||
if [[ -f ${flannel_env} ]]; then
|
||||
source "${flannel_env}"
|
||||
fi
|
||||
|
||||
if [[ -n "$FLANNEL_SUBNET" ]]; then
|
||||
# shellcheck disable=SC2034 # Variable name referenced in OPT_LOOP below
|
||||
DOCKER_OPT_BIP="--bip=$FLANNEL_SUBNET"
|
||||
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
|
||||
# shellcheck disable=SC2034 # Variable name referenced in OPT_LOOP below
|
||||
DOCKER_OPT_MTU="--mtu=$FLANNEL_MTU"
|
||||
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
|
||||
# shellcheck disable=SC2034 # Variable name referenced in OPT_LOOP below
|
||||
DOCKER_OPT_IPMASQ="--ip-masq=false"
|
||||
if [[ $FLANNEL_IPMASQ == true ]] && [[ $ipmasq == true ]]; then
|
||||
# shellcheck disable=SC2034 # Variable name referenced in OPT_LOOP below
|
||||
DOCKER_OPT_IPMASQ="--ip-masq=false"
|
||||
fi
|
||||
|
||||
eval docker_opts="\$${combined_opts_key}"
|
||||
|
|
@ -99,15 +99,15 @@ echo -n "" >"${docker_env}"
|
|||
|
||||
# OPT_LOOP
|
||||
for opt in $(compgen -v DOCKER_OPT_); do
|
||||
eval val=\$"${opt}"
|
||||
eval val=\$"${opt}"
|
||||
|
||||
if [[ "$indiv_opts" = true ]]; then
|
||||
echo "$opt=\"$val\"" >>"${docker_env}"
|
||||
fi
|
||||
if [[ $indiv_opts == true ]]; then
|
||||
echo "$opt=\"$val\"" >>"${docker_env}"
|
||||
fi
|
||||
|
||||
docker_opts+="$val "
|
||||
docker_opts+="$val "
|
||||
done
|
||||
|
||||
if [[ "$combined_opts" = true ]]; then
|
||||
echo "${combined_opts_key}=\"${docker_opts}\"" >>"${docker_env}"
|
||||
if [[ $combined_opts == true ]]; then
|
||||
echo "${combined_opts_key}=\"${docker_opts}\"" >>"${docker_env}"
|
||||
fi
|
||||
|
|
|
|||
16
shell.nix
16
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
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ spec:
|
|||
app: nginx
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: nginx:1.7.9
|
||||
ports:
|
||||
- containerPort: 80
|
||||
- name: nginx
|
||||
image: nginx:1.7.9
|
||||
ports:
|
||||
- containerPort: 80
|
||||
|
|
|
|||
|
|
@ -5,9 +5,11 @@
|
|||
"name": "test"
|
||||
},
|
||||
"spec": {
|
||||
"containers": [{
|
||||
"name": "test",
|
||||
"image": "busybox"
|
||||
}]
|
||||
"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