feat(shell): nf-lint-tf

This commit is contained in:
arcnmx 2024-01-16 11:02:55 -08:00
parent 47d1036c42
commit 4de65230b4
5 changed files with 26 additions and 5 deletions

6
.envrc
View file

@ -2,11 +2,11 @@ export NF_CONFIG_ROOT=$PWD
export HOME_HOSTNAME=$(hostname -s) export HOME_HOSTNAME=$(hostname -s)
FLAKE_ARGS=() FLAKE_ARGS=()
if [[ $(id -un) = kat ]]; then source_env_if_exists ".envrc.${USER-$(id -un)}"
git pull
fi
source_env_if_exists .envrc.conf source_env_if_exists .envrc.conf
use flake "${FLAKE_ARGS[@]}" use flake "${FLAKE_ARGS[@]}"
export FLAKE_OPTS=${FLAKE_OPTS:-"${FLAKE_ARGS[*]}"} export FLAKE_OPTS=${FLAKE_OPTS:-"${FLAKE_ARGS[*]}"}
watch_file devShell.nix

1
.envrc.kat Normal file
View file

@ -0,0 +1 @@
git pull

4
.gitignore vendored
View file

@ -2,5 +2,7 @@
/result* /result*
/.direnv/ /.direnv/
/wiki /wiki
.DS_Store /tf/terraform.tfvars
.terraform .terraform
.DS_Store
.envrc.conf

View file

@ -19,7 +19,15 @@ let
exec nix flake update "$@" exec nix flake update "$@"
''; '';
nf-deploy = pkgs.writeShellScriptBin "nf-deploy" '' nf-deploy = pkgs.writeShellScriptBin "nf-deploy" ''
exec nix run ''${FLAKE_OPTS-} ''$NF_CONFIG_ROOT#nf-deploy -- "$@" exec nix run ''${FLAKE_OPTS-} "$NF_CONFIG_ROOT#nf-deploy" -- "$@"
'';
nf-tf = pkgs.writeShellScriptBin "nf-tf" ''
cd "$NF_CONFIG_ROOT/tf"
exec nix run ''${FLAKE_OPTS-} "$NF_CONFIG_ROOT#terraform" -- "$@"
'';
nf-lint-tf = pkgs.writeShellScriptBin "nf-lint-tf" ''
cd "$NF_CONFIG_ROOT/tf"
exec nix run ''${FLAKE_OPTS-} "$NF_CONFIG_ROOT#nf-lint-tf" -- "$@"
''; '';
in in
pkgs.mkShell { pkgs.mkShell {
@ -30,6 +38,8 @@ pkgs.mkShell {
nf-actions-test nf-actions-test
nf-update nf-update
nf-deploy nf-deploy
nf-tf
nf-lint-tf
]; ];
shellHook = '' shellHook = ''
export NIX_BIN_DIR=$(dirname $(readlink -f $(type -P nix))) export NIX_BIN_DIR=$(dirname $(readlink -f $(type -P nix)))

View file

@ -1,10 +1,13 @@
{ {
config,
lib, lib,
pkgs, pkgs,
... ...
}: let }: let
inherit (lib.options) mkOption; inherit (lib.options) mkOption;
inherit (lib.types) attrsOf package; inherit (lib.types) attrsOf package;
inherit (lib.meta) getExe;
cfg = config.outputs.packages;
in { in {
options.outputs.packages = mkOption { options.outputs.packages = mkOption {
type = attrsOf package; type = attrsOf package;
@ -12,8 +15,13 @@ in {
}; };
config.outputs.packages = { config.outputs.packages = {
inherit (pkgs.buildPackages) terraform tflint;
nf-deploy = pkgs.writeShellScriptBin "nf-deploy" '' nf-deploy = pkgs.writeShellScriptBin "nf-deploy" ''
exec ${pkgs.runtimeShell} ${../../ci/deploy.sh} "$@" exec ${pkgs.runtimeShell} ${../../ci/deploy.sh} "$@"
''; '';
nf-lint-tf = pkgs.writeShellScriptBin "nf-lint-tf" ''
${getExe cfg.terraform} fmt "$@" &&
${cfg.tflint}/bin/tflint
'';
}; };
} }