From f1e5d125d117585a707cb44dfe7a16eaa157096a Mon Sep 17 00:00:00 2001 From: Daniel-Andrei Minca Date: Sat, 6 Jul 2024 23:38:31 +0200 Subject: [PATCH] feat(nix): implement overlays MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * setup repo structure * configure overlay for 'kluctl' package first; once this works, MVP delivered * since this is the initial commit on this feature, it's obviously broken and throwing the following error ```sh error: … while evaluating a branch condition at /nix/store/7gmkl9bfx98djaamhym69wkj4r3sh1q6-source/lib/lists.nix:125:9: 124| fold' = n: 125| if n == len | ^ 126| then nul … while calling the 'length' builtin at /nix/store/7gmkl9bfx98djaamhym69wkj4r3sh1q6-source/lib/lists.nix:123:13: 122| let 123| len = length list; | ^ 124| fold' = n: (stack trace truncated; use '--show-trace' to show the full trace) error: function 'anonymous lambda' called without required argument 'pkgs' at /nix/store/2cv47br877dpnc9p1cv3x95a27nsidb0-source/overlays/kluctl/default.nix:1:1: 1| { pkgs, config, lib, ... }: | ^ 2| ``` Resolves: #9 Related: Signed-off-by: Daniel-Andrei Minca --- flake.nix | 1 + overlays/default.nix | 10 ++++++++++ overlays/kluctl/default.nix | 7 +++++++ 3 files changed, 18 insertions(+) create mode 100644 overlays/default.nix create mode 100644 overlays/kluctl/default.nix diff --git a/flake.nix b/flake.nix index 9218b89..1e72aeb 100644 --- a/flake.nix +++ b/flake.nix @@ -58,6 +58,7 @@ sops-nix.homeManagerModules.sops ./hosts/common ./hosts/M-C02FX3JUML85 + (args: { nixpkgs.overlays = import ./overlays args; } ) ]; }; }; diff --git a/overlays/default.nix b/overlays/default.nix new file mode 100644 index 0000000..8aeac0b --- /dev/null +++ b/overlays/default.nix @@ -0,0 +1,10 @@ +# import all nix files in the current folder, and execute them with args as parameters +# The return value is a list of all execution results, which is the list of overlays + +args: +# execute and import all overlay files in the current directory with the given args +builtins.map + (f: (import (./. + "/${f}") args)) # execute and import the overlay file + (builtins.filter # find all overlay files in the current directory + (f: f != "default.nix") + (builtins.attrNames (builtins.readDir ./.))) diff --git a/overlays/kluctl/default.nix b/overlays/kluctl/default.nix new file mode 100644 index 0000000..e7834e8 --- /dev/null +++ b/overlays/kluctl/default.nix @@ -0,0 +1,7 @@ +{ pkgs, config, lib, ... }: + +(self: super: { + kluctl = super.kluctl.override { + version = "2.25.0"; + }; +})