Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into nix-2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Feb 22, 2018
2 parents fab1218 + 186c765 commit d12c991
Show file tree
Hide file tree
Showing 1,451 changed files with 38,254 additions and 19,355 deletions.
8 changes: 2 additions & 6 deletions doc/languages-frameworks/haskell.md
Expand Up @@ -334,14 +334,10 @@ navigate there.

Finally, you can run
```shell
hoogle server -p 8080
hoogle server -p 8080 --local
```
and navigate to http://localhost:8080/ for your own local
[Hoogle](https://www.haskell.org/hoogle/). Note, however, that Firefox and
possibly other browsers disallow navigation from `http:` to `file:` URIs for
security reasons, which might be quite an inconvenience. See [this
page](http://kb.mozillazine.org/Links_to_local_pages_do_not_work) for
workarounds.
[Hoogle](https://www.haskell.org/hoogle/).

### How to build a Haskell project using Stack

Expand Down
35 changes: 33 additions & 2 deletions doc/languages-frameworks/rust.md
Expand Up @@ -58,6 +58,8 @@ To install crates with nix there is also an experimental project called

## Compiling Rust crates using Nix instead of Cargo

### Simple operation

When run, `cargo build` produces a file called `Cargo.lock`,
containing pinned versions of all dependencies. Nixpkgs contains a
tool called `carnix` (`nix-env -iA nixos.carnix`), which can be used
Expand Down Expand Up @@ -153,6 +155,8 @@ Here, the `libc` crate has no `src` attribute, so `buildRustCrate`
will fetch it from [crates.io](https://crates.io). A `sha256`
attribute is still needed for Nix purity.

### Handling external dependencies

Some crates require external libraries. For crates from
[crates.io](https://crates.io), such libraries can be specified in
`defaultCrateOverrides` package in nixpkgs itself.
Expand Down Expand Up @@ -210,7 +214,10 @@ with import <nixpkgs> {};
}
```

Three more parameters can be overridden:
### Options and phases configuration

Actually, the overrides introduced in the previous section are more
general. A number of other parameters can be overridden:

- The version of rustc used to compile the crate:

Expand All @@ -232,6 +239,30 @@ Three more parameters can be overridden:
(hello {}).override { verbose = false; };
```

- Extra arguments to be passed to `rustc`:

```
(hello {}).override { extraRustcOpts = "-Z debuginfo=2"; };
```

- Phases, just like in any other derivation, can be specified using
the following attributes: `preUnpack`, `postUnpack`, `prePatch`,
`patches`, `postPatch`, `preConfigure` (in the case of a Rust crate,
this is run before calling the "build" script), `postConfigure`
(after the "build" script),`preBuild`, `postBuild`, `preInstall` and
`postInstall`. As an example, here is how to create a new module
before running the build script:

```
(hello {}).override {
preConfigure = ''
echo "pub const PATH=\"${hi.out}\";" >> src/path.rs"
'';
};
```

### Features

One can also supply features switches. For example, if we want to
compile `diesel_cli` only with the `postgres` feature, and no default
features, we would write:
Expand All @@ -243,7 +274,7 @@ features, we would write:
}
```


Where `diesel.nix` is the file generated by Carnix, as explained above.

## Using the Rust nightlies overlay

Expand Down
26 changes: 26 additions & 0 deletions doc/package-notes.xml
Expand Up @@ -660,6 +660,32 @@ cp ${myEmacsConfig} $out/share/emacs/site-lisp/default.el
passing <command>-q</command> to the Emacs command.
</para>

<para>
Sometimes <varname>emacsWithPackages</varname> is not enough, as
this package set has some priorities imposed on packages (with
the lowest priority assigned to Melpa Unstable, and the highest for
packages manually defined in
<filename>pkgs/top-level/emacs-packages.nix</filename>). But you
can't control this priorities when some package is installed as a
dependency. You can override it on per-package-basis, providing all
the required dependencies manually - but it's tedious and there is
always a possibility that an unwanted dependency will sneak in
through some other package. To completely override such a package
you can use <varname>overrideScope</varname>.
</para>

<screen>
overrides = super: self: rec {
haskell-mode = self.melpaPackages.haskell-mode;
...
};
((emacsPackagesNgGen emacs).overrideScope overrides).emacsWithPackages (p: with p; [
# here both these package will use haskell-mode of our own choice
ghc-mod
dante
])
</screen>

</section>

</section>
Expand Down
14 changes: 14 additions & 0 deletions doc/stdenv.xml
Expand Up @@ -1802,6 +1802,20 @@ addEnvHooks "$hostOffset" myBashFunction
disabled or patched to work with PaX.</para></listitem>
</varlistentry>

<varlistentry>
<term>autoPatchelfHook</term>
<listitem><para>This is a special setup hook which helps in packaging
proprietary software in that it automatically tries to find missing shared
library dependencies of ELF files. All packages within the
<envar>runtimeDependencies</envar> environment variable are unconditionally
added to executables, which is useful for programs that use
<citerefentry>
<refentrytitle>dlopen</refentrytitle>
<manvolnum>3</manvolnum>
</citerefentry>
to load libraries at runtime.</para></listitem>
</varlistentry>

</variablelist>

</para>
Expand Down
7 changes: 4 additions & 3 deletions lib/default.nix
Expand Up @@ -56,7 +56,8 @@ let
replaceStrings seq stringLength sub substring tail;
inherit (trivial) id const concat or and boolToString mergeAttrs
flip mapNullable inNixShell min max importJSON warn info
nixpkgsVersion mod functionArgs setFunctionArgs isFunction;
nixpkgsVersion mod compare splitByAndCompare
functionArgs setFunctionArgs isFunction;

inherit (fixedPoints) fix fix' extends composeExtensions
makeExtensible makeExtensibleWithCustomName;
Expand All @@ -71,8 +72,8 @@ let
inherit (lists) singleton foldr fold foldl foldl' imap0 imap1
concatMap flatten remove findSingle findFirst any all count
optional optionals toList range partition zipListsWith zipLists
reverseList listDfs toposort sort take drop sublist last init
crossLists unique intersectLists subtractLists
reverseList listDfs toposort sort compareLists take drop sublist
last init crossLists unique intersectLists subtractLists
mutuallyExclusive;
inherit (strings) concatStrings concatMapStrings concatImapStrings
intersperse concatStringsSep concatMapStringsSep
Expand Down
24 changes: 22 additions & 2 deletions lib/licenses.nix
Expand Up @@ -2,7 +2,7 @@
let

spdx = lic: lic // {
url = "http://spdx.org/licenses/${lic.spdxId}";
url = "http://spdx.org/licenses/${lic.spdxId}.html";
};

in
Expand Down Expand Up @@ -79,6 +79,11 @@ lib.mapAttrs (n: v: v // { shortName = n; }) rec {
fullName = ''Beerware License'';
};

bsd0 = spdx {
spdxId = "0BSD";
fullName = "BSD Zero Clause License";
};

bsd2 = spdx {
spdxId = "BSD-2-Clause";
fullName = ''BSD 2-clause "Simplified" License'';
Expand All @@ -94,6 +99,11 @@ lib.mapAttrs (n: v: v // { shortName = n; }) rec {
fullName = ''BSD 4-clause "Original" or "Old" License'';
};

clArtistic = spdx {
spdxId = "ClArtistic";
fullName = "Clarified Artistic License";
};

cc0 = spdx {
spdxId = "CC0-1.0";
fullName = "Creative Commons Zero v1.0 Universal";
Expand Down Expand Up @@ -482,6 +492,12 @@ lib.mapAttrs (n: v: v // { shortName = n; }) rec {
fullName = "PostgreSQL License";
};

postman = {
fullName = "Postman EULA";
url = https://www.getpostman.com/licenses/postman_base_app;
free = false;
};

psfl = spdx {
spdxId = "Python-2.0";
fullName = "Python Software Foundation License version 2";
Expand Down Expand Up @@ -569,6 +585,11 @@ lib.mapAttrs (n: v: v // { shortName = n; }) rec {
fullName = "Vovida Software License v1.0";
};

watcom = spdx {
spdxId = "Watcom-1.0";
fullName = "Sybase Open Watcom Public License 1.0";
};

w3c = spdx {
spdxId = "W3C";
fullName = "W3C Software Notice and License";
Expand Down Expand Up @@ -603,5 +624,4 @@ lib.mapAttrs (n: v: v // { shortName = n; }) rec {
spdxId = "ZPL-2.1";
fullName = "Zope Public License 2.1";
};

}
32 changes: 30 additions & 2 deletions lib/lists.nix
Expand Up @@ -385,6 +385,30 @@ rec {
if len < 2 then list
else (sort strictLess pivot.left) ++ [ first ] ++ (sort strictLess pivot.right));

/* Compare two lists element-by-element.
Example:
compareLists compare [] []
=> 0
compareLists compare [] [ "a" ]
=> -1
compareLists compare [ "a" ] []
=> 1
compareLists compare [ "a" "b" ] [ "a" "c" ]
=> 1
*/
compareLists = cmp: a: b:
if a == []
then if b == []
then 0
else -1
else if b == []
then 1
else let rel = cmp (head a) (head b); in
if rel == 0
then compareLists cmp (tail a) (tail b)
else rel;

/* Return the first (at most) N elements of a list.
Example:
Expand Down Expand Up @@ -440,8 +464,12 @@ rec {
init = list: assert list != []; take (length list - 1) list;


/* FIXME(zimbatm) Not used anywhere
*/
/* return the image of the cross product of some lists by a function
Example:
crossLists (x:y: "${toString x}${toString y}") [[1 2] [3 4]]
=> [ "13" "14" "23" "24" ]
*/
crossLists = f: foldl (fs: args: concatMap (f: map f args) fs) [f];


Expand Down

0 comments on commit d12c991

Please sign in to comment.