removed all __primops from nixpkgs

svn path=/nixpkgs/trunk/; revision=15693
This commit is contained in:
Marc Weber 2009-05-24 10:57:46 +00:00
parent f7f938a1d1
commit 3157bb1098
12 changed files with 66 additions and 50 deletions

View File

@ -1,7 +1,8 @@
args: with args;
let edf = composableDerivation.edf;
optionIncLib = name : attr : " -D${name}_INCLUDE_DIR=${__getAttr attr args}/incclude"
+ " -D${name}_LIBRARY=${__getAttr attr args}/lib "; # lib 64?
let inherit (builtins) getAttr;
edf = composableDerivation.edf;
optionIncLib = name : attr : " -D${name}_INCLUDE_DIR=${getAttr attr args}/incclude"
+ " -D${name}_LIBRARY=${getAttr attr args}/lib "; # lib 64?
in
composableDerivation.composableDerivation {} {

View File

@ -1,4 +1,5 @@
args: with args; with stringsWithDeps; with lib;
let inherit (builtins) head tail trace; in
(rec
{
inherit writeScript;
@ -316,8 +317,8 @@ args: with args; with stringsWithDeps; with lib;
envAdder = envAdderInner "";
envAdderList = l: if l==[] then "" else
"echo export ${__head l}='\"'\"\\\$${__head l}:${__head (__tail l)}\"'\"';\n" +
envAdderList (__tail (__tail l));
"echo export ${head l}='\"'\"\\\$${head l}:${head (tail l)}\"'\"';\n" +
envAdderList (tail (tail l));
wrapEnv = cmd: env: "
mv \"${cmd}\" \"${cmd}-orig\";
@ -350,8 +351,8 @@ args: with args; with stringsWithDeps; with lib;
echo '${toString (attrByPath ["propagatedBuildInputs"] [] args)}' >\$out/nix-support/propagated-build-inputs
") ["minInit" "defEnsureDir"];
/*debug = x:(__trace x x);
debugX = x:(__trace (__toXML x) x);*/
/*debug = x:(trace x x);
debugX = x:(trace (toXML x) x);*/
replaceScriptVar = file: name: value: "sed -e 's`^${name}=.*`${name}='\\''${value}'\\''`' -i ${file}";
replaceInScript = file: l: concatStringsSep "\n" ((pairMap (replaceScriptVar file) l));

View File

@ -22,7 +22,7 @@ let
then ""
else checkAttrInclusion
(s + "." + x)
(__getAttr x a)
(builtins.getAttr x a)
(lib.attrByPath [x] null b))
(attrNames a)) ""
);

View File

