zaphyra's git: haumea

fork of https://github.com/nix-community/haumea

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
{ lib, super }:

from: to:

# Example from / to
# - Lifting `options` from: _api, to: options
#
# Note:
#   underscore used as mere convention to signalling to the user the  "private"
#   nature, they won't be part of the final view presented to the user

let
  inherit (lib)
    recursiveUpdate
    ;
  inherit (super.utils)
    concatMapAttrsWith
    ;
in

cursor:

let toplevel = cursor == [ ]; in
concatMapAttrsWith recursiveUpdate
  (file: value: if ! value ? ${from} then { ${file} = value; } else {
    ${file} = removeAttrs value [ from ];
    # top level ${from} declarations are omitted from merging
    ${if toplevel then to else from} = { ${file} = value.${from}; };
  })