From 426480067cde9262020c2bc26e7f81842ae62825 Mon Sep 17 00:00:00 2001 From: Archit Gupta Date: Sat, 15 Apr 2023 01:45:39 -0700 Subject: [PATCH] Allow escaping nix filenames with + This allows having a dir for which loadNixDir generates a "default" attr without making the dir importable, by naming the file `+default.nix` instead of `default.nix`. --- default.nix | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/default.nix b/default.nix index 764c715..5562669 100644 --- a/default.nix +++ b/default.nix @@ -8,8 +8,8 @@ let inherit (nixpkgs.lib) attrNames attrVals composeManyExtensions filter filterAttrs foldAttrs foldl genAttrs hasSuffix listToAttrs mapAttrs mapAttrsToList mapAttrs' mergeAttrs nameValuePair optional optionalAttrs - optionalString parseDrvName pathExists pipe recursiveUpdate removeSuffix - zipAttrsWith; + optionalString parseDrvName pathExists pipe recursiveUpdate removePrefix + removeSuffix zipAttrsWith; exports = { inherit mkFlake loadNixDir systems; }; @@ -283,8 +283,10 @@ let attrNames (filter (hasSuffix ".nix")) (map (removeSuffix ".nix")) + (map (removePrefix "+")) ]) - (p: import (path + "/${p}.nix")); + (p: import (path + + (if pathExists (path + "/${p}.nix") then "/${p}.nix" else "/+${p}.nix"))); systems = rec { linuxDefault = [