diff --git a/flake.nix b/flake.nix index cb9ba84..2f4f59e 100644 --- a/flake.nix +++ b/flake.nix @@ -157,6 +157,7 @@ specialArgs = { flakeSelf = self; }; + lib = import ./lib {nixpkgs = pkgs;}; modules = [ agenix.nixosModules.default diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 0000000..400dc18 --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,8 @@ +{nixpkgs}: +nixpkgs.lib.extend (final: prev: { + toast = let + importLib = file: import file {lib = final;}; + in { + patches = importLib ./patches.nix; + }; +}) diff --git a/lib/patches.nix b/lib/patches.nix new file mode 100644 index 0000000..4f3c1a8 --- /dev/null +++ b/lib/patches.nix @@ -0,0 +1,13 @@ +{lib}: { + /** + Get a list of patches from a path. + */ + patchesInPath = path: let + pathContents = builtins.readDir path; + filter = name: value: + (value == "regular" || value == "symlink") && lib.strings.hasSuffix ".patch" name; + filteredContents = lib.attrsets.filterAttrs filter pathContents; + patchFilenames = builtins.attrNames filteredContents; + in + builtins.map (value: lib.path.append path value) patchFilenames; +}