Misterio77 / nix-colors

Modules and schemes to make theming with Nix awesome.
GNU General Public License v3.0
465 stars 38 forks source link

darwin: invalid regular expression in `schemeFromYAML.nix` #17

Closed montchr closed 2 years ago

montchr commented 2 years ago

Since updating to the latest version, I'm getting the following error on macOS:

error: invalid regular expression '([^#]*)(#.*|)'

       at /nix/store/wd2gc5qh1mj38klgf3x2l028sgcp8rmq-source/lib/core/schemeFromYAML.nix:28:33:

           27|     let
           28|       stripLine = line: elemAt (builtins.match "([^#]*)(#.*|)" line) 0;
             |                                 ^
           29|       usefulLine = line: builtins.match "[ \\t]*" line == null;

FWIW, I've seen similar Darwin-specific errors in home-manager relating to regular expressions.

Metadata

$ nix-shell -p nix-info --run "nix-info -m"
these 2 paths will be fetched (0.34 MiB download, 2.06 MiB unpacked):
  /nix/store/dwc47n75p5zbml53x8p25phnks1hlr9h-bash-interactive-5.1-p16-doc
  /nix/store/gzwsyaz1p2cj70rxgbj026s3bx8bsy6f-bash-interactive-5.1-p16-dev
copying path '/nix/store/dwc47n75p5zbml53x8p25phnks1hlr9h-bash-interactive-5.1-p16-doc' from 'https://cache.nixos.org'...
copying path '/nix/store/gzwsyaz1p2cj70rxgbj026s3bx8bsy6f-bash-interactive-5.1-p16-dev' from 'https://cache.nixos.org'...
 - system: `"x86_64-darwin"`
 - host os: `Darwin 21.5.0, macOS 10.16`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.8.1`
 - channels(montchr): `"home-manager, nixos-unstable, nixpkgs, nixpkgs-unstable, unstable"`
 - channels(root): `"nixpkgs-22.05pre357729.22dc22f8ced, unstable-22.05pre357729.22dc22f8ced, channel-nixpkgs-unstable-22.05pre357729.22dc22f8ced"`
 - nixpkgs: `/etc/nix/inputs/nixpkgs`

Stack Trace

$ nix flake update && darwin-rebuild build --verbose --flake . --show-trace
warning: Git tree '/Users/montchr/.config/dotfield' is dirty
warning: Git tree '/Users/montchr/.config/dotfield' is dirty
building the system configuration...
warning: Git tree '/Users/montchr/.config/dotfield' is dirty
error: invalid regular expression '([^#]*)(#.*|)'

       at /nix/store/wd2gc5qh1mj38klgf3x2l028sgcp8rmq-source/lib/core/schemeFromYAML.nix:28:33:

           27|     let
           28|       stripLine = line: elemAt (builtins.match "([^#]*)(#.*|)" line) 0;
             |                                 ^
           29|       usefulLine = line: builtins.match "[ \\t]*" line == null;

       … while evaluating 'stripLine'

       at /nix/store/wd2gc5qh1mj38klgf3x2l028sgcp8rmq-source/lib/core/schemeFromYAML.nix:28:19:

           27|     let
           28|       stripLine = line: elemAt (builtins.match "([^#]*)(#.*|)" line) 0;
             |                   ^
           29|       usefulLine = line: builtins.match "[ \\t]*" line == null;

       … from call site

       … while evaluating 'usefulLine'

       at /nix/store/wd2gc5qh1mj38klgf3x2l028sgcp8rmq-source/lib/core/schemeFromYAML.nix:29:20:

           28|       stripLine = line: elemAt (builtins.match "([^#]*)(#.*|)" line) 0;
           29|       usefulLine = line: builtins.match "[ \\t]*" line == null;
             |                    ^
           30|       parseString = token:

       … from call site

       … while evaluating 'mapListToAttrs'

       at /nix/store/wd2gc5qh1mj38klgf3x2l028sgcp8rmq-source/lib/core/schemeFromYAML.nix:5:23:

            4|   # All of these are borrowed from nixpkgs
            5|   mapListToAttrs = f: l: listToAttrs (map f l);
             |                       ^
            6|   escapeRegex = escape (stringToCharacters "\\[{()^$?*+|.");

       … from call site

       at /nix/store/wd2gc5qh1mj38klgf3x2l028sgcp8rmq-source/lib/core/schemeFromYAML.nix:47:5:

           46|     in
           47|     mapListToAttrs attrLine lines'';
             |     ^
           48|

       … while evaluating 'fromYAML'

       at /nix/store/wd2gc5qh1mj38klgf3x2l028sgcp8rmq-source/lib/core/schemeFromYAML.nix:26:14:

           25|   # From https://github.com/arcnmx/nixexprs
           26|   fromYAML = yaml:
             |              ^
           27|     let

       … from call site

       at /nix/store/wd2gc5qh1mj38klgf3x2l028sgcp8rmq-source/lib/core/schemeFromYAML.nix:59:55:

           58|
           59|   schemeFromYAML = slug: content: convertScheme slug (fromYAML content);
             |                                                       ^
           60| in

       … while evaluating the attribute 'value.content'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:918:14:

          917|     { _type = "override";
          918|       inherit priority content;
             |              ^
          919|     };

       … while evaluating the attribute 'value._type'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:871:73:

          870|       highestPrio = foldl' (prio: def: min (getPrio def) prio) 9999 defs;
          871|       strip = def: if def.value._type or "" == "override" then def // { value = def.value.content; } else def;
             |                                                                         ^
          872|     in {

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:770:19:

          769|           # Avoid sorting if we don't have to.
          770|           if any (def: def.value._type or "" == "order") defs''.values
             |                   ^
          771|           then sortProperties defs''.values

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:770:14:

          769|           # Avoid sorting if we don't have to.
          770|           if any (def: def.value._type or "" == "order") defs''.values
             |              ^
          771|           then sortProperties defs''.values

       … while evaluating the attribute 'values'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:774:9:

          773|       in {
          774|         values = defs''';
             |         ^
          775|         inherit (defs'') highestPrio;

       … while evaluating the attribute 'mergedValue'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:780:5:

          779|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
          780|     mergedValue =
             |     ^
          781|       if isDefined then

       … while evaluating the option `home-manager.users.montchr.colorScheme.colors.base00':

       … while evaluating the attribute 'value'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:746:9:

          745|     in warnDeprecation opt //
          746|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          747|         inherit (res.defsFinal') highestPrio;

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:296:72:

          295|           # For definitions that have an associated option
          296|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          297|

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:401:20:

          400|               then recurse (path ++ [name]) value
          401|               else f (path ++ [name]) value;
             |                    ^
          402|         in mapAttrs g;

       … while evaluating 'g'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:398:19:

          397|           g =
          398|             name: value:
             |                   ^
          399|             if isAttrs value && cond value

       … from call site

       … while evaluating the attribute 'default'

       at /nix/store/wd2gc5qh1mj38klgf3x2l028sgcp8rmq-source/module/colorscheme.nix:35:7:

           34|       type = types.enum [ "dark" "light" ];
           35|       default =
             |       ^
           36|         if builtins.substring 0 1 cfg.colors.base00 < "5" then

       … while evaluating the attribute 'value.content'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:918:14:

          917|     { _type = "override";
          918|       inherit priority content;
             |              ^
          919|     };

       … while evaluating the attribute 'value._type'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:871:73:

          870|       highestPrio = foldl' (prio: def: min (getPrio def) prio) 9999 defs;
          871|       strip = def: if def.value._type or "" == "override" then def // { value = def.value.content; } else def;
             |                                                                         ^
          872|     in {

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:770:19:

          769|           # Avoid sorting if we don't have to.
          770|           if any (def: def.value._type or "" == "order") defs''.values
             |                   ^
          771|           then sortProperties defs''.values

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:770:14:

          769|           # Avoid sorting if we don't have to.
          770|           if any (def: def.value._type or "" == "order") defs''.values
             |              ^
          771|           then sortProperties defs''.values

       … while evaluating the attribute 'values'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:774:9:

          773|       in {
          774|         values = defs''';
             |         ^
          775|         inherit (defs'') highestPrio;

       … while evaluating the attribute 'mergedValue'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:780:5:

          779|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
          780|     mergedValue =
             |     ^
          781|       if isDefined then

       … while evaluating the option `home-manager.users.montchr.colorScheme.kind':

       … while evaluating the attribute 'value'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:746:9:

          745|     in warnDeprecation opt //
          746|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          747|         inherit (res.defsFinal') highestPrio;

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:296:72:

          295|           # For definitions that have an associated option
          296|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          297|

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:401:20:

          400|               then recurse (path ++ [name]) value
          401|               else f (path ++ [name]) value;
             |                    ^
          402|         in mapAttrs g;

       … while evaluating 'g'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:398:19:

          397|           g =
          398|             name: value:
             |                   ^
          399|             if isAttrs value && cond value

       … from call site

       … while evaluating the attribute 'value'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:436:60:

          435|           # Push down position info.
          436|           (map (def: mapAttrs (n: v: { inherit (def) file; value = v; }) def.value) defs)));
             |                                                            ^
          437|       emptyValue = { value = {}; };

       … while evaluating 'dischargeProperties'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:832:25:

          831|   */
          832|   dischargeProperties = def:
             |                         ^
          833|     if def._type or "" == "merge" then

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:761:137:

          760|         defs' = concatMap (m:
          761|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                         ^
          762|         ) defs;

       … while evaluating definitions from `/nix/store/s6lzqq8mzb7j5kbyfm801sqy78wiwfz2-source/users/profiles/firefox':

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:760:28:

          759|         # Process mkMerge and mkIf properties.
          760|         defs' = concatMap (m:
             |                            ^
          761|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:760:17:

          759|         # Process mkMerge and mkIf properties.
          760|         defs' = concatMap (m:
             |                 ^
          761|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … while evaluating the attribute 'values'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:873:7:

          872|     in {
          873|       values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
             |       ^
          874|       inherit highestPrio;

       … while evaluating the attribute 'values'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:774:9:

          773|       in {
          774|         values = defs''';
             |         ^
          775|         inherit (defs'') highestPrio;

       … while evaluating the attribute 'optionalValue'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:792:5:

          791|
          792|     optionalValue =
             |     ^
          793|       if isDefined then { value = mergedValue; }

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:432:86:

          431|       merge = loc: defs:
          432|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
             |                                                                                      ^
          433|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue

       … from call site

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:432:51:

          431|       merge = loc: defs:
          432|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
             |                                                   ^
          433|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:225:62:

          224|   filterAttrs = pred: set:
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
             |                                                              ^
          226|

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:225:29:

          224|   filterAttrs = pred: set:
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
             |                             ^
          226|

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:225:18:

          224|   filterAttrs = pred: set:
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
             |                  ^
          226|

       … while evaluating 'filterAttrs'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:224:23:

          223|   */
          224|   filterAttrs = pred: set:
             |                       ^
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:432:35:

          431|       merge = loc: defs:
          432|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
             |                                   ^
          433|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue

       … while evaluating 'merge'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:431:20:

          430|       check = isAttrs;
          431|       merge = loc: defs:
             |                    ^
          432|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:782:59:

          781|       if isDefined then
          782|         if all (def: type.check def.value) defsFinal then type.merge loc defsFinal
             |                                                           ^
          783|         else let allInvalid = filter (def: ! type.check def.value) defsFinal;

       … while evaluating the attribute 'mergedValue'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:780:5:

          779|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
          780|     mergedValue =
             |     ^
          781|       if isDefined then

       … while evaluating the option `home-manager.users.montchr.programs.firefox.profiles.home.settings':

       … while evaluating the attribute 'value'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:746:9:

          745|     in warnDeprecation opt //
          746|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          747|         inherit (res.defsFinal') highestPrio;

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:296:72:

          295|           # For definitions that have an associated option
          296|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          297|

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:401:20:

          400|               then recurse (path ++ [name]) value
          401|               else f (path ++ [name]) value;
             |                    ^
          402|         in mapAttrs g;

       … while evaluating 'g'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:398:19:

          397|           g =
          398|             name: value:
             |                   ^
          399|             if isAttrs value && cond value

       … from call site

       … while evaluating the attribute 'condition'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:903:14:

          902|     { _type = "if";
          903|       inherit condition content;
             |              ^
          904|     };

       … while evaluating 'dischargeProperties'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:832:25:

          831|   */
          832|   dischargeProperties = def:
             |                         ^
          833|     if def._type or "" == "merge" then

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:761:137:

          760|         defs' = concatMap (m:
          761|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                         ^
          762|         ) defs;

       … while evaluating definitions from `/nix/store/lf67akljs7wgmx2gdnfqqv1lwnc0yka4-source/modules/programs/firefox.nix':

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:760:28:

          759|         # Process mkMerge and mkIf properties.
          760|         defs' = concatMap (m:
             |                            ^
          761|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:760:17:

          759|         # Process mkMerge and mkIf properties.
          760|         defs' = concatMap (m:
             |                 ^
          761|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … while evaluating the attribute 'values'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:873:7:

          872|     in {
          873|       values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
             |       ^
          874|       inherit highestPrio;

       … while evaluating the attribute 'values'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:774:9:

          773|       in {
          774|         values = defs''';
             |         ^
          775|         inherit (defs'') highestPrio;

       … while evaluating the attribute 'optionalValue'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:792:5:

          791|
          792|     optionalValue =
             |     ^
          793|       if isDefined then { value = mergedValue; }

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:432:86:

          431|       merge = loc: defs:
          432|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
             |                                                                                      ^
          433|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue

       … from call site

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:432:51:

          431|       merge = loc: defs:
          432|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
             |                                                   ^
          433|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:225:62:

          224|   filterAttrs = pred: set:
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
             |                                                              ^
          226|

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:225:29:

          224|   filterAttrs = pred: set:
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
             |                             ^
          226|

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:225:18:

          224|   filterAttrs = pred: set:
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
             |                  ^
          226|

       … while evaluating 'filterAttrs'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:224:23:

          223|   */
          224|   filterAttrs = pred: set:
             |                       ^
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:432:35:

          431|       merge = loc: defs:
          432|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
             |                                   ^
          433|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue

       … while evaluating 'merge'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:431:20:

          430|       check = isAttrs;
          431|       merge = loc: defs:
             |                    ^
          432|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:782:59:

          781|       if isDefined then
          782|         if all (def: type.check def.value) defsFinal then type.merge loc defsFinal
             |                                                           ^
          783|         else let allInvalid = filter (def: ! type.check def.value) defsFinal;

       … while evaluating the attribute 'mergedValue'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:780:5:

          779|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
          780|     mergedValue =
             |     ^
          781|       if isDefined then

       … while evaluating the option `home-manager.users.montchr.home.file':

       … while evaluating the attribute 'value'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:746:9:

          745|     in warnDeprecation opt //
          746|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          747|         inherit (res.defsFinal') highestPrio;

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:296:72:

          295|           # For definitions that have an associated option
          296|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          297|

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:401:20:

          400|               then recurse (path ++ [name]) value
          401|               else f (path ++ [name]) value;
             |                    ^
          402|         in mapAttrs g;

       … while evaluating 'g'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:398:19:

          397|           g =
          398|             name: value:
             |                   ^
          399|             if isAttrs value && cond value

       … from call site

       … while evaluating 'mapAttrsToList'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:355:23:

          354|   */
          355|   mapAttrsToList = f: attrs:
             |                       ^
          356|     map (name: f name attrs.${name}) (attrNames attrs);

       … from call site

       at /nix/store/lf67akljs7wgmx2gdnfqqv1lwnc0yka4-source/modules/files.nix:48:14:

           47|             (foldAttrs (acc: v: acc + v) 0
           48|             (mapAttrsToList (n: v: { ${v.target} = 1; }) cfg)));
             |              ^
           49|         dupsStr = concatStringsSep ", " dups;

       … while evaluating 'fold''

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/lists.nix:56:15:

           55|       len = length list;
           56|       fold' = n:
             |               ^
           57|         if n == len

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/lists.nix:60:8:

           59|         else op (elemAt list n) (fold' (n + 1));
           60|     in fold' 0;
             |        ^
           61|

       … while evaluating 'foldr'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/lists.nix:53:20:

           52|   */
           53|   foldr = op: nul: list:
             |                    ^
           54|     let

       … from call site

       at /nix/store/lf67akljs7wgmx2gdnfqqv1lwnc0yka4-source/modules/files.nix:47:14:

           46|             (filterAttrs (n: v: v > 1)
           47|             (foldAttrs (acc: v: acc + v) 0
             |              ^
           48|             (mapAttrsToList (n: v: { ${v.target} = 1; }) cfg)));

       … while evaluating 'filterAttrs'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:224:23:

          223|   */
          224|   filterAttrs = pred: set:
             |                       ^
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));

       … from call site

       at /nix/store/lf67akljs7wgmx2gdnfqqv1lwnc0yka4-source/modules/files.nix:46:14:

           45|           attrNames
           46|             (filterAttrs (n: v: v > 1)
             |              ^
           47|             (foldAttrs (acc: v: acc + v) 0

       … while evaluating the attribute 'assertion'

       at /nix/store/lf67akljs7wgmx2gdnfqqv1lwnc0yka4-source/modules/files.nix:51:9:

           50|       in {
           51|         assertion = dups == [];
             |         ^
           52|         message = ''

       … while evaluating the attribute 'assertion'

       at /nix/store/lf67akljs7wgmx2gdnfqqv1lwnc0yka4-source/nix-darwin/default.nix:120:32:

          119|           {
          120|             inherit (assertion) assertion;
             |                                ^
          121|             message = "${user} profile: ${assertion.message}";

       … while evaluating anonymous lambda

       at /nix/store/ng581mjj8f2zcw2fyxhv4dlz42561arz-source/modules/system/default.nix:11:50:

           10|
           11|   failedAssertions = map (x: x.message) (filter (x: !x.assertion) config.assertions);
             |                                                  ^
           12|

       … from call site

       … while evaluating 'throwAssertions'

       at /nix/store/ng581mjj8f2zcw2fyxhv4dlz42561arz-source/modules/system/default.nix:13:21:

           12|
           13|   throwAssertions = res: if (failedAssertions != []) then throw "\nFailed assertions:\n${concatStringsSep "\n" (map (x: "- ${x}") failedAssertions)}" else res;
             |                     ^
           14|   showWarnings = res: fold (w: x: builtins.trace "warning: ${w}" x) res config.warnings;

       … from call site

       at /nix/store/ng581mjj8f2zcw2fyxhv4dlz42561arz-source/modules/system/default.nix:73:29:

           72|
           73|     system.build.toplevel = throwAssertions (showWarnings (stdenvNoCC.mkDerivation {
             |                             ^
           74|       name = "darwin-system-${cfg.darwinLabel}";

       … while evaluating the attribute 'value'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:436:60:

          435|           # Push down position info.
          436|           (map (def: mapAttrs (n: v: { inherit (def) file; value = v; }) def.value) defs)));
             |                                                            ^
          437|       emptyValue = { value = {}; };

       … while evaluating 'dischargeProperties'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:832:25:

          831|   */
          832|   dischargeProperties = def:
             |                         ^
          833|     if def._type or "" == "merge" then

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:761:137:

          760|         defs' = concatMap (m:
          761|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                         ^
          762|         ) defs;

       … while evaluating definitions from `/nix/store/ng581mjj8f2zcw2fyxhv4dlz42561arz-source/modules/system':

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:760:28:

          759|         # Process mkMerge and mkIf properties.
          760|         defs' = concatMap (m:
             |                            ^
          761|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:760:17:

          759|         # Process mkMerge and mkIf properties.
          760|         defs' = concatMap (m:
             |                 ^
          761|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … while evaluating the attribute 'values'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:873:7:

          872|     in {
          873|       values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
             |       ^
          874|       inherit highestPrio;

       … while evaluating the attribute 'values'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:774:9:

          773|       in {
          774|         values = defs''';
             |         ^
          775|         inherit (defs'') highestPrio;

       … while evaluating the attribute 'optionalValue'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:792:5:

          791|
          792|     optionalValue =
             |     ^
          793|       if isDefined then { value = mergedValue; }

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:432:86:

          431|       merge = loc: defs:
          432|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
             |                                                                                      ^
          433|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue

       … from call site

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:432:51:

          431|       merge = loc: defs:
          432|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
             |                                                   ^
          433|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:225:62:

          224|   filterAttrs = pred: set:
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
             |                                                              ^
          226|

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:225:29:

          224|   filterAttrs = pred: set:
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
             |                             ^
          226|

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:225:18:

          224|   filterAttrs = pred: set:
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
             |                  ^
          226|

       … while evaluating 'filterAttrs'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:224:23:

          223|   */
          224|   filterAttrs = pred: set:
             |                       ^
          225|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:432:35:

          431|       merge = loc: defs:
          432|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
             |                                   ^
          433|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue

       … while evaluating 'merge'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/types.nix:431:20:

          430|       check = isAttrs;
          431|       merge = loc: defs:
             |                    ^
          432|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:782:59:

          781|       if isDefined then
          782|         if all (def: type.check def.value) defsFinal then type.merge loc defsFinal
             |                                                           ^
          783|         else let allInvalid = filter (def: ! type.check def.value) defsFinal;

       … while evaluating the attribute 'mergedValue'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:780:5:

          779|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
          780|     mergedValue =
             |     ^
          781|       if isDefined then

       … while evaluating the option `system.build':

       … while evaluating the attribute 'value'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:746:9:

          745|     in warnDeprecation opt //
          746|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          747|         inherit (res.defsFinal') highestPrio;

       … while evaluating anonymous lambda

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/modules.nix:296:72:

          295|           # For definitions that have an associated option
          296|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          297|

       … from call site

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:401:20:

          400|               then recurse (path ++ [name]) value
          401|               else f (path ++ [name]) value;
             |                    ^
          402|         in mapAttrs g;

       … while evaluating 'g'

       at /nix/store/jgiii63g7200vhkhnka2fpa8p6ph7f4k-source/lib/attrsets.nix:398:19:

          397|           g =
          398|             name: value:
             |                   ^
          399|             if isAttrs value && cond value

       … from call site
Misterio77 commented 2 years ago

Hmmm, it seems to be related to empty matches https://github.com/NixOS/nix/issues/1537

Working on a fix right now, thanks for the report!

Misterio77 commented 2 years ago

Here's a possible fix, could you try it out? https://github.com/Misterio77/nix-colors/commit/b492ce12721492fb3becdb7137e31e5c0f54bf8a

montchr commented 2 years ago

~Unfortunately nope:~ Yes! But now a new one:

error: invalid regular expression '([^ :]+): *(.*?) *'

       at /nix/store/l44mp4dv8ilaamrlkf2j7pah5kcvill0-source/lib/core/schemeFromYAML.nix:39:19:

           38|         let
           39|           match = builtins.match "([^ :]+): *(.*?) *" line;
             |                   ^
           40|         in

~The error output is different now, but it also differs pretty significantly from the source code 🤔~

Edit: I misread: this is a different expression! So it looks like your fix worked for the one on L28, but L39 is failing now:

https://github.com/Misterio77/nix-colors/blob/2c2e107765b7b2e54b10d3fc2ffe5ed2ca2c7731/lib/core/schemeFromYAML.nix#L39

Misterio77 commented 2 years ago

Okay! Please try this one now: 957021ec7eb0f2ba2dde29b86f4ffd6a31b568f0

montchr commented 2 years ago

It works! Thank you.

Hmmm, it seems to be related to empty matches

By the way, does this imply that I might have something configured incorrectly which would result in empty values?

Misterio77 commented 2 years ago

It works! Thank you.

Awesome! I'll push it to main in a sec

By the way, does this imply that I might have something configured incorrectly which would result in empty values?

No no, not at all. It seems nix uses the OS' native regex implementation, and Darwin's seems to not handle well when capture groups return empty data