summary refs log tree commit diff
path: root/lib/deprecated.nix
diff options
context:
space:
mode:
authorFrederik Rietdijk <fridh@fridh.nl>2018-07-26 12:05:40 +0200
committerDomen Kožar <domen@enlambda.com>2018-12-30 12:33:45 +0000
commitc6e043d57c2cc69a1068a5e6e34b385942876d0e (patch)
tree5235386c2d705ecc17c88c8179d5b4c051090038 /lib/deprecated.nix
parent30ff3e0f398ef1481f4a5f1b1bef730f0d71f712 (diff)
downloadnixpkgs-c6e043d57c2cc69a1068a5e6e34b385942876d0e.tar
nixpkgs-c6e043d57c2cc69a1068a5e6e34b385942876d0e.tar.gz
nixpkgs-c6e043d57c2cc69a1068a5e6e34b385942876d0e.tar.bz2
nixpkgs-c6e043d57c2cc69a1068a5e6e34b385942876d0e.tar.lz
nixpkgs-c6e043d57c2cc69a1068a5e6e34b385942876d0e.tar.xz
nixpkgs-c6e043d57c2cc69a1068a5e6e34b385942876d0e.tar.zst
nixpkgs-c6e043d57c2cc69a1068a5e6e34b385942876d0e.zip
Remove composableDerivation, closes #18763
Diffstat (limited to 'lib/deprecated.nix')
-rw-r--r--lib/deprecated.nix122
1 files changed, 1 insertions, 121 deletions
diff --git a/lib/deprecated.nix b/lib/deprecated.nix
index 34cf336d1f4..5a3a97c476d 100644
--- a/lib/deprecated.nix
+++ b/lib/deprecated.nix
@@ -35,74 +35,6 @@ rec {
           withStdOverrides;
 
 
-  # predecessors: proposed replacement for applyAndFun (which has a bug cause it merges twice)
-  # the naming "overridableDelayableArgs" tries to express that you can
-  # - override attr values which have been supplied earlier
-  # - use attr values before they have been supplied by accessing the fix point
-  #   name "fixed"
-  # f: the (delayed overridden) arguments are applied to this
-  #
-  # initial: initial attrs arguments and settings. see defaultOverridableDelayableArgs
-  #
-  # returns: f applied to the arguments // special attributes attrs
-  #     a) merge: merge applied args with new args. Wether an argument is overridden depends on the merge settings
-  #     b) replace: this let's you replace and remove names no matter which merge function has been set
-  #
-  # examples: see test cases "res" below;
-  overridableDelayableArgs =
-          f:        # the function applied to the arguments
-          initial:  # you pass attrs, the functions below are passing a function taking the fix argument
-    let
-        takeFixed = if lib.isFunction initial then initial else (fixed : initial); # transform initial to an expression always taking the fixed argument
-        tidy = args:
-            let # apply all functions given in "applyPreTidy" in sequence
-                applyPreTidyFun = fold ( n: a: x: n ( a x ) ) lib.id (maybeAttr "applyPreTidy" [] args);
-            in removeAttrs (applyPreTidyFun args) ( ["applyPreTidy"] ++ (maybeAttr  "removeAttrs" [] args) ); # tidy up args before applying them
-        fun = n: x:
-            let newArgs = fixed:
-                    let args = takeFixed fixed;
-                        mergeFun = args.${n};
-                    in if isAttrs x then (mergeFun args x)
-                       else assert lib.isFunction x;
-                            mergeFun args (x ( args // { inherit fixed; }));
-            in overridableDelayableArgs f newArgs;
-    in
-    (f (tidy (lib.fix takeFixed))) // {
-      merge   = fun "mergeFun";
-      replace = fun "keepFun";
-    };
-  defaultOverridableDelayableArgs = f:
-      let defaults = {
-            mergeFun = mergeAttrByFunc; # default merge function. merge strategie (concatenate lists, strings) is given by mergeAttrBy
-            keepFun = a: b: { inherit (a) removeAttrs mergeFun keepFun mergeAttrBy; } // b; # even when using replace preserve these values
-            applyPreTidy = []; # list of functions applied to args before args are tidied up (usage case : prepareDerivationArgs)
-            mergeAttrBy = mergeAttrBy // {
-              applyPreTidy = a: b: a ++ b;
-              removeAttrs = a: b: a ++ b;
-            };
-            removeAttrs = ["mergeFun" "keepFun" "mergeAttrBy" "removeAttrs" "fixed" ]; # before applying the arguments to the function make sure these names are gone
-          };
-      in (overridableDelayableArgs f defaults).merge;
-
-
-
-  # rec { # an example of how composedArgsAndFun can be used
-  #  a  = composedArgsAndFun (x: x) { a = ["2"]; meta = { d = "bar";}; };
-  #  # meta.d will be lost ! It's your task to preserve it (eg using a merge function)
-  #  b  = a.passthru.function { a = [ "3" ]; meta = { d2 = "bar2";}; };
-  #  # instead of passing/ overriding values you can use a merge function:
-  #  c  = b.passthru.function ( x: { a = x.a  ++ ["4"]; }); # consider using (maybeAttr "a" [] x)
-  # }
-  # result:
-  # {
-  #   a = { a = ["2"];     meta = { d = "bar"; }; passthru = { function = .. }; };
-  #   b = { a = ["3"];     meta = { d2 = "bar2"; }; passthru = { function = .. }; };
-  #   c = { a = ["3" "4"]; meta = { d2 = "bar2"; }; passthru = { function = .. }; };
-  #   # c2 is equal to c
-  # }
-  composedArgsAndFun = f: foldArgs defaultMerge f {};
-
-
   # shortcut for attrByPath ["name"] default attrs
   maybeAttrNullable = maybeAttr;
 
@@ -285,7 +217,7 @@ rec {
   # };
   # will result in
   # { mergeAttrsBy = [...]; buildInputs = [ a b c d ]; }
-  # is used by prepareDerivationArgs, defaultOverridableDelayableArgs and can be used when composing using
+  # is used by defaultOverridableDelayableArgs and can be used when composing using
   # foldArgs, composedArgsAndFun or applyAndFun. Example: composableDerivation in all-packages.nix
   mergeAttrByFunc = x: y:
     let
@@ -318,58 +250,6 @@ rec {
     // listToAttrs (map (n: nameValuePair n (a: b: "${a}\n${b}") ) [ "preConfigure" "postInstall" ])
   ;
 
-  # prepareDerivationArgs tries to make writing configurable derivations easier
-  # example:
-  #  prepareDerivationArgs {
-  #    mergeAttrBy = {
-  #       myScript = x: y: x ++ "\n" ++ y;
-  #    };
-  #    cfg = {
-  #      readlineSupport = true;
-  #    };
-  #    flags = {
-  #      readline = {
-  #        set = {
-  #           configureFlags = [ "--with-compiler=${compiler}" ];
-  #           buildInputs = [ compiler ];
-  #           pass = { inherit compiler; READLINE=1; };
-  #           assertion = compiler.dllSupport;
-  #           myScript = "foo";
-  #        };
-  #        unset = { configureFlags = ["--without-compiler"]; };
-  #      };
-  #    };
-  #    src = ...
-  #    buildPhase = '' ... '';
-  #    name = ...
-  #    myScript = "bar";
-  #  };
-  # if you don't have need for unset you can omit the surrounding set = { .. } attr
-  # all attrs except flags cfg and mergeAttrBy will be merged with the
-  # additional data from flags depending on config settings
-  # It's used in composableDerivation in all-packages.nix. It's also used
-  # heavily in the new python and libs implementation
-  #
-  # should we check for misspelled cfg options?
-  # TODO use args.mergeFun here as well?
-  prepareDerivationArgs = args:
-    let args2 = { cfg = {}; flags = {}; } // args;
-        flagName = name: "${name}Support";
-        cfgWithDefaults = (listToAttrs (map (n: nameValuePair (flagName n) false) (attrNames args2.flags)))
-                          // args2.cfg;
-        opts = attrValues (mapAttrs (a: v:
-                let v2 = if v ? set || v ? unset then v else { set = v; };
-                    n = if cfgWithDefaults.${flagName a} then "set" else "unset";
-                    attr = maybeAttr n {} v2; in
-                if (maybeAttr "assertion" true attr)
-                  then attr
-                  else throw "assertion of flag ${a} of derivation ${args.name} failed"
-               ) args2.flags );
-    in removeAttrs
-      (mergeAttrsByFuncDefaults ([args] ++ opts ++ [{ passthru = cfgWithDefaults; }]))
-      ["flags" "cfg" "mergeAttrBy" ];
-
-
   nixType = x:
       if isAttrs x then
           if x ? outPath then "derivation"