From 742b1d2029beb29215998780dce294c911bfd97a Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 9 May 2024 01:04:55 +0200 Subject: [PATCH] Add a separate file for the `try-files` function --- flake.nix | 9 +-------- lib/utils/try-files.nix | 9 +++++++++ 2 files changed, 10 insertions(+), 8 deletions(-) create mode 100644 lib/utils/try-files.nix diff --git a/flake.nix b/flake.nix index c624e9f..27bbe08 100644 --- a/flake.nix +++ b/flake.nix @@ -30,14 +30,7 @@ }; systems = builtins.mapAttrs (name: value: defaultMachine // value) machines; - tryFiles = files: default: - lib.lists.foldr - (a: b: - if (a != null) && (builtins.pathExists a) - then a - else b) - default - files; + tryFiles = import ./lib/utils/try-files.nix { inherit lib; }; in flake-utils.lib.eachDefaultSystem ( system: diff --git a/lib/utils/try-files.nix b/lib/utils/try-files.nix new file mode 100644 index 0000000..c71e5fc --- /dev/null +++ b/lib/utils/try-files.nix @@ -0,0 +1,9 @@ +{ lib, ... }: + files: default: + lib.lists.foldr + (a: b: + if (a != null) && (builtins.pathExists a) + then a + else b) + default + files