Skip to content

Commit

Permalink
build the patched nix version and a few other additions,\nnamely also…
Browse files Browse the repository at this point in the history
… allow override in callPackagesWith (which doesn't use makeOverridable)\n support makeOverridable functor\nalso build 16.03 channel (not displaying yet)
  • Loading branch information
fkz committed Mar 7, 2016
1 parent 7283e09 commit 84483f1
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 10 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
NIXOS_VERSION = 15.09
NIXPKGS = https://nixos.org/channels/nixos-$(NIXOS_VERSION)/nixexprs.tar.xz
NIXPKGS_UNSTABLE = https://nixos.org/channels/nixos-16.03-beta/nixexprs.tar.xz

rwildcard=$(foreach d,$(wildcard $1*),$(call rwildcard,$d/,$2) $(filter $(subst *,%,$2),$d))

Expand All @@ -17,6 +18,7 @@ HTML = index.html news.html \
docs/papers.html \
nixops/index.html \
nixpkgs/packages.json.gz \
nixpkgs/packages-unstable.json.gz \
nixos/options.json.gz \
nix/install

Expand Down Expand Up @@ -161,6 +163,10 @@ endif
nixpkgs/packages.json.gz:
nixpkgs/packages.json-generation/generate-packages.json.gzip $@ $(NIXPKGS)

nixpkgs/packages-unstable.json.gz:
nixpkgs/packages.json-generation/generate-packages.json.gzip $@ $(NIXPKGS_UNSTABLE)


nixos/options.json.gz:
gzip -9 < $$(nix-build --no-out-link '<nixpkgs/nixos/release.nix>' -I nixpkgs=$(NIXPKGS) -A options)/share/doc/nixos/options.json > $@.tmp
mv $@.tmp $@
4 changes: 2 additions & 2 deletions nixpkgs/packages.json-generation/addAttrs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

let inherit (nixpkgs) lib;
forceCatch = error-handler: x:
let result = builtins.catch (builtins.deepSeq x x); in
let result = builtins.catch "EvalError" (builtins.deepSeq x x); in
if lib.isAttrs result && result ? type && result.type == "error" then error-handler result else result;
get-attribute = package: import ./get-attributes.nix { inherit (nixpkgs) lib; inherit package; };
info = x: forceCatch (x:x) {
Expand All @@ -18,7 +18,7 @@ let inherit (nixpkgs) lib;
parameters = get-attribute x;
};
mapRecursively = n: x:
forceCatch (error: [ ({ ${n + "(error)"} = { name = n; meta = { longDescription = error.message; }; }; }) ])
forceCatch (error: [ ({ ${n + "(error)"} = { name = n; inherit error; meta = { longDescription = error.message; }; }; }) ])
(if lib.isDerivation x then
[(lib.setAttrByPath [n] (info x))]
else if lib.isAttrs x then
Expand Down
17 changes: 14 additions & 3 deletions nixpkgs/packages.json-generation/generate-packages.json.gzip
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
#!/bin/sh
set -e
set -o pipefail
# hack to build nix
unset IN_NIX_SHELL
alias curl="curl --insecure"
# download nixpkgs and patch
nixpkgs=$(nix-instantiate --find-file nixpkgs -I nixpkgs=$2); \
pushd nixpkgs/packages.json-generation; \
rm -rf nixpkgs
rm -rf nixpkgs nix
cp -R $nixpkgs nixpkgs
chmod u+w -R nixpkgs
patch -p1 -d nixpkgs < nixpkgs.patch
# download and build patched nix version
rm -rf nix
curl -L https://github.com/fkz/nix/archive/generate-nixos-packages.tar.gz | tar xz
mv nix-generate-nixos-packages nix
nix-build -A nixUnstable ./nixpkgs --arg config 'import ./nixUnstable.nix'
(echo -n '{ "commit": "' && cat nixpkgs/.git-revision && echo -n '","packages":' \
&& ~/src/working-nix/inst/bin/nix-instantiate --expr --eval 'import ./addAttrs.nix {}' --strict --json --show-trace \
&& ./result/bin/nix-instantiate --eval --expr 'import ./addAttrs.nix {}' --strict --json --show-trace \
&& echo -n '}') \
| sed "s|$(pwd)/nixpkgs/||g" | sed "s|__elim__.||g" | gzip -9 > ../../$1.tmp
popd
echo "Written $1.tmp"
# gunzip < $1.tmp | python -mjson.tool
# gunzip < $1.stmp | python -mjson.tool

# I haven't gotten my system configured so it
# does the gzipping right
Expand Down
4 changes: 2 additions & 2 deletions nixpkgs/packages.json-generation/get-attributes.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ let
isSimple = x: builtins.isString x || builtins.isBool x || builtins.isInt x || builtins.isNull x;
protect = x: if isDerivation x then { type = "derivation"; } else if isSimple x then x else "(protected)";
arguments =
if !(package ? _function) then { error = "some error happened"; } else
if !(package ? _function) then { error = "This derivation seems not to use lib.makeOverridable, so parameters couldn't be determined"; } else
let f = name: isOptional: if builtins.hasAttr name package.origArgs then protect package.origArgs.${name} else if isOptional then "(optional)" else { type = "derivation"; }; in
lib.mapAttrs f (builtins.functionArgs package._function);
lib.mapAttrs f package._functionArgs;
isDerivation = x:
lib.isDerivation x || lib.isFunction x ||
(if lib.isList x then lib.any isDerivation x
Expand Down
18 changes: 15 additions & 3 deletions nixpkgs/packages.json-generation/nixpkgs.patch
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,30 @@ diff --git a/lib/customisation.nix b/lib/customisation.nix
index 5854954..57995a4 100644
--- a/lib/customisation.nix
+++ b/lib/customisation.nix
@@ -60,9 +60,14 @@ rec {
@@ -60,9 +60,15 @@ rec {
{ override = newArgs: makeOverridable f (overrideWith newArgs);
overrideDerivation = fdrv:
makeOverridable (args: overrideDerivation (f args) fdrv) origArgs;
+ inherit origArgs;
+ _function = if lib.isFunction f then f else f._function;
+
+ _functionArgs = builtins.functionArgs f;
})
else if builtins.isFunction ff then
{ override = newArgs: makeOverridable f (overrideWith newArgs);
+ inherit origArgs;
+ _function = if lib.isFunction f then f else f._function;
__functor = self: ff;
+ _functionArgs = builtins.functionArgs f;
+ __functor = self: args: let result = makeOverridable ff args; in result // { origArgs = origArgs // result.origArgs; _functionArgs = builtins.functionArgs f // result._functionArgs; };
- __functor = self: ff;
overrideDerivation = throw "overrideDerivation not yet supported for functors";
}
@@ -112,5 +119,9 @@
pkgs = f finalArgs;
mkAttrOverridable = name: pkg: pkg // {
override = newArgs: mkAttrOverridable name (f (finalArgs // newArgs)).${name};
+ _function = if lib.isFunction f then f else f._function;
+ _functionArgs = builtins.functionArgs f;
+ _functionArgs = builtins.functionArgs f;
+ origArgs = finalArgs;
};
in lib.mapAttrs mkAttrOverridable pkgs;

0 comments on commit 84483f1

Please sign in to comment.