-
-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WIP: Displaying package parameters #78
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ab7da43
Add package parameters to list of packages
fkz f24b6ec
patch nixpkgs
fkz 0e0cbb3
fix last commit
fkz b7f5344
generate package parameter info.This currently uses a hardcoded path …
fkz d13dd46
build the patched nix version and a few other additions
fkz 6fa8a66
search for parameters, better error catching (so an error inside of a…
fkz 8193c64
do gzipping
fkz ccc0caf
fix duplicated event handlers
fkz 9080c0d
fix javascript
fkz d199294
use fetchTarball to build nix
fkz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
NIXOS_VERSION = 16.03 | ||
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)) | ||
|
||
|
@@ -15,7 +16,11 @@ HTML = index.html news.html \ | |
disnix/index.html disnix/download.html disnix/docs.html \ | ||
disnix/extensions.html disnix/examples.html disnix/support.html \ | ||
docs/papers.html \ | ||
nixops/index.html | ||
nixops/index.html \ | ||
nixpkgs/packages.json.gz \ | ||
nixpkgs/packages-unstable.json.gz \ | ||
nixos/options.json.gz \ | ||
nix/install | ||
|
||
|
||
### Prettify the NixOS manual. | ||
|
@@ -160,13 +165,11 @@ ifeq ($(UPDATE), 1) | |
endif | ||
|
||
nixpkgs/packages.json.gz: | ||
nixpkgs=$$(nix-instantiate --find-file nixpkgs -I nixpkgs=$(NIXPKGS)); \ | ||
(echo -n '{ "commit": "' && cat $$nixpkgs/.git-revision && echo -n '","packages":' \ | ||
&& nix-env -f '<nixpkgs>' -I nixpkgs=$(NIXPKGS) -qa --json --arg config '{}' \ | ||
&& echo -n '}') \ | ||
| sed "s|$$nixpkgs/||g" | gzip -9 > [email protected] | ||
gunzip < [email protected] | python -mjson.tool > /dev/null | ||
mv [email protected] $@ | ||
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 > [email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
let config = { | ||
config = { | ||
allowBroken = true; | ||
allowUnfree = true; | ||
}; | ||
}; in | ||
{ nixpkgs ? import ./nixpkgs config }: | ||
|
||
let inherit (nixpkgs) lib; | ||
forceCatch = error-handler: x: | ||
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 package forceCatch lib; }; | ||
info = x: { | ||
name = x.name; | ||
system = x.system; | ||
meta = x.meta; | ||
parameters = forceCatch (x: x) (get-attribute x); | ||
}; | ||
mapRecursively = n: x: | ||
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 | ||
if x ? "recurseForDerivations" && x.recurseForDerivations then | ||
lib.concatMap (name: mapRecursively "${n}.${name}" x.${name}) (lib.attrNames x) | ||
else | ||
[] | ||
else if lib.isList x then | ||
[] # map (mapRecursively "${n}.list") x | ||
else []); in | ||
lib.zipAttrsWith (name: values: lib.head values) | ||
(mapRecursively "__elim__" (nixpkgs // { recurseForDerivations = true; })) |
22 changes: 22 additions & 0 deletions
22
nixpkgs/packages.json-generation/generate-packages.json.gzip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/sh | ||
set -e | ||
set -o pipefail | ||
# hack to build nix | ||
unset IN_NIX_SHELL | ||
# download nixpkgs and patch | ||
nixpkgs=$(nix-instantiate --find-file nixpkgs -I nixpkgs=$2); \ | ||
pushd nixpkgs/packages.json-generation; \ | ||
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 | ||
nix-build -A nixUnstable ./nixpkgs --arg config 'import ./nixUnstable.nix' | ||
(echo -n '{ "commit": "' && cat nixpkgs/.git-revision && echo -n '","packages":' \ | ||
&& ./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.stmp | python -mjson.tool | ||
mv $1.tmp $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ lib, forceCatch | ||
, package }: | ||
|
||
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 ? _functionArgs) then { error = "This derivation seems not to use lib.makeOverridable, so parameters couldn't be determined"; } else | ||
let f = name: isOptional: | ||
forceCatch (x: x // { type = "derivation"; }) | ||
(if builtins.hasAttr name package.origArgs | ||
then protect package.origArgs.${name} | ||
else if isOptional then "(optional)" else { type = "derivation"; }); in | ||
lib.mapAttrs f package._functionArgs; | ||
isDerivation = x: | ||
lib.isDerivation x || lib.isFunction x || | ||
(if lib.isList x then lib.any isDerivation x | ||
else if lib.isAttrs x then lib.any isDerivation (lib.attrValues x) | ||
else false); | ||
result = lib.filterAttrs (x: y: !isDerivation y) arguments; | ||
in result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
let path-to-nix = builtins.fetchTarball https://github.com/fkz/nix/archive/generate-nixos-packages.tar.gz; in { | ||
packageOverrides = pkgs: { | ||
nixUnstable = pkgs.lib.overrideDerivation pkgs.nixUnstable (old: rec { | ||
name = "nix-${version}"; | ||
version = builtins.readFile (path-to-nix + "/version"); | ||
src = (import "${path-to-nix}/release.nix" {}).tarball + "/tarballs/${name}pre1234_abcdef.tar.xz"; | ||
}); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
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,13 @@ rec { | ||
{ override = newArgs: makeOverridable f (overrideWith newArgs); | ||
overrideDerivation = fdrv: | ||
makeOverridable (args: overrideDerivation (f args) fdrv) origArgs; | ||
+ inherit origArgs; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe we shouldn't inherit, it's a bit dangerous. |
||
+ _functionArgs = builtins.functionArgs f; | ||
}) | ||
else if builtins.isFunction ff then | ||
{ override = newArgs: makeOverridable f (overrideWith newArgs); | ||
+ inherit origArgs; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here |
||
+ _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,7 @@ | ||
pkgs = f finalArgs; | ||
mkAttrOverridable = name: pkg: pkg // { | ||
override = newArgs: mkAttrOverridable name (f (finalArgs // newArgs)).${name}; | ||
+ _functionArgs = builtins.functionArgs f; | ||
+ origArgs = finalArgs; | ||
}; | ||
in lib.mapAttrs mkAttrOverridable pkgs; |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should raise an error, or actually recurse over it.