From c81e8841bfbba8a5b2eaacf4adc7e215557daefd Mon Sep 17 00:00:00 2001 From: Jashandeep Sohi Date: Thu, 21 Dec 2023 11:40:30 -0800 Subject: [PATCH] add templates --- flake.nix | 32 +++++++++++++++++++++++ templates/app-repo/flake.nix | 45 +++++++++++++++++++++++++++++++++ templates/deploy-repo/flake.nix | 27 ++++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 templates/app-repo/flake.nix create mode 100644 templates/deploy-repo/flake.nix diff --git a/flake.nix b/flake.nix index be367fe..3616ede 100644 --- a/flake.nix +++ b/flake.nix @@ -52,5 +52,37 @@ }; }; + + flake = { + templates = { + + app-repo = { + path = ./templates/app-repo; + description = "Application source repo"; + welcomeText = '' + Add the following to `.gitignore`: + + ```sh + echo .devenv >> .gitignore + echo .pre-commit-hook.yaml >> .gitignore + ``` + ''; + }; + + deploy-repo = { + path = ./templates/deploy-repo; + description = "GitOps deploy repo"; + welcomeText = '' + Add the following to `.gitignore`: + + ```sh + echo .devenv >> .gitignore + echo .pre-commit-hook.yaml >> .gitignore + echo '**/secret*.yaml' >> .gitignore + ``` + ''; + }; + }; + }; }); } diff --git a/templates/app-repo/flake.nix b/templates/app-repo/flake.nix new file mode 100644 index 0000000..cbd9a10 --- /dev/null +++ b/templates/app-repo/flake.nix @@ -0,0 +1,45 @@ +{ + description = "Description for the project"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + devenv-k8s.url = "github:LCOGT/devenv-k8s"; + }; + + outputs = inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ + inputs.devenv-k8s.flakeModules.default + ]; + + systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ]; + + perSystem = { config, self', inputs', pkgs, system, ... }: { + # Per-system attributes can be defined here. The self' and inputs' + # module parameters provide easy access to attributes of the same + # system. + + # https://devenv.sh/basics/ + # Enter using `nix develop --impure` + devenv.shells.default = { + # https://devenv.sh/packages/ + packages = [ + + ]; + + # https://devenv.sh/reference/options/#entershell + enterShell = '' + echo Hello + ''; + }; + }; + + flake = { + # The usual flake attributes can be defined here, including system- + # agnostic ones like nixosModule and system-enumerating ones, although + # those are more easily expressed in perSystem. + + }; + }; +} diff --git a/templates/deploy-repo/flake.nix b/templates/deploy-repo/flake.nix new file mode 100644 index 0000000..28ff746 --- /dev/null +++ b/templates/deploy-repo/flake.nix @@ -0,0 +1,27 @@ +{ + description = "GitOps deploy repo"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-parts.url = "github:hercules-ci/flake-parts"; + devenv-k8s.url = "github:LCOGT/devenv-k8s"; + }; + + outputs = inputs@{ flake-parts, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { + imports = [ + inputs.devenv-k8s.flakeModules.default + ]; + + systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ]; + + perSystem = { lib, config, ... }: { + + # Enable these as you see fit + config.devenv.shells.default = { + pre-commit.hooks.kustomize-build-staging.enable = lib.mkForce false; + pre-commit.hooks.kustomize-build-prod.enable = lib.mkForce false; + }; + }; + }; +}