From 0edb15f0d2f3feeead10d3cb05b60040681263d0 Mon Sep 17 00:00:00 2001 From: Paul Meyer <49727155+katexochen@users.noreply.github.com> Date: Wed, 14 Feb 2024 17:12:42 +0100 Subject: [PATCH] packages: use packagesFromDirectoryRecursive instead of own by-name implementation Signed-off-by: Paul Meyer <49727155+katexochen@users.noreply.github.com> --- flake.nix | 2 +- lib/default.nix | 20 -------------------- packages/default.nix | 6 ++++-- 3 files changed, 5 insertions(+), 23 deletions(-) delete mode 100644 lib/default.nix diff --git a/flake.nix b/flake.nix index 0067601698..3b1314b015 100644 --- a/flake.nix +++ b/flake.nix @@ -21,7 +21,7 @@ }: flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; - lib = pkgs.lib.extend (import ./lib); + inherit (pkgs) lib; treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix; in { diff --git a/lib/default.nix b/lib/default.nix deleted file mode 100644 index bb8c9b9809..0000000000 --- a/lib/default.nix +++ /dev/null @@ -1,20 +0,0 @@ -final: _prev: { - by-name = pkgs: path: - let - entries = builtins.readDir path; - filenames = builtins.attrNames entries; - callPackage = final.callPackageWith (pkgs // self); - maybeNameValuePair = filename: - if entries.${filename} == "directory" - then [ - { - name = filename; - value = callPackage (path + "/${filename}/package.nix") { }; - } - ] - else [ ]; - nameValuePairs = builtins.concatMap maybeNameValuePair filenames; - self = builtins.listToAttrs nameValuePairs; - in - self; -} diff --git a/packages/default.nix b/packages/default.nix index e8bfade638..6512b67a5b 100644 --- a/packages/default.nix +++ b/packages/default.nix @@ -1,10 +1,12 @@ { lib, pkgs }: - let pkgs' = pkgs // self; callPackages = lib.callPackagesWith pkgs'; - self = lib.by-name pkgs' ./by-name // { + self = (lib.packagesFromDirectoryRecursive { + callPackage = lib.callPackageWith pkgs'; + directory = ./by-name; + }) // { containers = callPackages ./containers.nix { pkgs = pkgs'; }; scripts = callPackages ./scripts.nix { pkgs = pkgs'; }; genpolicy-msft = pkgs.pkgsStatic.callPackage ./by-name/genpolicy-msft/package.nix { };