From 262dabbaf23654a001da7ab24640cb812ca381cc Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Thu, 28 Mar 2019 23:52:37 +0100 Subject: [PATCH] Refactor `overlay.nix` Simplify `overlay.nix` a bit by removing unnecessary filtering on attribute values. --- overlay.nix | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/overlay.nix b/overlay.nix index bda4332..122729d 100644 --- a/overlay.nix +++ b/overlay.nix @@ -1,23 +1,18 @@ -# You can use this file as a nixpkgs overlay. -# It's useful in the case where you don't want to add the whole NUR namespace -# to your configuration. +# You can use this file as a nixpkgs overlay. This is useful in the +# case where you don't want to add the whole NUR namespace to your +# configuration. self: super: let - filterSet = - (f: g: s: builtins.listToAttrs - (map - (n: { name = n; value = builtins.getAttr n s; }) - (builtins.filter - (n: f n && g (builtins.getAttr n s)) - (builtins.attrNames s) - ) - ) - ); - isReserved = n: builtins.elem n ["lib" "overlays" "modules"]; -in filterSet - (n: !(isReserved n)) # filter out non-packages - (p: true) # all packages are ok - (import ./default.nix { pkgs = super; }) + isReserved = n: n == "lib" || n == "overlays" || n == "modules"; + nameValuePair = n: v: { name = n; value = v; }; + nurAttrs = import ./default.nix { pkgs = super; }; + +in + + builtins.listToAttrs + (map (n: nameValuePair n nurAttrs.${n}) + (builtins.filter (n: !isReserved n) + (builtins.attrNames nurAttrs)))