From 5387a1a4c52a360c10ece840f02ca75cf82d32ea Mon Sep 17 00:00:00 2001 From: lillecarl Date: Mon, 16 Feb 2026 20:56:51 +0000 Subject: [PATCH] add flake demo --- demo/flake.lock | 40 ++++++++++++++++++++++++++++ demo/flake.nix | 69 +++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 2 +- 3 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 demo/flake.lock create mode 100644 demo/flake.nix diff --git a/demo/flake.lock b/demo/flake.lock new file mode 100644 index 0000000..3f9d1bf --- /dev/null +++ b/demo/flake.lock @@ -0,0 +1,40 @@ +{ + "nodes": { + "easykubenix": { + "locked": { + "lastModified": 0, + "narHash": "sha256-ZtLBBABdyRw7QFEK1nOJlwc6PS2Rh5K3sLzgYcKAUi8=", + "path": "../", + "type": "path" + }, + "original": { + "path": "../", + "type": "path" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1771008912, + "narHash": "sha256-gf2AmWVTs8lEq7z/3ZAsgnZDhWIckkb+ZnAo5RzSxJg=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "a82ccc39b39b621151d6732718e3e250109076fa", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "easykubenix": "easykubenix", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/demo/flake.nix b/demo/flake.nix new file mode 100644 index 0000000..ec7f5f7 --- /dev/null +++ b/demo/flake.nix @@ -0,0 +1,69 @@ +{ + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + easykubenix.url = "path:../"; + }; + outputs = + inputs: + let + eachSys = + func: + inputs.nixpkgs.lib.genAttrs [ + "x86_64-linux" + "aarch64-linux" + ] func; + in + { + packages = eachSys ( + system: + let + pkgs = import inputs.nixpkgs { inherit system; }; + inherit (pkgs) lib; + + hello-bash = pkgs.writeShellApplication { + name = "hello-bash"; + text = "echo Hello, world!"; + }; + + eknEval = inputs.easykubenix.lib.easykubenix { + inherit pkgs; + modules = [ + { + kubernetes.objects.namespace.ConfigMap.name = { + data = "I am a configMap"; + }; + kubernetes.objects.namespace.Pod.hello = { + spec.containers = [ + { + name = "hello"; + image = "gcr.io/distroless/static:latest"; + command = lib.getExe hello-bash; + volumeMounts = [ + { + name = "nix-store"; + mountPath = "/nix"; + subPath = "nix"; + } + ]; + } + ]; + spec.volumes = [ + { + name = "nix-store"; + csi = { + driver = "nix.csi.store"; + readOnly = true; + }; + } + ]; + }; + } + ]; + }; + in + { + inherit (eknEval) manifestYAMLFile; + } + ); + }; +} diff --git a/flake.nix b/flake.nix index df03319..16434fd 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - outputs = { + outputs = _: { lib.easykubenix = import ./default.nix; }; }