nix-helpers: b21d890377e64c3754c666bb54d2c6cba209fdd8

     1: # Turns nested attribute sets into a single level, with dot-separated names.
     2: { die, hello, lib }:
     3: 
     4: with builtins;
     5: with lib;
     6: with rec {
     7:   # Recurses through attrsets looking for derivations or non-attrsets. 'path'
     8:   # keeps track of where we are in the overall structure.
     9:   go = path: val:
    10:     if !(isAttrs val) || isDerivation val
    11:     # A leaf: use 'path' to make the attribute name and keep value as-is
    12:     then {
    13:       "${concatStringsSep "." path}" = val;
    14:     }
    15:     # An attrset: process every entry, appending their 'path' as needed, and
    16:     # merge all results.
    17:     else
    18:       fold mergeAttrs { }
    19:       (map (name: go (path ++ [ name ]) (getAttr name val)) (attrNames val));
    20: };
    21: 
    22: # Only call 'go' if we've got an attrset (and hence 'path' makes sense)
    23: val:
    24: if !(isAttrs val) || isDerivation val then val else go [ ] val

Generated by git2html.