From b3a98f222839a51dc72f41cc085c74df708be2e4 Mon Sep 17 00:00:00 2001 From: Jashandeep Sohi Date: Mon, 11 Dec 2023 23:41:42 -0800 Subject: [PATCH] expose flakeModule --- flake-module.nix | 36 +++++++++++++++++++++++++++++++ flake.nix | 56 ++++++++++-------------------------------------- 2 files changed, 47 insertions(+), 45 deletions(-) create mode 100644 flake-module.nix diff --git a/flake-module.nix b/flake-module.nix new file mode 100644 index 0000000..a24c510 --- /dev/null +++ b/flake-module.nix @@ -0,0 +1,36 @@ +localFlake: +{ inputs, ... }: +{ + imports = [ + inputs.devenv.flakeModule + ]; + + perSystem = { inputs', pkgs, ... }: { + packages.kpt = inputs'.kpt.packages.default; + packages.octopilot = inputs'.octopilot.packages.default; + + devenv.shells.default = { + name = "devenv-k8s"; + + imports = [ + ./skaffold-builder.nix + ./cd.nix + ]; + + # https://devenv.sh/packages/ + packages = [ + pkgs.git + pkgs.kubectl + pkgs.kind + pkgs.skaffold + pkgs.kubeseal + pkgs.kubernetes-helm + pkgs.kustomize + pkgs.jq + + inputs'.kpt.packages.default + inputs'.octopilot.packages.default + ]; + }; + }; +} diff --git a/flake.nix b/flake.nix index 7aacf58..345ba36 100644 --- a/flake.nix +++ b/flake.nix @@ -33,54 +33,20 @@ }; outputs = inputs@{ flake-parts, ... }: - flake-parts.lib.mkFlake { inherit inputs; } { - imports = [ - inputs.devenv.flakeModule - ]; - + flake-parts.lib.mkFlake { inherit inputs; } ({ withSystem, flake-parts-lib, ...}: + let + inherit (flake-parts-lib) importApply; + flakeModules.default = importApply ./flake-module.nix { inherit withSystem; }; + in + { systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; - perSystem = { config, self', inputs', pkgs, system, lib, ... }: { - # Per-system attributes can be defined here. The self' and inputs' - # module parameters provide easy access to attributes of the same - # system. - - packages.kpt = inputs'.kpt.packages.default; - packages.octopilot = inputs'.octopilot.packages.default; - - devenv.shells.default = { - name = "devenv-k8s"; - - imports = [ - ./skaffold-builder.nix - ./cd.nix - ]; - - # https://devenv.sh/packages/ - packages = [ - pkgs.git - pkgs.kubectl - pkgs.kind - pkgs.skaffold - pkgs.kubeseal - pkgs.kubernetes-helm - pkgs.kustomize - pkgs.jq - - inputs'.kpt.packages.default - inputs'.octopilot.packages.default - ]; - - # See full reference at https://devenv.sh/reference/options/ - - }; + imports = [ + flakeModules.default + ]; - }; 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. - + inherit flakeModules; }; - }; + }); }