From 32dc1a09cb806199265e722ceaa61a779a84f2a7 Mon Sep 17 00:00:00 2001 From: Bryton Hall Date: Sun, 11 Jun 2023 23:53:55 -0400 Subject: [PATCH] flake: format --- docs/content/examples/secrets/_index.md | 2 +- flake.nix | 63 +++++++++++++------------ 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/docs/content/examples/secrets/_index.md b/docs/content/examples/secrets/_index.md index 5392770..c132e06 100644 --- a/docs/content/examples/secrets/_index.md +++ b/docs/content/examples/secrets/_index.md @@ -13,4 +13,4 @@ Then it's up to you when and where to apply from with something along the lines pkgs.writeShellScript "apply" '' cat /path/to/manifests | ${pkgs.vals}/bin/vals eval | ${pkgs.kubectl}/bin/kubectl -f - '' -``` \ No newline at end of file +``` diff --git a/flake.nix b/flake.nix index d88e0f4..33c454a 100644 --- a/flake.nix +++ b/flake.nix @@ -13,33 +13,35 @@ }; }; - outputs = inputs @ {self, ...}: + outputs = inputs @ { self, ... }: (inputs.flake-utils.lib.eachDefaultSystem ( - system: let + system: + let pkgs = import inputs.nixpkgs { inherit system; - overlays = [self.overlays.default]; + overlays = [ self.overlays.default ]; config.allowUnsupportedSystem = true; }; inherit (pkgs) lib; kubenix = { - lib = import ./lib {inherit lib pkgs;}; + lib = import ./lib { inherit lib pkgs; }; evalModules = self.evalModules.${system}; modules = self.nixosModules.kubenix; }; # evalModules with same interface as lib.evalModules and kubenix as # special argument - evalModules = attrs @ { - module ? null, - modules ? [module], - ... - }: let - lib' = lib.extend (lib: _self: import ./lib/upstreamables.nix {inherit lib pkgs;}); - attrs' = builtins.removeAttrs attrs ["module"]; - in + evalModules = + attrs @ { module ? null + , modules ? [ module ] + , ... + }: + let + lib' = lib.extend (lib: _self: import ./lib/upstreamables.nix { inherit lib pkgs; }); + attrs' = builtins.removeAttrs attrs [ "module" ]; + in lib'.evalModules (lib.recursiveUpdate { modules = @@ -58,7 +60,8 @@ }; } attrs'); - in { + in + { inherit evalModules pkgs; devShells.default = pkgs.mkShell { @@ -133,9 +136,9 @@ packages = inputs.flake-utils.lib.flattenTree - { - inherit (pkgs) kubernetes kubectl; - } + { + inherit (pkgs) kubernetes kubectl; + } // { cli = pkgs.callPackage ./pkgs/kubenix.nix { inherit (self.packages.${system}); @@ -149,25 +152,25 @@ # the submodules module currently doesn't evaluate: # error: No module found ‹name›/latest # not sure how important that documentation is a this time - self.nixosModules.kubenix ["submodule" "submodules"]); - }) - .options; + self.nixosModules.kubenix [ "submodule" "submodules" ]); + }).options; }; } // import ./jobs { inherit pkgs; }; - checks = let - wasSuccess = suite: - if suite.success - then pkgs.runCommandNoCC "testing-suite-config-assertions-for-${suite.name}-succeeded" {} "echo success > $out" - else pkgs.runCommandNoCC "testing-suite-config-assertions-for-${suite.name}-failed" {} "exit 1"; - examples = import ./docs/content/examples; - mkK8STests = attrs: - (import ./tests {inherit evalModules;}) - ({registry = "docker.io/gatehub";} // attrs); - in + checks = + let + wasSuccess = suite: + if suite.success + then pkgs.runCommandNoCC "testing-suite-config-assertions-for-${suite.name}-succeeded" { } "echo success > $out" + else pkgs.runCommandNoCC "testing-suite-config-assertions-for-${suite.name}-failed" { } "exit 1"; + examples = import ./docs/content/examples; + mkK8STests = attrs: + (import ./tests { inherit evalModules; }) + ({ registry = "docker.io/gatehub"; } // attrs); + in { # TODO: access "success" derivation with nice testing utils for nice output testing = wasSuccess examples.testing.config.testing; @@ -175,7 +178,7 @@ // builtins.listToAttrs (builtins.map (v: { name = "test-k8s-${builtins.replaceStrings ["."] ["_"] v}"; - value = wasSuccess (mkK8STests {k8sVersion = v;}); + value = wasSuccess (mkK8STests { k8sVersion = v; }); }) (import ./versions.nix).versions); }