Skip to content

Commit

Permalink
flake: format
Browse files Browse the repository at this point in the history
  • Loading branch information
hall committed Jun 12, 2023
1 parent 5d95447 commit 32dc1a0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 31 deletions.
2 changes: 1 addition & 1 deletion docs/content/examples/secrets/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 -
''
```
```
63 changes: 33 additions & 30 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -58,7 +60,8 @@
};
}
attrs');
in {
in
{
inherit evalModules pkgs;

devShells.default = pkgs.mkShell {
Expand Down Expand Up @@ -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});
Expand All @@ -149,33 +152,33 @@
# 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;
}
// 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);
}
Expand Down

0 comments on commit 32dc1a0

Please sign in to comment.