@ -12,10 +12,11 @@
p: # p = pkgs
let
inherit (builtins) isAttrs hasAttr;
inherit (p) lib fetchurl stdenv getConfig;
inherit (p.composableDerivation) composableDerivation;
# withName prevents nix-env -qa \* from aborting (pythonLibStub is a derivation but hasn't a name)
withName = lib.mapAttrs (n : v : if (__isAttrs v && (!__hasAttr "name" v)) then null else v);
withName = lib.mapAttrs (n : v : if (isAttrs v && (!hasAttr "name" v)) then null else v);
in
withName ( lib.fix ( t : { # t = this attrs
@ -608,7 +609,7 @@ in
};
all = lib.filter (x:
(__isAttrs x)
(isAttrs x)
&& ((lib.maybeAttr "libPython" false x) == t.version)
&& (lib.maybeAttr "name" false x != false) # don't collect pythonLibStub etc
) (lib.flattenAttrs (removeAttrs t ["all"])); # nix is not yet lazy enough, so I've to remove all first

View File

@ -7,7 +7,7 @@ stdenv.mkDerivation {
sha256 = "0cciavzd05bpm5yfppid0s0vsf8kabwia9620vgvi26sv1gjgwhb";
};
postInstall = ''
echo -e '#! /bin/sh \n $( readlink -f $( type -tP wish${__substring 0 3 version}) ) "$@"' >$out/bin/wish
echo -e '#! /bin/sh \n $( readlink -f $( type -tP wish${builtins.substring 0 3 version}) ) "$@"' >$out/bin/wish
chmod a+x $out/bin/wish
'';
configureFlags="--with-tcl=${tcl}/lib";

View File

@ -1,4 +1,8 @@
let lib = import ./default.nix; in
let lib = import ./default.nix;
inherit (builtins) trace attrNamesToStr isAttrs isFunction isList head substring attrNames;
in
rec {
@ -20,20 +24,20 @@ rec {
# this can help debug your code as well - designed to not produce thousands of lines
traceShowVal = x : __trace (showVal x) x;
traceShowValMarked = str: x: __trace (str + showVal x) x;
attrNamesToStr = a : lib.concatStringsSep "; " (map (x : "${x}=") (__attrNames a));
traceShowVal = x : trace (showVal x) x;
traceShowValMarked = str: x: trace (str + showVal x) x;
attrNamesToStr = a : lib.concatStringsSep "; " (map (x : "${x}=") (attrNames a));
showVal = x :
if __isAttrs x then
if isAttrs x then
if x ? outPath then "x is a derivation, name ${if x ? name then x.name else "<no name>"}, { ${attrNamesToStr x} }"
else "x is attr set { ${attrNamesToStr x} }"
else if __isFunction x then "x is a function"
else if isFunction x then "x is a function"
else if x == [] then "x is an empty list"
else if __isList x then "x is a list, first item is : ${showVal (__head x)}"
else if isList x then "x is a list, first item is : ${showVal (head x)}"
else if x == true then "x is boolean true"
else if x == false then "x is boolean false"
else if x == null then "x is null"
else "x is probably a string starting, starting characters: ${__substring 0 50 x}..";
else "x is probably a string starting, starting characters: ${substring 0 50 x}..";
# trace the arguments passed to function and its result
traceCall = n : f : a : let t = n2 : x : traceShowValMarked "${n} ${n2}:" x; in t "result" (f (t "arg 1" a));
traceCall2 = n : f : a : b : let t = n2 : x : traceShowValMarked "${n} ${n2}:" x; in t "result" (f (t "arg 1" a) (t "arg 2" b));

View File

@ -1,4 +1,7 @@
let lib = import ./default.nix; in
let lib = import ./default.nix;
inherit (builtins) isFunction hasAttr getAttr head tail isList isAttrs attrNames;
in
with import ./lists.nix;
with import ./attrsets.nix;
@ -53,7 +56,7 @@ rec {
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 (__isFunction initial) then initial else (fixed : initial); # transform initial to an expression always taking the fixed argument
takeFixed = if (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);
@ -61,9 +64,9 @@ rec {
fun = n : x :
let newArgs = fixed :
let args = takeFixed fixed;
mergeFun = __getAttr n args;
in if __isAttrs x then (mergeFun args x)
else assert __isFunction x;
mergeFun = getAttr n args;
in if isAttrs x then (mergeFun args x)
else assert isFunction x;
mergeFun args (x ( args // { inherit fixed; }));
in overridableDelayableArgs f newArgs;
in
@ -302,15 +305,15 @@ rec {
fold lib.mergeAttrs {} [
x y
(mapAttrs ( a : v : # merge special names using given functions
if (__hasAttr a x)
then if (__hasAttr a y)
then v (__getAttr a x) (__getAttr a y) # both have attr, use merge func
else (__getAttr a x) # only x has attr
else (__getAttr a y) # only y has attr)
if (hasAttr a x)
then if (hasAttr a y)
then v (getAttr a x) (getAttr a y) # both have attr, use merge func
else (getAttr a x) # only x has attr
else (getAttr a y) # only y has attr)
) (removeAttrs mergeAttrBy2
# don't merge attrs which are neither in x nor y
(filter (a : (! __hasAttr a x) && (! __hasAttr a y) )
(__attrNames mergeAttrBy2))
(filter (a : (! hasAttr a x) && (! hasAttr a y) )
(attrNames mergeAttrBy2))
)
)
];
@ -326,8 +329,8 @@ rec {
# pick attrs subset_attr_names and apply f
subsetmap = f : attrs : subset_attr_names :
listToAttrs (fold ( attr : r : if __hasAttr attr attrs
then r ++ [ ( nameValuePair attr ( f (__getAttr attr attrs) ) ) ] else r ) []
listToAttrs (fold ( attr : r : if hasAttr attr attrs
then r ++ [ ( nameValuePair attr ( f (getAttr attr attrs) ) ) ] else r ) []
subset_attr_names );
# prepareDerivationArgs tries to make writing configurable derivations easier
@ -371,7 +374,7 @@ rec {
// args2.cfg;
opts = flattenAttrs (mapAttrs (a : v :
let v2 = if (v ? set || v ? unset) then v else { set = v; };
n = if (__getAttr (flagName a) cfgWithDefaults) then "set" else "unset";
n = if (getAttr (flagName a) cfgWithDefaults) then "set" else "unset";
attr = maybeAttr n {} v2; in
if (maybeAttr "assertion" true attr)
then attr
@ -387,11 +390,11 @@ rec {
let eqListStrict = a : b :
if (a == []) != (b == []) then false
else if a == [] then true
else eqStrict (__head a) (__head b) && eqListStrict (__tail a) (__tail b);
else eqStrict (head a) (head b) && eqListStrict (tail a) (tail b);
in
if __isList a && __isList b then eqListStrict a b
else if __isAttrs a && isAttrs b then
(eqListStrict (__attrNames a) (__attrNames b))
if isList a && isList b then eqListStrict a b
else if isAttrs a && isAttrs b then
(eqListStrict (attrNames a) (attrNames b))
&& (eqListStrict (lib.attrValues a) (lib.attrValues b))
else a == b; # FIXME !
}

View File

@ -1,6 +1,10 @@
/* String manipulation functions. */
let lib = import ./default.nix; in
let lib = import ./default.nix;
inherit (builtins) substring add sub stringLength;
in
rec {
inherit (builtins) stringLength substring head tail lessThan sub;
@ -86,10 +90,10 @@ rec {
if s == "" then "" else
let takeTillSlash = left : c : s :
if left == 0 then s
else if (__substring left 1 s == "/") then
(__substring (__add left 1) (__sub c 1) s)
else takeTillSlash (__sub left 1) (__add c 1) s; in
takeTillSlash (__sub (__stringLength s) 1) 1 s;
else if (substring left 1 s == "/") then
(substring (add left 1) (sub c 1) s)
else takeTillSlash (sub left 1) (add c 1) s; in
takeTillSlash (sub (stringLength s) 1) 1 s;
# Compares strings not requiring context equality
# Obviously, a workaround but works on all Nix versions

View File

@ -1,3 +1,4 @@
let inherit (builtins) add; in
with import ./default.nix;
runTests {
@ -69,14 +70,14 @@ runTests {
res4 = let x = defaultOverridableDelayableArgs id { a = 7; };
in (x.merge) ( x: { b = 10; });
res5 = let x = defaultOverridableDelayableArgs id { a = 7; };
in (x.merge) ( x: { a = __add x.a 3; });
res6 = let x = defaultOverridableDelayableArgs id { a = 7; mergeAttrBy = { a = __add; }; };
in (x.merge) ( x: { a = add x.a 3; });
res6 = let x = defaultOverridableDelayableArgs id { a = 7; mergeAttrBy = { a = add; }; };
y = x.merge {};
in (y.merge) { a = 10; };
resRem7 = res6.replace (a : removeAttrs a ["a"]);
resReplace6 = let x = defaultOverridableDelayableArgs id { a = 7; mergeAttrBy = { a = __add; }; };
resReplace6 = let x = defaultOverridableDelayableArgs id { a = 7; mergeAttrBy = { a = add; }; };
x2 = x.merge { a = 20; }; # now we have 27
in (x2.replace) { a = 10; }; # and override the value by 10

View File

@ -12,8 +12,9 @@
args: with args; with args.lib;
let
inherit (builtins) getAttr attrNames;
toConfigLine = name : set :
"[(\"name\",\"${name}\")," + ( concatStringsSep "," (map (a: "(\"${a}\",\"${__getAttr a set}\")" ) (__attrNames set)))+"]";
"[(\"name\",\"${name}\")," + ( concatStringsSep "," (map (a: "(\"${a}\",\"${getAttr a set}\")" ) (attrNames set)))+"]";
config = pkgs.writeText "nix-repository-manager_config"
(bleedingEdgeRepos.managedRepoDir+"\n" +
concatStringsSep "\n" (mapRecordFlatten toConfigLine (bleedingEdgeRepos.repos)));

View File

@ -47,7 +47,7 @@ rec {
inherit searchRelativeTo;
# Forces rebuilds.
hack = __currentTime;
hack = builtins.currentTime;
};

View File

@ -1794,11 +1794,11 @@ let
libraries =
# core_libs distributed with this ghc version
(lib.flattenAttrs ghcsAndLibs.ghc68.core_libs)
# (map ( a : __getAttr a ghcsAndLibs.ghc68.core_libs ) [ "cabal" "mtl" "base" ]
# (map ( a : builtins.getAttr a ghcsAndLibs.ghc68.core_libs ) [ "cabal" "mtl" "base" ]
# some extra libs
++ (lib.flattenAttrs (ghc68extraLibs ghcsAndLibs.ghc68) );
# ++ map ( a : __getAttr a (ghc68extraLibs ghcsAndLibs.ghc68 ) ) [ "mtl" "parsec" ... ]
# ++ map ( a : builtins.getAttr a (ghc68extraLibs ghcsAndLibs.ghc68 ) ) [ "mtl" "parsec" ... ]
inherit ghc;
};