From 26128d00dace0a6dc849a66620b4b037aae64689 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Mon, 25 Dec 2023 20:04:35 +0800 Subject: [PATCH] lib: remove filesToAttr There's no part of the setup is using it so we're dumping it. --- lib/default.nix | 43 --------------------------------------- lib/extras/extend-lib.nix | 3 +-- 2 files changed, 1 insertion(+), 45 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index e50ba8c5..a70c86e6 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -2,49 +2,6 @@ { lib }: rec { - /* Create an attribute set that represents the structure of the modules - inside of a directory. While it can recurse into directories, it will - stop once it detects `default.nix` inside. - - Signature: - path -> attrset - Where: - - `path` is the starting point. - Returns: - An attribute set. The keys are the basename of the file or the directory - and the values are the filepath to the Nix file. - - !!! Implementation detail is based from - https://github.com/divnix/digga/blob/main/src/importers.nix looking at it - multiple times for the purpose of familiarizing myself to coding in Nix - and functional programming shtick. - - Example: - filesToAttr ./hosts - => { ni = ./hosts/ni/default.nix; zilch = ./hosts/zilch/default.nix } - */ - filesToAttr = dirPath: - let - isModule = file: type: - (type == "regular" && lib.hasSuffix ".nix" file) - || (type == "directory"); - - collect = file: type: { - name = lib.removeSuffix ".nix" file; - value = - let path = dirPath + "/${file}"; - in if (type == "regular") - || (type == "directory" && lib.pathExists (path + "/default.nix")) then - path - else - filesToAttr path; - }; - - files = lib.filterAttrs isModule (builtins.readDir dirPath); - in - lib.filterAttrs (name: value: value != { }) - (lib.mapAttrs' collect files); - /* Count the attributes with the given predicate. Examples: diff --git a/lib/extras/extend-lib.nix b/lib/extras/extend-lib.nix index 664e7f8a..ada4c684 100644 --- a/lib/extras/extend-lib.nix +++ b/lib/extras/extend-lib.nix @@ -3,8 +3,7 @@ self: super: let publicLib = import ../. { lib = super; }; in { - inherit (publicLib) filesToAttr countAttrs getSecrets - attachSopsPathPrefix; + inherit (publicLib) countAttrs getSecrets attachSopsPathPrefix; # Until I figure out how to properly add them only for their respective # environment, this is the working solution for now. Not really perfect