diff --git a/doc/coding-conventions.xml b/doc/coding-conventions.xml index d556c7ebe1ed..f244c11d4f20 100644 --- a/doc/coding-conventions.xml +++ b/doc/coding-conventions.xml @@ -1,56 +1,59 @@ + Coding conventions +
+ Syntax -Coding conventions - - -
Syntax - - - - Use 2 spaces of indentation per indentation level in - Nix expressions, 4 spaces in shell scripts. - - Do not use tab characters, i.e. configure your - editor to use soft tabs. For instance, use (setq-default - indent-tabs-mode nil) in Emacs. Everybody has different - tab settings so it’s asking for trouble. - - Use lowerCamelCase for variable - names, not UpperCamelCase. Note, this rule does - not apply to package attribute names, which instead follow the rules - in . - - Function calls with attribute set arguments are - written as - + + + + Use 2 spaces of indentation per indentation level in Nix expressions, 4 + spaces in shell scripts. + + + + + Do not use tab characters, i.e. configure your editor to use soft tabs. + For instance, use (setq-default indent-tabs-mode nil) + in Emacs. Everybody has different tab settings so it’s asking for + trouble. + + + + + Use lowerCamelCase for variable names, not + UpperCamelCase. Note, this rule does not apply to + package attribute names, which instead follow the rules in + . + + + + + Function calls with attribute set arguments are written as foo { arg = ...; } - - not - + not foo { arg = ...; } - - Also fine is - + Also fine is foo { arg = ...; } - - if it's a short call. - - In attribute sets or lists that span multiple lines, - the attribute names or list elements should be aligned: - + if it's a short call. + + + + + In attribute sets or lists that span multiple lines, the attribute names + or list elements should be aligned: # A long list. list = @@ -73,12 +76,11 @@ attrs = { if true then big_expr else big_expr; }; - - - - Short lists or attribute sets can be written on one - line: - + + + + + Short lists or attribute sets can be written on one line: # A short list. list = [ elem1 elem2 elem3 ]; @@ -86,66 +88,58 @@ list = [ elem1 elem2 elem3 ]; # A short set. attrs = { x = 1280; y = 1024; }; - - - - Breaking in the middle of a function argument can - give hard-to-read code, like - + + + + + Breaking in the middle of a function argument can give hard-to-read code, + like someFunction { x = 1280; y = 1024; } otherArg yetAnotherArg - - (especially if the argument is very large, spanning multiple - lines). - - Better: - + (especially if the argument is very large, spanning multiple lines). + + + Better: someFunction { x = 1280; y = 1024; } otherArg yetAnotherArg - - or - + or let res = { x = 1280; y = 1024; }; in someFunction res otherArg yetAnotherArg - - - - The bodies of functions, asserts, and withs are not - indented to prevent a lot of superfluous indentation levels, i.e. - + + + + + The bodies of functions, asserts, and withs are not indented to prevent a + lot of superfluous indentation levels, i.e. { arg1, arg2 }: assert system == "i686-linux"; stdenv.mkDerivation { ... - - not - + not { arg1, arg2 }: assert system == "i686-linux"; stdenv.mkDerivation { ... - - - - Function formal arguments are written as: - + + + + + Function formal arguments are written as: { arg1, arg2, arg3 }: - - but if they don't fit on one line they're written as: - + but if they don't fit on one line they're written as: { arg1, arg2, arg3 , arg4, ... @@ -153,35 +147,28 @@ stdenv.mkDerivation { ... argN }: - - - - Functions should list their expected arguments as - precisely as possible. That is, write - + + + + + Functions should list their expected arguments as precisely as possible. + That is, write { stdenv, fetchurl, perl }: ... - - instead of - + instead of args: with args; ... - - or - + or { stdenv, fetchurl, perl, ... }: ... - - - - For functions that are truly generic in the number of - arguments (such as wrappers around mkDerivation) - that have some required arguments, you should write them using an - @-pattern: - + + + For functions that are truly generic in the number of arguments (such as + wrappers around mkDerivation) that have some required + arguments, you should write them using an @-pattern: { stdenv, doCoverageAnalysis ? false, ... } @ args: @@ -189,9 +176,7 @@ stdenv.mkDerivation (args // { ... if doCoverageAnalysis then "bla" else "" ... }) - - instead of - + instead of args: @@ -199,432 +184,557 @@ args.stdenv.mkDerivation (args // { ... if args ? doCoverageAnalysis && args.doCoverageAnalysis then "bla" else "" ... }) + + + +
+
+ Package naming - - - - -
- - -
Package naming - -In Nixpkgs, there are generally three different names associated with a package: - - - - The name attribute of the - derivation (excluding the version part). This is what most users - see, in particular when using - nix-env. - - The variable name used for the instantiated package - in all-packages.nix, and when passing it as a - dependency to other functions. Typically this is called the - package attribute name. This is what Nix - expression authors see. It can also be used when installing using - nix-env -iA. - - The filename for (the directory containing) the Nix - expression. - - - -Most of the time, these are the same. For instance, the package -e2fsprogs has a name attribute -"e2fsprogs-version", is -bound to the variable name e2fsprogs in -all-packages.nix, and the Nix expression is in -pkgs/os-specific/linux/e2fsprogs/default.nix. - - -There are a few naming guidelines: - - - - Generally, try to stick to the upstream package - name. - - Don’t use uppercase letters in the - name attribute — e.g., - "mplayer-1.0rc2" instead of - "MPlayer-1.0rc2". - - The version part of the name - attribute must start with a digit (following a - dash) — e.g., "hello-0.3.1rc2". - - If a package is not a release but a commit from a repository, then - the version part of the name must be the date of that - (fetched) commit. The date must be in "YYYY-MM-DD" format. - Also append "unstable" to the name - e.g., - "pkgname-unstable-2014-09-23". - - Dashes in the package name should be preserved in - new variable names, rather than converted to underscores or camel - cased — e.g., http-parser instead of - http_parser or httpParser. The - hyphenated style is preferred in all three package - names. - - If there are multiple versions of a package, this - should be reflected in the variable names in - all-packages.nix, - e.g. json-c-0-9 and json-c-0-11. - If there is an obvious “default” version, make an attribute like - json-c = json-c-0-9;. - See also - - - - - -
- - -
File naming and organisation - -Names of files and directories should be in lowercase, with -dashes between words — not in camel case. For instance, it should be -all-packages.nix, not -allPackages.nix or -AllPackages.nix. - -
Hierarchy - -Each package should be stored in its own directory somewhere in -the pkgs/ tree, i.e. in -pkgs/category/subcategory/.../pkgname. -Below are some rules for picking the right category for a package. -Many packages fall under several categories; what matters is the -primary purpose of a package. For example, the -libxml2 package builds both a library and some -tools; but it’s a library foremost, so it goes under -pkgs/development/libraries. - -When in doubt, consider refactoring the -pkgs/ tree, e.g. creating new categories or -splitting up an existing category. - - - - If it’s used to support software development: + + In Nixpkgs, there are generally three different names associated with a + package: + - - - If it’s a library used by other packages: - - development/libraries (e.g. libxml2) - - - - If it’s a compiler: - - development/compilers (e.g. gcc) - - - - If it’s an interpreter: - - development/interpreters (e.g. guile) - - - - If it’s a (set of) development tool(s): - - - - If it’s a parser generator (including lexers): - - development/tools/parsing (e.g. bison, flex) - - - - If it’s a build manager: - - development/tools/build-managers (e.g. gnumake) - - - - Else: - - development/tools/misc (e.g. binutils) - - - - - - - Else: - - development/misc - - - + + The name attribute of the derivation (excluding the + version part). This is what most users see, in particular when using + nix-env. + - - - If it’s a (set of) tool(s): - (A tool is a relatively small program, especially one intended - to be used non-interactively.) + + The variable name used for the instantiated package in + all-packages.nix, and when passing it as a + dependency to other functions. Typically this is called the + package attribute name. This is what Nix expression + authors see. It can also be used when installing using nix-env + -iA. + + + + + The filename for (the directory containing) the Nix expression. + + + + Most of the time, these are the same. For instance, the package + e2fsprogs has a name attribute + "e2fsprogs-version", is bound + to the variable name e2fsprogs in + all-packages.nix, and the Nix expression is in + pkgs/os-specific/linux/e2fsprogs/default.nix. + + + + There are a few naming guidelines: + + + + Generally, try to stick to the upstream package name. + + + + + Don’t use uppercase letters in the name attribute + — e.g., "mplayer-1.0rc2" instead of + "MPlayer-1.0rc2". + + + + + The version part of the name attribute + must start with a digit (following a dash) — e.g., + "hello-0.3.1rc2". + + + + + If a package is not a release but a commit from a repository, then the + version part of the name must be the date of that + (fetched) commit. The date must be in "YYYY-MM-DD" + format. Also append "unstable" to the name - e.g., + "pkgname-unstable-2014-09-23". + + + + + Dashes in the package name should be preserved in new variable names, + rather than converted to underscores or camel cased — e.g., + http-parser instead of http_parser + or httpParser. The hyphenated style is preferred in + all three package names. + + + + + If there are multiple versions of a package, this should be reflected in + the variable names in all-packages.nix, e.g. + json-c-0-9 and json-c-0-11. If + there is an obvious “default” version, make an attribute like + json-c = json-c-0-9;. See also + + + + + +
+
+ File naming and organisation + + + Names of files and directories should be in lowercase, with dashes between + words — not in camel case. For instance, it should be + all-packages.nix, not + allPackages.nix or + AllPackages.nix. + + +
+ Hierarchy + + + Each package should be stored in its own directory somewhere in the + pkgs/ tree, i.e. in + pkgs/category/subcategory/.../pkgname. + Below are some rules for picking the right category for a package. Many + packages fall under several categories; what matters is the + primary purpose of a package. For example, the + libxml2 package builds both a library and some tools; + but it’s a library foremost, so it goes under + pkgs/development/libraries. + + + + When in doubt, consider refactoring the pkgs/ tree, + e.g. creating new categories or splitting up an existing category. + + + + + If it’s used to support software development: + - - If it’s for networking: - - tools/networking (e.g. wget) - - - - If it’s for text processing: - - tools/text (e.g. diffutils) - - - - If it’s a system utility, i.e., + + If it’s a library used by other packages: + + + development/libraries (e.g. + libxml2) + + + + + If it’s a compiler: + + + development/compilers (e.g. + gcc) + + + + + If it’s an interpreter: + + + development/interpreters (e.g. + guile) + + + + + If it’s a (set of) development tool(s): + + + + If it’s a parser generator (including lexers): + + + development/tools/parsing (e.g. + bison, flex) + + + + + If it’s a build manager: + + + development/tools/build-managers (e.g. + gnumake) + + + + + Else: + + + development/tools/misc (e.g. + binutils) + + + + + + + + Else: + + + development/misc + + + + + + + + If it’s a (set of) tool(s): + + + (A tool is a relatively small program, especially one intended to be + used non-interactively.) + + + + If it’s for networking: + + + tools/networking (e.g. + wget) + + + + + If it’s for text processing: + + + tools/text (e.g. diffutils) + + + + + If it’s a system utility, i.e., something related or essential to the operation of a system: - - tools/system (e.g. cron) - - - - If it’s an archiver (which may + + + tools/system (e.g. cron) + + + + + If it’s an archiver (which may include a compression function): - - tools/archivers (e.g. zip, tar) - - - - If it’s a compression program: - - tools/compression (e.g. gzip, bzip2) - - - - If it’s a security-related program: - - tools/security (e.g. nmap, gnupg) - - - - Else: - - tools/misc - - + + + tools/archivers (e.g. zip, + tar) + + + + + If it’s a compression program: + + + tools/compression (e.g. + gzip, bzip2) + + + + + If it’s a security-related program: + + + tools/security (e.g. nmap, + gnupg) + + + + + Else: + + + tools/misc + + + - - - - If it’s a shell: - - shells (e.g. bash) - - - - If it’s a server: - + + + + If it’s a shell: + + + shells (e.g. bash) + + + + + If it’s a server: + - - If it’s a web server: - - servers/http (e.g. apache-httpd) - - - - If it’s an implementation of the X Windowing System: - - servers/x11 (e.g. xorg — this includes the client libraries and programs) - - - - Else: - - servers/misc - - + + If it’s a web server: + + + servers/http (e.g. + apache-httpd) + + + + + If it’s an implementation of the X Windowing System: + + + servers/x11 (e.g. xorg — + this includes the client libraries and programs) + + + + + Else: + + + servers/misc + + + - - - - If it’s a desktop environment: - - desktops (e.g. kde, gnome, enlightenment) - - - - If it’s a window manager: - - applications/window-managers (e.g. awesome, stumpwm) - - - - If it’s an application: - - A (typically large) program with a distinct user - interface, primarily used interactively. + + + + If it’s a desktop environment: + + + desktops (e.g. kde, + gnome, enlightenment) + + + + + If it’s a window manager: + + + applications/window-managers (e.g. + awesome, stumpwm) + + + + + If it’s an application: + + + A (typically large) program with a distinct user interface, primarily + used interactively. + - - If it’s a version management system: - - applications/version-management (e.g. subversion) - - - - If it’s for video playback / editing: - - applications/video (e.g. vlc) - - - - If it’s for graphics viewing / editing: - - applications/graphics (e.g. gimp) - - - - If it’s for networking: - - - - If it’s a mailreader: - - applications/networking/mailreaders (e.g. thunderbird) - - - - If it’s a newsreader: - - applications/networking/newsreaders (e.g. pan) - - - - If it’s a web browser: - - applications/networking/browsers (e.g. firefox) - - - - Else: - - applications/networking/misc - - - - - - - Else: - - applications/misc - - + + If it’s a version management system: + + + applications/version-management (e.g. + subversion) + + + + + If it’s for video playback / editing: + + + applications/video (e.g. + vlc) + + + + + If it’s for graphics viewing / editing: + + + applications/graphics (e.g. + gimp) + + + + + If it’s for networking: + + + + If it’s a mailreader: + + + applications/networking/mailreaders (e.g. + thunderbird) + + + + + If it’s a newsreader: + + + applications/networking/newsreaders (e.g. + pan) + + + + + If it’s a web browser: + + + applications/networking/browsers (e.g. + firefox) + + + + + Else: + + + applications/networking/misc + + + + + + + + Else: + + + applications/misc + + + - - - - If it’s data (i.e., does not have a + + + + If it’s data (i.e., does not have a straight-forward executable semantics): - + - - If it’s a font: - - data/fonts - - - - If it’s related to SGML/XML processing: - - - - If it’s an XML DTD: - - data/sgml+xml/schemas/xml-dtd (e.g. docbook) - - - - If it’s an XSLT stylesheet: - - (Okay, these are executable...) - data/sgml+xml/stylesheets/xslt (e.g. docbook-xsl) - - - - - + + If it’s a font: + + + data/fonts + + + + + If it’s related to SGML/XML processing: + + + + If it’s an XML DTD: + + + data/sgml+xml/schemas/xml-dtd (e.g. + docbook) + + + + + If it’s an XSLT stylesheet: + + + (Okay, these are executable...) + + + data/sgml+xml/stylesheets/xslt (e.g. + docbook-xsl) + + + + + + - - - - If it’s a game: - - games - - - - Else: - - misc - - - + + + + If it’s a game: + + + games + + + + + Else: + + + misc + + + + +
-
+
+ Versioning -
Versioning + + Because every version of a package in Nixpkgs creates a potential + maintenance burden, old versions of a package should not be kept unless + there is a good reason to do so. For instance, Nixpkgs contains several + versions of GCC because other packages don’t build with the latest + version of GCC. Other examples are having both the latest stable and latest + pre-release version of a package, or to keep several major releases of an + application that differ significantly in functionality. + -Because every version of a package in Nixpkgs creates a -potential maintenance burden, old versions of a package should not be -kept unless there is a good reason to do so. For instance, Nixpkgs -contains several versions of GCC because other packages don’t build -with the latest version of GCC. Other examples are having both the -latest stable and latest pre-release version of a package, or to keep -several major releases of an application that differ significantly in -functionality. + + If there is only one version of a package, its Nix expression should be + named e2fsprogs/default.nix. If there are multiple + versions, this should be reflected in the filename, e.g. + e2fsprogs/1.41.8.nix and + e2fsprogs/1.41.9.nix. The version in the filename + should leave out unnecessary detail. For instance, if we keep the latest + Firefox 2.0.x and 3.5.x versions in Nixpkgs, they should be named + firefox/2.0.nix and + firefox/3.5.nix, respectively (which, at a given + point, might contain versions 2.0.0.20 and + 3.5.4). If a version requires many auxiliary files, you + can use a subdirectory for each version, e.g. + firefox/2.0/default.nix and + firefox/3.5/default.nix. + -If there is only one version of a package, its Nix expression -should be named e2fsprogs/default.nix. If there -are multiple versions, this should be reflected in the filename, -e.g. e2fsprogs/1.41.8.nix and -e2fsprogs/1.41.9.nix. The version in the -filename should leave out unnecessary detail. For instance, if we -keep the latest Firefox 2.0.x and 3.5.x versions in Nixpkgs, they -should be named firefox/2.0.nix and -firefox/3.5.nix, respectively (which, at a given -point, might contain versions 2.0.0.20 and -3.5.4). If a version requires many auxiliary -files, you can use a subdirectory for each version, -e.g. firefox/2.0/default.nix and -firefox/3.5/default.nix. + + All versions of a package must be included in + all-packages.nix to make sure that they evaluate + correctly. + +
+
+
+ Fetching Sources -All versions of a package must be included -in all-packages.nix to make sure that they -evaluate correctly. - -
- -
-
Fetching Sources - There are multiple ways to fetch a package source in nixpkgs. The - general guideline is that you should package sources with a high degree of - availability. Right now there is only one fetcher which has mirroring - support and that is fetchurl. Note that you should also - prefer protocols which have a corresponding proxy environment variable. + + There are multiple ways to fetch a package source in nixpkgs. The general + guideline is that you should package sources with a high degree of + availability. Right now there is only one fetcher which has mirroring + support and that is fetchurl. Note that you should also + prefer protocols which have a corresponding proxy environment variable. - You can find many source fetch helpers in pkgs/build-support/fetch*. + + + You can find many source fetch helpers in + pkgs/build-support/fetch*. - In the file pkgs/top-level/all-packages.nix you can - find fetch helpers, these have names on the form - fetchFrom*. The intention of these are to provide - snapshot fetches but using the same api as some of the version controlled - fetchers from pkgs/build-support/. As an example going - from bad to good: - - - Bad: Uses git:// which won't be proxied. + + + In the file pkgs/top-level/all-packages.nix you can find + fetch helpers, these have names on the form fetchFrom*. + The intention of these are to provide snapshot fetches but using the same + api as some of the version controlled fetchers from + pkgs/build-support/. As an example going from bad to + good: + + + + Bad: Uses git:// which won't be proxied. src = fetchgit { url = "git://github.com/NixOS/nix.git"; @@ -632,10 +742,11 @@ src = fetchgit { sha256 = "1cw5fszffl5pkpa6s6wjnkiv6lm5k618s32sp60kvmvpy7a2v9kg"; } - - - - Better: This is ok, but an archive fetch will still be faster. + + + + + Better: This is ok, but an archive fetch will still be faster. src = fetchgit { url = "https://github.com/NixOS/nix.git"; @@ -643,10 +754,11 @@ src = fetchgit { sha256 = "1cw5fszffl5pkpa6s6wjnkiv6lm5k618s32sp60kvmvpy7a2v9kg"; } - - - - Best: Fetches a snapshot archive and you get the rev you want. + + + + + Best: Fetches a snapshot archive and you get the rev you want. src = fetchFromGitHub { owner = "NixOS"; @@ -655,15 +767,19 @@ src = fetchFromGitHub { sha256 = "04yri911rj9j19qqqn6m82266fl05pz98inasni0vxr1cf1gdgv9"; } - - - + + + + +
+
+ Patches + + + Patches available online should be retrieved using + fetchpatch. -
-
Patches - Patches available online should be retrieved using - fetchpatch. patches = [ @@ -675,30 +791,54 @@ patches = [ ]; - Otherwise, you can add a .patch file to the - nixpkgs repository. In the interest of keeping our - maintenance burden to a minimum, only patches that are unique - to nixpkgs should be added in this way. - -patches = [ ./0001-changes.patch ]; - - If you do need to do create this sort of patch file, - one way to do so is with git: - - Move to the root directory of the source code - you're patching. -$ cd the/program/source - If a git repository is not already present, - create one and stage all of the source files. -$ git init -$ git add . - Edit some files to make whatever changes need - to be included in the patch. - Use git to create a diff, and pipe the output - to a patch file: -$ git diff > nixpkgs/pkgs/the/package/0001-changes.patch - - -
+ + Otherwise, you can add a .patch file to the + nixpkgs repository. In the interest of keeping our + maintenance burden to a minimum, only patches that are unique to + nixpkgs should be added in this way. + + + + +patches = [ ./0001-changes.patch ]; + + + + + If you do need to do create this sort of patch file, one way to do so is + with git: + + + + Move to the root directory of the source code you're patching. + +$ cd the/program/source + + + + + If a git repository is not already present, create one and stage all of + the source files. + +$ git init +$ git add . + + + + + Edit some files to make whatever changes need to be included in the + patch. + + + + + Use git to create a diff, and pipe the output to a patch file: + +$ git diff > nixpkgs/pkgs/the/package/0001-changes.patch + + + + +
diff --git a/doc/configuration.xml b/doc/configuration.xml index 5370265c53ad..4411b4844e99 100644 --- a/doc/configuration.xml +++ b/doc/configuration.xml @@ -1,42 +1,51 @@ - -Global configuration - -Nix comes with certain defaults about what packages can and -cannot be installed, based on a package's metadata. By default, Nix -will prevent installation if any of the following criteria are -true: - - - The package is thought to be broken, and has had - its meta.broken set to - true. - - The package isn't intended to run on the given system, as none of its meta.platforms match the given system. - - The package's meta.license is set - to a license which is considered to be unfree. - - The package has known security vulnerabilities but - has not or can not be updated for some reason, and a list of issues - has been entered in to the package's - meta.knownVulnerabilities. - - -Note that all this is checked during evaluation already, -and the check includes any package that is evaluated. -In particular, all build-time dependencies are checked. -nix-env -qa will (attempt to) hide any packages -that would be refused. - - -Each of these criteria can be altered in the nixpkgs -configuration. - -The nixpkgs configuration for a NixOS system is set in the -configuration.nix, as in the following example: + Global configuration + + Nix comes with certain defaults about what packages can and cannot be + installed, based on a package's metadata. By default, Nix will prevent + installation if any of the following criteria are true: + + + + + The package is thought to be broken, and has had its + meta.broken set to true. + + + + + The package isn't intended to run on the given system, as none of its + meta.platforms match the given system. + + + + + The package's meta.license is set to a license which is + considered to be unfree. + + + + + The package has known security vulnerabilities but has not or can not be + updated for some reason, and a list of issues has been entered in to the + package's meta.knownVulnerabilities. + + + + + Note that all this is checked during evaluation already, and the check + includes any package that is evaluated. In particular, all build-time + dependencies are checked. nix-env -qa will (attempt to) + hide any packages that would be refused. + + + Each of these criteria can be altered in the nixpkgs configuration. + + + The nixpkgs configuration for a NixOS system is set in the + configuration.nix, as in the following example: { nixpkgs.config = { @@ -44,187 +53,197 @@ configuration. }; } -However, this does not allow unfree software for individual users. -Their configurations are managed separately. - -A user's of nixpkgs configuration is stored in a user-specific -configuration file located at -~/.config/nixpkgs/config.nix. For example: + However, this does not allow unfree software for individual users. Their + configurations are managed separately. + + + A user's of nixpkgs configuration is stored in a user-specific configuration + file located at ~/.config/nixpkgs/config.nix. For + example: { allowUnfree = true; } - - -Note that we are not able to test or build unfree software on Hydra -due to policy. Most unfree licenses prohibit us from either executing or -distributing the software. - -
+ + + Note that we are not able to test or build unfree software on Hydra due to + policy. Most unfree licenses prohibit us from either executing or + distributing the software. + +
Installing broken packages - - There are two ways to try compiling a package which has been - marked as broken. + + There are two ways to try compiling a package which has been marked as + broken. + - - For allowing the build of a broken package once, you can use an - environment variable for a single invocation of the nix tools: - - $ export NIXPKGS_ALLOW_BROKEN=1 - - - - For permanently allowing broken packages to be built, you may - add allowBroken = true; to your user's - configuration file, like this: - + + + For allowing the build of a broken package once, you can use an + environment variable for a single invocation of the nix tools: +$ export NIXPKGS_ALLOW_BROKEN=1 + + + + + For permanently allowing broken packages to be built, you may add + allowBroken = true; to your user's configuration file, + like this: { allowBroken = true; } - + + -
- -
+
+
Installing packages on unsupported systems - - There are also two ways to try compiling a package which has been marked as unsuported for the given system. + There are also two ways to try compiling a package which has been marked as + unsuported for the given system. - - For allowing the build of a broken package once, you can use an environment variable for a single invocation of the nix tools: - - $ export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 - - - - - For permanently allowing broken packages to be built, you may add allowUnsupportedSystem = true; to your user's configuration file, like this: - + + + For allowing the build of a broken package once, you can use an + environment variable for a single invocation of the nix tools: +$ export NIXPKGS_ALLOW_UNSUPPORTED_SYSTEM=1 + + + + + For permanently allowing broken packages to be built, you may add + allowUnsupportedSystem = true; to your user's + configuration file, like this: { allowUnsupportedSystem = true; } - - + + - The difference between an a package being unsupported on some system and being broken is admittedly a bit fuzzy. - If a program ought to work on a certain platform, but doesn't, the platform should be included in meta.platforms, but marked as broken with e.g. meta.broken = !hostPlatform.isWindows. - Of course, this begs the question of what "ought" means exactly. - That is left to the package maintainer. + The difference between an a package being unsupported on some system and + being broken is admittedly a bit fuzzy. If a program + ought to work on a certain platform, but doesn't, the + platform should be included in meta.platforms, but marked + as broken with e.g. meta.broken = + !hostPlatform.isWindows. Of course, this begs the question of what + "ought" means exactly. That is left to the package maintainer. -
- -
+
+
Installing unfree packages - There are several ways to tweak how Nix handles a package - which has been marked as unfree. + + There are several ways to tweak how Nix handles a package which has been + marked as unfree. + - - To temporarily allow all unfree packages, you can use an - environment variable for a single invocation of the nix tools: - - $ export NIXPKGS_ALLOW_UNFREE=1 - - - - It is possible to permanently allow individual unfree packages, - while still blocking unfree packages by default using the - allowUnfreePredicate configuration - option in the user configuration file. - - This option is a function which accepts a package as a - parameter, and returns a boolean. The following example - configuration accepts a package and always returns false: + + + To temporarily allow all unfree packages, you can use an environment + variable for a single invocation of the nix tools: +$ export NIXPKGS_ALLOW_UNFREE=1 + + + + + It is possible to permanently allow individual unfree packages, while + still blocking unfree packages by default using the + allowUnfreePredicate configuration option in the user + configuration file. + + + This option is a function which accepts a package as a parameter, and + returns a boolean. The following example configuration accepts a package + and always returns false: { allowUnfreePredicate = (pkg: false); } - - - A more useful example, the following configuration allows - only allows flash player and visual studio code: - + + + A more useful example, the following configuration allows only allows + flash player and visual studio code: { allowUnfreePredicate = (pkg: elem (builtins.parseDrvName pkg.name).name [ "flashplayer" "vscode" ]); } - - - - It is also possible to whitelist and blacklist licenses - that are specifically acceptable or not acceptable, using - whitelistedLicenses and - blacklistedLicenses, respectively. - - - The following example configuration whitelists the - licenses amd and wtfpl: - + + + + + It is also possible to whitelist and blacklist licenses that are + specifically acceptable or not acceptable, using + whitelistedLicenses and + blacklistedLicenses, respectively. + + + The following example configuration whitelists the licenses + amd and wtfpl: { whitelistedLicenses = with stdenv.lib.licenses; [ amd wtfpl ]; } - - - The following example configuration blacklists the - gpl3 and agpl3 licenses: - + + + The following example configuration blacklists the gpl3 + and agpl3 licenses: { blacklistedLicenses = with stdenv.lib.licenses; [ agpl3 gpl3 ]; } - - + + - A complete list of licenses can be found in the file - lib/licenses.nix of the nixpkgs tree. -
+ + A complete list of licenses can be found in the file + lib/licenses.nix of the nixpkgs tree. + +
+
+ Installing insecure packages - -
- - Installing insecure packages - - - There are several ways to tweak how Nix handles a package - which has been marked as insecure. + + There are several ways to tweak how Nix handles a package which has been + marked as insecure. + - - To temporarily allow all insecure packages, you can use an - environment variable for a single invocation of the nix tools: - - $ export NIXPKGS_ALLOW_INSECURE=1 - - - - It is possible to permanently allow individual insecure - packages, while still blocking other insecure packages by - default using the permittedInsecurePackages - configuration option in the user configuration file. - - The following example configuration permits the - installation of the hypothetically insecure package - hello, version 1.2.3: + + + To temporarily allow all insecure packages, you can use an environment + variable for a single invocation of the nix tools: +$ export NIXPKGS_ALLOW_INSECURE=1 + + + + + It is possible to permanently allow individual insecure packages, while + still blocking other insecure packages by default using the + permittedInsecurePackages configuration option in the + user configuration file. + + + The following example configuration permits the installation of the + hypothetically insecure package hello, version + 1.2.3: { permittedInsecurePackages = [ @@ -232,47 +251,44 @@ distributing the software. ]; } - - - - - It is also possible to create a custom policy around which - insecure packages to allow and deny, by overriding the - allowInsecurePredicate configuration - option. - - The allowInsecurePredicate option is a - function which accepts a package and returns a boolean, much - like allowUnfreePredicate. - - The following configuration example only allows insecure - packages with very short names: - + + + + + It is also possible to create a custom policy around which insecure + packages to allow and deny, by overriding the + allowInsecurePredicate configuration option. + + + The allowInsecurePredicate option is a function which + accepts a package and returns a boolean, much like + allowUnfreePredicate. + + + The following configuration example only allows insecure packages with + very short names: { allowInsecurePredicate = (pkg: (builtins.stringLength (builtins.parseDrvName pkg.name).name) <= 5); } - - - Note that permittedInsecurePackages is - only checked if allowInsecurePredicate is not - specified. - + + + Note that permittedInsecurePackages is only checked if + allowInsecurePredicate is not specified. + + -
- +
+
+ Modify packages via <literal>packageOverrides</literal> -
Modify -packages via <literal>packageOverrides</literal> - -You can define a function called -packageOverrides in your local -~/.config/nixpkgs/config.nix to override nix packages. It -must be a function that takes pkgs as an argument and return modified -set of packages. - + + You can define a function called packageOverrides in your + local ~/.config/nixpkgs/config.nix to override nix + packages. It must be a function that takes pkgs as an argument and return + modified set of packages. { packageOverrides = pkgs: rec { @@ -280,30 +296,27 @@ set of packages. }; } - - - -
- -
+ +
+
Declarative Package Management
- Build an environment + Build an environment - - Using packageOverrides, it is possible to manage - packages declaratively. This means that we can list all of our desired - packages within a declarative Nix expression. For example, to have - aspell, bc, - ffmpeg, coreutils, - gdb, nixUnstable, - emscripten, jq, - nox, and silver-searcher, we could - use the following in ~/.config/nixpkgs/config.nix: - + + Using packageOverrides, it is possible to manage + packages declaratively. This means that we can list all of our desired + packages within a declarative Nix expression. For example, to have + aspell, bc, + ffmpeg, coreutils, + gdb, nixUnstable, + emscripten, jq, + nox, and silver-searcher, we could + use the following in ~/.config/nixpkgs/config.nix: + - + { packageOverrides = pkgs: with pkgs; { myPackages = pkgs.buildEnv { @@ -314,17 +327,17 @@ set of packages. } - - To install it into our environment, you can just run nix-env -iA - nixpkgs.myPackages. If you want to load the packages to be built - from a working copy of nixpkgs you just run - nix-env -f. -iA myPackages. To explore what's been - installed, just look through ~/.nix-profile/. You can - see that a lot of stuff has been installed. Some of this stuff is useful - some of it isn't. Let's tell Nixpkgs to only link the stuff that we want: - + + To install it into our environment, you can just run nix-env -iA + nixpkgs.myPackages. If you want to load the packages to be built + from a working copy of nixpkgs you just run + nix-env -f. -iA myPackages. To explore what's been + installed, just look through ~/.nix-profile/. You can + see that a lot of stuff has been installed. Some of this stuff is useful + some of it isn't. Let's tell Nixpkgs to only link the stuff that we want: + - + { packageOverrides = pkgs: with pkgs; { myPackages = pkgs.buildEnv { @@ -336,31 +349,30 @@ set of packages. } - - pathsToLink tells Nixpkgs to only link the paths listed - which gets rid of the extra stuff in the profile. - /bin and /share are good - defaults for a user environment, getting rid of the clutter. If you are - running on Nix on MacOS, you may want to add another path as well, - /Applications, that makes GUI apps available. - - + + pathsToLink tells Nixpkgs to only link the paths listed + which gets rid of the extra stuff in the profile. /bin + and /share are good defaults for a user environment, + getting rid of the clutter. If you are running on Nix on MacOS, you may + want to add another path as well, /Applications, that + makes GUI apps available. +
- Getting documentation + Getting documentation - - After building that new environment, look through - ~/.nix-profile to make sure everything is there that - we wanted. Discerning readers will note that some files are missing. Look - inside ~/.nix-profile/share/man/man1/ to verify this. - There are no man pages for any of the Nix tools! This is because some - packages like Nix have multiple outputs for things like documentation (see - section 4). Let's make Nix install those as well. - + + After building that new environment, look through + ~/.nix-profile to make sure everything is there that + we wanted. Discerning readers will note that some files are missing. Look + inside ~/.nix-profile/share/man/man1/ to verify this. + There are no man pages for any of the Nix tools! This is because some + packages like Nix have multiple outputs for things like documentation (see + section 4). Let's make Nix install those as well. + - + { packageOverrides = pkgs: with pkgs; { myPackages = pkgs.buildEnv { @@ -373,14 +385,13 @@ set of packages. } - - This provides us with some useful documentation for using our packages. - However, if we actually want those manpages to be detected by man, we need - to set up our environment. This can also be managed within Nix - expressions. - + + This provides us with some useful documentation for using our packages. + However, if we actually want those manpages to be detected by man, we need + to set up our environment. This can also be managed within Nix expressions. + - + { packageOverrides = pkgs: with pkgs; rec { myProfile = writeText "my-profile" '' @@ -412,13 +423,13 @@ cp ${myProfile} $out/etc/profile.d/my-profile.sh } - - For this to work fully, you must also have this script sourced when you - are logged in. Try adding something like this to your - ~/.profile file: - + + For this to work fully, you must also have this script sourced when you are + logged in. Try adding something like this to your + ~/.profile file: + - + #!/bin/sh if [ -d $HOME/.nix-profile/etc/profile.d ]; then for i in $HOME/.nix-profile/etc/profile.d/*.sh; do @@ -429,23 +440,22 @@ if [ -d $HOME/.nix-profile/etc/profile.d ]; then fi - - Now just run source $HOME/.profile and you can starting - loading man pages from your environent. - - + + Now just run source $HOME/.profile and you can starting + loading man pages from your environent. +
- GNU info setup + GNU info setup - - Configuring GNU info is a little bit trickier than man pages. To work - correctly, info needs a database to be generated. This can be done with - some small modifications to our environment scripts. - + + Configuring GNU info is a little bit trickier than man pages. To work + correctly, info needs a database to be generated. This can be done with + some small modifications to our environment scripts. + - + { packageOverrides = pkgs: with pkgs; rec { myProfile = writeText "my-profile" '' @@ -487,16 +497,13 @@ cp ${myProfile} $out/etc/profile.d/my-profile.sh } - - postBuild tells Nixpkgs to run a command after building - the environment. In this case, install-info adds the - installed info pages to dir which is GNU info's default - root node. Note that texinfoInteractive is added to the - environment to give the install-info command. - - + + postBuild tells Nixpkgs to run a command after building + the environment. In this case, install-info adds the + installed info pages to dir which is GNU info's default + root node. Note that texinfoInteractive is added to the + environment to give the install-info command. +
- -
- +
diff --git a/doc/contributing.xml b/doc/contributing.xml index 7aa0df271ff4..d28442b7a2c6 100644 --- a/doc/contributing.xml +++ b/doc/contributing.xml @@ -1,35 +1,35 @@ - -Contributing to this documentation - -The DocBook sources of the Nixpkgs manual are in the Contributing to this documentation + + The DocBook sources of the Nixpkgs manual are in the + doc -subdirectory of the Nixpkgs repository. - -You can quickly check your edits with make: - + subdirectory of the Nixpkgs repository. + + + You can quickly check your edits with make: + $ cd /path/to/nixpkgs/doc $ nix-shell [nix-shell]$ make - -If you experience problems, run make debug -to help understand the docbook errors. - -After making modifications to the manual, it's important to -build it before committing. You can do that as follows: - + + If you experience problems, run make debug to help + understand the docbook errors. + + + After making modifications to the manual, it's important to build it before + committing. You can do that as follows: $ cd /path/to/nixpkgs/doc $ nix-shell [nix-shell]$ make clean [nix-shell]$ nix-build . - -If the build succeeds, the manual will be in -./result/share/doc/nixpkgs/manual.html. - + If the build succeeds, the manual will be in + ./result/share/doc/nixpkgs/manual.html. + diff --git a/doc/cross-compilation.xml b/doc/cross-compilation.xml index 0b2b85aeeef6..fe0e0d88d30e 100644 --- a/doc/cross-compilation.xml +++ b/doc/cross-compilation.xml @@ -1,308 +1,469 @@ - -Cross-compilation - -
+ Cross-compilation +
Introduction + - "Cross-compilation" means compiling a program on one machine for another type of machine. - For example, a typical use of cross compilation is to compile programs for embedded devices. - These devices often don't have the computing power and memory to compile their own programs. - One might think that cross-compilation is a fairly niche concern, but there are advantages to being rigorous about distinguishing build-time vs run-time environments even when one is developing and deploying on the same machine. - Nixpkgs is increasingly adopting the opinion that packages should be written with cross-compilation in mind, and nixpkgs should evaluate in a similar way (by minimizing cross-compilation-specific special cases) whether or not one is cross-compiling. + "Cross-compilation" means compiling a program on one machine for another + type of machine. For example, a typical use of cross compilation is to + compile programs for embedded devices. These devices often don't have the + computing power and memory to compile their own programs. One might think + that cross-compilation is a fairly niche concern, but there are advantages + to being rigorous about distinguishing build-time vs run-time environments + even when one is developing and deploying on the same machine. Nixpkgs is + increasingly adopting the opinion that packages should be written with + cross-compilation in mind, and nixpkgs should evaluate in a similar way (by + minimizing cross-compilation-specific special cases) whether or not one is + cross-compiling. - This chapter will be organized in three parts. - First, it will describe the basics of how to package software in a way that supports cross-compilation. - Second, it will describe how to use Nixpkgs when cross-compiling. - Third, it will describe the internal infrastructure supporting cross-compilation. + This chapter will be organized in three parts. First, it will describe the + basics of how to package software in a way that supports cross-compilation. + Second, it will describe how to use Nixpkgs when cross-compiling. Third, it + will describe the internal infrastructure supporting cross-compilation. -
- +
- -
+
Packaging in a cross-friendly manner
- Platform parameters - - Nixpkgs follows the common historical convention of GNU autoconf of distinguishing between 3 types of platform: build, host, and target. + Platform parameters - In summary, build is the platform on which a package is being built, host is the platform on which it is to run. The third attribute, target, is relevant only for certain specific compilers and build tools. - + + Nixpkgs follows the + common + historical convention of GNU autoconf of distinguishing between 3 + types of platform: build, + host, and target. In + summary, build is the platform on which a package + is being built, host is the platform on which it + is to run. The third attribute, target, is + relevant only for certain specific compilers and build tools. + - - In Nixpkgs, these three platforms are defined as attribute sets under the names buildPlatform, hostPlatform, and targetPlatform. - All three are always defined as attributes in the standard environment, and at the top level. That means one can get at them just like a dependency in a function that is imported with callPackage: - { stdenv, buildPlatform, hostPlatform, fooDep, barDep, .. }: ...buildPlatform..., or just off stdenv: - { stdenv, fooDep, barDep, .. }: ...stdenv.buildPlatform.... - - - - buildPlatform - - The "build platform" is the platform on which a package is built. - Once someone has a built package, or pre-built binary package, the build platform should not matter and be safe to ignore. - - - - hostPlatform - - The "host platform" is the platform on which a package will be run. - This is the simplest platform to understand, but also the one with the worst name. - - - - targetPlatform - - - The "target platform" attribute is, unlike the other two attributes, not actually fundamental to the process of building software. - Instead, it is only relevant for compatibility with building certain specific compilers and build tools. - It can be safely ignored for all other packages. - - - The build process of certain compilers is written in such a way that the compiler resulting from a single build can itself only produce binaries for a single platform. - The task specifying this single "target platform" is thus pushed to build time of the compiler. - The root cause of this mistake is often that the compiler (which will be run on the host) and the the standard library/runtime (which will be run on the target) are built by a single build process. - - - There is no fundamental need to think about a single target ahead of time like this. - If the tool supports modular or pluggable backends, both the need to specify the target at build time and the constraint of having only a single target disappear. - An example of such a tool is LLVM. - - - Although the existence of a "target platfom" is arguably a historical mistake, it is a common one: examples of tools that suffer from it are GCC, Binutils, GHC and Autoconf. - Nixpkgs tries to avoid sharing in the mistake where possible. - Still, because the concept of a target platform is so ingrained, it is best to support it as is. - - - - - - The exact schema these fields follow is a bit ill-defined due to a long and convoluted evolution, but this is slowly being cleaned up. - You can see examples of ones used in practice in lib.systems.examples; note how they are not all very consistent. - For now, here are few fields can count on them containing: - - - - system - - - This is a two-component shorthand for the platform. - Examples of this would be "x86_64-darwin" and "i686-linux"; see lib.systems.doubles for more. - This format isn't very standard, but has built-in support in Nix, such as the builtins.currentSystem impure string. - - - - - config - - - This is a 3- or 4- component shorthand for the platform. - Examples of this would be "x86_64-unknown-linux-gnu" and "aarch64-apple-darwin14". - This is a standard format called the "LLVM target triple", as they are pioneered by LLVM and traditionally just used for the targetPlatform. - This format is strictly more informative than the "Nix host double", as the previous format could analogously be termed. - This needs a better name than config! - - - - - parsed - - - This is a nix representation of a parsed LLVM target triple with white-listed components. - This can be specified directly, or actually parsed from the config. - [Technically, only one need be specified and the others can be inferred, though the precision of inference may not be very good.] - See lib.systems.parse for the exact representation. - - - - - libc - - - This is a string identifying the standard C library used. - Valid identifiers include "glibc" for GNU libc, "libSystem" for Darwin's Libsystem, and "uclibc" for µClibc. - It should probably be refactored to use the module system, like parse. - - - - - is* - - - These predicates are defined in lib.systems.inspect, and slapped on every platform. - They are superior to the ones in stdenv as they force the user to be explicit about which platform they are inspecting. - Please use these instead of those. - - - - - platform - - - This is, quite frankly, a dumping ground of ad-hoc settings (it's an attribute set). - See lib.systems.platforms for examples—there's hopefully one in there that will work verbatim for each platform that is working. - Please help us triage these flags and give them better homes! - - - - + + In Nixpkgs, these three platforms are defined as attribute sets under the + names buildPlatform, hostPlatform, + and targetPlatform. All three are always defined as + attributes in the standard environment, and at the top level. That means + one can get at them just like a dependency in a function that is imported + with callPackage: +{ stdenv, buildPlatform, hostPlatform, fooDep, barDep, .. }: ...buildPlatform... + , or just off stdenv: +{ stdenv, fooDep, barDep, .. }: ...stdenv.buildPlatform... + . + + + + + buildPlatform + + + + The "build platform" is the platform on which a package is built. Once + someone has a built package, or pre-built binary package, the build + platform should not matter and be safe to ignore. + + + + + hostPlatform + + + + The "host platform" is the platform on which a package will be run. This + is the simplest platform to understand, but also the one with the worst + name. + + + + + targetPlatform + + + + The "target platform" attribute is, unlike the other two attributes, not + actually fundamental to the process of building software. Instead, it is + only relevant for compatibility with building certain specific compilers + and build tools. It can be safely ignored for all other packages. + + + The build process of certain compilers is written in such a way that the + compiler resulting from a single build can itself only produce binaries + for a single platform. The task specifying this single "target platform" + is thus pushed to build time of the compiler. The root cause of this + mistake is often that the compiler (which will be run on the host) and + the the standard library/runtime (which will be run on the target) are + built by a single build process. + + + There is no fundamental need to think about a single target ahead of + time like this. If the tool supports modular or pluggable backends, both + the need to specify the target at build time and the constraint of + having only a single target disappear. An example of such a tool is + LLVM. + + + Although the existence of a "target platfom" is arguably a historical + mistake, it is a common one: examples of tools that suffer from it are + GCC, Binutils, GHC and Autoconf. Nixpkgs tries to avoid sharing in the + mistake where possible. Still, because the concept of a target platform + is so ingrained, it is best to support it as is. + + + + + + + The exact schema these fields follow is a bit ill-defined due to a long and + convoluted evolution, but this is slowly being cleaned up. You can see + examples of ones used in practice in + lib.systems.examples; note how they are not all very + consistent. For now, here are few fields can count on them containing: + + + + + system + + + + This is a two-component shorthand for the platform. Examples of this + would be "x86_64-darwin" and "i686-linux"; see + lib.systems.doubles for more. This format isn't very + standard, but has built-in support in Nix, such as the + builtins.currentSystem impure string. + + + + + config + + + + This is a 3- or 4- component shorthand for the platform. Examples of + this would be "x86_64-unknown-linux-gnu" and "aarch64-apple-darwin14". + This is a standard format called the "LLVM target triple", as they are + pioneered by LLVM and traditionally just used for the + targetPlatform. This format is strictly more + informative than the "Nix host double", as the previous format could + analogously be termed. This needs a better name than + config! + + + + + parsed + + + + This is a nix representation of a parsed LLVM target triple with + white-listed components. This can be specified directly, or actually + parsed from the config. [Technically, only one need + be specified and the others can be inferred, though the precision of + inference may not be very good.] See + lib.systems.parse for the exact representation. + + + + + libc + + + + This is a string identifying the standard C library used. Valid + identifiers include "glibc" for GNU libc, "libSystem" for Darwin's + Libsystem, and "uclibc" for µClibc. It should probably be refactored to + use the module system, like parse. + + + + + is* + + + + These predicates are defined in lib.systems.inspect, + and slapped on every platform. They are superior to the ones in + stdenv as they force the user to be explicit about + which platform they are inspecting. Please use these instead of those. + + + + + platform + + + + This is, quite frankly, a dumping ground of ad-hoc settings (it's an + attribute set). See lib.systems.platforms for + examples—there's hopefully one in there that will work verbatim for + each platform that is working. Please help us triage these flags and + give them better homes! + + + +
- Specifying Dependencies + Specifying Dependencies + + + In this section we explore the relationship between both runtime and + buildtime dependencies and the 3 Autoconf platforms. + + + + A runtime dependency between 2 packages implies that between them both the + host and target platforms match. This is directly implied by the meaning of + "host platform" and "runtime dependency": The package dependency exists + while both packages are running on a single host platform. + + + + A build time dependency, however, implies a shift in platforms between the + depending package and the depended-on package. The meaning of a build time + dependency is that to build the depending package we need to be able to run + the depended-on's package. The depending package's build platform is + therefore equal to the depended-on package's host platform. Analogously, + the depending package's host platform is equal to the depended-on package's + target platform. + + + + In this manner, given the 3 platforms for one package, we can determine the + three platforms for all its transitive dependencies. This is the most + important guiding principle behind cross-compilation with Nixpkgs, and will + be called the sliding window principle. + + + + Some examples will probably make this clearer. If a package is being built + with a (build, host, target) platform triple of + (foo, bar, bar), then its build-time dependencies would + have a triple of (foo, foo, bar), and those + packages' build-time dependencies would have triple of + (foo, foo, foo). In other words, it should take two + "rounds" of following build-time dependency edges before one reaches a + fixed point where, by the sliding window principle, the platform triple no + longer changes. Indeed, this happens with cross compilation, where only + rounds of native dependencies starting with the second necessarily coincide + with native packages. + + + - In this section we explore the relationship between both runtime and buildtime dependencies and the 3 Autoconf platforms. + The depending package's target platform is unconstrained by the sliding + window principle, which makes sense in that one can in principle build + cross compilers targeting arbitrary platforms. + + + + How does this work in practice? Nixpkgs is now structured so that + build-time dependencies are taken from buildPackages, + whereas run-time dependencies are taken from the top level attribute set. + For example, buildPackages.gcc should be used at build + time, while gcc should be used at run time. Now, for + most of Nixpkgs's history, there was no buildPackages, + and most packages have not been refactored to use it explicitly. Instead, + one can use the six (gasp) attributes used for + specifying dependencies as documented in + . We "splice" together the + run-time and build-time package sets with callPackage, + and then mkDerivation for each of four attributes pulls + the right derivation out. This splicing can be skipped when not cross + compiling as the package sets are the same, but is a bit slow for cross + compiling. Because of this, a best-of-both-worlds solution is in the works + with no splicing or explicit access of buildPackages + needed. For now, feel free to use either method. + + + - A runtime dependency between 2 packages implies that between them both the host and target platforms match. - This is directly implied by the meaning of "host platform" and "runtime dependency": - The package dependency exists while both packages are running on a single host platform. + There is also a "backlink" targetPackages, yielding a + package set whose buildPackages is the current package + set. This is a hack, though, to accommodate compilers with lousy build + systems. Please do not use this unless you are absolutely sure you are + packaging such a compiler and there is no other way. - - A build time dependency, however, implies a shift in platforms between the depending package and the depended-on package. - The meaning of a build time dependency is that to build the depending package we need to be able to run the depended-on's package. - The depending package's build platform is therefore equal to the depended-on package's host platform. - Analogously, the depending package's host platform is equal to the depended-on package's target platform. - - - In this manner, given the 3 platforms for one package, we can determine the three platforms for all its transitive dependencies. - This is the most important guiding principle behind cross-compilation with Nixpkgs, and will be called the sliding window principle. - - - Some examples will probably make this clearer. - If a package is being built with a (build, host, target) platform triple of (foo, bar, bar), then its build-time dependencies would have a triple of (foo, foo, bar), and those packages' build-time dependencies would have triple of (foo, foo, foo). - In other words, it should take two "rounds" of following build-time dependency edges before one reaches a fixed point where, by the sliding window principle, the platform triple no longer changes. - Indeed, this happens with cross compilation, where only rounds of native dependencies starting with the second necessarily coincide with native packages. - - - The depending package's target platform is unconstrained by the sliding window principle, which makes sense in that one can in principle build cross compilers targeting arbitrary platforms. - - - How does this work in practice? Nixpkgs is now structured so that build-time dependencies are taken from buildPackages, whereas run-time dependencies are taken from the top level attribute set. - For example, buildPackages.gcc should be used at build time, while gcc should be used at run time. - Now, for most of Nixpkgs's history, there was no buildPackages, and most packages have not been refactored to use it explicitly. - Instead, one can use the six (gasp) attributes used for specifying dependencies as documented in . - We "splice" together the run-time and build-time package sets with callPackage, and then mkDerivation for each of four attributes pulls the right derivation out. - This splicing can be skipped when not cross compiling as the package sets are the same, but is a bit slow for cross compiling. - Because of this, a best-of-both-worlds solution is in the works with no splicing or explicit access of buildPackages needed. - For now, feel free to use either method. - - - There is also a "backlink" targetPackages, yielding a package set whose buildPackages is the current package set. - This is a hack, though, to accommodate compilers with lousy build systems. - Please do not use this unless you are absolutely sure you are packaging such a compiler and there is no other way. - +
- Cross packagaing cookbook - - Some frequently problems when packaging for cross compilation are good to just spell and answer. - Ideally the information above is exhaustive, so this section cannot provide any new information, - but its ludicrous and cruel to expect everyone to spend effort working through the interaction of many features just to figure out the same answer to the same common problem. - Feel free to add to this list! - - - - - What if my package's build system needs to build a C program to be run under the build environment? - - - depsBuildBuild = [ buildPackages.stdenv.cc ]; - Add it to your mkDerivation invocation. - - - - - My package fails to find ar. - - - Many packages assume that an unprefixed ar is available, but Nix doesn't provide one. - It only provides a prefixed one, just as it only does for all the other binutils programs. - It may be necessary to patch the package to fix the build system to use a prefixed `ar`. - - - - - My package's testsuite needs to run host platform code. - - - doCheck = stdenv.hostPlatform != stdenv.buildPlatfrom; - Add it to your mkDerivation invocation. - - - -
-
+ Cross packagaing cookbook + + Some frequently problems when packaging for cross compilation are good to + just spell and answer. Ideally the information above is exhaustive, so this + section cannot provide any new information, but its ludicrous and cruel to + expect everyone to spend effort working through the interaction of many + features just to figure out the same answer to the same common problem. + Feel free to add to this list! + + + + + + + What if my package's build system needs to build a C program to be run + under the build environment? + + + + +depsBuildBuild = [ buildPackages.stdenv.cc ]; + Add it to your mkDerivation invocation. + + + + + + + My package fails to find ar. + + + + + Many packages assume that an unprefixed ar is + available, but Nix doesn't provide one. It only provides a prefixed one, + just as it only does for all the other binutils programs. It may be + necessary to patch the package to fix the build system to use a prefixed + `ar`. + + + + + + + My package's testsuite needs to run host platform code. + + + + +doCheck = stdenv.hostPlatform != stdenv.buildPlatfrom; + Add it to your mkDerivation invocation. + + + + +
+ - -
+
Cross-building packages - - More information needs to moved from the old wiki, especially , for this section. - + + + + More information needs to moved from the old wiki, especially + , for this + section. + + + - Nixpkgs can be instantiated with localSystem alone, in which case there is no cross compiling and everything is built by and for that system, - or also with crossSystem, in which case packages run on the latter, but all building happens on the former. - Both parameters take the same schema as the 3 (build, host, and target) platforms defined in the previous section. - As mentioned above, lib.systems.examples has some platforms which are used as arguments for these parameters in practice. - You can use them programmatically, or on the command line: + Nixpkgs can be instantiated with localSystem alone, in + which case there is no cross compiling and everything is built by and for + that system, or also with crossSystem, in which case + packages run on the latter, but all building happens on the former. Both + parameters take the same schema as the 3 (build, host, and target) platforms + defined in the previous section. As mentioned above, + lib.systems.examples has some platforms which are used as + arguments for these parameters in practice. You can use them + programmatically, or on the command line: + nix-build <nixpkgs> --arg crossSystem '(import <nixpkgs/lib>).systems.examples.fooBarBaz' -A whatever + - - Eventually we would like to make these platform examples an unnecessary convenience so that + + Eventually we would like to make these platform examples an unnecessary + convenience so that + nix-build <nixpkgs> --arg crossSystem.config '<arch>-<os>-<vendor>-<abi>' -A whatever - works in the vast majority of cases. - The problem today is dependencies on other sorts of configuration which aren't given proper defaults. - We rely on the examples to crudely to set those configuration parameters in some vaguely sane manner on the users behalf. - Issue #34274 tracks this inconvenience along with its root cause in crufty configuration options. - + works in the vast majority of cases. The problem today is dependencies on + other sorts of configuration which aren't given proper defaults. We rely on + the examples to crudely to set those configuration parameters in some + vaguely sane manner on the users behalf. Issue + #34274 + tracks this inconvenience along with its root cause in crufty configuration + options. + + - While one is free to pass both parameters in full, there's a lot of logic to fill in missing fields. - As discussed in the previous section, only one of system, config, and parsed is needed to infer the other two. - Additionally, libc will be inferred from parse. - Finally, localSystem.system is also impurely inferred based on the platform evaluation occurs. - This means it is often not necessary to pass localSystem at all, as in the command-line example in the previous paragraph. + While one is free to pass both parameters in full, there's a lot of logic to + fill in missing fields. As discussed in the previous section, only one of + system, config, and + parsed is needed to infer the other two. Additionally, + libc will be inferred from parse. + Finally, localSystem.system is also + impurely inferred based on the platform evaluation + occurs. This means it is often not necessary to pass + localSystem at all, as in the command-line example in the + previous paragraph. + - - Many sources (manual, wiki, etc) probably mention passing system, platform, along with the optional crossSystem to nixpkgs: - import <nixpkgs> { system = ..; platform = ..; crossSystem = ..; }. - Passing those two instead of localSystem is still supported for compatibility, but is discouraged. - Indeed, much of the inference we do for these parameters is motivated by compatibility as much as convenience. - + + Many sources (manual, wiki, etc) probably mention passing + system, platform, along with the + optional crossSystem to nixpkgs: import + <nixpkgs> { system = ..; platform = ..; crossSystem = ..; + }. Passing those two instead of localSystem is + still supported for compatibility, but is discouraged. Indeed, much of the + inference we do for these parameters is motivated by compatibility as much + as convenience. + + - One would think that localSystem and crossSystem overlap horribly with the three *Platforms (buildPlatform, hostPlatform, and targetPlatform; see stage.nix or the manual). - Actually, those identifiers are purposefully not used here to draw a subtle but important distinction: - While the granularity of having 3 platforms is necessary to properly *build* packages, it is overkill for specifying the user's *intent* when making a build plan or package set. - A simple "build vs deploy" dichotomy is adequate: the sliding window principle described in the previous section shows how to interpolate between the these two "end points" to get the 3 platform triple for each bootstrapping stage. - That means for any package a given package set, even those not bound on the top level but only reachable via dependencies or buildPackages, the three platforms will be defined as one of localSystem or crossSystem, with the former replacing the latter as one traverses build-time dependencies. - A last simple difference then is crossSystem should be null when one doesn't want to cross-compile, while the *Platforms are always non-null. - localSystem is always non-null. + One would think that localSystem and + crossSystem overlap horribly with the three + *Platforms (buildPlatform, + hostPlatform, and targetPlatform; see + stage.nix or the manual). Actually, those identifiers are + purposefully not used here to draw a subtle but important distinction: While + the granularity of having 3 platforms is necessary to properly *build* + packages, it is overkill for specifying the user's *intent* when making a + build plan or package set. A simple "build vs deploy" dichotomy is adequate: + the sliding window principle described in the previous section shows how to + interpolate between the these two "end points" to get the 3 platform triple + for each bootstrapping stage. That means for any package a given package + set, even those not bound on the top level but only reachable via + dependencies or buildPackages, the three platforms will + be defined as one of localSystem or + crossSystem, with the former replacing the latter as one + traverses build-time dependencies. A last simple difference then is + crossSystem should be null when one doesn't want to + cross-compile, while the *Platforms are always non-null. + localSystem is always non-null. -
- +
- -
+
Cross-compilation infrastructure - To be written. - - If one explores nixpkgs, they will see derivations with names like gccCross. - Such *Cross derivations is a holdover from before we properly distinguished between the host and target platforms - —the derivation with "Cross" in the name covered the build = host != target case, while the other covered the host = target, with build platform the same or not based on whether one was using its .nativeDrv or .crossDrv. - This ugliness will disappear soon. - -
+ + To be written. + + + + + If one explores nixpkgs, they will see derivations with names like + gccCross. Such *Cross derivations is + a holdover from before we properly distinguished between the host and + target platforms —the derivation with "Cross" in the name covered the + build = host != target case, while the other covered the + host = target, with build platform the same or not based + on whether one was using its .nativeDrv or + .crossDrv. This ugliness will disappear soon. + + +
diff --git a/doc/functions.xml b/doc/functions.xml index b2e450972947..155ea2bd0043 100644 --- a/doc/functions.xml +++ b/doc/functions.xml @@ -1,144 +1,139 @@ - -Functions reference - - - The nixpkgs repository has several utility functions to manipulate Nix expressions. - - -
+ Functions reference + + The nixpkgs repository has several utility functions to manipulate Nix + expressions. + +
Overriding - Sometimes one wants to override parts of - nixpkgs, e.g. derivation attributes, the results of - derivations or even the whole package set. + Sometimes one wants to override parts of nixpkgs, e.g. + derivation attributes, the results of derivations or even the whole package + set.
- <pkg>.override + <pkg>.override - - The function override is usually available for all the - derivations in the nixpkgs expression (pkgs). - - - It is used to override the arguments passed to a function. - - - Example usages: + + The function override is usually available for all the + derivations in the nixpkgs expression (pkgs). + - pkgs.foo.override { arg1 = val1; arg2 = val2; ... } - import pkgs.path { overlays = [ (self: super: { + + It is used to override the arguments passed to a function. + + + + Example usages: +pkgs.foo.override { arg1 = val1; arg2 = val2; ... } +import pkgs.path { overlays = [ (self: super: { foo = super.foo.override { barSupport = true ; }; })]}; - mypkg = pkgs.callPackage ./mypkg.nix { +mypkg = pkgs.callPackage ./mypkg.nix { mydep = pkgs.mydep.override { ... }; } - - - - In the first example, pkgs.foo is the result of a function call - with some default arguments, usually a derivation. - Using pkgs.foo.override will call the same function with - the given new arguments. - + + + In the first example, pkgs.foo is the result of a + function call with some default arguments, usually a derivation. Using + pkgs.foo.override will call the same function with the + given new arguments. +
- <pkg>.overrideAttrs + <pkg>.overrideAttrs - - The function overrideAttrs allows overriding the - attribute set passed to a stdenv.mkDerivation call, - producing a new derivation based on the original one. - This function is available on all derivations produced by the - stdenv.mkDerivation function, which is most packages - in the nixpkgs expression pkgs. - + + The function overrideAttrs allows overriding the + attribute set passed to a stdenv.mkDerivation call, + producing a new derivation based on the original one. This function is + available on all derivations produced by the + stdenv.mkDerivation function, which is most packages in + the nixpkgs expression pkgs. + - - Example usage: - - helloWithDebug = pkgs.hello.overrideAttrs (oldAttrs: rec { + + Example usage: +helloWithDebug = pkgs.hello.overrideAttrs (oldAttrs: rec { separateDebugInfo = true; }); - + + + In the above example, the separateDebugInfo attribute is + overridden to be true, thus building debug info for + helloWithDebug, while all other attributes will be + retained from the original hello package. + + + + The argument oldAttrs is conventionally used to refer to + the attr set originally passed to stdenv.mkDerivation. + + + - In the above example, the separateDebugInfo attribute is - overridden to be true, thus building debug info for - helloWithDebug, while all other attributes will be - retained from the original hello package. + Note that separateDebugInfo is processed only by the + stdenv.mkDerivation function, not the generated, raw + Nix derivation. Thus, using overrideDerivation will not + work in this case, as it overrides only the attributes of the final + derivation. It is for this reason that overrideAttrs + should be preferred in (almost) all cases to + overrideDerivation, i.e. to allow using + sdenv.mkDerivation to process input arguments, as well + as the fact that it is easier to use (you can use the same attribute names + you see in your Nix code, instead of the ones generated (e.g. + buildInputs vs nativeBuildInputs, + and involves less typing. - - - The argument oldAttrs is conventionally used to refer to - the attr set originally passed to stdenv.mkDerivation. - - - - - Note that separateDebugInfo is processed only by the - stdenv.mkDerivation function, not the generated, raw - Nix derivation. Thus, using overrideDerivation will - not work in this case, as it overrides only the attributes of the final - derivation. It is for this reason that overrideAttrs - should be preferred in (almost) all cases to - overrideDerivation, i.e. to allow using - sdenv.mkDerivation to process input arguments, as well - as the fact that it is easier to use (you can use the same attribute - names you see in your Nix code, instead of the ones generated (e.g. - buildInputs vs nativeBuildInputs, - and involves less typing. - - - +
-
- <pkg>.overrideDerivation - - - You should prefer overrideAttrs in almost all - cases, see its documentation for the reasons why. - overrideDerivation is not deprecated and will continue - to work, but is less nice to use and does not have as many abilities as - overrideAttrs. - - - - - Do not use this function in Nixpkgs as it evaluates a Derivation - before modifying it, which breaks package abstraction and removes - error-checking of function arguments. In addition, this - evaluation-per-function application incurs a performance penalty, - which can become a problem if many overrides are used. - It is only intended for ad-hoc customisation, such as in - ~/.config/nixpkgs/config.nix. - - + <pkg>.overrideDerivation + - The function overrideDerivation creates a new derivation - based on an existing one by overriding the original's attributes with - the attribute set produced by the specified function. - This function is available on all - derivations defined using the makeOverridable function. - Most standard derivation-producing functions, such as - stdenv.mkDerivation, are defined using this - function, which means most packages in the nixpkgs expression, - pkgs, have this function. + You should prefer overrideAttrs in almost all cases, + see its documentation for the reasons why. + overrideDerivation is not deprecated and will continue + to work, but is less nice to use and does not have as many abilities as + overrideAttrs. + + - Example usage: + Do not use this function in Nixpkgs as it evaluates a Derivation before + modifying it, which breaks package abstraction and removes error-checking + of function arguments. In addition, this evaluation-per-function + application incurs a performance penalty, which can become a problem if + many overrides are used. It is only intended for ad-hoc customisation, + such as in ~/.config/nixpkgs/config.nix. + + - mySed = pkgs.gnused.overrideDerivation (oldAttrs: { + + The function overrideDerivation creates a new derivation + based on an existing one by overriding the original's attributes with the + attribute set produced by the specified function. This function is + available on all derivations defined using the + makeOverridable function. Most standard + derivation-producing functions, such as + stdenv.mkDerivation, are defined using this function, + which means most packages in the nixpkgs expression, + pkgs, have this function. + + + + Example usage: +mySed = pkgs.gnused.overrideDerivation (oldAttrs: { name = "sed-4.2.2-pre"; src = fetchurl { url = ftp://alpha.gnu.org/gnu/sed/sed-4.2.2-pre.tar.bz2; @@ -146,98 +141,90 @@ }; patches = []; }); - + + + In the above example, the name, src, + and patches of the derivation will be overridden, while + all other attributes will be retained from the original derivation. + + + + The argument oldAttrs is used to refer to the attribute + set of the original derivation. + + + - In the above example, the name, src, - and patches of the derivation will be overridden, while - all other attributes will be retained from the original derivation. + A package's attributes are evaluated *before* being modified by the + overrideDerivation function. For example, the + name attribute reference in url = + "mirror://gnu/hello/${name}.tar.gz"; is filled-in *before* the + overrideDerivation function modifies the attribute set. + This means that overriding the name attribute, in this + example, *will not* change the value of the url + attribute. Instead, we need to override both the name + *and* url attributes. - - - The argument oldAttrs is used to refer to the attribute set of - the original derivation. - - - - - A package's attributes are evaluated *before* being modified by - the overrideDerivation function. - For example, the name attribute reference - in url = "mirror://gnu/hello/${name}.tar.gz"; - is filled-in *before* the overrideDerivation function - modifies the attribute set. This means that overriding the - name attribute, in this example, *will not* change the - value of the url attribute. Instead, we need to override - both the name *and* url attributes. - - - +
- lib.makeOverridable + lib.makeOverridable - - The function lib.makeOverridable is used to make the result - of a function easily customizable. This utility only makes sense for functions - that accept an argument set and return an attribute set. - + + The function lib.makeOverridable is used to make the + result of a function easily customizable. This utility only makes sense for + functions that accept an argument set and return an attribute set. + - - Example usage: - - f = { a, b }: { result = a+b; } + + Example usage: +f = { a, b }: { result = a+b; } c = lib.makeOverridable f { a = 1; b = 2; } + - - - - The variable c is the value of the f function - applied with some default arguments. Hence the value of c.result - is 3, in this example. - - - - The variable c however also has some additional functions, like - c.override which can be used to - override the default arguments. In this example the value of - (c.override { a = 4; }).result is 6. - + + The variable c is the value of the f + function applied with some default arguments. Hence the value of + c.result is 3, in this example. + + + The variable c however also has some additional + functions, like c.override which + can be used to override the default arguments. In this example the value of + (c.override { a = 4; }).result is 6. +
- -
- -
+
+
Generators - Generators are functions that create file formats from nix - data structures, e. g. for configuration files. - There are generators available for: INI, - JSON and YAML + Generators are functions that create file formats from nix data structures, + e. g. for configuration files. There are generators available for: + INI, JSON and YAML - All generators follow a similar call interface: generatorName - configFunctions data, where configFunctions is - an attrset of user-defined functions that format nested parts of the - content. - They each have common defaults, so often they do not need to be set - manually. An example is mkSectionName ? (name: libStr.escape [ "[" "]" - ] name) from the INI generator. It receives the - name of a section and sanitizes it. The default - mkSectionName escapes [ and - ] with a backslash. + All generators follow a similar call interface: generatorName + configFunctions data, where configFunctions is an + attrset of user-defined functions that format nested parts of the content. + They each have common defaults, so often they do not need to be set + manually. An example is mkSectionName ? (name: libStr.escape [ "[" "]" + ] name) from the INI generator. It receives the + name of a section and sanitizes it. The default + mkSectionName escapes [ and + ] with a backslash. - Generators can be fine-tuned to produce exactly the file format required - by your application/service. One example is an INI-file format which uses - : as separator, the strings - "yes"/"no" as boolean values - and requires all string values to be quoted: + Generators can be fine-tuned to produce exactly the file format required by + your application/service. One example is an INI-file format which uses + : as separator, the strings + "yes"/"no" as boolean values and + requires all string values to be quoted: @@ -270,7 +257,9 @@ in customToINI { } - This will produce the following INI file as nix string: + + This will produce the following INI file as nix string: + [main] @@ -284,111 +273,138 @@ str\:ange:"very::strange" merge:"diff3" - Nix store paths can be converted to strings by enclosing a - derivation attribute like so: "${drv}". + + + Nix store paths can be converted to strings by enclosing a derivation + attribute like so: "${drv}". + + - Detailed documentation for each generator can be found in - lib/generators.nix. + Detailed documentation for each generator can be found in + lib/generators.nix. - -
- -
+
+
Debugging Nix Expressions - Nix is a unityped, dynamic language, this means every value can - potentially appear anywhere. Since it is also non-strict, evaluation order - and what ultimately is evaluated might surprise you. Therefore it is important - to be able to debug nix expressions. + + Nix is a unityped, dynamic language, this means every value can potentially + appear anywhere. Since it is also non-strict, evaluation order and what + ultimately is evaluated might surprise you. Therefore it is important to be + able to debug nix expressions. + - - In the lib/debug.nix file you will find a number of - functions that help (pretty-)printing values while evaluation is runnnig. You - can even specify how deep these values should be printed recursively, and - transform them on the fly. Please consult the docstrings in - lib/debug.nix for usage information. -
- - -
+ + In the lib/debug.nix file you will find a number of + functions that help (pretty-)printing values while evaluation is runnnig. + You can even specify how deep these values should be printed recursively, + and transform them on the fly. Please consult the docstrings in + lib/debug.nix for usage information. + +
+
buildFHSUserEnv - buildFHSUserEnv provides a way to build and run - FHS-compatible lightweight sandboxes. It creates an isolated root with - bound /nix/store, so its footprint in terms of disk - space needed is quite small. This allows one to run software which is hard or - unfeasible to patch for NixOS -- 3rd-party source trees with FHS assumptions, - games distributed as tarballs, software with integrity checking and/or external - self-updated binaries. It uses Linux namespaces feature to create - temporary lightweight environments which are destroyed after all child - processes exit, without root user rights requirement. Accepted arguments are: + buildFHSUserEnv provides a way to build and run + FHS-compatible lightweight sandboxes. It creates an isolated root with bound + /nix/store, so its footprint in terms of disk space + needed is quite small. This allows one to run software which is hard or + unfeasible to patch for NixOS -- 3rd-party source trees with FHS + assumptions, games distributed as tarballs, software with integrity checking + and/or external self-updated binaries. It uses Linux namespaces feature to + create temporary lightweight environments which are destroyed after all + child processes exit, without root user rights requirement. Accepted + arguments are: - - name - - Environment name. - - - - targetPkgs - - Packages to be installed for the main host's architecture - (i.e. x86_64 on x86_64 installations). Along with libraries binaries are also - installed. - - - - multiPkgs - - Packages to be installed for all architectures supported by - a host (i.e. i686 and x86_64 on x86_64 installations). Only libraries are - installed by default. - - - - extraBuildCommands - - Additional commands to be executed for finalizing the - directory structure. - - - - extraBuildCommandsMulti - - Like extraBuildCommands, but - executed only on multilib architectures. - - - - extraOutputsToInstall - - Additional derivation outputs to be linked for both - target and multi-architecture packages. - - - - extraInstallCommands - - Additional commands to be executed for finalizing the - derivation with runner script. - - - - runScript - - A command that would be executed inside the sandbox and - passed all the command line arguments. It defaults to - bash. - + + name + + + + Environment name. + + + + + targetPkgs + + + + Packages to be installed for the main host's architecture (i.e. x86_64 on + x86_64 installations). Along with libraries binaries are also installed. + + + + + multiPkgs + + + + Packages to be installed for all architectures supported by a host (i.e. + i686 and x86_64 on x86_64 installations). Only libraries are installed by + default. + + + + + extraBuildCommands + + + + Additional commands to be executed for finalizing the directory + structure. + + + + + extraBuildCommandsMulti + + + + Like extraBuildCommands, but executed only on multilib + architectures. + + + + + extraOutputsToInstall + + + + Additional derivation outputs to be linked for both target and + multi-architecture packages. + + + + + extraInstallCommands + + + + Additional commands to be executed for finalizing the derivation with + runner script. + + + + + runScript + + + + A command that would be executed inside the sandbox and passed all the + command line arguments. It defaults to bash. + + + - One can create a simple environment using a shell.nix - like that: + One can create a simple environment using a shell.nix + like that: - Running nix-shell would then drop you into a shell with - these libraries and binaries available. You can use this to run - closed-source applications which expect FHS structure without hassles: - simply change runScript to the application path, - e.g. ./bin/start.sh -- relative paths are supported. + Running nix-shell would then drop you into a shell with + these libraries and binaries available. You can use this to run + closed-source applications which expect FHS structure without hassles: + simply change runScript to the application path, e.g. + ./bin/start.sh -- relative paths are supported. -
- -
-pkgs.dockerTools - - - pkgs.dockerTools is a set of functions for creating and - manipulating Docker images according to the - - Docker Image Specification v1.2.0 - . Docker itself is not used to perform any of the operations done by these - functions. - - - - - The dockerTools API is unstable and may be subject to - backwards-incompatible changes in the future. - - - -
- buildImage +
+
+ pkgs.dockerTools - This function is analogous to the docker build command, - in that can used to build a Docker-compatible repository tarball containing - a single image with one or multiple layers. As such, the result - is suitable for being loaded in Docker with docker load. + pkgs.dockerTools is a set of functions for creating and + manipulating Docker images according to the + + Docker Image Specification v1.2.0 . Docker itself is not used to + perform any of the operations done by these functions. - - The parameters of buildImage with relative example values are - described below: - + + + The dockerTools API is unstable and may be subject to + backwards-incompatible changes in the future. + + - Docker build - +
+ buildImage + + + This function is analogous to the docker build command, + in that can used to build a Docker-compatible repository tarball containing + a single image with one or multiple layers. As such, the result is suitable + for being loaded in Docker with docker load. + + + + The parameters of buildImage with relative example + values are described below: + + + + Docker build + buildImage { name = "redis"; tag = "latest"; @@ -480,154 +495,148 @@ merge:"diff3" }; } - + - The above example will build a Docker image redis/latest - from the given base image. Loading and running this image in Docker results in - redis-server being started automatically. - + + The above example will build a Docker image redis/latest + from the given base image. Loading and running this image in Docker results + in redis-server being started automatically. + - - + + + + name specifies the name of the resulting image. This + is the only required argument for buildImage. + + + + + tag specifies the tag of the resulting image. By + default it's latest. + + + + + fromImage is the repository tarball containing the + base image. It must be a valid Docker image, such as exported by + docker save. By default it's null, + which can be seen as equivalent to FROM scratch of a + Dockerfile. + + + + + fromImageName can be used to further specify the base + image within the repository, in case it contains multiple images. By + default it's null, in which case + buildImage will peek the first image available in the + repository. + + + + + fromImageTag can be used to further specify the tag of + the base image within the repository, in case an image contains multiple + tags. By default it's null, in which case + buildImage will peek the first tag available for the + base image. + + + + + contents is a derivation that will be copied in the + new layer of the resulting image. This can be similarly seen as + ADD contents/ / in a Dockerfile. + By default it's null. + + + + + runAsRoot is a bash script that will run as root in an + environment that overlays the existing layers of the base image with the + new resulting layer, including the previously copied + contents derivation. This can be similarly seen as + RUN ... in a Dockerfile. + + + Using this parameter requires the kvm device to be + available. + + + + + + + config is used to specify the configuration of the + containers that will be started off the built image in Docker. The + available options are listed in the + + Docker Image Specification v1.2.0 . + + + + + + After the new layer has been created, its closure (to which + contents, config and + runAsRoot contribute) will be copied in the layer + itself. Only new dependencies that are not already in the existing layers + will be copied. + + + + At the end of the process, only one new single layer will be produced and + added to the resulting image. + + + + The resulting repository will only list the single image + image/tag. In the case of + it would be + redis/latest. + + + + It is possible to inspect the arguments with which an image was built using + its buildArgs attribute. + + + - name specifies the name of the resulting image. - This is the only required argument for buildImage. + If you see errors similar to getProtocolByName: does not exist + (no such protocol name: tcp) you may need to add + pkgs.iana-etc to contents. - + - + - tag specifies the tag of the resulting image. - By default it's latest. + If you see errors similar to Error_Protocol ("certificate has + unknown CA",True,UnknownCa) you may need to add + pkgs.cacert to contents. - + +
- - - fromImage is the repository tarball containing the base image. - It must be a valid Docker image, such as exported by docker save. - By default it's null, which can be seen as equivalent - to FROM scratch of a Dockerfile. - - +
+ pullImage - - - fromImageName can be used to further specify - the base image within the repository, in case it contains multiple images. - By default it's null, in which case - buildImage will peek the first image available - in the repository. - - + + This function is analogous to the docker pull command, + in that can be used to fetch a Docker image from a Docker registry. + Currently only registry v1 is supported. By default + Docker Hub is used to + pull images. + - - - fromImageTag can be used to further specify the tag - of the base image within the repository, in case an image contains multiple tags. - By default it's null, in which case - buildImage will peek the first tag available for the base image. - - + + Its parameters are described in the example below: + - - - contents is a derivation that will be copied in the new - layer of the resulting image. This can be similarly seen as - ADD contents/ / in a Dockerfile. - By default it's null. - - - - - - runAsRoot is a bash script that will run as root - in an environment that overlays the existing layers of the base image with - the new resulting layer, including the previously copied - contents derivation. - This can be similarly seen as - RUN ... in a Dockerfile. - - - - Using this parameter requires the kvm - device to be available. - - - - - - - - config is used to specify the configuration of the - containers that will be started off the built image in Docker. - The available options are listed in the - - Docker Image Specification v1.2.0 - . - - - - - - - After the new layer has been created, its closure - (to which contents, config and - runAsRoot contribute) will be copied in the layer itself. - Only new dependencies that are not already in the existing layers will be copied. - - - - At the end of the process, only one new single layer will be produced and - added to the resulting image. - - - - The resulting repository will only list the single image - image/tag. In the case of - it would be redis/latest. - - - - It is possible to inspect the arguments with which an image was built - using its buildArgs attribute. - - - - - - - If you see errors similar to getProtocolByName: does not exist (no such protocol name: tcp) - you may need to add pkgs.iana-etc to contents. - - - - - - If you see errors similar to Error_Protocol ("certificate has unknown CA",True,UnknownCa) - you may need to add pkgs.cacert to contents. - - - -
- -
- pullImage - - - This function is analogous to the docker pull command, - in that can be used to fetch a Docker image from a Docker registry. - Currently only registry v1 is supported. - By default Docker Hub - is used to pull images. - - - - Its parameters are described in the example below: - - - Docker pull - + + Docker pull + pullImage { imageName = "debian"; imageTag = "jessie"; @@ -638,80 +647,78 @@ merge:"diff3" registryVersion = "v1"; } - + - - + + + + imageName specifies the name of the image to be + downloaded, which can also include the registry namespace (e.g. + library/debian). This argument is required. + + + + + imageTag specifies the tag of the image to be + downloaded. By default it's latest. + + + + + imageId, if specified this exact image will be + fetched, instead of imageName/imageTag. However, the + resulting repository will still be named + imageName/imageTag. By default it's + null. + + + + + sha256 is the checksum of the whole fetched image. + This argument is required. + + + + The checksum is computed on the unpacked directory, not on the final + tarball. + + + + + + In the above example the default values are shown for the variables + indexUrl and registryVersion. Hence + by default the Docker.io registry is used to pull the images. + + + +
+ +
+ exportImage + + + This function is analogous to the docker export command, + in that can used to flatten a Docker image that contains multiple layers. + It is in fact the result of the merge of all the layers of the image. As + such, the result is suitable for being imported in Docker with + docker import. + + + - imageName specifies the name of the image to be downloaded, - which can also include the registry namespace (e.g. library/debian). - This argument is required. + Using this function requires the kvm device to be + available. - + - - - imageTag specifies the tag of the image to be downloaded. - By default it's latest. - - + + The parameters of exportImage are the following: + - - - imageId, if specified this exact image will be fetched, instead - of imageName/imageTag. However, the resulting repository - will still be named imageName/imageTag. - By default it's null. - - - - - - sha256 is the checksum of the whole fetched image. - This argument is required. - - - - The checksum is computed on the unpacked directory, not on the final tarball. - - - - - - - In the above example the default values are shown for the variables - indexUrl and registryVersion. - Hence by default the Docker.io registry is used to pull the images. - - - - -
- -
- exportImage - - - This function is analogous to the docker export command, - in that can used to flatten a Docker image that contains multiple layers. - It is in fact the result of the merge of all the layers of the image. - As such, the result is suitable for being imported in Docker - with docker import. - - - - - Using this function requires the kvm - device to be available. - - - - - The parameters of exportImage are the following: - - - Docker export - + + Docker export + exportImage { fromImage = someLayeredImage; fromImageName = null; @@ -720,33 +727,35 @@ merge:"diff3" name = someLayeredImage.name; } - + - - The parameters relative to the base image have the same synopsis as - described in , except that - fromImage is the only required argument in this case. - + + The parameters relative to the base image have the same synopsis as + described in , except + that fromImage is the only required argument in this + case. + - - The name argument is the name of the derivation output, - which defaults to fromImage.name. - -
+ + The name argument is the name of the derivation output, + which defaults to fromImage.name. + +
-
- shadowSetup +
+ shadowSetup - - This constant string is a helper for setting up the base files for managing - users and groups, only if such files don't exist already. - It is suitable for being used in a - runAsRoot script for cases like - in the example below: - + + This constant string is a helper for setting up the base files for managing + users and groups, only if such files don't exist already. It is suitable + for being used in a runAsRoot + script for cases like + in the example below: + - Shadow base files - + + Shadow base files + buildImage { name = "shadow-basic"; @@ -760,16 +769,13 @@ merge:"diff3" ''; } - - - - Creating base files like /etc/passwd or - /etc/login.defs are necessary for shadow-utils to - manipulate users and groups. - - -
- -
+ + + Creating base files like /etc/passwd or + /etc/login.defs are necessary for shadow-utils to + manipulate users and groups. + +
+
diff --git a/doc/languages-frameworks/beam.xml b/doc/languages-frameworks/beam.xml index 1a18ed27237c..ac7a83ed4265 100644 --- a/doc/languages-frameworks/beam.xml +++ b/doc/languages-frameworks/beam.xml @@ -1,124 +1,137 @@
+ BEAM Languages (Erlang, Elixir & LFE) - BEAM Languages (Erlang, Elixir & LFE) -
- Introduction - - In this document and related Nix expressions, we use the term, - BEAM, to describe the environment. BEAM is the name - of the Erlang Virtual Machine and, as far as we're concerned, from a - packaging perspective, all languages that run on the BEAM are - interchangeable. That which varies, like the build system, is transparent - to users of any given BEAM package, so we make no distinction. - -
-
- Structure - - All BEAM-related expressions are available via the top-level - beam attribute, which includes: - - - - - interpreters: a set of compilers running on the - BEAM, including multiple Erlang/OTP versions - (beam.interpreters.erlangR19, etc), Elixir - (beam.interpreters.elixir) and LFE - (beam.interpreters.lfe). - - - - - packages: a set of package sets, each compiled with - a specific Erlang/OTP version, e.g. - beam.packages.erlangR19. - - - - - The default Erlang compiler, defined by - beam.interpreters.erlang, is aliased as - erlang. The default BEAM package set is defined by - beam.packages.erlang and aliased at the top level as - beamPackages. - - - To create a package set built with a custom Erlang version, use the - lambda, beam.packagesWith, which accepts an Erlang/OTP - derivation and produces a package set similar to - beam.packages.erlang. - - - Many Erlang/OTP distributions available in - beam.interpreters have versions with ODBC and/or Java - enabled. For example, there's - beam.interpreters.erlangR19_odbc_javac, which - corresponds to beam.interpreters.erlangR19. - - - We also provide the lambda, - beam.packages.erlang.callPackage, which simplifies - writing BEAM package definitions by injecting all packages from - beam.packages.erlang into the top-level context. - -
-
- Build Tools -
- Rebar3 - - By default, Rebar3 wants to manage its own dependencies. This is perfectly - acceptable in the normal, non-Nix setup, but in the Nix world, it is not. - To rectify this, we provide two versions of Rebar3: - - - - rebar3: patched to remove the ability to download - anything. When not running it via nix-shell or - nix-build, it's probably not going to work as - desired. - - - - - rebar3-open: the normal, unmodified Rebar3. It - should work exactly as would any other version of Rebar3. Any Erlang - package should rely on rebar3 instead. See . - - - - -
-
- Mix & Erlang.mk - - Both Mix and Erlang.mk work exactly as expected. There is a bootstrap - process that needs to be run for both, however, which is supported by the - buildMix and buildErlangMk - derivations, respectively. - -
-
+
+ Introduction -
- How to Install BEAM Packages - BEAM packages are not registered at the top level, simply because they are - not relevant to the vast majority of Nix users. They are installable using - the beam.packages.erlang attribute set (aliased as - beamPackages), which points to packages built by the - default Erlang/OTP version in Nixpkgs, as defined by - beam.interpreters.erlang. + In this document and related Nix expressions, we use the term, + BEAM, to describe the environment. BEAM is the name of + the Erlang Virtual Machine and, as far as we're concerned, from a packaging + perspective, all languages that run on the BEAM are interchangeable. That + which varies, like the build system, is transparent to users of any given + BEAM package, so we make no distinction. + +
- To list the available packages in - beamPackages, use the following command: +
+ Structure + + + All BEAM-related expressions are available via the top-level + beam attribute, which includes: - + + + + interpreters: a set of compilers running on the BEAM, + including multiple Erlang/OTP versions + (beam.interpreters.erlangR19, etc), Elixir + (beam.interpreters.elixir) and LFE + (beam.interpreters.lfe). + + + + + packages: a set of package sets, each compiled with a + specific Erlang/OTP version, e.g. + beam.packages.erlangR19. + + + + + + The default Erlang compiler, defined by + beam.interpreters.erlang, is aliased as + erlang. The default BEAM package set is defined by + beam.packages.erlang and aliased at the top level as + beamPackages. + + + + To create a package set built with a custom Erlang version, use the lambda, + beam.packagesWith, which accepts an Erlang/OTP derivation + and produces a package set similar to + beam.packages.erlang. + + + + Many Erlang/OTP distributions available in + beam.interpreters have versions with ODBC and/or Java + enabled. For example, there's + beam.interpreters.erlangR19_odbc_javac, which corresponds + to beam.interpreters.erlangR19. + + + + We also provide the lambda, + beam.packages.erlang.callPackage, which simplifies + writing BEAM package definitions by injecting all packages from + beam.packages.erlang into the top-level context. + +
+ +
+ Build Tools + +
+ Rebar3 + + + By default, Rebar3 wants to manage its own dependencies. This is perfectly + acceptable in the normal, non-Nix setup, but in the Nix world, it is not. + To rectify this, we provide two versions of Rebar3: + + + + rebar3: patched to remove the ability to download + anything. When not running it via nix-shell or + nix-build, it's probably not going to work as + desired. + + + + + rebar3-open: the normal, unmodified Rebar3. It should + work exactly as would any other version of Rebar3. Any Erlang package + should rely on rebar3 instead. See + . + + + + +
+ +
+ Mix & Erlang.mk + + + Both Mix and Erlang.mk work exactly as expected. There is a bootstrap + process that needs to be run for both, however, which is supported by the + buildMix and buildErlangMk + derivations, respectively. + +
+
+ +
+ How to Install BEAM Packages + + + BEAM packages are not registered at the top level, simply because they are + not relevant to the vast majority of Nix users. They are installable using + the beam.packages.erlang attribute set (aliased as + beamPackages), which points to packages built by the + default Erlang/OTP version in Nixpkgs, as defined by + beam.interpreters.erlang. To list the available packages + in beamPackages, use the following command: + + + $ nix-env -f "<nixpkgs>" -qaP -A beamPackages beamPackages.esqlite esqlite-0.2.1 beamPackages.goldrush goldrush-0.1.7 @@ -128,34 +141,43 @@ beamPackages.lager lager-3.0.2 beamPackages.meck meck-0.8.3 beamPackages.rebar3-pc pc-1.1.0 + - To install any of those packages into your profile, refer to them by their - attribute path (first column): + To install any of those packages into your profile, refer to them by their + attribute path (first column): - + + $ nix-env -f "<nixpkgs>" -iA beamPackages.ibrowse + - The attribute path of any BEAM package corresponds to the name of that - particular package in Hex or its - OTP Application/Release name. + The attribute path of any BEAM package corresponds to the name of that + particular package in Hex or its + OTP Application/Release name. -
-
+
+ +
Packaging BEAM Applications +
- Erlang Applications -
- Rebar3 Packages - - The Nix function, buildRebar3, defined in - beam.packages.erlang.buildRebar3 and aliased at the - top level, can be used to build a derivation that understands how to - build a Rebar3 project. For example, we can build hex2nix as - follows: - - + Erlang Applications + +
+ Rebar3 Packages + + + The Nix function, buildRebar3, defined in + beam.packages.erlang.buildRebar3 and aliased at the top + level, can be used to build a derivation that understands how to build a + Rebar3 project. For example, we can build + hex2nix + as follows: + + + { stdenv, fetchFromGitHub, buildRebar3, ibrowse, jsx, erlware_commons }: buildRebar3 rec { @@ -172,33 +194,40 @@ $ nix-env -f "<nixpkgs>" -iA beamPackages.ibrowse beamDeps = [ ibrowse jsx erlware_commons ]; } - - Such derivations are callable with - beam.packages.erlang.callPackage (see ). To call this package using the normal - callPackage, refer to dependency packages via - beamPackages, e.g. - beamPackages.ibrowse. - - - Notably, buildRebar3 includes - beamDeps, while - stdenv.mkDerivation does not. BEAM dependencies added - there will be correctly handled by the system. - - - If a package needs to compile native code via Rebar3's port compilation - mechanism, add compilePort = true; to the derivation. - -
-
- Erlang.mk Packages - - Erlang.mk functions similarly to Rebar3, except we use - buildErlangMk instead of - buildRebar3. - - + + + Such derivations are callable with + beam.packages.erlang.callPackage (see + ). To call this package using + the normal callPackage, refer to dependency packages + via beamPackages, e.g. + beamPackages.ibrowse. + + + + Notably, buildRebar3 includes + beamDeps, while stdenv.mkDerivation + does not. BEAM dependencies added there will be correctly handled by the + system. + + + + If a package needs to compile native code via Rebar3's port compilation + mechanism, add compilePort = true; to the derivation. + +
+ +
+ Erlang.mk Packages + + + Erlang.mk functions similarly to Rebar3, except we use + buildErlangMk instead of + buildRebar3. + + + { buildErlangMk, fetchHex, cowlib, ranch }: buildErlangMk { @@ -222,14 +251,17 @@ $ nix-env -f "<nixpkgs>" -iA beamPackages.ibrowse }; } -
-
- Mix Packages - - Mix functions similarly to Rebar3, except we use - buildMix instead of buildRebar3. - - +
+ +
+ Mix Packages + + + Mix functions similarly to Rebar3, except we use + buildMix instead of buildRebar3. + + + { buildMix, fetchHex, plug, absinthe }: buildMix { @@ -253,10 +285,12 @@ $ nix-env -f "<nixpkgs>" -iA beamPackages.ibrowse }; } - - Alternatively, we can use buildHex as a shortcut: - - + + + Alternatively, we can use buildHex as a shortcut: + + + { buildHex, buildMix, plug, absinthe }: buildHex { @@ -278,21 +312,25 @@ $ nix-env -f "<nixpkgs>" -iA beamPackages.ibrowse }; } -
+
-
-
+
+ +
How to Develop +
- Accessing an Environment - - Often, we simply want to access a valid environment that contains a - specific package and its dependencies. We can accomplish that with the - env attribute of a derivation. For example, let's say - we want to access an Erlang REPL with ibrowse loaded - up. We could do the following: - - + Accessing an Environment + + + Often, we simply want to access a valid environment that contains a + specific package and its dependencies. We can accomplish that with the + env attribute of a derivation. For example, let's say we + want to access an Erlang REPL with ibrowse loaded up. We + could do the following: + + + $ nix-shell -A beamPackages.ibrowse.env --run "erl" Erlang/OTP 18 [erts-7.0] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] @@ -333,22 +371,25 @@ $ nix-env -f "<nixpkgs>" -iA beamPackages.ibrowse ok 2> - - Notice the -A beamPackages.ibrowse.env. That is the key - to this functionality. - + + + Notice the -A beamPackages.ibrowse.env. That is the key + to this functionality. +
+
- Creating a Shell - - Getting access to an environment often isn't enough to do real - development. Usually, we need to create a shell.nix - file and do our development inside of the environment specified therein. - This file looks a lot like the packaging described above, except that - src points to the project root and we call the package - directly. - - + Creating a Shell + + + Getting access to an environment often isn't enough to do real development. + Usually, we need to create a shell.nix file and do our + development inside of the environment specified therein. This file looks a + lot like the packaging described above, except that src + points to the project root and we call the package directly. + + + { pkgs ? import "<nixpkgs"> {} }: with pkgs; @@ -368,13 +409,16 @@ in drv -
+ +
Building in a Shell (for Mix Projects) + - We can leverage the support of the derivation, irrespective of the build - derivation, by calling the commands themselves. + We can leverage the support of the derivation, irrespective of the build + derivation, by calling the commands themselves. - + + # ============================================================================= # Variables # ============================================================================= @@ -431,44 +475,54 @@ analyze: build plt $(NIX_SHELL) --run "mix dialyzer --no-compile" + - Using a shell.nix as described (see shell.nix as described (see + ) should just work. Aside from - test, plt, and - analyze, the Make targets work just fine for all of the - build derivations. + test, plt, and + analyze, the Make targets work just fine for all of the + build derivations. +
-
-
-
+
+ +
Generating Packages from Hex with <literal>hex2nix</literal> + - Updating the Hex package set - requires hex2nix. Given the - path to the Erlang modules (usually - pkgs/development/erlang-modules), it will dump a file - called hex-packages.nix, containing all the packages that - use a recognized build system in Hex. It can't be determined, however, - whether every package is buildable. - - - To make life easier for our users, try to build every Hex package and remove those that fail. - To do that, simply run the following command in the root of your - nixpkgs repository: - - + Updating the Hex package set + requires + hex2nix. + Given the path to the Erlang modules (usually + pkgs/development/erlang-modules), it will dump a file + called hex-packages.nix, containing all the packages that + use a recognized build system in + Hex. It can't be determined, + however, whether every package is buildable. + + + + To make life easier for our users, try to build every + Hex package and remove those + that fail. To do that, simply run the following command in the root of your + nixpkgs repository: + + + $ nix-build -A beamPackages - - That will attempt to build every package in - beamPackages. Then manually remove those that fail. - Hopefully, someone will improve hex2nix in the - future to automate the process. - -
+ + + That will attempt to build every package in beamPackages. + Then manually remove those that fail. Hopefully, someone will improve + hex2nix + in the future to automate the process. + +
diff --git a/doc/languages-frameworks/bower.xml b/doc/languages-frameworks/bower.xml index 742d3c2e9fe5..db7536cdc14e 100644 --- a/doc/languages-frameworks/bower.xml +++ b/doc/languages-frameworks/bower.xml @@ -1,40 +1,37 @@
+ Bower -Bower + + Bower is a package manager for web + site front-end components. Bower packages (comprising of build artefacts and + sometimes sources) are stored in git repositories, + typically on Github. The package registry is run by the Bower team with + package metadata coming from the bower.json file within + each package. + - - Bower is a package manager - for web site front-end components. Bower packages (comprising of - build artefacts and sometimes sources) are stored in - git repositories, typically on Github. The - package registry is run by the Bower team with package metadata - coming from the bower.json file within each - package. - + + The end result of running Bower is a bower_components + directory which can be included in the web app's build process. + - - The end result of running Bower is a - bower_components directory which can be included - in the web app's build process. - - - + Bower can be run interactively, by installing nodePackages.bower. More interestingly, the Bower components can be declared in a Nix derivation, with the help of nodePackages.bower2nix. - + -
+
<command>bower2nix</command> usage - - Suppose you have a bower.json with the following contents: - - -<filename>bower.json</filename> + + Suppose you have a bower.json with the following + contents: + + <filename>bower.json</filename> - - - - - - Running bower2nix will produce something like the - following output: + + + + Running bower2nix will produce something like the + following output: - - - - - Using the bower2nix command line arguments, the - output can be redirected to a file. A name like - bower-packages.nix would be fine. - - - - The resulting derivation is a union of all the downloaded Bower - packages (and their dependencies). To use it, they still need to be - linked together by Bower, which is where - buildBowerComponents is useful. - -
- -
<varname>buildBowerComponents</varname> function + - The function is implemented in - pkgs/development/bower-modules/generic/default.nix. - Example usage: + Using the bower2nix command line arguments, the output + can be redirected to a file. A name like + bower-packages.nix would be fine. + -buildBowerComponents + + The resulting derivation is a union of all the downloaded Bower packages + (and their dependencies). To use it, they still need to be linked together + by Bower, which is where buildBowerComponents is useful. + +
+ +
+ <varname>buildBowerComponents</varname> function + + + The function is implemented in + + pkgs/development/bower-modules/generic/default.nix. + Example usage: + + buildBowerComponents bowerComponents = buildBowerComponents { name = "my-web-app"; @@ -92,42 +87,42 @@ bowerComponents = buildBowerComponents { src = myWebApp; }; - + - -In , the following arguments -are of special significance to the function: + + In , the following arguments are + of special significance to the function: + + + + generated specifies the file which was created by + bower2nix. + + + + + src is your project's sources. It needs to contain a + bower.json file. + + + + - - - - generated specifies the file which was created by bower2nix. - - + + buildBowerComponents will run Bower to link together the + output of bower2nix, resulting in a + bower_components directory which can be used. + - - - src is your project's sources. It needs to - contain a bower.json file. - - - - + + Here is an example of a web frontend build process using + gulp. You might use grunt, or anything + else. + - - buildBowerComponents will run Bower to link - together the output of bower2nix, resulting in a - bower_components directory which can be used. - - - - Here is an example of a web frontend build process using - gulp. You might use grunt, or - anything else. - - -Example build script (<filename>gulpfile.js</filename>) + + Example build script (<filename>gulpfile.js</filename>) - + - - Full example — <filename>default.nix</filename> + + Full example — <filename>default.nix</filename> { myWebApp ? { outPath = ./.; name = "myWebApp"; } , pkgs ? import <nixpkgs> {} @@ -172,73 +167,63 @@ pkgs.stdenv.mkDerivation { installPhase = "mv gulpdist $out"; } - + - -A few notes about : - - - - - The result of buildBowerComponents is an - input to the frontend build. - - - - - - Whether to symlink or copy the - bower_components directory depends on the - build tool in use. In this case a copy is used to avoid - gulp silliness with permissions. - - - - - - gulp requires HOME to - refer to a writeable directory. - - - - - + + A few notes about : + + + + The result of buildBowerComponents is an input to the + frontend build. + + + + + Whether to symlink or copy the bower_components + directory depends on the build tool in use. In this case a copy is used + to avoid gulp silliness with permissions. + + + + + gulp requires HOME to refer to a + writeable directory. + + + + The actual build command. Other tools could be used. - - - - -
+ + + + +
-
+
Troubleshooting - - - - - ENOCACHE errors from + + + ENOCACHE errors from buildBowerComponents - - This means that Bower was looking for a package version which - doesn't exist in the generated - bower-packages.nix. - - - If bower.json has been updated, then run - bower2nix again. - - - It could also be a bug in bower2nix or - fetchbower. If possible, try reformulating - the version specification in bower.json. - + + This means that Bower was looking for a package version which doesn't + exist in the generated bower-packages.nix. + + + If bower.json has been updated, then run + bower2nix again. + + + It could also be a bug in bower2nix or + fetchbower. If possible, try reformulating the version + specification in bower.json. + - - - -
- + + +
diff --git a/doc/languages-frameworks/coq.xml b/doc/languages-frameworks/coq.xml index 0ce1abd6194c..d5f2574039f2 100644 --- a/doc/languages-frameworks/coq.xml +++ b/doc/languages-frameworks/coq.xml @@ -1,36 +1,38 @@
+ Coq -Coq - - Coq libraries should be installed in - $(out)/lib/coq/${coq.coq-version}/user-contrib/. - Such directories are automatically added to the - $COQPATH environment variable by the hook defined - in the Coq derivation. - - - Some libraries require OCaml and sometimes also Camlp5 or findlib. - The exact versions that were used to build Coq are saved in the - coq.ocaml and coq.camlp5 - and coq.findlib attributes. - - - Coq libraries may be compatible with some specific versions of Coq only. - The compatibleCoqVersions attribute is used to - precisely select those versions of Coq that are compatible with this - derivation. - - - Here is a simple package example. It is a pure Coq library, thus it - depends on Coq. It builds on the Mathematical Components library, thus it - also takes mathcomp as buildInputs. - Its Makefile has been generated using - coq_makefile so we only have to - set the $COQLIB variable at install time. - - + + Coq libraries should be installed in + $(out)/lib/coq/${coq.coq-version}/user-contrib/. Such + directories are automatically added to the $COQPATH + environment variable by the hook defined in the Coq derivation. + + + + Some libraries require OCaml and sometimes also Camlp5 or findlib. The exact + versions that were used to build Coq are saved in the + coq.ocaml and coq.camlp5 and + coq.findlib attributes. + + + + Coq libraries may be compatible with some specific versions of Coq only. The + compatibleCoqVersions attribute is used to precisely + select those versions of Coq that are compatible with this derivation. + + + + Here is a simple package example. It is a pure Coq library, thus it depends + on Coq. It builds on the Mathematical Components library, thus it also takes + mathcomp as buildInputs. Its + Makefile has been generated using + coq_makefile so we only have to set the + $COQLIB variable at install time. + + + { stdenv, fetchFromGitHub, coq, mathcomp }: stdenv.mkDerivation rec { diff --git a/doc/languages-frameworks/go.xml b/doc/languages-frameworks/go.xml index 54ea60c90212..ab4c9f0f7c88 100644 --- a/doc/languages-frameworks/go.xml +++ b/doc/languages-frameworks/go.xml @@ -1,14 +1,14 @@
+ Go -Go + + The function buildGoPackage builds standard Go programs. + -The function buildGoPackage builds -standard Go programs. - - -buildGoPackage + + buildGoPackage deis = buildGoPackage rec { name = "deis-${version}"; @@ -29,55 +29,56 @@ deis = buildGoPackage rec { buildFlags = "--tags release"; } - + - is an example expression using buildGoPackage, -the following arguments are of special significance to the function: - - - - + + is an example expression using + buildGoPackage, the following arguments are of special significance to the + function: + + - goPackagePath specifies the package's canonical Go import path. + goPackagePath specifies the package's canonical Go + import path. - - - + + - subPackages limits the builder from building child packages that - have not been listed. If subPackages is not specified, all child - packages will be built. + subPackages limits the builder from building child + packages that have not been listed. If subPackages is + not specified, all child packages will be built. - In this example only github.com/deis/deis/client will be built. + In this example only github.com/deis/deis/client will + be built. - - - + + - goDeps is where the Go dependencies of a Go program are listed - as a list of package source identified by Go import path. - It could be imported as a separate deps.nix file for - readability. The dependency data structure is described below. + goDeps is where the Go dependencies of a Go program are + listed as a list of package source identified by Go import path. It could + be imported as a separate deps.nix file for + readability. The dependency data structure is described below. - - - + + - buildFlags is a list of flags passed to the go build command. + buildFlags is a list of flags passed to the go build + command. - + + + - + + The goDeps attribute can be imported from a separate + nix file that defines which Go libraries are needed and + should be included in GOPATH for + buildPhase. + - - -The goDeps attribute can be imported from a separate - nix file that defines which Go libraries are needed and should - be included in GOPATH for buildPhase. - - -deps.nix + + deps.nix [ { @@ -100,67 +101,60 @@ the following arguments are of special significance to the function: } ] - + - - - - - + + + - goDeps is a list of Go dependencies. + goDeps is a list of Go dependencies. - - - + + - goPackagePath specifies Go package import path. + goPackagePath specifies Go package import path. - - - + + - fetch type that needs to be used to get package source. If git - is used there should be url, rev and sha256 - defined next to it. + fetch type that needs to be used to get package source. + If git is used there should be url, + rev and sha256 defined next to it. - + + + - + + To extract dependency information from a Go package in automated way use + go2nix. It can + produce complete derivation and goDeps file for Go + programs. + - - -To extract dependency information from a Go package in automated way use go2nix. - It can produce complete derivation and goDeps file for Go programs. - - - buildGoPackage produces - where bin includes program binaries. You can test build a Go binary as follows: - - + + buildGoPackage produces + where + bin includes program binaries. You can test build a Go + binary as follows: + $ nix-build -A deis.bin - or build all outputs with: - - + $ nix-build -A deis.all + bin output will be installed by default with + nix-env -i or systemPackages. + - bin output will be installed by default with nix-env -i - or systemPackages. - - - - -You may use Go packages installed into the active Nix profiles by adding -the following to your ~/.bashrc: - + + You may use Go packages installed into the active Nix profiles by adding the + following to your ~/.bashrc: for p in $NIX_PROFILES; do GOPATH="$p/share/go:$GOPATH" done - - +
diff --git a/doc/languages-frameworks/index.xml b/doc/languages-frameworks/index.xml index a1c265f67484..f22984cb56b0 100644 --- a/doc/languages-frameworks/index.xml +++ b/doc/languages-frameworks/index.xml @@ -1,36 +1,31 @@ - -Support for specific programming languages and frameworks - -The standard build -environment makes it easy to build typical Autotools-based -packages with very little code. Any other kind of package can be -accomodated by overriding the appropriate phases of -stdenv. However, there are specialised functions -in Nixpkgs to easily build packages for other programming languages, -such as Perl or Haskell. These are described in this chapter. - - - - - - - - - - - - - - - - - - - - - - + Support for specific programming languages and frameworks + + The standard build environment makes it + easy to build typical Autotools-based packages with very little code. Any + other kind of package can be accomodated by overriding the appropriate phases + of stdenv. However, there are specialised functions in + Nixpkgs to easily build packages for other programming languages, such as + Perl or Haskell. These are described in this chapter. + + + + + + + + + + + + + + + + + + + diff --git a/doc/languages-frameworks/java.xml b/doc/languages-frameworks/java.xml index 2507cc2c469a..dcf4d17fa57d 100644 --- a/doc/languages-frameworks/java.xml +++ b/doc/languages-frameworks/java.xml @@ -1,11 +1,10 @@
+ Java -Java - -Ant-based Java packages are typically built from source as follows: - + + Ant-based Java packages are typically built from source as follows: stdenv.mkDerivation { name = "..."; @@ -16,33 +15,33 @@ stdenv.mkDerivation { buildPhase = "ant"; } + Note that jdk is an alias for the OpenJDK. + -Note that jdk is an alias for the OpenJDK. - -JAR files that are intended to be used by other packages should -be installed in $out/share/java. The OpenJDK has -a stdenv setup hook that adds any JARs in the -share/java directories of the build inputs to the -CLASSPATH environment variable. For instance, if the -package libfoo installs a JAR named -foo.jar in its share/java -directory, and another package declares the attribute - + + JAR files that are intended to be used by other packages should be installed + in $out/share/java. The OpenJDK has a stdenv setup hook + that adds any JARs in the share/java directories of the + build inputs to the CLASSPATH environment variable. For + instance, if the package libfoo installs a JAR named + foo.jar in its share/java + directory, and another package declares the attribute buildInputs = [ jdk libfoo ]; + then CLASSPATH will be set to + /nix/store/...-libfoo/share/java/foo.jar. + -then CLASSPATH will be set to -/nix/store/...-libfoo/share/java/foo.jar. - -Private JARs -should be installed in a location like -$out/share/package-name. - -If your Java package provides a program, you need to generate a -wrapper script to run it using the OpenJRE. You can use -makeWrapper for this: + + Private JARs should be installed in a location like + $out/share/package-name. + + + If your Java package provides a program, you need to generate a wrapper + script to run it using the OpenJRE. You can use + makeWrapper for this: buildInputs = [ makeWrapper ]; @@ -53,23 +52,20 @@ installPhase = --add-flags "-cp $out/share/java/foo.jar org.foo.Main" ''; + Note the use of jre, which is the part of the OpenJDK + package that contains the Java Runtime Environment. By using + ${jre}/bin/java instead of + ${jdk}/bin/java, you prevent your package from depending + on the JDK at runtime. + -Note the use of jre, which is the part of the -OpenJDK package that contains the Java Runtime Environment. By using -${jre}/bin/java instead of -${jdk}/bin/java, you prevent your package from -depending on the JDK at runtime. - -It is possible to use a different Java compiler than -javac from the OpenJDK. For instance, to use the -GNU Java Compiler: - + + It is possible to use a different Java compiler than javac + from the OpenJDK. For instance, to use the GNU Java Compiler: buildInputs = [ gcj ant ]; - -Here, Ant will automatically use gij (the GNU Java -Runtime) instead of the OpenJRE. - + Here, Ant will automatically use gij (the GNU Java + Runtime) instead of the OpenJRE. +
- diff --git a/doc/languages-frameworks/lua.xml b/doc/languages-frameworks/lua.xml index 39b086af4cb1..210140299960 100644 --- a/doc/languages-frameworks/lua.xml +++ b/doc/languages-frameworks/lua.xml @@ -1,24 +1,22 @@
+ Lua -Lua - - - Lua packages are built by the buildLuaPackage function. This function is - implemented - in + + Lua packages are built by the buildLuaPackage function. + This function is implemented in + pkgs/development/lua-modules/generic/default.nix and works similarly to buildPerlPackage. (See for details.) - + - - Lua packages are defined - in pkgs/top-level/lua-packages.nix. + + Lua packages are defined in + pkgs/top-level/lua-packages.nix. Most of them are simple. For example: - - + fileSystem = buildLuaPackage { name = "filesystem-1.6.2"; src = fetchurl { @@ -32,20 +30,19 @@ fileSystem = buildLuaPackage { }; }; - + - + Though, more complicated package should be placed in a seperate file in pkgs/development/lua-modules. - - - Lua packages accept additional parameter disabled, which defines - the condition of disabling package from luaPackages. For example, if package has - disabled assigned to lua.luaversion != "5.1", - it will not be included in any luaPackages except lua51Packages, making it - only be built for lua 5.1. - + + + Lua packages accept additional parameter disabled, which + defines the condition of disabling package from luaPackages. For example, if + package has disabled assigned to lua.luaversion + != "5.1", it will not be included in any luaPackages except + lua51Packages, making it only be built for lua 5.1. +
- diff --git a/doc/languages-frameworks/perl.xml b/doc/languages-frameworks/perl.xml index 149fcb275a09..2fe64999e139 100644 --- a/doc/languages-frameworks/perl.xml +++ b/doc/languages-frameworks/perl.xml @@ -1,24 +1,27 @@
+ Perl -Perl + + Nixpkgs provides a function buildPerlPackage, a generic + package builder function for any Perl package that has a standard + Makefile.PL. It’s implemented in + pkgs/development/perl-modules/generic. + -Nixpkgs provides a function buildPerlPackage, -a generic package builder function for any Perl package that has a -standard Makefile.PL. It’s implemented in pkgs/development/perl-modules/generic. - -Perl packages from CPAN are defined in + Perl packages from CPAN are defined in + pkgs/top-level/perl-packages.nix, -rather than pkgs/all-packages.nix. Most Perl -packages are so straight-forward to build that they are defined here -directly, rather than having a separate function for each package -called from perl-packages.nix. However, more -complicated packages should be put in a separate file, typically in -pkgs/development/perl-modules. Here is an -example of the former: - + rather than pkgs/all-packages.nix. Most Perl packages + are so straight-forward to build that they are defined here directly, rather + than having a separate function for each package called from + perl-packages.nix. However, more complicated packages + should be put in a separate file, typically in + pkgs/development/perl-modules. Here is an example of the + former: ClassC3 = buildPerlPackage rec { name = "Class-C3-0.21"; @@ -28,74 +31,72 @@ ClassC3 = buildPerlPackage rec { }; }; - -Note the use of mirror://cpan/, and the -${name} in the URL definition to ensure that the -name attribute is consistent with the source that we’re actually -downloading. Perl packages are made available in -all-packages.nix through the variable -perlPackages. For instance, if you have a package -that needs ClassC3, you would typically write - + Note the use of mirror://cpan/, and the + ${name} in the URL definition to ensure that the name + attribute is consistent with the source that we’re actually downloading. + Perl packages are made available in all-packages.nix + through the variable perlPackages. For instance, if you + have a package that needs ClassC3, you would typically + write foo = import ../path/to/foo.nix { inherit stdenv fetchurl ...; inherit (perlPackages) ClassC3; }; - -in all-packages.nix. You can test building a -Perl package as follows: - + in all-packages.nix. You can test building a Perl + package as follows: $ nix-build -A perlPackages.ClassC3 - -buildPerlPackage adds perl- to -the start of the name attribute, so the package above is actually -called perl-Class-C3-0.21. So to install it, you -can say: - + buildPerlPackage adds perl- to the + start of the name attribute, so the package above is actually called + perl-Class-C3-0.21. So to install it, you can say: $ nix-env -i perl-Class-C3 + (Of course you can also install using the attribute name: nix-env -i + -A perlPackages.ClassC3.) + -(Of course you can also install using the attribute name: -nix-env -i -A perlPackages.ClassC3.) - -So what does buildPerlPackage do? It does -the following: - - - - In the configure phase, it calls perl - Makefile.PL to generate a Makefile. You can set the - variable makeMakerFlags to pass flags to - Makefile.PL - - It adds the contents of the PERL5LIB - environment variable to #! .../bin/perl line of - Perl scripts as -Idir - flags. This ensures that a script can find its - dependencies. - - In the fixup phase, it writes the propagated build - inputs (propagatedBuildInputs) to the file - $out/nix-support/propagated-user-env-packages. - nix-env recursively installs all packages listed - in this file when you install a package that has it. This ensures - that a Perl package can find its dependencies. - - - - - -buildPerlPackage is built on top of -stdenv, so everything can be customised in the -usual way. For instance, the BerkeleyDB module has -a preConfigure hook to generate a configuration -file used by Makefile.PL: + + So what does buildPerlPackage do? It does the following: + + + + In the configure phase, it calls perl Makefile.PL to + generate a Makefile. You can set the variable + makeMakerFlags to pass flags to + Makefile.PL + + + + + It adds the contents of the PERL5LIB environment variable + to #! .../bin/perl line of Perl scripts as + -Idir flags. This ensures + that a script can find its dependencies. + + + + + In the fixup phase, it writes the propagated build inputs + (propagatedBuildInputs) to the file + $out/nix-support/propagated-user-env-packages. + nix-env recursively installs all packages listed in + this file when you install a package that has it. This ensures that a Perl + package can find its dependencies. + + + + + + buildPerlPackage is built on top of + stdenv, so everything can be customised in the usual way. + For instance, the BerkeleyDB module has a + preConfigure hook to generate a configuration file used by + Makefile.PL: { buildPerlPackage, fetchurl, db }: @@ -113,18 +114,15 @@ buildPerlPackage rec { ''; } + - - -Dependencies on other Perl packages can be specified in the -buildInputs and -propagatedBuildInputs attributes. If something is -exclusively a build-time dependency, use -buildInputs; if it’s (also) a runtime dependency, -use propagatedBuildInputs. For instance, this -builds a Perl module that has runtime dependencies on a bunch of other -modules: - + + Dependencies on other Perl packages can be specified in the + buildInputs and propagatedBuildInputs + attributes. If something is exclusively a build-time dependency, use + buildInputs; if it’s (also) a runtime dependency, use + propagatedBuildInputs. For instance, this builds a Perl + module that has runtime dependencies on a bunch of other modules: ClassC3Componentised = buildPerlPackage rec { name = "Class-C3-Componentised-1.0004"; @@ -137,24 +135,26 @@ ClassC3Componentised = buildPerlPackage rec { ]; }; + - +
+ Generation from CPAN -
Generation from CPAN - -Nix expressions for Perl packages can be generated (almost) -automatically from CPAN. This is done by the program -nix-generate-from-cpan, which can be installed -as follows: + + Nix expressions for Perl packages can be generated (almost) automatically + from CPAN. This is done by the program + nix-generate-from-cpan, which can be installed as + follows: + $ nix-env -i nix-generate-from-cpan -This program takes a Perl module name, looks it up on CPAN, -fetches and unpacks the corresponding package, and prints a Nix -expression on standard output. For example: - + + This program takes a Perl module name, looks it up on CPAN, fetches and + unpacks the corresponding package, and prints a Nix expression on standard + output. For example: $ nix-generate-from-cpan XML::Simple XMLSimple = buildPerlPackage rec { @@ -170,26 +170,23 @@ $ nix-generate-from-cpan XML::Simple }; }; + The output can be pasted into + pkgs/top-level/perl-packages.nix or wherever else you + need it. + +
-The output can be pasted into -pkgs/top-level/perl-packages.nix or wherever else -you need it. +
+ Cross-compiling modules + + Nixpkgs has experimental support for cross-compiling Perl modules. In many + cases, it will just work out of the box, even for modules with native + extensions. Sometimes, however, the Makefile.PL for a module may + (indirectly) import a native module. In that case, you will need to make a + stub for that module that will satisfy the Makefile.PL and install it into + lib/perl5/site_perl/cross_perl/${perl.version}. See the + postInstall for DBI for an example. + +
- -
Cross-compiling modules - -Nixpkgs has experimental support for cross-compiling Perl -modules. In many cases, it will just work out of the box, even for -modules with native extensions. Sometimes, however, the Makefile.PL -for a module may (indirectly) import a native module. In that case, -you will need to make a stub for that module that will satisfy the -Makefile.PL and install it into -lib/perl5/site_perl/cross_perl/${perl.version}. -See the postInstall for DBI for -an example. - -
- -
- diff --git a/doc/languages-frameworks/qt.xml b/doc/languages-frameworks/qt.xml index 1dbbb5341ba3..b9b605b81da1 100644 --- a/doc/languages-frameworks/qt.xml +++ b/doc/languages-frameworks/qt.xml @@ -1,58 +1,74 @@
+ Qt -Qt + + Qt is a comprehensive desktop and mobile application development toolkit for + C++. Legacy support is available for Qt 3 and Qt 4, but all current + development uses Qt 5. The Qt 5 packages in Nixpkgs are updated frequently to + take advantage of new features, but older versions are typically retained + until their support window ends. The most important consideration in + packaging Qt-based software is ensuring that each package and all its + dependencies use the same version of Qt 5; this consideration motivates most + of the tools described below. + - -Qt is a comprehensive desktop and mobile application development toolkit for C++. -Legacy support is available for Qt 3 and Qt 4, but all current development uses Qt 5. -The Qt 5 packages in Nixpkgs are updated frequently to take advantage of new features, -but older versions are typically retained until their support window ends. -The most important consideration in packaging Qt-based software is ensuring that each package and all its dependencies use the same version of Qt 5; -this consideration motivates most of the tools described below. - +
+ Packaging Libraries for Nixpkgs -
Packaging Libraries for Nixpkgs + + Whenever possible, libraries that use Qt 5 should be built with each + available version. Packages providing libraries should be added to the + top-level function mkLibsForQt5, which is used to build a + set of libraries for every Qt 5 version. A special + callPackage function is used in this scope to ensure that + the entire dependency tree uses the same Qt 5 version. Import dependencies + unqualified, i.e., qtbase not + qt5.qtbase. Do not import a package + set such as qt5 or libsForQt5. + - -Whenever possible, libraries that use Qt 5 should be built with each available version. -Packages providing libraries should be added to the top-level function mkLibsForQt5, -which is used to build a set of libraries for every Qt 5 version. -A special callPackage function is used in this scope to ensure that the entire dependency tree uses the same Qt 5 version. -Import dependencies unqualified, i.e., qtbase not qt5.qtbase. -Do not import a package set such as qt5 or libsForQt5. - + + If a library does not support a particular version of Qt 5, it is best to + mark it as broken by setting its meta.broken attribute. A + package may be marked broken for certain versions by testing the + qtbase.version attribute, which will always give the + current Qt 5 version. + +
- -If a library does not support a particular version of Qt 5, it is best to mark it as broken by setting its meta.broken attribute. -A package may be marked broken for certain versions by testing the qtbase.version attribute, which will always give the current Qt 5 version. - +
+ Packaging Applications for Nixpkgs + + Call your application expression using + libsForQt5.callPackage instead of + callPackage. Import dependencies unqualified, i.e., + qtbase not qt5.qtbase. Do + not import a package set such as qt5 or + libsForQt5. + + + + Qt 5 maintains strict backward compatibility, so it is generally best to + build an application package against the latest version using the + libsForQt5 library set. In case a package does not build + with the latest Qt version, it is possible to pick a set pinned to a + particular version, e.g. libsForQt55 for Qt 5.5, if that + is the latest version the package supports. If a package must be pinned to + an older Qt version, be sure to file a bug upstream; because Qt is strictly + backwards-compatible, any incompatibility is by definition a bug in the + application. + + + + When testing applications in Nixpkgs, it is a common practice to build the + package with nix-build and run it using the created + symbolic link. This will not work with Qt applications, however, because + they have many hard runtime requirements that can only be guaranteed if the + package is actually installed. To test a Qt application, install it with + nix-env or run it inside nix-shell. + +
- -
Packaging Applications for Nixpkgs - - -Call your application expression using libsForQt5.callPackage instead of callPackage. -Import dependencies unqualified, i.e., qtbase not qt5.qtbase. -Do not import a package set such as qt5 or libsForQt5. - - - -Qt 5 maintains strict backward compatibility, so it is generally best to build an application package against the latest version using the libsForQt5 library set. -In case a package does not build with the latest Qt version, it is possible to pick a set pinned to a particular version, e.g. libsForQt55 for Qt 5.5, if that is the latest version the package supports. -If a package must be pinned to an older Qt version, be sure to file a bug upstream; -because Qt is strictly backwards-compatible, any incompatibility is by definition a bug in the application. - - - -When testing applications in Nixpkgs, it is a common practice to build the package with nix-build and run it using the created symbolic link. -This will not work with Qt applications, however, because they have many hard runtime requirements that can only be guaranteed if the package is actually installed. -To test a Qt application, install it with nix-env or run it inside nix-shell. - - -
- -
- diff --git a/doc/languages-frameworks/ruby.xml b/doc/languages-frameworks/ruby.xml index 6bb809192f89..c52a72a3df4a 100644 --- a/doc/languages-frameworks/ruby.xml +++ b/doc/languages-frameworks/ruby.xml @@ -1,17 +1,19 @@
+ Ruby -Ruby + + There currently is support to bundle applications that are packaged as Ruby + gems. The utility "bundix" allows you to write a + Gemfile, let bundler create a + Gemfile.lock, and then convert this into a nix + expression that contains all Gem dependencies automatically. + -There currently is support to bundle applications that are packaged as -Ruby gems. The utility "bundix" allows you to write a -Gemfile, let bundler create a -Gemfile.lock, and then convert this into a nix -expression that contains all Gem dependencies automatically. - - -For example, to package sensu, we did: + + For example, to package sensu, we did: + -Please check in the Gemfile, -Gemfile.lock and the -gemset.nix so future updates can be run easily. - + + Please check in the Gemfile, + Gemfile.lock and the gemset.nix so + future updates can be run easily. + -For tools written in Ruby - i.e. where the desire is to install -a package and then execute e.g. rake at the command -line, there is an alternative builder called bundlerApp. -Set up the gemset.nix the same way, and then, for -example: - + + For tools written in Ruby - i.e. where the desire is to install a package and + then execute e.g. rake at the command line, there is an + alternative builder called bundlerApp. Set up the + gemset.nix the same way, and then, for example: + -The chief advantage of bundlerApp over -bundlerEnv is the executables introduced in the -environment are precisely those selected in the exes -list, as opposed to bundlerEnv which adds all the -executables made available by gems in the gemset, which can mean e.g. -rspec or rake in unpredictable -versions available from various packages. - + + The chief advantage of bundlerApp over + bundlerEnv is the executables introduced in the + environment are precisely those selected in the exes list, + as opposed to bundlerEnv which adds all the executables + made available by gems in the gemset, which can mean e.g. + rspec or rake in unpredictable versions + available from various packages. + -Resulting derivations for both builders also have two helpful -attributes, env and wrappedRuby. -The first one allows one to quickly drop into -nix-shell with the specified environment present. -E.g. nix-shell -A sensu.env would give you an -environment with Ruby preset so it has all the libraries necessary -for sensu in its paths. The second one can be -used to make derivations from custom Ruby scripts which have -Gemfiles with their dependencies specified. It is -a derivation with ruby wrapped so it can find all -the needed dependencies. For example, to make a derivation -my-script for a my-script.rb -(which should be placed in bin) you should run -bundix as specified above and then use -bundlerEnv like this: - + + Resulting derivations for both builders also have two helpful attributes, + env and wrappedRuby. The first one + allows one to quickly drop into nix-shell with the + specified environment present. E.g. nix-shell -A sensu.env + would give you an environment with Ruby preset so it has all the libraries + necessary for sensu in its paths. The second one can be + used to make derivations from custom Ruby scripts which have + Gemfiles with their dependencies specified. It is a + derivation with ruby wrapped so it can find all the needed + dependencies. For example, to make a derivation my-script + for a my-script.rb (which should be placed in + bin) you should run bundix as + specified above and then use bundlerEnv like this: + -
diff --git a/doc/languages-frameworks/texlive.xml b/doc/languages-frameworks/texlive.xml index 4515e17ec09e..af0b07166e3e 100644 --- a/doc/languages-frameworks/texlive.xml +++ b/doc/languages-frameworks/texlive.xml @@ -1,27 +1,42 @@
+ TeX Live -TeX Live + + Since release 15.09 there is a new TeX Live packaging that lives entirely + under attribute texlive. + + +
+ User's guide -Since release 15.09 there is a new TeX Live packaging that lives entirely under attribute texlive. -
User's guide - - For basic usage just pull texlive.combined.scheme-basic for an environment with basic LaTeX support. - - It typically won't work to use separately installed packages together. - Instead, you can build a custom set of packages like this: - + + + For basic usage just pull texlive.combined.scheme-basic + for an environment with basic LaTeX support. + + + + + It typically won't work to use separately installed packages together. + Instead, you can build a custom set of packages like this: + texlive.combine { inherit (texlive) scheme-small collection-langkorean algorithms cm-super; } - There are all the schemes, collections and a few thousand packages, as defined upstream (perhaps with tiny differences). - - - By default you only get executables and files needed during runtime, and a little documentation for the core packages. To change that, you need to add pkgFilter function to combine. - + There are all the schemes, collections and a few thousand packages, as + defined upstream (perhaps with tiny differences). + + + + + By default you only get executables and files needed during runtime, and a + little documentation for the core packages. To change that, you need to + add pkgFilter function to combine. + texlive.combine { # inherit (texlive) whatever-you-want; pkgFilter = pkg: @@ -30,34 +45,55 @@ texlive.combine { # there are also other attributes: version, name } - - - You can list packages e.g. by nix-repl. - + + + + + You can list packages e.g. by nix-repl. + $ nix-repl nix-repl> :l <nixpkgs> nix-repl> texlive.collection-<TAB> - - - Note that the wrapper assumes that the result has a chance to be useful. For example, the core executables should be present, as well as some core data files. The supported way of ensuring this is by including some scheme, for example scheme-basic, into the combination. - + + + + + Note that the wrapper assumes that the result has a chance to be useful. + For example, the core executables should be present, as well as some core + data files. The supported way of ensuring this is by including some + scheme, for example scheme-basic, into the combination. + + -
+
+ +
+ Known problems -
Known problems - - Some tools are still missing, e.g. luajittex; - - some apps aren't packaged/tested yet (asymptote, biber, etc.); - - feature/bug: when a package is rejected by pkgFilter, its dependencies are still propagated; - - in case of any bugs or feature requests, file a github issue or better a pull request and /cc @vcunat. + + + Some tools are still missing, e.g. luajittex; + + + + + some apps aren't packaged/tested yet (asymptote, biber, etc.); + + + + + feature/bug: when a package is rejected by pkgFilter, + its dependencies are still propagated; + + + + + in case of any bugs or feature requests, file a github issue or better a + pull request and /cc @vcunat. + + +
- - -
- diff --git a/doc/manual.xml b/doc/manual.xml index 385079eb5785..f31897aed039 100644 --- a/doc/manual.xml +++ b/doc/manual.xml @@ -1,29 +1,24 @@ - - - - Nixpkgs Contributors Guide - - Version - - - - - - - - - - - - - - - - - - - - + + Nixpkgs Contributors Guide + Version + + + + + + + + + + + + + + + + + + diff --git a/doc/meta.xml b/doc/meta.xml index 5dbe810810d1..ad16e7683f58 100644 --- a/doc/meta.xml +++ b/doc/meta.xml @@ -1,14 +1,12 @@ - -Meta-attributes - -Nix packages can declare meta-attributes -that contain information about a package such as a description, its -homepage, its license, and so on. For instance, the GNU Hello package -has a meta declaration like this: - + Meta-attributes + + Nix packages can declare meta-attributes that contain + information about a package such as a description, its homepage, its license, + and so on. For instance, the GNU Hello package has a meta + declaration like this: meta = { description = "A program that produces a familiar, friendly greeting"; @@ -22,16 +20,15 @@ meta = { platforms = stdenv.lib.platforms.all; }; - - - -Meta-attributes are not passed to the builder of the package. -Thus, a change to a meta-attribute doesn’t trigger a recompilation of -the package. The value of a meta-attribute must be a string. - -The meta-attributes of a package can be queried from the -command-line using nix-env: - + + + Meta-attributes are not passed to the builder of the package. Thus, a change + to a meta-attribute doesn’t trigger a recompilation of the package. The + value of a meta-attribute must be a string. + + + The meta-attributes of a package can be queried from the command-line using + nix-env: $ nix-env -qa hello --json { @@ -70,252 +67,299 @@ $ nix-env -qa hello --json - -nix-env knows about the -description field specifically: - + nix-env knows about the description + field specifically: $ nix-env -qa hello --description hello-2.3 A program that produces a familiar, friendly greeting + +
+ Standard meta-attributes - + + It is expected that each meta-attribute is one of the following: + - -
Standard -meta-attributes - -It is expected that each meta-attribute is one of the following: - - - - - description - A short (one-line) description of the package. - This is shown by nix-env -q --description and - also on the Nixpkgs release pages. - - Don’t include a period at the end. Don’t include newline - characters. Capitalise the first character. For brevity, don’t - repeat the name of package — just describe what it does. - - Wrong: "libpng is a library that allows you to decode PNG images." - - Right: "A library for decoding PNG images" - - - - - - longDescription - An arbitrarily long description of the - package. - - - - branch - Release branch. Used to specify that a package is not - going to receive updates that are not in this branch; for example, Linux - kernel 3.0 is supposed to be updated to 3.0.X, not 3.1. - - - - homepage - The package’s homepage. Example: - http://www.gnu.org/software/hello/manual/ - - - - downloadPage - The page where a link to the current version can be found. Example: - http://ftp.gnu.org/gnu/hello/ - - - - license + + + description + - - The license, or licenses, for the package. One from the attribute set - defined in - nixpkgs/lib/licenses.nix. At this moment - using both a list of licenses and a single license is valid. If the - license field is in the form of a list representation, then it means - that parts of the package are licensed differently. Each license - should preferably be referenced by their attribute. The non-list - attribute value can also be a space delimited string representation of - the contained attribute shortNames or spdxIds. The following are all valid - examples: - - Single license referenced by attribute (preferred) - stdenv.lib.licenses.gpl3. - - Single license referenced by its attribute shortName (frowned upon) - "gpl3". - - Single license referenced by its attribute spdxId (frowned upon) - "GPL-3.0". - - Multiple licenses referenced by attribute (preferred) - with stdenv.lib.licenses; [ asl20 free ofl ]. - - Multiple licenses referenced as a space delimited string of attribute shortNames (frowned upon) - "asl20 free ofl". - - - For details, see . - + + A short (one-line) description of the package. This is shown by + nix-env -q --description and also on the Nixpkgs + release pages. + + + Don’t include a period at the end. Don’t include newline characters. + Capitalise the first character. For brevity, don’t repeat the name of + package — just describe what it does. + + + Wrong: "libpng is a library that allows you to decode PNG + images." + + + Right: "A library for decoding PNG images" + - - - - maintainers - A list of names and e-mail addresses of the - maintainers of this Nix expression. If - you would like to be a maintainer of a package, you may want to add - yourself to + + longDescription + + + + An arbitrarily long description of the package. + + + + + branch + + + + Release branch. Used to specify that a package is not going to receive + updates that are not in this branch; for example, Linux kernel 3.0 is + supposed to be updated to 3.0.X, not 3.1. + + + + + homepage + + + + The package’s homepage. Example: + http://www.gnu.org/software/hello/manual/ + + + + + downloadPage + + + + The page where a link to the current version can be found. Example: + http://ftp.gnu.org/gnu/hello/ + + + + + license + + + + The license, or licenses, for the package. One from the attribute set + defined in + + nixpkgs/lib/licenses.nix. At this moment + using both a list of licenses and a single license is valid. If the + license field is in the form of a list representation, then it means that + parts of the package are licensed differently. Each license should + preferably be referenced by their attribute. The non-list attribute value + can also be a space delimited string representation of the contained + attribute shortNames or spdxIds. The following are all valid examples: + + + + Single license referenced by attribute (preferred) + stdenv.lib.licenses.gpl3. + + + + + Single license referenced by its attribute shortName (frowned upon) + "gpl3". + + + + + Single license referenced by its attribute spdxId (frowned upon) + "GPL-3.0". + + + + + Multiple licenses referenced by attribute (preferred) with + stdenv.lib.licenses; [ asl20 free ofl ]. + + + + + Multiple licenses referenced as a space delimited string of attribute + shortNames (frowned upon) "asl20 free ofl". + + + + For details, see . + + + + + maintainers + + + + A list of names and e-mail addresses of the maintainers of this Nix + expression. If you would like to be a maintainer of a package, you may + want to add yourself to + nixpkgs/maintainers/maintainer-list.nix - and write something like [ stdenv.lib.maintainers.alice - stdenv.lib.maintainers.bob ]. - - - - priority - The priority of the package, - used by nix-env to resolve file name conflicts - between packages. See the Nix manual page for - nix-env for details. Example: - "10" (a low-priority - package). - - - - platforms - The list of Nix platform types on which the - package is supported. Hydra builds packages according to the - platform specified. If no platform is specified, the package does - not have prebuilt binaries. An example is: - + and write something like [ stdenv.lib.maintainers.alice + stdenv.lib.maintainers.bob ]. + + + + + priority + + + + The priority of the package, used by + nix-env to resolve file name conflicts between + packages. See the Nix manual page for nix-env for + details. Example: "10" (a low-priority package). + + + + + platforms + + + + The list of Nix platform types on which the package is supported. Hydra + builds packages according to the platform specified. If no platform is + specified, the package does not have prebuilt binaries. An example is: meta.platforms = stdenv.lib.platforms.linux; - - Attribute Set stdenv.lib.platforms defines - - various common lists of platforms types. - - - - hydraPlatforms - The list of Nix platform types for which the Hydra - instance at hydra.nixos.org will build the - package. (Hydra is the Nix-based continuous build system.) It - defaults to the value of meta.platforms. Thus, - the only reason to set meta.hydraPlatforms is - if you want hydra.nixos.org to build the - package on a subset of meta.platforms, or not - at all, e.g. - + Attribute Set stdenv.lib.platforms defines + + various common lists of platforms types. + + + + + hydraPlatforms + + + + The list of Nix platform types for which the Hydra instance at + hydra.nixos.org will build the package. (Hydra is the + Nix-based continuous build system.) It defaults to the value of + meta.platforms. Thus, the only reason to set + meta.hydraPlatforms is if you want + hydra.nixos.org to build the package on a subset of + meta.platforms, or not at all, e.g. meta.platforms = stdenv.lib.platforms.linux; meta.hydraPlatforms = []; + + + + + broken + + + + If set to true, the package is marked as “broken”, + meaning that it won’t show up in nix-env -qa, and + cannot be built or installed. Such packages should be removed from + Nixpkgs eventually unless they are fixed. + + + + + updateWalker + + + + If set to true, the package is tested to be updated + correctly by the update-walker.sh script without + additional settings. Such packages have meta.version + set and their homepage (or the page specified by + meta.downloadPage) contains a direct link to the + package tarball. + + + + +
+
+ Licenses - - - - - broken - If set to true, the package is - marked as “broken”, meaning that it won’t show up in - nix-env -qa, and cannot be built or installed. - Such packages should be removed from Nixpkgs eventually unless - they are fixed. - - - - updateWalker - If set to true, the package is - tested to be updated correctly by the update-walker.sh - script without additional settings. Such packages have - meta.version set and their homepage (or - the page specified by meta.downloadPage) contains - a direct link to the package tarball. - - - - - -
- - -
Licenses - -The meta.license attribute should preferrably contain -a value from stdenv.lib.licenses defined in - -nixpkgs/lib/licenses.nix, -or in-place license description of the same format if the license is -unlikely to be useful in another expression. - -Although it's typically better to indicate the specific license, -a few generic options are available: - - - - - stdenv.lib.licenses.free, - "free" - - Catch-all for free software licenses not listed - above. - - - - stdenv.lib.licenses.unfreeRedistributable, - "unfree-redistributable" - - Unfree package that can be redistributed in binary - form. That is, it’s legal to redistribute the - output of the derivation. This means that - the package can be included in the Nixpkgs - channel. - - Sometimes proprietary software can only be redistributed - unmodified. Make sure the builder doesn’t actually modify the - original binaries; otherwise we’re breaking the license. For - instance, the NVIDIA X11 drivers can be redistributed unmodified, - but our builder applies patchelf to make them - work. Thus, its license is "unfree" and it - cannot be included in the Nixpkgs channel. - - - - stdenv.lib.licenses.unfree, - "unfree" - - Unfree package that cannot be redistributed. You - can build it yourself, but you cannot redistribute the output of - the derivation. Thus it cannot be included in the Nixpkgs - channel. - - - - stdenv.lib.licenses.unfreeRedistributableFirmware, - "unfree-redistributable-firmware" - - This package supplies unfree, redistributable - firmware. This is a separate value from - unfree-redistributable because not everybody - cares whether firmware is free. - - - - - - - -
- + + The meta.license attribute should preferrably contain a + value from stdenv.lib.licenses defined in + + nixpkgs/lib/licenses.nix, or in-place license + description of the same format if the license is unlikely to be useful in + another expression. + + + Although it's typically better to indicate the specific license, a few + generic options are available: + + + stdenv.lib.licenses.free, + "free" + + + + Catch-all for free software licenses not listed above. + + + + + stdenv.lib.licenses.unfreeRedistributable, + "unfree-redistributable" + + + + Unfree package that can be redistributed in binary form. That is, it’s + legal to redistribute the output of the derivation. + This means that the package can be included in the Nixpkgs channel. + + + Sometimes proprietary software can only be redistributed unmodified. + Make sure the builder doesn’t actually modify the original binaries; + otherwise we’re breaking the license. For instance, the NVIDIA X11 + drivers can be redistributed unmodified, but our builder applies + patchelf to make them work. Thus, its license is + "unfree" and it cannot be included in the Nixpkgs + channel. + + + + + stdenv.lib.licenses.unfree, + "unfree" + + + + Unfree package that cannot be redistributed. You can build it yourself, + but you cannot redistribute the output of the derivation. Thus it cannot + be included in the Nixpkgs channel. + + + + + stdenv.lib.licenses.unfreeRedistributableFirmware, + "unfree-redistributable-firmware" + + + + This package supplies unfree, redistributable firmware. This is a + separate value from unfree-redistributable because + not everybody cares whether firmware is free. + + + + + +
diff --git a/doc/multiple-output.xml b/doc/multiple-output.xml index 277d3d814136..040c12c92913 100644 --- a/doc/multiple-output.xml +++ b/doc/multiple-output.xml @@ -5,105 +5,319 @@ + Multiple-output packages +
+ Introduction -Multiple-output packages + + The Nix language allows a derivation to produce multiple outputs, which is + similar to what is utilized by other Linux distribution packaging systems. + The outputs reside in separate nix store paths, so they can be mostly + handled independently of each other, including passing to build inputs, + garbage collection or binary substitution. The exception is that building + from source always produces all the outputs. + -
Introduction - The Nix language allows a derivation to produce multiple outputs, which is similar to what is utilized by other Linux distribution packaging systems. The outputs reside in separate nix store paths, so they can be mostly handled independently of each other, including passing to build inputs, garbage collection or binary substitution. The exception is that building from source always produces all the outputs. - The main motivation is to save disk space by reducing runtime closure sizes; consequently also sizes of substituted binaries get reduced. Splitting can be used to have more granular runtime dependencies, for example the typical reduction is to split away development-only files, as those are typically not needed during runtime. As a result, closure sizes of many packages can get reduced to a half or even much less. - The reduction effects could be instead achieved by building the parts in completely separate derivations. That would often additionally reduce build-time closures, but it tends to be much harder to write such derivations, as build systems typically assume all parts are being built at once. This compromise approach of single source package producing multiple binary packages is also utilized often by rpm and deb. -
+ + The main motivation is to save disk space by reducing runtime closure sizes; + consequently also sizes of substituted binaries get reduced. Splitting can + be used to have more granular runtime dependencies, for example the typical + reduction is to split away development-only files, as those are typically + not needed during runtime. As a result, closure sizes of many packages can + get reduced to a half or even much less. + + + + + The reduction effects could be instead achieved by building the parts in + completely separate derivations. That would often additionally reduce + build-time closures, but it tends to be much harder to write such + derivations, as build systems typically assume all parts are being built at + once. This compromise approach of single source package producing multiple + binary packages is also utilized often by rpm and deb. + + +
+
+ Installing a split package + + + When installing a package via systemPackages or + nix-env you have several options: + -
Installing a split package - When installing a package via systemPackages or nix-env you have several options: - You can install particular outputs explicitly, as each is available in the Nix language as an attribute of the package. The outputs attribute contains a list of output names. - You can let it use the default outputs. These are handled by meta.outputsToInstall attribute that contains a list of output names. - TODO: more about tweaking the attribute, etc. - NixOS provides configuration option environment.extraOutputsToInstall that allows adding extra outputs of environment.systemPackages atop the default ones. It's mainly meant for documentation and debug symbols, and it's also modified by specific options. - At this moment there is no similar configurability for packages installed by nix-env. You can still use approach from to override meta.outputsToInstall attributes, but that's a rather inconvenient way. - + + + You can install particular outputs explicitly, as each is available in the + Nix language as an attribute of the package. The + outputs attribute contains a list of output names. + + + + + You can let it use the default outputs. These are handled by + meta.outputsToInstall attribute that contains a list of + output names. + + + TODO: more about tweaking the attribute, etc. + + + + + NixOS provides configuration option + environment.extraOutputsToInstall that allows adding + extra outputs of environment.systemPackages atop the + default ones. It's mainly meant for documentation and debug symbols, and + it's also modified by specific options. + + + + At this moment there is no similar configurability for packages installed + by nix-env. You can still use approach from + to override + meta.outputsToInstall attributes, but that's a rather + inconvenient way. + + + -
+
+
+ Using a split package -
Using a split package - In the Nix language the individual outputs can be reached explicitly as attributes, e.g. coreutils.info, but the typical case is just using packages as build inputs. - When a multiple-output derivation gets into a build input of another derivation, the dev output is added if it exists, otherwise the first output is added. In addition to that, propagatedBuildOutputs of that package which by default contain $outputBin and $outputLib are also added. (See .) -
+ + In the Nix language the individual outputs can be reached explicitly as + attributes, e.g. coreutils.info, but the typical case is + just using packages as build inputs. + + + When a multiple-output derivation gets into a build input of another + derivation, the dev output is added if it exists, + otherwise the first output is added. In addition to that, + propagatedBuildOutputs of that package which by default + contain $outputBin and $outputLib are + also added. (See .) + +
+
+ Writing a split derivation -
Writing a split derivation - Here you find how to write a derivation that produces multiple outputs. - In nixpkgs there is a framework supporting multiple-output derivations. It tries to cover most cases by default behavior. You can find the source separated in <nixpkgs/pkgs/build-support/setup-hooks/multiple-outputs.sh>; it's relatively well-readable. The whole machinery is triggered by defining the outputs attribute to contain the list of desired output names (strings). - outputs = [ "bin" "dev" "out" "doc" ]; - Often such a single line is enough. For each output an equally named environment variable is passed to the builder and contains the path in nix store for that output. Typically you also want to have the main out output, as it catches any files that didn't get elsewhere. - There is a special handling of the debug output, described at . + + Here you find how to write a derivation that produces multiple outputs. + + + + In nixpkgs there is a framework supporting multiple-output derivations. It + tries to cover most cases by default behavior. You can find the source + separated in + <nixpkgs/pkgs/build-support/setup-hooks/multiple-outputs.sh>; + it's relatively well-readable. The whole machinery is triggered by defining + the outputs attribute to contain the list of desired + output names (strings). + + +outputs = [ "bin" "dev" "out" "doc" ]; + + + Often such a single line is enough. For each output an equally named + environment variable is passed to the builder and contains the path in nix + store for that output. Typically you also want to have the main + out output, as it catches any files that didn't get + elsewhere. + + + + + There is a special handling of the debug output, + described at . + +
- <quote>Binaries first</quote> - A commonly adopted convention in nixpkgs is that executables provided by the package are contained within its first output. This convention allows the dependent packages to reference the executables provided by packages in a uniform manner. For instance, provided with the knowledge that the perl package contains a perl executable it can be referenced as ${pkgs.perl}/bin/perl within a Nix derivation that needs to execute a Perl script. - The glibc package is a deliberate single exception to the binaries first convention. The glibc has libs as its first output allowing the libraries provided by glibc to be referenced directly (e.g. ${stdenv.glibc}/lib/ld-linux-x86-64.so.2). The executables provided by glibc can be accessed via its bin attribute (e.g. ${stdenv.glibc.bin}/bin/ldd). - The reason for why glibc deviates from the convention is because referencing a library provided by glibc is a very common operation among Nix packages. For instance, third-party executables packaged by Nix are typically patched and relinked with the relevant version of glibc libraries from Nix packages (please see the documentation on patchelf for more details). + <quote>Binaries first</quote> + + + A commonly adopted convention in nixpkgs is that + executables provided by the package are contained within its first output. + This convention allows the dependent packages to reference the executables + provided by packages in a uniform manner. For instance, provided with the + knowledge that the perl package contains a + perl executable it can be referenced as + ${pkgs.perl}/bin/perl within a Nix derivation that needs + to execute a Perl script. + + + + The glibc package is a deliberate single exception to + the binaries first convention. The glibc + has libs as its first output allowing the libraries + provided by glibc to be referenced directly (e.g. + ${stdenv.glibc}/lib/ld-linux-x86-64.so.2). The + executables provided by glibc can be accessed via its + bin attribute (e.g. + ${stdenv.glibc.bin}/bin/ldd). + + + + The reason for why glibc deviates from the convention is + because referencing a library provided by glibc is a + very common operation among Nix packages. For instance, third-party + executables packaged by Nix are typically patched and relinked with the + relevant version of glibc libraries from Nix packages + (please see the documentation on + patchelf for more + details). +
- File type groups - The support code currently recognizes some particular kinds of outputs and either instructs the build system of the package to put files into their desired outputs or it moves the files during the fixup phase. Each group of file types has an outputFoo variable specifying the output name where they should go. If that variable isn't defined by the derivation writer, it is guessed – a default output name is defined, falling back to other possibilities if the output isn't defined. - + File type groups - - $outputDev - is for development-only files. These include C(++) headers, pkg-config, cmake and aclocal files. They go to dev or out by default. - - + + The support code currently recognizes some particular kinds of outputs and + either instructs the build system of the package to put files into their + desired outputs or it moves the files during the fixup phase. Each group of + file types has an outputFoo variable specifying the + output name where they should go. If that variable isn't defined by the + derivation writer, it is guessed – a default output name is defined, + falling back to other possibilities if the output isn't defined. + - - $outputBin - is meant for user-facing binaries, typically residing in bin/. They go to bin or out by default. - - - - $outputLib - is meant for libraries, typically residing in lib/ and libexec/. They go to lib or out by default. - - - - $outputDoc - is for user documentation, typically residing in share/doc/. It goes to doc or out by default. - - - - $outputDevdoc - is for developer documentation. Currently we count gtk-doc and devhelp books in there. It goes to devdoc or is removed (!) by default. This is because e.g. gtk-doc tends to be rather large and completely unused by nixpkgs users. - - - - $outputMan - is for man pages (except for section 3). They go to man or $outputBin by default. - - - - $outputDevman - is for section 3 man pages. They go to devman or $outputMan by default. - - - - $outputInfo - is for info pages. They go to info or $outputBin by default. - - - + + + + $outputDev + + + + is for development-only files. These include C(++) headers, pkg-config, + cmake and aclocal files. They go to dev or + out by default. + + + + + + $outputBin + + + + is meant for user-facing binaries, typically residing in bin/. They go + to bin or out by default. + + + + + + $outputLib + + + + is meant for libraries, typically residing in lib/ + and libexec/. They go to lib or + out by default. + + + + + + $outputDoc + + + + is for user documentation, typically residing in + share/doc/. It goes to doc or + out by default. + + + + + + $outputDevdoc + + + + is for developer documentation. Currently we count + gtk-doc and devhelp books in there. It goes to devdoc + or is removed (!) by default. This is because e.g. gtk-doc tends to be + rather large and completely unused by nixpkgs users. + + + + + + $outputMan + + + + is for man pages (except for section 3). They go to + man or $outputBin by default. + + + + + + $outputDevman + + + + is for section 3 man pages. They go to devman or + $outputMan by default. + + + + + + $outputInfo + + + + is for info pages. They go to info or + $outputBin by default. + + + +
-
Common caveats - - Some configure scripts don't like some of the parameters passed by default by the framework, e.g. --docdir=/foo/bar. You can disable this by setting setOutputFlags = false;. - The outputs of a single derivation can retain references to each other, but note that circular references are not allowed. (And each strongly-connected component would act as a single output anyway.) - Most of split packages contain their core functionality in libraries. These libraries tend to refer to various kind of data that typically gets into out, e.g. locale strings, so there is often no advantage in separating the libraries into lib, as keeping them in out is easier. - Some packages have hidden assumptions on install paths, which complicates splitting. - +
+ Common caveats + + + + + Some configure scripts don't like some of the parameters passed by + default by the framework, e.g. --docdir=/foo/bar. You + can disable this by setting setOutputFlags = false;. + + + + + The outputs of a single derivation can retain references to each other, + but note that circular references are not allowed. (And each + strongly-connected component would act as a single output anyway.) + + + + + Most of split packages contain their core functionality in libraries. + These libraries tend to refer to various kind of data that typically gets + into out, e.g. locale strings, so there is often no + advantage in separating the libraries into lib, as + keeping them in out is easier. + + + + + Some packages have hidden assumptions on install paths, which complicates + splitting. + + +
- -
- +
+ diff --git a/doc/overlays.xml b/doc/overlays.xml index cc0aef447d2d..2decf9febe80 100644 --- a/doc/overlays.xml +++ b/doc/overlays.xml @@ -1,95 +1,117 @@ - -Overlays - -This chapter describes how to extend and change Nixpkgs packages using -overlays. Overlays are used to add layers in the fix-point used by Nixpkgs -to compose the set of all packages. - -Nixpkgs can be configured with a list of overlays, which are -applied in order. This means that the order of the overlays can be significant -if multiple layers override the same package. - + Overlays + + This chapter describes how to extend and change Nixpkgs packages using + overlays. Overlays are used to add layers in the fix-point used by Nixpkgs to + compose the set of all packages. + + + Nixpkgs can be configured with a list of overlays, which are applied in + order. This means that the order of the overlays can be significant if + multiple layers override the same package. + +
+ Installing overlays -
-Installing overlays + + The list of overlays is determined as follows. + -The list of overlays is determined as follows. + + If the overlays argument is not provided explicitly, we + look for overlays in a path. The path is determined as follows: + + + + First, if an overlays argument to the nixpkgs function + itself is given, then that is used. + + + This can be passed explicitly when importing nipxkgs, for example + import <nixpkgs> { overlays = [ overlay1 overlay2 ]; + }. + + + + + Otherwise, if the Nix path entry <nixpkgs-overlays> + exists, we look for overlays at that path, as described below. + + + See the section on NIX_PATH in the Nix manual for more + details on how to set a value for + <nixpkgs-overlays>. + + + + + If one of ~/.config/nixpkgs/overlays.nix and + ~/.config/nixpkgs/overlays/ exists, then we look for + overlays at that path, as described below. It is an error if both exist. + + + + -If the overlays argument is not provided explicitly, we look for overlays in a path. The path -is determined as follows: + + If we are looking for overlays at a path, then there are two cases: + + + + If the path is a file, then the file is imported as a Nix expression and + used as the list of overlays. + + + + + If the path is a directory, then we take the content of the directory, + order it lexicographically, and attempt to interpret each as an overlay + by: + + + + Importing the file, if it is a .nix file. + + + + + Importing a top-level default.nix file, if it is + a directory. + + + + + + + - - - - First, if an overlays argument to the nixpkgs function itself is given, - then that is used. - - This can be passed explicitly when importing nipxkgs, for example - import <nixpkgs> { overlays = [ overlay1 overlay2 ]; }. - - - - Otherwise, if the Nix path entry <nixpkgs-overlays> exists, we look for overlays - at that path, as described below. - - See the section on NIX_PATH in the Nix manual for more details on how to - set a value for <nixpkgs-overlays>. - - - - If one of ~/.config/nixpkgs/overlays.nix and - ~/.config/nixpkgs/overlays/ exists, then we look for overlays at that path, as - described below. It is an error if both exist. - - - - - -If we are looking for overlays at a path, then there are two cases: - - - If the path is a file, then the file is imported as a Nix expression and used as the list of - overlays. - - - - If the path is a directory, then we take the content of the directory, order it - lexicographically, and attempt to interpret each as an overlay by: - - - Importing the file, if it is a .nix file. - - - Importing a top-level default.nix file, if it is a directory. - - - - - - - -On a NixOS system the value of the nixpkgs.overlays option, if present, -is passed to the system Nixpkgs directly as an argument. Note that this does not affect the overlays for -non-NixOS operations (e.g. nix-env), which are looked up independently. - -The overlays.nix option therefore provides a convenient way to use the same -overlays for a NixOS system configuration and user configuration: the same file can be used -as overlays.nix and imported as the value of nixpkgs.overlays. - -
+ + On a NixOS system the value of the nixpkgs.overlays + option, if present, is passed to the system Nixpkgs directly as an argument. + Note that this does not affect the overlays for non-NixOS operations (e.g. + nix-env), which are looked up independently. + + + The overlays.nix option therefore provides a convenient + way to use the same overlays for a NixOS system configuration and user + configuration: the same file can be used as + overlays.nix and imported as the value of + nixpkgs.overlays. + +
+
+ Defining overlays -
-Defining overlays - -Overlays are Nix functions which accept two arguments, -conventionally called self and super, -and return a set of packages. For example, the following is a valid overlay. + + Overlays are Nix functions which accept two arguments, conventionally called + self and super, and return a set of + packages. For example, the following is a valid overlay. + self: super: @@ -104,31 +126,39 @@ self: super: } -The first argument (self) corresponds to the final package -set. You should use this set for the dependencies of all packages specified in your -overlay. For example, all the dependencies of rr in the example above come -from self, as well as the overridden dependencies used in the -boost override. + + The first argument (self) corresponds to the final + package set. You should use this set for the dependencies of all packages + specified in your overlay. For example, all the dependencies of + rr in the example above come from + self, as well as the overridden dependencies used in the + boost override. + -The second argument (super) -corresponds to the result of the evaluation of the previous stages of -Nixpkgs. It does not contain any of the packages added by the current -overlay, nor any of the following overlays. This set should be used either -to refer to packages you wish to override, or to access functions defined -in Nixpkgs. For example, the original recipe of boost -in the above example, comes from super, as well as the -callPackage function. + + The second argument (super) corresponds to the result of + the evaluation of the previous stages of Nixpkgs. It does not contain any of + the packages added by the current overlay, nor any of the following + overlays. This set should be used either to refer to packages you wish to + override, or to access functions defined in Nixpkgs. For example, the + original recipe of boost in the above example, comes from + super, as well as the callPackage + function. + -The value returned by this function should be a set similar to -pkgs/top-level/all-packages.nix, containing -overridden and/or new packages. - -Overlays are similar to other methods for customizing Nixpkgs, in particular -the packageOverrides attribute described in . -Indeed, packageOverrides acts as an overlay with only the -super argument. It is therefore appropriate for basic use, -but overlays are more powerful and easier to distribute. - -
+ + The value returned by this function should be a set similar to + pkgs/top-level/all-packages.nix, containing overridden + and/or new packages. + + + Overlays are similar to other methods for customizing Nixpkgs, in particular + the packageOverrides attribute described in + . Indeed, + packageOverrides acts as an overlay with only the + super argument. It is therefore appropriate for basic + use, but overlays are more powerful and easier to distribute. + +
diff --git a/doc/package-notes.xml b/doc/package-notes.xml index 1fccfd5d329d..f16826ae6806 100644 --- a/doc/package-notes.xml +++ b/doc/package-notes.xml @@ -1,206 +1,185 @@ - -Package Notes - -This chapter contains information about how to use and maintain -the Nix expressions for a number of specific packages, such as the -Linux kernel or X.org. - - + Package Notes + + This chapter contains information about how to use and maintain the Nix + expressions for a number of specific packages, such as the Linux kernel or + X.org. + +
+ Linux kernel -
+ + The Nix expressions to build the Linux kernel are in + pkgs/os-specific/linux/kernel. + -Linux kernel - -The Nix expressions to build the Linux kernel are in pkgs/os-specific/linux/kernel. - -The function that builds the kernel has an argument -kernelPatches which should be a list of -{name, patch, extraConfig} attribute sets, where -name is the name of the patch (which is included in -the kernel’s meta.description attribute), -patch is the patch itself (possibly compressed), -and extraConfig (optional) is a string specifying -extra options to be concatenated to the kernel configuration file -(.config). - -The kernel derivation exports an attribute -features specifying whether optional functionality -is or isn’t enabled. This is used in NixOS to implement -kernel-specific behaviour. For instance, if the kernel has the -iwlwifi feature (i.e. has built-in support for -Intel wireless chipsets), then NixOS doesn’t have to build the -external iwlwifi package: + + The function that builds the kernel has an argument + kernelPatches which should be a list of {name, + patch, extraConfig} attribute sets, where name + is the name of the patch (which is included in the kernel’s + meta.description attribute), patch is + the patch itself (possibly compressed), and extraConfig + (optional) is a string specifying extra options to be concatenated to the + kernel configuration file (.config). + + + The kernel derivation exports an attribute features + specifying whether optional functionality is or isn’t enabled. This is + used in NixOS to implement kernel-specific behaviour. For instance, if the + kernel has the iwlwifi feature (i.e. has built-in support + for Intel wireless chipsets), then NixOS doesn’t have to build the + external iwlwifi package: modulesTree = [kernel] ++ pkgs.lib.optional (!kernel.features ? iwlwifi) kernelPackages.iwlwifi ++ ...; + - - -How to add a new (major) version of the Linux kernel to Nixpkgs: - - - - - Copy the old Nix expression - (e.g. linux-2.6.21.nix) to the new one - (e.g. linux-2.6.22.nix) and update it. - - - - Add the new kernel to all-packages.nix - (e.g., create an attribute - kernel_2_6_22). - - - - Now we’re going to update the kernel configuration. First - unpack the kernel. Then for each supported platform - (i686, x86_64, - uml) do the following: - + + How to add a new (major) version of the Linux kernel to Nixpkgs: + + + + Copy the old Nix expression (e.g. linux-2.6.21.nix) + to the new one (e.g. linux-2.6.22.nix) and update + it. + + + + + Add the new kernel to all-packages.nix (e.g., create + an attribute kernel_2_6_22). + + + + + Now we’re going to update the kernel configuration. First unpack the + kernel. Then for each supported platform (i686, + x86_64, uml) do the following: - - - Make an copy from the old - config (e.g. config-2.6.21-i686-smp) to - the new one - (e.g. config-2.6.22-i686-smp). - - - - Copy the config file for this platform - (e.g. config-2.6.22-i686-smp) to - .config in the kernel source tree. - - - - - Run make oldconfig - ARCH={i386,x86_64,um} - and answer all questions. (For the uml configuration, also - add SHELL=bash.) Make sure to keep the - configuration consistent between platforms (i.e. don’t - enable some feature on i686 and disable - it on x86_64). - - - - - If needed you can also run make - menuconfig: - - + + + Make an copy from the old config (e.g. + config-2.6.21-i686-smp) to the new one (e.g. + config-2.6.22-i686-smp). + + + + + Copy the config file for this platform (e.g. + config-2.6.22-i686-smp) to + .config in the kernel source tree. + + + + + Run make oldconfig + ARCH={i386,x86_64,um} and answer + all questions. (For the uml configuration, also add + SHELL=bash.) Make sure to keep the configuration + consistent between platforms (i.e. don’t enable some feature on + i686 and disable it on x86_64). + + + + + If needed you can also run make menuconfig: + $ nix-env -i ncurses $ export NIX_CFLAGS_LINK=-lncurses $ make menuconfig ARCH=arch - - - - - - Copy .config over the new config - file (e.g. config-2.6.22-i686-smp). - - + + + + + Copy .config over the new config file (e.g. + config-2.6.22-i686-smp). + + - - - - - - - Test building the kernel: nix-build -A - kernel_2_6_22. If it compiles, ship it! For extra - credit, try booting NixOS with it. - - - - It may be that the new kernel requires updating the external - kernel modules and kernel-dependent packages listed in the - linuxPackagesFor function in - all-packages.nix (such as the NVIDIA drivers, - AUFS, etc.). If the updated packages aren’t backwards compatible - with older kernels, you may need to keep the older versions - around. - - - - - - -
- - + + + + + Test building the kernel: nix-build -A kernel_2_6_22. + If it compiles, ship it! For extra credit, try booting NixOS with it. + + + + + It may be that the new kernel requires updating the external kernel + modules and kernel-dependent packages listed in the + linuxPackagesFor function in + all-packages.nix (such as the NVIDIA drivers, AUFS, + etc.). If the updated packages aren’t backwards compatible with older + kernels, you may need to keep the older versions around. + + + + +
+
+ X.org -
- -X.org - -The Nix expressions for the X.org packages reside in -pkgs/servers/x11/xorg/default.nix. This file is -automatically generated from lists of tarballs in an X.org release. -As such it should not be modified directly; rather, you should modify -the lists, the generator script or the file -pkgs/servers/x11/xorg/overrides.nix, in which you -can override or add to the derivations produced by the -generator. - -The generator is invoked as follows: + + The Nix expressions for the X.org packages reside in + pkgs/servers/x11/xorg/default.nix. This file is + automatically generated from lists of tarballs in an X.org release. As such + it should not be modified directly; rather, you should modify the lists, the + generator script or the file + pkgs/servers/x11/xorg/overrides.nix, in which you can + override or add to the derivations produced by the generator. + + + The generator is invoked as follows: $ cd pkgs/servers/x11/xorg $ cat tarballs-7.5.list extra.list old.list \ | perl ./generate-expr-from-tarballs.pl + For each of the tarballs in the .list files, the script + downloads it, unpacks it, and searches its configure.ac + and *.pc.in files for dependencies. This information is + used to generate default.nix. The generator caches + downloaded tarballs between runs. Pay close attention to the NOT + FOUND: name messages at the end of the + run, since they may indicate missing dependencies. (Some might be optional + dependencies, however.) + -For each of the tarballs in the .list files, the -script downloads it, unpacks it, and searches its -configure.ac and *.pc.in -files for dependencies. This information is used to generate -default.nix. The generator caches downloaded -tarballs between runs. Pay close attention to the NOT FOUND: -name messages at the end of the -run, since they may indicate missing dependencies. (Some might be -optional dependencies, however.) - -A file like tarballs-7.5.list contains all -tarballs in a X.org release. It can be generated like this: - + + A file like tarballs-7.5.list contains all tarballs in + a X.org release. It can be generated like this: $ export i="mirror://xorg/X11R7.4/src/everything/" $ cat $(PRINT_PATH=1 nix-prefetch-url $i | tail -n 1) \ | perl -e 'while (<>) { if (/(href|HREF)="([^"]*.bz2)"/) { print "$ENV{'i'}$2\n"; }; }' \ | sort > tarballs-7.4.list + extra.list contains libraries that aren’t part of + X.org proper, but are closely related to it, such as + libxcb. old.list contains some + packages that were removed from X.org, but are still needed by some people + or by other packages (such as imake). + -extra.list contains libraries that aren’t part of -X.org proper, but are closely related to it, such as -libxcb. old.list contains -some packages that were removed from X.org, but are still needed by -some people or by other packages (such as -imake). - -If the expression for a package requires derivation attributes -that the generator cannot figure out automatically (say, -patches or a postInstall hook), -you should modify -pkgs/servers/x11/xorg/overrides.nix. - -
- - - + + If the expression for a package requires derivation attributes that the + generator cannot figure out automatically (say, patches + or a postInstall hook), you should modify + pkgs/servers/x11/xorg/overrides.nix. + +
- - - - - - -
- +
Eclipse - The Nix expressions related to the Eclipse platform and IDE are in - pkgs/applications/editors/eclipse. + The Nix expressions related to the Eclipse platform and IDE are in + pkgs/applications/editors/eclipse. - Nixpkgs provides a number of packages that will install Eclipse in - its various forms, these range from the bare-bones Eclipse - Platform to the more fully featured Eclipse SDK or Scala-IDE - packages and multiple version are often available. It is possible - to list available Eclipse packages by issuing the command: - + Nixpkgs provides a number of packages that will install Eclipse in its + various forms, these range from the bare-bones Eclipse Platform to the more + fully featured Eclipse SDK or Scala-IDE packages and multiple version are + often available. It is possible to list available Eclipse packages by + issuing the command: $ nix-env -f '<nixpkgs>' -qaP -A eclipses --description - - Once an Eclipse variant is installed it can be run using the - eclipse command, as expected. From within - Eclipse it is then possible to install plugins in the usual manner - by either manually specifying an Eclipse update site or by - installing the Marketplace Client plugin and using it to discover - and install other plugins. This installation method provides an - Eclipse installation that closely resemble a manually installed - Eclipse. + Once an Eclipse variant is installed it can be run using the + eclipse command, as expected. From within Eclipse it is + then possible to install plugins in the usual manner by either manually + specifying an Eclipse update site or by installing the Marketplace Client + plugin and using it to discover and install other plugins. This installation + method provides an Eclipse installation that closely resemble a manually + installed Eclipse. - If you prefer to install plugins in a more declarative manner then - Nixpkgs also offer a number of Eclipse plugins that can be - installed in an Eclipse environment. This - type of environment is created using the function - eclipseWithPlugins found inside the - nixpkgs.eclipses attribute set. This function - takes as argument { eclipse, plugins ? [], jvmArgs ? [] - } where eclipse is a one of the - Eclipse packages described above, plugins is a - list of plugin derivations, and jvmArgs is a - list of arguments given to the JVM running the Eclipse. For - example, say you wish to install the latest Eclipse Platform with - the popular Eclipse Color Theme plugin and also allow Eclipse to - use more RAM. You could then add - + If you prefer to install plugins in a more declarative manner then Nixpkgs + also offer a number of Eclipse plugins that can be installed in an + Eclipse environment. This type of environment is + created using the function eclipseWithPlugins found + inside the nixpkgs.eclipses attribute set. This function + takes as argument { eclipse, plugins ? [], jvmArgs ? [] } + where eclipse is a one of the Eclipse packages described + above, plugins is a list of plugin derivations, and + jvmArgs is a list of arguments given to the JVM running + the Eclipse. For example, say you wish to install the latest Eclipse + Platform with the popular Eclipse Color Theme plugin and also allow Eclipse + to use more RAM. You could then add packageOverrides = pkgs: { myEclipse = with pkgs.eclipses; eclipseWithPlugins { @@ -276,42 +243,38 @@ packageOverrides = pkgs: { }; } - - to your Nixpkgs configuration - (~/.config/nixpkgs/config.nix) and install it by - running nix-env -f '<nixpkgs>' -iA - myEclipse and afterward run Eclipse as usual. It is - possible to find out which plugins are available for installation - using eclipseWithPlugins by running - + to your Nixpkgs configuration + (~/.config/nixpkgs/config.nix) and install it by + running nix-env -f '<nixpkgs>' -iA myEclipse and + afterward run Eclipse as usual. It is possible to find out which plugins are + available for installation using eclipseWithPlugins by + running $ nix-env -f '<nixpkgs>' -qaP -A eclipses.plugins --description - If there is a need to install plugins that are not available in - Nixpkgs then it may be possible to define these plugins outside - Nixpkgs using the buildEclipseUpdateSite and - buildEclipsePlugin functions found in the - nixpkgs.eclipses.plugins attribute set. Use the - buildEclipseUpdateSite function to install a - plugin distributed as an Eclipse update site. This function takes - { name, src } as argument where - src indicates the Eclipse update site archive. - All Eclipse features and plugins within the downloaded update site - will be installed. When an update site archive is not available - then the buildEclipsePlugin function can be - used to install a plugin that consists of a pair of feature and - plugin JARs. This function takes an argument { name, - srcFeature, srcPlugin } where - srcFeature and srcPlugin are - the feature and plugin JARs, respectively. + If there is a need to install plugins that are not available in Nixpkgs then + it may be possible to define these plugins outside Nixpkgs using the + buildEclipseUpdateSite and + buildEclipsePlugin functions found in the + nixpkgs.eclipses.plugins attribute set. Use the + buildEclipseUpdateSite function to install a plugin + distributed as an Eclipse update site. This function takes { name, + src } as argument where src indicates the + Eclipse update site archive. All Eclipse features and plugins within the + downloaded update site will be installed. When an update site archive is not + available then the buildEclipsePlugin function can be + used to install a plugin that consists of a pair of feature and plugin JARs. + This function takes an argument { name, srcFeature, srcPlugin + } where srcFeature and + srcPlugin are the feature and plugin JARs, respectively. - Expanding the previous example with two plugins using the above - functions we have + Expanding the previous example with two plugins using the above functions we + have packageOverrides = pkgs: { myEclipse = with pkgs.eclipses; eclipseWithPlugins { @@ -343,210 +306,214 @@ packageOverrides = pkgs: { } +
+
+ Elm -
+ + The Nix expressions for Elm reside in + pkgs/development/compilers/elm. They are generated + automatically by update-elm.rb script. One should specify + versions of Elm packages inside the script, clear the + packages directory and run the script from inside it. + elm-reactor is special because it also has Elm package + dependencies. The process is not automated very much for now -- you should + get the elm-reactor source tree (e.g. with + nix-shell) and run elm2nix.rb inside + it. Place the resulting package.nix file into + packages/elm-reactor-elm.nix. + +
+
+ Interactive shell helpers -
- -Elm - - -The Nix expressions for Elm reside in -pkgs/development/compilers/elm. They are generated -automatically by update-elm.rb script. One should -specify versions of Elm packages inside the script, clear the -packages directory and run the script from inside it. -elm-reactor is special because it also has Elm package -dependencies. The process is not automated very much for now -- you should -get the elm-reactor source tree (e.g. with -nix-shell) and run elm2nix.rb inside -it. Place the resulting package.nix file into -packages/elm-reactor-elm.nix. - - -
- -
- -Interactive shell helpers - - - Some packages provide the shell integration to be more useful. But - unlike other systems, nix doesn't have a standard share directory - location. This is why a bunch PACKAGE-share - scripts are shipped that print the location of the corresponding - shared folder. - - Current list of such packages is as following: - - + + Some packages provide the shell integration to be more useful. But unlike + other systems, nix doesn't have a standard share directory location. This is + why a bunch PACKAGE-share scripts are shipped that print + the location of the corresponding shared folder. Current list of such + packages is as following: + - - autojump: autojump-share - + + autojump: autojump-share + - - fzf: fzf-share - + + fzf: fzf-share + - - - E.g. autojump can then used in the .bashrc like this: + + E.g. autojump can then used in the .bashrc like this: source "$(autojump-share)/autojump.bash" - + +
+
+ Steam -
+
+ Steam in Nix -
+ + Steam is distributed as a .deb file, for now only as + an i686 package (the amd64 package only has documentation). When unpacked, + it has a script called steam that in ubuntu (their + target distro) would go to /usr/bin . When run for the + first time, this script copies some files to the user's home, which include + another script that is the ultimate responsible for launching the steam + binary, which is also in $HOME. + -Steam + + Nix problems and constraints: + + + + We don't have /bin/bash and many scripts point + there. Similarly for /usr/bin/python . + + + + + We don't have the dynamic loader in /lib . + + + + + The steam.sh script in $HOME can not be patched, as + it is checked and rewritten by steam. + + + + + The steam binary cannot be patched, it's also checked. + + + + -
+ + The current approach to deploy Steam in NixOS is composing a FHS-compatible + chroot environment, as documented + here. + This allows us to have binaries in the expected paths without disrupting + the system, and to avoid patching them to work in a non FHS environment. + +
-Steam in Nix +
+ How to play - - Steam is distributed as a .deb file, for now only - as an i686 package (the amd64 package only has documentation). - When unpacked, it has a script called steam that - in ubuntu (their target distro) would go to /usr/bin - . When run for the first time, this script copies some - files to the user's home, which include another script that is the - ultimate responsible for launching the steam binary, which is also - in $HOME. - - - Nix problems and constraints: - - We don't have /bin/bash and many - scripts point there. Similarly for /usr/bin/python - . - We don't have the dynamic loader in /lib - . - The steam.sh script in $HOME can - not be patched, as it is checked and rewritten by steam. - The steam binary cannot be patched, it's also checked. - - - - The current approach to deploy Steam in NixOS is composing a FHS-compatible - chroot environment, as documented - here. - This allows us to have binaries in the expected paths without disrupting the system, - and to avoid patching them to work in a non FHS environment. - - -
- -
- -How to play - - - For 64-bit systems it's important to have - hardware.opengl.driSupport32Bit = true; - in your /etc/nixos/configuration.nix. You'll also need - hardware.pulseaudio.support32Bit = true; - if you are using PulseAudio - this will enable 32bit ALSA apps integration. - To use the Steam controller, you need to add - services.udev.extraRules = '' + + For 64-bit systems it's important to have +hardware.opengl.driSupport32Bit = true; + in your /etc/nixos/configuration.nix. You'll also need +hardware.pulseaudio.support32Bit = true; + if you are using PulseAudio - this will enable 32bit ALSA apps integration. + To use the Steam controller, you need to add +services.udev.extraRules = '' SUBSYSTEM=="usb", ATTRS{idVendor}=="28de", MODE="0666" KERNEL=="uinput", MODE="0660", GROUP="users", OPTIONS+="static_node=uinput" ''; - to your configuration. - + to your configuration. + +
-
+
+ Troubleshooting -
+ + + + Steam fails to start. What do I do? + + + Try to run +strace steam + to see what is causing steam to fail. + + + + + Using the FOSS Radeon or nouveau (nvidia) drivers + + + + + The newStdcpp parameter was removed since NixOS + 17.09 and should not be needed anymore. + + + + + Steam ships statically linked with a version of libcrypto that + conflics with the one dynamically loaded by radeonsi_dri.so. If you + get the error +steam.sh: line 713: 7842 Segmentation fault (core dumped) + have a look at + this + pull request. + + + + + + + Java + + + + + There is no java in steam chrootenv by default. If you get a message + like +/home/foo/.local/share/Steam/SteamApps/common/towns/towns.sh: line 1: java: command not found + You need to add + steam.override { withJava = true; }; + to your configuration. + + + + + + + +
-Troubleshooting +
+ steam-run - - - - - Steam fails to start. What do I do? - Try to run - strace steam - to see what is causing steam to fail. - - - - Using the FOSS Radeon or nouveau (nvidia) drivers - - The newStdcpp parameter - was removed since NixOS 17.09 and should not be needed anymore. - - - - Steam ships statically linked with a version of libcrypto that - conflics with the one dynamically loaded by radeonsi_dri.so. - If you get the error - steam.sh: line 713: 7842 Segmentation fault (core dumped) - have a look at this pull request. - - - - - - Java - - - There is no java in steam chrootenv by default. If you get a message like - /home/foo/.local/share/Steam/SteamApps/common/towns/towns.sh: line 1: java: command not found - You need to add - steam.override { withJava = true; }; - to your configuration. - - - - - - -
- -
- -steam-run - -The FHS-compatible chroot used for steam can also be used to run -other linux games that expect a FHS environment. -To do it, add + + The FHS-compatible chroot used for steam can also be used to run other + linux games that expect a FHS environment. To do it, add pkgs.(steam.override { nativeOnly = true; newStdcpp = true; }).run -to your configuration, rebuild, and run the game with + to your configuration, rebuild, and run the game with steam-run ./foo - + +
+
+
+ Emacs -
+
+ Configuring Emacs -
- -
- -Emacs - -
- -Configuring Emacs - - - The Emacs package comes with some extra helpers to make it easier to - configure. emacsWithPackages allows you to manage - packages from ELPA. This means that you will not have to install - that packages from within Emacs. For instance, if you wanted to use - company, counsel, - flycheck, ivy, - magit, projectile, and - use-package you could use this as a - ~/.config/nixpkgs/config.nix override: - + + The Emacs package comes with some extra helpers to make it easier to + configure. emacsWithPackages allows you to manage + packages from ELPA. This means that you will not have to install that + packages from within Emacs. For instance, if you wanted to use + company, counsel, + flycheck, ivy, + magit, projectile, and + use-package you could use this as a + ~/.config/nixpkgs/config.nix override: + { @@ -564,17 +531,17 @@ to your configuration, rebuild, and run the game with } - - You can install it like any other packages via nix-env -iA - myEmacs. However, this will only install those packages. - It will not configure them for us. To do this, we - need to provide a configuration file. Luckily, it is possible to do - this from within Nix! By modifying the above example, we can make - Emacs load a custom config file. The key is to create a package that - provide a default.el file in - /share/emacs/site-start/. Emacs knows to load - this file automatically when it starts. - + + You can install it like any other packages via nix-env -iA + myEmacs. However, this will only install those packages. It will + not configure them for us. To do this, we need to + provide a configuration file. Luckily, it is possible to do this from + within Nix! By modifying the above example, we can make Emacs load a custom + config file. The key is to create a package that provide a + default.el file in + /share/emacs/site-start/. Emacs knows to load this + file automatically when it starts. + { @@ -654,25 +621,24 @@ cp ${myEmacsConfig} $out/share/emacs/site-lisp/default.el } - - This provides a fairly full Emacs start file. It will load in - addition to the user's presonal config. You can always disable it by - passing -q to the Emacs command. - + + This provides a fairly full Emacs start file. It will load in addition to + the user's presonal config. You can always disable it by passing + -q to the Emacs command. + - - Sometimes emacsWithPackages 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 - pkgs/top-level/emacs-packages.nix). 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 overrideScope. - + + Sometimes emacsWithPackages 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 pkgs/top-level/emacs-packages.nix). 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 + overrideScope. + overrides = super: self: rec { @@ -685,34 +651,34 @@ overrides = super: self: rec { dante ]) +
+
+
+ Weechat -
- -
- -
-Weechat - -Weechat can be configured to include your choice of plugins, reducing its -closure size from the default configuration which includes all available -plugins. To make use of this functionality, install an expression that -overrides its configuration such as + + Weechat can be configured to include your choice of plugins, reducing its + closure size from the default configuration which includes all available + plugins. To make use of this functionality, install an expression that + overrides its configuration such as weechat.override {configure = {availablePlugins, ...}: { plugins = with availablePlugins; [ python perl ]; } } - - -The plugins currently available are python, -perl, ruby, guile, -tcl and lua. - - -The python plugin allows the addition of extra libraries. For instance, -the inotify.py script in weechat-scripts requires -D-Bus or libnotify, and the fish.py script requires -pycrypto. To use these scripts, use the python -plugin's withPackages attribute: + + + + The plugins currently available are python, + perl, ruby, guile, + tcl and lua. + + + + The python plugin allows the addition of extra libraries. For instance, the + inotify.py script in weechat-scripts requires D-Bus or + libnotify, and the fish.py script requires pycrypto. To + use these scripts, use the python plugin's + withPackages attribute: weechat.override { configure = {availablePlugins, ...}: { plugins = with availablePlugins; [ (python.withPackages (ps: with ps; [ pycrypto python-dbus ])) @@ -720,16 +686,17 @@ plugin's withPackages attribute: } } - - -In order to also keep all default plugins installed, it is possible to use -the following method: + + + + In order to also keep all default plugins installed, it is possible to use + the following method: weechat.override { configure = { availablePlugins, ... }: { plugins = builtins.attrValues (availablePlugins // { python = availablePlugins.python.withPackages (ps: with ps; [ pycrypto python-dbus ]); }); }; } - -
+ +
diff --git a/doc/platform-notes.xml b/doc/platform-notes.xml index f4f6ec600294..b2c20c2d35c0 100644 --- a/doc/platform-notes.xml +++ b/doc/platform-notes.xml @@ -1,27 +1,25 @@ + Platform Notes +
+ Darwin (macOS) -Platform Notes + + Some common issues when packaging software for darwin: + -
- -Darwin (macOS) -Some common issues when packaging software for darwin: - - - - + + - The darwin stdenv uses clang instead of gcc. - When referring to the compiler $CC or cc - will work in both cases. Some builds hardcode gcc/g++ in their - build scripts, that can usually be fixed with using something - like makeFlags = [ "CC=cc" ]; or by patching - the build scripts. + The darwin stdenv uses clang instead of gcc. When + referring to the compiler $CC or cc + will work in both cases. Some builds hardcode gcc/g++ in their build + scripts, that can usually be fixed with using something like + makeFlags = [ "CC=cc" ]; or by patching the build + scripts. - - + stdenv.mkDerivation { name = "libfoo-1.2.3"; # ... @@ -30,36 +28,33 @@ ''; } - - - + + - On darwin libraries are linked using absolute paths, libraries - are resolved by their install_name at link - time. Sometimes packages won't set this correctly causing the - library lookups to fail at runtime. This can be fixed by adding - extra linker flags or by running install_name_tool -id - during the fixupPhase. + On darwin libraries are linked using absolute paths, libraries are + resolved by their install_name at link time. Sometimes + packages won't set this correctly causing the library lookups to fail at + runtime. This can be fixed by adding extra linker flags or by running + install_name_tool -id during the + fixupPhase. - - + stdenv.mkDerivation { name = "libfoo-1.2.3"; # ... makeFlags = stdenv.lib.optional stdenv.isDarwin "LDFLAGS=-Wl,-install_name,$(out)/lib/libfoo.dylib"; } - - - + + - Some packages assume xcode is available and use xcrun - to resolve build tools like clang, etc. - This causes errors like xcode-select: error: no developer tools were found at '/Applications/Xcode.app' - while the build doesn't actually depend on xcode. + Some packages assume xcode is available and use xcrun + to resolve build tools like clang, etc. This causes + errors like xcode-select: error: no developer tools were found at + '/Applications/Xcode.app' while the build doesn't actually depend + on xcode. - - + stdenv.mkDerivation { name = "libfoo-1.2.3"; # ... @@ -69,15 +64,12 @@ ''; } - - The package xcbuild can be used to build projects - that really depend on Xcode, however projects that build some kind of - graphical interface won't work without using Xcode in an impure way. + The package xcbuild can be used to build projects that + really depend on Xcode, however projects that build some kind of graphical + interface won't work without using Xcode in an impure way. - - - -
- + + +
diff --git a/doc/quick-start.xml b/doc/quick-start.xml index ca86e6c9519b..0cba3a4769c4 100644 --- a/doc/quick-start.xml +++ b/doc/quick-start.xml @@ -1,223 +1,219 @@ - -Quick Start to Adding a Package - -To add a package to Nixpkgs: - - - - - Checkout the Nixpkgs source tree: - + Quick Start to Adding a Package + + To add a package to Nixpkgs: + + + + Checkout the Nixpkgs source tree: $ git clone git://github.com/NixOS/nixpkgs.git $ cd nixpkgs - - - - - Find a good place in the Nixpkgs tree to add the Nix - expression for your package. For instance, a library package - typically goes into - pkgs/development/libraries/pkgname, - while a web browser goes into - pkgs/applications/networking/browsers/pkgname. - See for some hints on the tree - organisation. Create a directory for your package, e.g. - + + + + Find a good place in the Nixpkgs tree to add the Nix expression for your + package. For instance, a library package typically goes into + pkgs/development/libraries/pkgname, + while a web browser goes into + pkgs/applications/networking/browsers/pkgname. + See for some hints on the tree + organisation. Create a directory for your package, e.g. $ mkdir pkgs/development/libraries/libfoo - - - - - In the package directory, create a Nix expression — a piece - of code that describes how to build the package. In this case, it - should be a function that is called with the - package dependencies as arguments, and returns a build of the - package in the Nix store. The expression should usually be called - default.nix. - + + + + In the package directory, create a Nix expression — a piece of code that + describes how to build the package. In this case, it should be a + function that is called with the package dependencies + as arguments, and returns a build of the package in the Nix store. The + expression should usually be called default.nix. $ emacs pkgs/development/libraries/libfoo/default.nix $ git add pkgs/development/libraries/libfoo/default.nix - - - You can have a look at the existing Nix expressions under - pkgs/ to see how it’s done. Here are some - good ones: - - - - - GNU Hello: + You can have a look at the existing Nix expressions under + pkgs/ to see how it’s done. Here are some good + ones: + + + + GNU Hello: + pkgs/applications/misc/hello/default.nix. - Trivial package, which specifies some meta - attributes which is good practice. - - - - GNU cpio: meta + attributes which is good practice. + + + + + GNU cpio: + pkgs/tools/archivers/cpio/default.nix. - Also a simple package. The generic builder in - stdenv does everything for you. It has - no dependencies beyond stdenv. - - - - GNU Multiple Precision arithmetic library (GMP): stdenv + does everything for you. It has no dependencies beyond + stdenv. + + + + + GNU Multiple Precision arithmetic library (GMP): + pkgs/development/libraries/gmp/5.1.x.nix. - Also done by the generic builder, but has a dependency on - m4. - - - - Pan, a GTK-based newsreader: m4. + + + + + Pan, a GTK-based newsreader: + pkgs/applications/networking/newsreaders/pan/default.nix. - Has an optional dependency on gtkspell, - which is only built if spellCheck is - true. - - - - Apache HTTPD: gtkspell, which is + only built if spellCheck is true. + + + + + Apache HTTPD: + pkgs/servers/http/apache-httpd/2.4.nix. - A bunch of optional features, variable substitutions in the - configure flags, a post-install hook, and miscellaneous - hackery. - - - - Thunderbird: + + + + Thunderbird: + pkgs/applications/networking/mailreaders/thunderbird/default.nix. - Lots of dependencies. - - - - JDiskReport, a Java utility: + + + + JDiskReport, a Java utility: + pkgs/tools/misc/jdiskreport/default.nix - (and the builder). - Nixpkgs doesn’t have a decent stdenv for - Java yet so this is pretty ad-hoc. - - - - XML::Simple, a Perl module: stdenv for Java yet + so this is pretty ad-hoc. + + + + + XML::Simple, a Perl module: + pkgs/top-level/perl-packages.nix - (search for the XMLSimple attribute). - Most Perl modules are so simple to build that they are - defined directly in perl-packages.nix; - no need to make a separate file for them. - - - - Adobe Reader: XMLSimple attribute). Most Perl + modules are so simple to build that they are defined directly in + perl-packages.nix; no need to make a separate file + for them. + + + + + Adobe Reader: + pkgs/applications/misc/adobe-reader/default.nix. - Shows how binary-only packages can be supported. In - particular the builder - uses patchelf to set the RUNPATH and ELF - interpreter of the executables so that the right libraries - are found at runtime. - - - - + uses patchelf to set the RUNPATH and ELF interpreter + of the executables so that the right libraries are found at runtime. + + + - - Some notes: - - - - - All meta - attributes are optional, but it’s still a good idea to - provide at least the description, - homepage and license. - - - - You can use nix-prefetch-url (or similar nix-prefetch-git, etc) - url to get the SHA-256 hash of - source distributions. There are similar commands as nix-prefetch-git and - nix-prefetch-hg available in nix-prefetch-scripts package. - - - - A list of schemes for mirror:// - URLs can be found in pkgs/build-support/fetchurl/mirrors.nix. - - - - + + Some notes: + + + + All meta attributes are + optional, but it’s still a good idea to provide at least the + description, homepage and + license. + + + + + You can use nix-prefetch-url (or similar + nix-prefetch-git, etc) url to get the + SHA-256 hash of source distributions. There are similar commands as + nix-prefetch-git and + nix-prefetch-hg available in + nix-prefetch-scripts package. + + + + + A list of schemes for mirror:// URLs can be found in + pkgs/build-support/fetchurl/mirrors.nix. + + + - - The exact syntax and semantics of the Nix expression - language, including the built-in function, are described in the - Nix manual in the + The exact syntax and semantics of the Nix expression language, including + the built-in function, are described in the Nix manual in the + chapter - on writing Nix expressions. - - - - - Add a call to the function defined in the previous step to - . + + + + + Add a call to the function defined in the previous step to + pkgs/top-level/all-packages.nix - with some descriptive name for the variable, - e.g. libfoo. - - + with some descriptive name for the variable, e.g. + libfoo. + $ emacs pkgs/top-level/all-packages.nix - - - The attributes in that file are sorted by category (like - “Development / Libraries”) that more-or-less correspond to the - directory structure of Nixpkgs, and then by attribute name. - - - - To test whether the package builds, run the following command - from the root of the nixpkgs source tree: - - + + The attributes in that file are sorted by category (like “Development / + Libraries”) that more-or-less correspond to the directory structure of + Nixpkgs, and then by attribute name. + + + + + To test whether the package builds, run the following command from the + root of the nixpkgs source tree: + $ nix-build -A libfoo - - where libfoo should be the variable name - defined in the previous step. You may want to add the flag - to keep the temporary build directory in case - something fails. If the build succeeds, a symlink - ./result to the package in the Nix store is - created. - - - - If you want to install the package into your profile - (optional), do - - -$ nix-env -f . -iA libfoo - + where libfoo should be the variable name defined in the + previous step. You may want to add the flag to keep + the temporary build directory in case something fails. If the build + succeeds, a symlink ./result to the package in the + Nix store is created. - - - - Optionally commit the new package and open a pull request, or send a patch to - https://groups.google.com/forum/#!forum/nix-devel. - - - - - - - + + + + If you want to install the package into your profile (optional), do + +$ nix-env -f . -iA libfoo + + + + + Optionally commit the new package and open a pull request, or send a patch + to https://groups.google.com/forum/#!forum/nix-devel. + + + + diff --git a/doc/release-notes.xml b/doc/release-notes.xml index a50ee877acdd..6dae6ae5620e 100644 --- a/doc/release-notes.xml +++ b/doc/release-notes.xml @@ -1,164 +1,177 @@
+ Nixpkgs Release Notes +
+ Release 0.14 (June 4, 2012) -Nixpkgs Release Notes + + In preparation for the switch from Subversion to Git, this release is mainly + the prevent the Nixpkgs version number from going backwards. (This would + happen because prerelease version numbers produced for the Git repository + are lower than those for the Subversion repository.) + + + Since the last release, there have been thousands of changes and new + packages by numerous contributors. For details, see the commit logs. + +
+
+ Release 0.13 (February 5, 2010) -
Release 0.14 (June 4, 2012) + + As always, there are many changes. Some of the most important updates are: + + + + Glibc 2.9. + + + + + GCC 4.3.3. + + + + + Linux 2.6.32. + + + + + X.org 7.5. + + + + + KDE 4.3.4. + + + + +
+
+ Release 0.12 (April 24, 2009) -In preparation for the switch from Subversion to Git, this -release is mainly the prevent the Nixpkgs version number from going -backwards. (This would happen because prerelease version numbers -produced for the Git repository are lower than those for the -Subversion repository.) + + There are way too many additions to Nixpkgs since the last release to list + here: for example, the number of packages on Linux has increased from 1002 + to 2159. However, some specific improvements are worth listing: + + + + Nixpkgs now has a manual. In particular, it describes the standard build + environment in detail. + + + + + Major new packages: + + + + KDE 4. + + + + + TeXLive. + + + + + VirtualBox. + + + + … and many others. + + + + + Important updates: + + + + Glibc 2.7. + + + + + GCC 4.2.4. + + + + + Linux 2.6.25 — 2.6.28. + + + + + Firefox 3. + + + + + X.org 7.3. + + + + + + + + Support for building derivations in a virtual machine, including RPM and + Debian builds in automatically generated VM images. See + pkgs/build-support/vm/default.nix for details. + + + + + Improved support for building Haskell packages. + + + + -Since the last release, there have been thousands of changes and -new packages by numerous contributors. For details, see the commit -logs. - -
- - -
Release 0.13 (February 5, 2010) - -As always, there are many changes. Some of the most important -updates are: - - - - Glibc 2.9. - - GCC 4.3.3. - - Linux 2.6.32. - - X.org 7.5. - - KDE 4.3.4. - - - - - - -
- - -
Release 0.12 (April 24, 2009) - -There are way too many additions to Nixpkgs since the last -release to list here: for example, the number of packages on Linux has -increased from 1002 to 2159. However, some specific improvements are -worth listing: - - - - Nixpkgs now has a manual. In particular, it - describes the standard build environment in - detail. - - Major new packages: - - - - KDE 4. - - TeXLive. - - VirtualBox. - - - - … and many others. - - - - Important updates: - - - - Glibc 2.7. - - GCC 4.2.4. - - Linux 2.6.25 — 2.6.28. - - Firefox 3. - - X.org 7.3. - - - - - - Support for building derivations in a virtual - machine, including RPM and Debian builds in automatically generated - VM images. See - pkgs/build-support/vm/default.nix for - details. - - Improved support for building Haskell - packages. - - - - - -The following people contributed to this release: - -Andres Löh, -Arie Middelkoop, -Armijn Hemel, -Eelco Dolstra, -Lluís Batlle, -Ludovic Courtès, -Marc Weber, -Mart Kolthof, -Martin Bravenboer, -Michael Raskin, -Nicolas Pierron, -Peter Simons, -Pjotr Prins, -Rob Vermaas, -Sander van der Burg, -Tobias Hammerschmidt, -Valentin David, -Wouter den Breejen and -Yury G. Kudryashov. - -In addition, several people contributed patches on the -nix-dev mailing list. - -
- - -
Release 0.11 (September 11, 2007) - -This release has the following improvements: - - - - - The standard build environment - (stdenv) is now pure on the - x86_64-linux and powerpc-linux - platforms, just as on i686-linux. (Purity means - that building and using the standard environment has no dependencies - outside of the Nix store. For instance, it doesn’t require an - external C compiler such as /usr/bin/gcc.) - Also, the statically linked binaries used in the bootstrap process - are now automatically reproducible, making it easy to update the - bootstrap tools and to add support for other Linux platforms. See - pkgs/stdenv/linux/make-bootstrap-tools.nix for - details. - - - Hook variables in the generic builder are now - executed using the eval shell command. This - has a major advantage: you can write hooks directly in Nix - expressions. For instance, rather than writing a builder like this: + + The following people contributed to this release: Andres Löh, Arie + Middelkoop, Armijn Hemel, Eelco Dolstra, Lluís Batlle, Ludovic Courtès, + Marc Weber, Mart Kolthof, Martin Bravenboer, Michael Raskin, Nicolas + Pierron, Peter Simons, Pjotr Prins, Rob Vermaas, Sander van der Burg, Tobias + Hammerschmidt, Valentin David, Wouter den Breejen and Yury G. Kudryashov. In + addition, several people contributed patches on the + nix-dev mailing list. + +
+
+ Release 0.11 (September 11, 2007) + + This release has the following improvements: + + + + The standard build environment (stdenv) is now pure on + the x86_64-linux and powerpc-linux + platforms, just as on i686-linux. (Purity means that + building and using the standard environment has no dependencies outside + of the Nix store. For instance, it doesn’t require an external C + compiler such as /usr/bin/gcc.) Also, the statically + linked binaries used in the bootstrap process are now automatically + reproducible, making it easy to update the bootstrap tools and to add + support for other Linux platforms. See + pkgs/stdenv/linux/make-bootstrap-tools.nix for + details. + + + + + Hook variables in the generic builder are now executed using the + eval shell command. This has a major advantage: you + can write hooks directly in Nix expressions. For instance, rather than + writing a builder like this: source $stdenv/setup @@ -169,290 +182,311 @@ postInstall() { } genericBuild - - (the gzip builder), you can just add this - attribute to the derivation: - + (the gzip builder), you can just add this attribute to + the derivation: postInstall = "ln -sf gzip $out/bin/gunzip; ln -sf gzip $out/bin/zcat"; - - and so a separate build script becomes unnecessary. This should - allow us to get rid of most builders in Nixpkgs. - - - It is now possible to have the generic builder pass - arguments to configure and - make that contain whitespace. Previously, for - example, you could say in a builder, - + and so a separate build script becomes unnecessary. This should allow us + to get rid of most builders in Nixpkgs. + + + + + It is now possible to have the generic builder pass arguments to + configure and make that contain + whitespace. Previously, for example, you could say in a builder, configureFlags="CFLAGS=-O0" - - but not - + but not configureFlags="CFLAGS=-O0 -g" - - since the -g would be interpreted as a separate - argument to configure. Now you can say - + since the -g would be interpreted as a separate + argument to configure. Now you can say configureFlagsArray=("CFLAGS=-O0 -g") - - or similarly - + or similarly configureFlagsArray=("CFLAGS=-O0 -g" "LDFLAGS=-L/foo -L/bar") - - which does the right thing. Idem for makeFlags, - installFlags, checkFlags and - distFlags. - - Unfortunately you can't pass arrays to Bash through the - environment, so you can't put the array above in a Nix expression, - e.g., - + which does the right thing. Idem for makeFlags, + installFlags, checkFlags and + distFlags. + + + Unfortunately you can't pass arrays to Bash through the environment, so + you can't put the array above in a Nix expression, e.g., configureFlagsArray = ["CFLAGS=-O0 -g"]; - - since it would just be flattened to a since string. However, you - can use the inline hooks described above: - + since it would just be flattened to a since string. However, you + can use the inline hooks described above: preConfigure = "configureFlagsArray=(\"CFLAGS=-O0 -g\")"; - - - - - The function fetchurl now has - support for two different kinds of mirroring of files. First, it - has support for content-addressable mirrors. - For example, given the fetchurl call - + + + + + The function fetchurl now has support for two + different kinds of mirroring of files. First, it has support for + content-addressable mirrors. For example, given the + fetchurl call fetchurl { url = http://releases.mozilla.org/.../firefox-2.0.0.6-source.tar.bz2; sha1 = "eb72f55e4a8bf08e8c6ef227c0ade3d068ba1082"; } - - fetchurl will first try to download this file - from fetchurl will first try to download this file from + . - If that file doesn’t exist, it will try the original URL. In - general, the “content-addressed” location is - mirror/hash-type/hash. - There is currently only one content-addressable mirror (mirror/hash-type/hash. + There is currently only one content-addressable mirror + (), but more can be - specified in the hashedMirrors attribute in - pkgs/build-support/fetchurl/mirrors.nix, or by - setting the NIX_HASHED_MIRRORS environment variable - to a whitespace-separated list of URLs. - - Second, fetchurl has support for - widely-mirrored distribution sites such as SourceForge or the Linux - kernel archives. Given a URL of the form - mirror://site/path, - it will try to download path from a - configurable list of mirrors for site. - (This idea was borrowed from Gentoo Linux.) Example: + specified in the hashedMirrors attribute in + pkgs/build-support/fetchurl/mirrors.nix, or by + setting the NIX_HASHED_MIRRORS environment variable to a + whitespace-separated list of URLs. + + + Second, fetchurl has support for widely-mirrored + distribution sites such as SourceForge or the Linux kernel archives. + Given a URL of the form + mirror://site/path, + it will try to download path from a + configurable list of mirrors for site. (This + idea was borrowed from Gentoo Linux.) Example: fetchurl { url = mirror://gnu/gcc/gcc-4.2.0/gcc-core-4.2.0.tar.bz2; sha256 = "0ykhzxhr8857dr97z0j9wyybfz1kjr71xk457cfapfw5fjas4ny1"; } - Currently site can be - sourceforge, gnu and - kernel. The list of mirrors is defined in - pkgs/build-support/fetchurl/mirrors.nix. You - can override the list of mirrors for a particular site by setting - the environment variable - NIX_MIRRORS_site, e.g. + Currently site can be + sourceforge, gnu and + kernel. The list of mirrors is defined in + pkgs/build-support/fetchurl/mirrors.nix. You can + override the list of mirrors for a particular site by setting the + environment variable + NIX_MIRRORS_site, e.g. export NIX_MIRRORS_sourceforge=http://osdn.dl.sourceforge.net/sourceforge/ + + + + + Important updates: + + + + Glibc 2.5. + + + + + GCC 4.1.2. + + + + + Gnome 2.16.3. + + + + + X11R7.2. + + + + + Linux 2.6.21.7 and 2.6.22.6. + + + + + Emacs 22.1. + + + + + + + + Major new packages: + + + + KDE 3.5.6 Base. + + + + + Wine 0.9.43. + + + + + OpenOffice 2.2.1. + + + + + Many Linux system packages to support NixOS. + + + + + + - + + The following people contributed to this release: Andres Löh, Arie + Middelkoop, Armijn Hemel, Eelco Dolstra, Marc Weber, Mart Kolthof, Martin + Bravenboer, Michael Raskin, Wouter den Breejen and Yury G. Kudryashov. + +
+
+ Release 0.10 (October 12, 2006) + + + This release of Nixpkgs requires + Nix 0.10 + or higher. + + - Important updates: - - - - Glibc 2.5. - - GCC 4.1.2. - - Gnome 2.16.3. - - X11R7.2. - - Linux 2.6.21.7 and 2.6.22.6. - - Emacs 22.1. - - - - - - - Major new packages: - - - - KDE 3.5.6 Base. - - Wine 0.9.43. - - OpenOffice 2.2.1. - - Many Linux system packages to support - NixOS. - - - - - - - - - -The following people contributed to this release: - - Andres Löh, - Arie Middelkoop, - Armijn Hemel, - Eelco Dolstra, - Marc Weber, - Mart Kolthof, - Martin Bravenboer, - Michael Raskin, - Wouter den Breejen and - Yury G. Kudryashov. - - - -
- - -
Release 0.10 (October 12, 2006) - -This release of Nixpkgs requires Nix -0.10 or higher. - -This release has the following improvements: - - - - pkgs/system/all-packages-generic.nix - is gone, we now just have - pkgs/top-level/all-packages.nix that contains - all available packages. This should cause much less confusion with - users. all-packages.nix is a function that by - default returns packages for the current platform, but you can - override this by specifying a different system - argument. - - Certain packages in Nixpkgs are now - user-configurable through a configuration file, i.e., without having - to edit the Nix expressions in Nixpkgs. For instance, the Firefox - provided in the Nixpkgs channel is built without the RealPlayer - plugin (for legal reasons). Previously, you could easily enable - RealPlayer support by editing the call to the Firefox function in - all-packages.nix, but such changes are not - respected when Firefox is subsequently updated through the Nixpkgs - channel. - - The Nixpkgs configuration file (found in - ~/.nixpkgs/config.nix or through the - NIXPKGS_CONFIG environment variable) is an attribute - set that contains configuration options that - all-packages.nix reads and uses for certain - packages. For instance, the following configuration file: + + This release has the following improvements: + + + + + pkgs/system/all-packages-generic.nix is gone, we now + just have pkgs/top-level/all-packages.nix that + contains all available packages. This should cause much less confusion + with users. all-packages.nix is a function that by + default returns packages for the current platform, but you can override + this by specifying a different system argument. + + + + + Certain packages in Nixpkgs are now user-configurable through a + configuration file, i.e., without having to edit the Nix expressions in + Nixpkgs. For instance, the Firefox provided in the Nixpkgs channel is + built without the RealPlayer plugin (for legal reasons). Previously, you + could easily enable RealPlayer support by editing the call to the Firefox + function in all-packages.nix, but such changes are + not respected when Firefox is subsequently updated through the Nixpkgs + channel. + + + The Nixpkgs configuration file (found in + ~/.nixpkgs/config.nix or through the + NIXPKGS_CONFIG environment variable) is an attribute set + that contains configuration options that + all-packages.nix reads and uses for certain packages. + For instance, the following configuration file: { firefox = { enableRealPlayer = true; }; } - - persistently enables RealPlayer support in the Firefox - build. - - (Actually, firefox.enableRealPlayer is the - only configuration option currently available, - but more are sure to be added.) - - Support for new platforms: - - - - i686-cygwin, i.e., Windows - (using Cygwin). - The standard environment on i686-cygwin by - default builds binaries for the Cygwin environment (i.e., it - uses Cygwin tools and produces executables that use the Cygwin - library). However, there is also a standard environment that - produces binaries that use MinGW. You can use it - by calling all-package.nix with the - stdenvType argument set to - "i686-mingw". - - i686-darwin, i.e., Mac OS X - on Intel CPUs. - - powerpc-linux. - - x86_64-linux, i.e., Linux on - 64-bit AMD/Intel CPUs. Unlike i686-linux, - this platform doesn’t have a pure stdenv - yet. - - - + persistently enables RealPlayer support in the Firefox build. - - - - The default compiler is now GCC 4.1.1. - - X11 updated to X.org’s X11R7.1. - - Notable new packages: - - - - Opera. - - Microsoft Visual C++ 2005 Express Edition and - the Windows SDK. - - - - In total there are now around 809 packages in Nixpkgs. - - - - - It is now much easier to - override the default C compiler and other tools in - stdenv for specific packages. - all-packages.nix provides two utility - functions for this purpose: overrideGCC and - overrideInStdenv. Both take a - stdenv and return an augmented - stdenv; the formed changes the C compiler, and - the latter adds additional packages to the front of - stdenv’s initial PATH, allowing - tools to be overridden. - - For instance, the package strategoxt - doesn’t build with the GNU Make in stdenv - (version 3.81), so we call it with an augmented - stdenv that uses GNU Make 3.80: - + + (Actually, firefox.enableRealPlayer is the + only configuration option currently available, but + more are sure to be added.) + + + + + Support for new platforms: + + + + i686-cygwin, i.e., Windows (using + Cygwin). The standard + environment on i686-cygwin by default builds + binaries for the Cygwin environment (i.e., it uses Cygwin tools and + produces executables that use the Cygwin library). However, there is + also a standard environment that produces binaries that use + MinGW. You can + use it by calling all-package.nix with the + stdenvType argument set to + "i686-mingw". + + + + + i686-darwin, i.e., Mac OS X on Intel CPUs. + + + + + powerpc-linux. + + + + + x86_64-linux, i.e., Linux on 64-bit AMD/Intel CPUs. + Unlike i686-linux, this platform doesn’t have a + pure stdenv yet. + + + + + + + + The default compiler is now GCC 4.1.1. + + + + + X11 updated to X.org’s X11R7.1. + + + + + Notable new packages: + + + + Opera. + + + + + Microsoft Visual C++ 2005 Express Edition and the Windows SDK. + + + + In total there are now around 809 packages in Nixpkgs. + + + + + It is now much easier to override the default C + compiler and other tools in stdenv for specific + packages. all-packages.nix provides two utility + functions for this purpose: overrideGCC and + overrideInStdenv. Both take a + stdenv and return an augmented + stdenv; the formed changes the C compiler, and the + latter adds additional packages to the front of + stdenv’s initial PATH, allowing tools + to be overridden. + + + For instance, the package strategoxt doesn’t build + with the GNU Make in stdenv (version 3.81), so we call + it with an augmented stdenv that uses GNU Make 3.80: strategoxt = (import ../development/compilers/strategoxt) { inherit fetchurl pkgconfig sdf aterm; @@ -460,44 +494,37 @@ strategoxt = (import ../development/compilers/strategoxt) { }; gnumake380 = ...; - - Likewise, there are many packages that don’t compile with the - default GCC (4.1.1), but that’s easily fixed: - + Likewise, there are many packages that don’t compile with the default + GCC (4.1.1), but that’s easily fixed: exult = import ../games/exult { inherit fetchurl SDL SDL_mixer zlib libpng unzip; stdenv = overrideGCC stdenv gcc34; }; - - - - - It has also become much easier to experiment with - changes to the stdenv setup script (which notably - contains the generic builder). Since edits to - pkgs/stdenv/generic/setup.sh trigger a rebuild - of everything, this was formerly quite painful. - But now stdenv contains a function to - “regenerate” stdenv with a different setup - script, allowing the use of a different setup script for specific - packages: - + + + + + It has also become much easier to experiment with changes to the + stdenv setup script (which notably contains the generic + builder). Since edits to pkgs/stdenv/generic/setup.sh + trigger a rebuild of everything, this was formerly + quite painful. But now stdenv contains a function to + “regenerate” stdenv with a different setup script, + allowing the use of a different setup script for specific packages: pkg = import ... { stdenv = stdenv.regenerate ./my-setup.sh; ... } - - - - - Packages can now have a human-readable - description field. Package descriptions are - shown by nix-env -qa --description. In addition, - they’re shown on the Nixpkgs release page. A description can be - added to a package as follows: - + + + + + Packages can now have a human-readable description + field. Package descriptions are shown by nix-env -qa + --description. In addition, they’re shown on the Nixpkgs + release page. A description can be added to a package as follows: stdenv.mkDerivation { name = "exult-1.2"; @@ -506,228 +533,268 @@ stdenv.mkDerivation { description = "A reimplementation of the Ultima VII game engine"; }; } - - The meta attribute is not passed to the builder, - so changes to the description do not trigger a rebuild. Additional - meta attributes may be defined in the future - (such as the URL of the package’s homepage, the license, - etc.). - - - - -The following people contributed to this release: - - Andres Löh, - Armijn Hemel, - Christof Douma, - Eelco Dolstra, - Eelco Visser, - Mart Kolthof, - Martin Bravenboer, - Merijn de Jonge, - Rob Vermaas and - Roy van den Broek. - - - -
- - -
Release 0.9 (January 31, 2006) - -There have been zillions of changes since the last release of -Nixpkgs. Many packages have been added or updated. The following are -some of the more notable changes: - - - - Distribution files have been moved to . - - The C library on Linux, Glibc, has been updated to - version 2.3.6. - - The default compiler is now GCC 3.4.5. GCC 4.0.2 is - also available. - - The old, unofficial Xlibs has been replaced by the - official modularised X11 distribution from X.org, i.e., X11R7.0. - X11R7.0 consists of 287 (!) packages, all of which are in Nixpkgs - though not all have been tested. It is now possible to build a - working X server (previously we only had X client libraries). We - use a fully Nixified X server on NixOS. - - The Sun JDK 5 has been purified, i.e., it doesn’t - require any non-Nix components such as - /lib/ld-linux.so.2. This means that Java - applications such as Eclipse and Azureus can run on - NixOS. - - Hardware-accelerated OpenGL support, used by games - like Quake 3 (which is now built from source). - - Improved support for FreeBSD on - x86. - - Improved Haskell support; e.g., the GHC build is now - pure. - - Some support for cross-compilation: cross-compiling - builds of GCC and Binutils, and cross-compiled builds of the C - library uClibc. - - Notable new packages: - - - - teTeX, including support for building LaTeX - documents using Nix (with automatic dependency - determination). - - Ruby. - - System-level packages to support NixOS, - e.g. Grub, GNU parted and so - on. - - ecj, the Eclipse Compiler for - Java, so we finally have a freely distributable compiler that - supports Java 5.0. - - php. - - The GIMP. - - Inkscape. - - GAIM. - - kdelibs. This allows us to - add KDE-based packages (such as - kcachegrind). - - - - - - - -The following people contributed to this release: - - Andres Löh, - Armijn Hemel, - Bogdan Dumitriu, - Christof Douma, - Eelco Dolstra, - Eelco Visser, - Mart Kolthof, - Martin Bravenboer, - Rob Vermaas and - Roy van den Broek. - - - -
- - -
Release 0.8 (April 11, 2005) - -This release is mostly to remain synchronised with the changed -hashing scheme in Nix 0.8. - -Notable updates: - - - - Adobe Reader 7.0 - - Various security updates (zlib 1.2.2, etc.) - - - - - -
- - -
Release 0.7 (March 14, 2005) - - - - - - The bootstrap process for the standard build - environment on Linux (stdenv-linux) has been improved. It is no - longer dependent in its initial bootstrap stages on the system - Glibc, GCC, and other tools. Rather, Nixpkgs contains a statically - linked bash and curl, and uses that to download other statically - linked tools. These are then used to build a Glibc and dynamically - linked versions of all other tools. - - This change also makes the bootstrap process faster. For - instance, GCC is built only once instead of three times. - - (Contributed by Armijn Hemel.) - - - - - - Tarballs used by Nixpkgs are now obtained from the same server - that hosts Nixpkgs (). This reduces the - risk of packages being unbuildable due to moved or deleted files on - various servers. - - - - - - There now is a generic mechanism for building Perl modules. - See the various Perl modules defined in - pkgs/system/all-packages-generic.nix. - - - - - - Notable new packages: - - - - Qt 3 - MySQL - MythTV - Mono - MonoDevelop (alpha) - Xine - + The meta attribute is not passed to the builder, so + changes to the description do not trigger a rebuild. Additional + meta attributes may be defined in the future (such as + the URL of the package’s homepage, the license, etc.). + + + + The following people contributed to this release: Andres Löh, Armijn Hemel, + Christof Douma, Eelco Dolstra, Eelco Visser, Mart Kolthof, Martin + Bravenboer, Merijn de Jonge, Rob Vermaas and Roy van den Broek. +
+
+ Release 0.9 (January 31, 2006) - - - - - Notable updates: + + There have been zillions of changes since the last release of Nixpkgs. Many + packages have been added or updated. The following are some of the more + notable changes: + - - GCC 3.4.3 - Glibc 2.3.4 - GTK 2.6 - + + + Distribution files have been moved to + . + + + + + The C library on Linux, Glibc, has been updated to version 2.3.6. + + + + + The default compiler is now GCC 3.4.5. GCC 4.0.2 is also available. + + + + + The old, unofficial Xlibs has been replaced by the official modularised + X11 distribution from X.org, i.e., X11R7.0. X11R7.0 consists of 287 (!) + packages, all of which are in Nixpkgs though not all have been tested. It + is now possible to build a working X server (previously we only had X + client libraries). We use a fully Nixified X server on NixOS. + + + + + The Sun JDK 5 has been purified, i.e., it doesn’t require any non-Nix + components such as /lib/ld-linux.so.2. This means + that Java applications such as Eclipse and Azureus can run on NixOS. + + + + + Hardware-accelerated OpenGL support, used by games like Quake 3 (which is + now built from source). + + + + + Improved support for FreeBSD on x86. + + + + + Improved Haskell support; e.g., the GHC build is now pure. + + + + + Some support for cross-compilation: cross-compiling builds of GCC and + Binutils, and cross-compiled builds of the C library uClibc. + + + + + Notable new packages: + + + + teTeX, including support for building LaTeX documents using Nix (with + automatic dependency determination). + + + + + Ruby. + + + + + System-level packages to support NixOS, e.g. Grub, GNU + parted and so on. + + + + + ecj, the Eclipse Compiler for Java, so we finally + have a freely distributable compiler that supports Java 5.0. + + + + + php. + + + + + The GIMP. + + + + + Inkscape. + + + + + GAIM. + + + + + kdelibs. This allows us to add KDE-based packages + (such as kcachegrind). + + + + + + + The following people contributed to this release: Andres Löh, Armijn Hemel, + Bogdan Dumitriu, Christof Douma, Eelco Dolstra, Eelco Visser, Mart Kolthof, + Martin Bravenboer, Rob Vermaas and Roy van den Broek. + +
+
+ Release 0.8 (April 11, 2005) + + + This release is mostly to remain synchronised with the changed hashing + scheme in Nix 0.8. - + + Notable updates: + + + + Adobe Reader 7.0 + + + + + Various security updates (zlib 1.2.2, etc.) + + + + +
+
+ Release 0.7 (March 14, 2005) - - -
- - + + + + The bootstrap process for the standard build environment on Linux + (stdenv-linux) has been improved. It is no longer dependent in its initial + bootstrap stages on the system Glibc, GCC, and other tools. Rather, + Nixpkgs contains a statically linked bash and curl, and uses that to + download other statically linked tools. These are then used to build a + Glibc and dynamically linked versions of all other tools. + + + This change also makes the bootstrap process faster. For instance, GCC is + built only once instead of three times. + + + (Contributed by Armijn Hemel.) + + + + + Tarballs used by Nixpkgs are now obtained from the same server that hosts + Nixpkgs (). This + reduces the risk of packages being unbuildable due to moved or deleted + files on various servers. + + + + + There now is a generic mechanism for building Perl modules. See the + various Perl modules defined in pkgs/system/all-packages-generic.nix. + + + + + Notable new packages: + + + + Qt 3 + + + + + MySQL + + + + + MythTV + + + + + Mono + + + + + MonoDevelop (alpha) + + + + + Xine + + + + + + + + Notable updates: + + + + GCC 3.4.3 + + + + + Glibc 2.3.4 + + + + + GTK 2.6 + + + + + + +
diff --git a/doc/reviewing-contributions.xml b/doc/reviewing-contributions.xml index 7b017f0a8cc4..b648691183b8 100644 --- a/doc/reviewing-contributions.xml +++ b/doc/reviewing-contributions.xml @@ -3,95 +3,148 @@ xmlns:xi="http://www.w3.org/2001/XInclude" version="5.0" xml:id="sec-reviewing-contributions"> - -Reviewing contributions - - - The following section is a draft and reviewing policy is still being - discussed. - - -The nixpkgs projects receives a fairly high number of contributions via - GitHub pull-requests. Reviewing and approving these is an important task and a - way to contribute to the project. - -The high change rate of nixpkgs make any pull request that is open for - long enough subject to conflicts that will require extra work from the - submitter or the merger. Reviewing pull requests in a timely manner and being + Reviewing contributions + + + The following section is a draft and reviewing policy is still being + discussed. + + + + The nixpkgs projects receives a fairly high number of contributions via + GitHub pull-requests. Reviewing and approving these is an important task and + a way to contribute to the project. + + + The high change rate of nixpkgs make any pull request that is open for long + enough subject to conflicts that will require extra work from the submitter + or the merger. Reviewing pull requests in a timely manner and being responsive to the comments is the key to avoid these. GitHub provides sort - filters that can be used to see the most - recently and the and the + least - recently updated pull-requests. - We highly encourage looking at - this list of ready to merge, unreviewed pull requests. - -When reviewing a pull request, please always be nice and polite. + recently updated pull-requests. We highly encourage looking at + + this list of ready to merge, unreviewed pull requests. + + + When reviewing a pull request, please always be nice and polite. Controversial changes can lead to controversial opinions, but it is important - to respect every community members and their work. - -GitHub provides reactions, they are a simple and quick way to provide + to respect every community members and their work. + + + GitHub provides reactions, they are a simple and quick way to provide feedback to pull-requests or any comments. The thumb-down reaction should be used with care and if possible accompanied with some explanations so the - submitter has directions to improve his contribution. - -Pull-requests reviews should include a list of what has been reviewed in a - comment, so other reviewers and mergers can know the state of the - review. - -All the review template samples provided in this section are generic and + submitter has directions to improve his contribution. + + + Pull-requests reviews should include a list of what has been reviewed in a + comment, so other reviewers and mergers can know the state of the review. + + + All the review template samples provided in this section are generic and meant as examples. Their usage is optional and the reviewer is free to adapt - them to his liking. + them to his liking. + +
+ Package updates -
Package updates + + A package update is the most trivial and common type of pull-request. These + pull-requests mainly consist in updating the version part of the package + name and the source hash. + -A package update is the most trivial and common type of pull-request. - These pull-requests mainly consist in updating the version part of the package - name and the source hash. -It can happen that non trivial updates include patches or more complex - changes. + + It can happen that non trivial updates include patches or more complex + changes. + -Reviewing process: + + Reviewing process: + - - Add labels to the pull-request. (Requires commit - rights) + + + + Add labels to the pull-request. (Requires commit rights) + - 8.has: package (update) and any topic - label that fit the updated package. + + + 8.has: package (update) and any topic label that fit + the updated package. + + - - Ensure that the package versioning is fitting the - guidelines. - Ensure that the commit text is fitting the - guidelines. - Ensure that the package maintainers are notified. + + + + Ensure that the package versioning is fitting the guidelines. + + + + + Ensure that the commit text is fitting the guidelines. + + + + + Ensure that the package maintainers are notified. + - mention-bot usually notify GitHub users based on the - submitted changes, but it can happen that it misses some of the - package maintainers. + + + mention-bot usually notify GitHub users based on the submitted changes, + but it can happen that it misses some of the package maintainers. + + - - Ensure that the meta field contains correct - information. + + + + Ensure that the meta field contains correct information. + - License can change with version updates, so it should be - checked to be fitting upstream license. - If the package has no maintainer, a maintainer must be - set. This can be the update submitter or a community member that - accepts to take maintainership of the package. + + + License can change with version updates, so it should be checked to be + fitting upstream license. + + + + + If the package has no maintainer, a maintainer must be set. This can be + the update submitter or a community member that accepts to take + maintainership of the package. + + - - Ensure that the code contains no typos. - Building the package locally. + + + + Ensure that the code contains no typos. + + + + + Building the package locally. + - Pull-requests are often targeted to the master or staging - branch so building the pull-request locally as it is submitted can - trigger a large amount of source builds. - It is possible to rebase the changes on nixos-unstable or - nixpkgs-unstable for easier review by running the following commands - from a nixpkgs clone. + + + Pull-requests are often targeted to the master or staging branch so + building the pull-request locally as it is submitted can trigger a large + amount of source builds. + + + It is possible to rebase the changes on nixos-unstable or + nixpkgs-unstable for easier review by running the following commands + from a nixpkgs clone. $ git remote add channels https://github.com/NixOS/nixpkgs-channels.git @@ -100,43 +153,56 @@ $ git fetch origin pull/PRNUMBER/head $ git rebase --onto nixos-unstable BASEBRANCH FETCH_HEAD - - - This should be done only once to be able to fetch channel - branches from the nixpkgs-channels repository. - - - Fetching the nixos-unstable branch. - - - Fetching the pull-request changes, PRNUMBER - is the number at the end of the pull-request title and - BASEBRANCH the base branch of the - pull-request. - - - Rebasing the pull-request changes to the nixos-unstable - branch. - - - - - - The nox - tool can be used to review a pull-request content in a single command. - It doesn't rebase on a channel branch so it might trigger multiple - source builds. PRNUMBER should be replaced by the - number at the end of the pull-request title. + + + + This should be done only once to be able to fetch channel branches + from the nixpkgs-channels repository. + + + + + Fetching the nixos-unstable branch. + + + + + Fetching the pull-request changes, PRNUMBER is the + number at the end of the pull-request title and + BASEBRANCH the base branch of the pull-request. + + + + + Rebasing the pull-request changes to the nixos-unstable branch. + + + + + + + + The nox tool can + be used to review a pull-request content in a single command. It doesn't + rebase on a channel branch so it might trigger multiple source builds. + PRNUMBER should be replaced by the number at the end + of the pull-request title. + $ nix-shell -p nox --run "nox-review -k pr PRNUMBER" - + - - Running every binary. - + + + + Running every binary. + + + -Sample template for a package update review + + Sample template for a package update review ##### Reviewed points @@ -150,55 +216,105 @@ $ nix-shell -p nox --run "nox-review -k pr PRNUMBER" ##### Comments - -
+ + +
+
+ New packages -
New packages + + New packages are a common type of pull-requests. These pull requests + consists in adding a new nix-expression for a package. + -New packages are a common type of pull-requests. These pull requests - consists in adding a new nix-expression for a package. + + Reviewing process: + -Reviewing process: - - - Add labels to the pull-request. (Requires commit - rights) + + + + Add labels to the pull-request. (Requires commit rights) + - 8.has: package (new) and any topic - label that fit the new package. + + + 8.has: package (new) and any topic label that fit the + new package. + + - - Ensure that the package versioning is fitting the - guidelines. - Ensure that the commit name is fitting the - guidelines. - Ensure that the meta field contains correct - information. + + + + Ensure that the package versioning is fitting the guidelines. + + + + + Ensure that the commit name is fitting the guidelines. + + + + + Ensure that the meta field contains correct information. + - License must be checked to be fitting upstream - license. - Platforms should be set or the package will not get binary - substitutes. - A maintainer must be set, this can be the package - submitter or a community member that accepts to take maintainership of - the package. + + + License must be checked to be fitting upstream license. + + + + + Platforms should be set or the package will not get binary substitutes. + + + + + A maintainer must be set, this can be the package submitter or a + community member that accepts to take maintainership of the package. + + - - Ensure that the code contains no typos. - Ensure the package source. + + + + Ensure that the code contains no typos. + + + + + Ensure the package source. + - Mirrors urls should be used when - available. - The most appropriate function should be used (e.g. - packages from GitHub should use - fetchFromGitHub). + + + Mirrors urls should be used when available. + + + + + The most appropriate function should be used (e.g. packages from GitHub + should use fetchFromGitHub). + + - - Building the package locally. - Running every binary. - + + + + Building the package locally. + + + + + Running every binary. + + + -Sample template for a new package review + + Sample template for a new package review ##### Reviewed points @@ -220,58 +336,107 @@ $ nix-shell -p nox --run "nox-review -k pr PRNUMBER" ##### Comments - -
+ + +
+
+ Module updates -
Module updates + + Module updates are submissions changing modules in some ways. These often + contains changes to the options or introduce new options. + -Module updates are submissions changing modules in some ways. These often - contains changes to the options or introduce new options. + + Reviewing process + -Reviewing process - - - Add labels to the pull-request. (Requires commit - rights) + + + + Add labels to the pull-request. (Requires commit rights) + - 8.has: module (update) and any topic - label that fit the module. + + + 8.has: module (update) and any topic label that fit + the module. + + - - Ensure that the module maintainers are notified. + + + + Ensure that the module maintainers are notified. + - Mention-bot notify GitHub users based on the submitted - changes, but it can happen that it miss some of the package - maintainers. + + + Mention-bot notify GitHub users based on the submitted changes, but it + can happen that it miss some of the package maintainers. + + - - Ensure that the module tests, if any, are - succeeding. - Ensure that the introduced options are correct. + + + + Ensure that the module tests, if any, are succeeding. + + + + + Ensure that the introduced options are correct. + - Type should be appropriate (string related types differs - in their merging capabilities, optionSet and - string types are deprecated). - Description, default and example should be - provided. + + + Type should be appropriate (string related types differs in their + merging capabilities, optionSet and + string types are deprecated). + + + + + Description, default and example should be provided. + + - - Ensure that option changes are backward compatible. + + + + Ensure that option changes are backward compatible. + - mkRenamedOptionModule and - mkAliasOptionModule functions provide way to make - option changes backward compatible. + + + mkRenamedOptionModule and + mkAliasOptionModule functions provide way to make + option changes backward compatible. + + - - Ensure that removed options are declared with - mkRemovedOptionModule - Ensure that changes that are not backward compatible are - mentioned in release notes. - Ensure that documentations affected by the change is - updated. - + + + + Ensure that removed options are declared with + mkRemovedOptionModule + + + + + Ensure that changes that are not backward compatible are mentioned in + release notes. + + + + + Ensure that documentations affected by the change is updated. + + + -Sample template for a module update review + + Sample template for a module update review ##### Reviewed points @@ -288,51 +453,89 @@ $ nix-shell -p nox --run "nox-review -k pr PRNUMBER" ##### Comments - -
+ + +
+
+ New modules -
New modules + + New modules submissions introduce a new module to NixOS. + -New modules submissions introduce a new module to NixOS. + + + + Add labels to the pull-request. (Requires commit rights) + + + + + 8.has: module (new) and any topic label that fit the + module. + + + + + + + Ensure that the module tests, if any, are succeeding. + + + + + Ensure that the introduced options are correct. + + + + + Type should be appropriate (string related types differs in their + merging capabilities, optionSet and + string types are deprecated). + + + + + Description, default and example should be provided. + + + + + + + Ensure that module meta field is present + + + + + Maintainers should be declared in meta.maintainers. + + + + + Module documentation should be declared with + meta.doc. + + + + + + + Ensure that the module respect other modules functionality. + + + + + For example, enabling a module should not open firewall ports by + default. + + + + + - - Add labels to the pull-request. (Requires commit - rights) - - 8.has: module (new) and any topic label - that fit the module. - - - Ensure that the module tests, if any, are - succeeding. - Ensure that the introduced options are correct. - - Type should be appropriate (string related types differs - in their merging capabilities, optionSet and - string types are deprecated). - Description, default and example should be - provided. - - - Ensure that module meta field is - present - - Maintainers should be declared in - meta.maintainers. - Module documentation should be declared with - meta.doc. - - - Ensure that the module respect other modules - functionality. - - For example, enabling a module should not open firewall - ports by default. - - - - -Sample template for a new module review + + Sample template for a new module review ##### Reviewed points @@ -350,32 +553,41 @@ $ nix-shell -p nox --run "nox-review -k pr PRNUMBER" ##### Comments - -
+ + +
+
+ Other submissions -
Other submissions + + Other type of submissions requires different reviewing steps. + -Other type of submissions requires different reviewing steps. + + If you consider having enough knowledge and experience in a topic and would + like to be a long-term reviewer for related submissions, please contact the + current reviewers for that topic. They will give you information about the + reviewing process. The main reviewers for a topic can be hard to find as + there is no list, but checking past pull-requests to see who reviewed or + git-blaming the code to see who committed to that topic can give some hints. + -If you consider having enough knowledge and experience in a topic and - would like to be a long-term reviewer for related submissions, please contact - the current reviewers for that topic. They will give you information about the - reviewing process. -The main reviewers for a topic can be hard to find as there is no list, but -checking past pull-requests to see who reviewed or git-blaming the code to see -who committed to that topic can give some hints. + + Container system, boot system and library changes are some examples of the + pull requests fitting this category. + +
+
+ Merging pull-requests -Container system, boot system and library changes are some examples of the - pull requests fitting this category. + + It is possible for community members that have enough knowledge and + experience on a special topic to contribute by merging pull requests. + -
- -
Merging pull-requests - -It is possible for community members that have enough knowledge and - experience on a special topic to contribute by merging pull requests. - -TODO: add the procedure to request merging rights. + + TODO: add the procedure to request merging rights. + -In a case a contributor leaves definitively the Nix community, he should - create an issue or notify the mailing list with references of packages and - modules he maintains so the maintainership can be taken over by other - contributors. - -
+ + In a case a contributor leaves definitively the Nix community, he should + create an issue or notify the mailing list with references of packages and + modules he maintains so the maintainership can be taken over by other + contributors. + +
diff --git a/doc/stdenv.xml b/doc/stdenv.xml index 2a3316b8d018..d5028c51cd51 100644 --- a/doc/stdenv.xml +++ b/doc/stdenv.xml @@ -1,27 +1,24 @@ + The Standard Environment + + The standard build environment in the Nix Packages collection provides an + environment for building Unix packages that does a lot of common build tasks + automatically. In fact, for Unix packages that use the standard + ./configure; make; make install build interface, you + don’t need to write a build script at all; the standard environment does + everything automatically. If stdenv doesn’t do what you + need automatically, you can easily customise or override the various build + phases. + +
+ Using <literal>stdenv</literal> -The Standard Environment - - -The standard build environment in the Nix Packages collection -provides an environment for building Unix packages that does a lot of -common build tasks automatically. In fact, for Unix packages that use -the standard ./configure; make; make install build -interface, you don’t need to write a build script at all; the standard -environment does everything automatically. If -stdenv doesn’t do what you need automatically, you -can easily customise or override the various build phases. - - -
Using -<literal>stdenv</literal> - -To build a package with the standard environment, you use the -function stdenv.mkDerivation, instead of the -primitive built-in function derivation, e.g. - + + To build a package with the standard environment, you use the function + stdenv.mkDerivation, instead of the primitive built-in + function derivation, e.g. stdenv.mkDerivation { name = "libfoo-1.2.3"; @@ -30,39 +27,35 @@ stdenv.mkDerivation { sha256 = "0x2g1jqygyr5wiwg4ma1nd7w4ydpy82z9gkcv8vh2v8dn3y58v5m"; }; } - -(stdenv needs to be in scope, so if you write this -in a separate Nix expression from -pkgs/all-packages.nix, you need to pass it as a -function argument.) Specifying a name and a -src is the absolute minimum you need to do. Many -packages have dependencies that are not provided in the standard -environment. It’s usually sufficient to specify those dependencies in -the buildInputs attribute: - + (stdenv needs to be in scope, so if you write this in a + separate Nix expression from pkgs/all-packages.nix, you + need to pass it as a function argument.) Specifying a + name and a src is the absolute minimum + you need to do. Many packages have dependencies that are not provided in the + standard environment. It’s usually sufficient to specify those + dependencies in the buildInputs attribute: stdenv.mkDerivation { name = "libfoo-1.2.3"; ... buildInputs = [libbar perl ncurses]; } + This attribute ensures that the bin subdirectories of + these packages appear in the PATH environment variable during + the build, that their include subdirectories are + searched by the C compiler, and so on. (See + for details.) + -This attribute ensures that the bin -subdirectories of these packages appear in the PATH -environment variable during the build, that their -include subdirectories are searched by the C -compiler, and so on. (See for -details.) - -Often it is necessary to override or modify some aspect of the -build. To make this easier, the standard environment breaks the -package build into a number of phases, all of -which can be overridden or modified individually: unpacking the -sources, applying patches, configuring, building, and installing. -(There are some others; see .) -For instance, a package that doesn’t supply a makefile but instead has -to be compiled “manually” could be handled like this: - + + Often it is necessary to override or modify some aspect of the build. To + make this easier, the standard environment breaks the package build into a + number of phases, all of which can be overridden or + modified individually: unpacking the sources, applying patches, configuring, + building, and installing. (There are some others; see + .) For instance, a package that doesn’t + supply a makefile but instead has to be compiled “manually” could be + handled like this: stdenv.mkDerivation { name = "fnord-4.5"; @@ -75,35 +68,33 @@ stdenv.mkDerivation { cp foo $out/bin ''; } + (Note the use of ''-style string literals, which are very + convenient for large multi-line script fragments because they don’t need + escaping of " and \, and because + indentation is intelligently removed.) + -(Note the use of ''-style string literals, which -are very convenient for large multi-line script fragments because they -don’t need escaping of " and \, -and because indentation is intelligently removed.) - -There are many other attributes to customise the build. These -are listed in . - -While the standard environment provides a generic builder, you -can still supply your own build script: + + There are many other attributes to customise the build. These are listed in + . + + + While the standard environment provides a generic builder, you can still + supply your own build script: stdenv.mkDerivation { name = "libfoo-1.2.3"; ... builder = ./builder.sh; } - -where the builder can do anything it wants, but typically starts with - + where the builder can do anything it wants, but typically starts with source $stdenv/setup - -to let stdenv set up the environment (e.g., process -the buildInputs). If you want, you can still use -stdenv’s generic builder: - + to let stdenv set up the environment (e.g., process the + buildInputs). If you want, you can still use + stdenv’s generic builder: source $stdenv/setup @@ -119,116 +110,186 @@ installPhase() { genericBuild + +
+
+ Tools provided by <literal>stdenv</literal> - + + The standard environment provides the following packages: + + + + The GNU C Compiler, configured with C and C++ support. + + + + + GNU coreutils (contains a few dozen standard Unix commands). + + + + + GNU findutils (contains find). + + + + + GNU diffutils (contains diff, cmp). + + + + + GNU sed. + + + + + GNU grep. + + + + + GNU awk. + + + + + GNU tar. + + + + + gzip, bzip2 and + xz. + + + + + GNU Make. It has been patched to provide nested output + that can be fed into the nix-log2xml command and + log2html stylesheet to create a structured, readable + output of the build steps performed by Make. + + + + + Bash. This is the shell used for all builders in the Nix Packages + collection. Not using /bin/sh removes a large source + of portability problems. + + + + + The patch command. + + + + -
+ + On Linux, stdenv also includes the + patchelf utility. + +
+
+ Specifying dependencies + + As described in the Nix manual, almost any *.drv store + path in a derivation's attribute set will induce a dependency on that + derivation. mkDerivation, however, takes a few attributes + intended to, between them, include all the dependencies of a package. This + is done both for structure and consistency, but also so that certain other + setup can take place. For example, certain dependencies need their bin + directories added to the PATH. That is built-in, but other + setup is done via a pluggable mechanism that works in conjunction with these + dependency attributes. See for details. + -
Tools provided by -<literal>stdenv</literal> + + Dependencies can be broken down along three axes: their host and target + platforms relative to the new derivation's, and whether they are propagated. + The platform distinctions are motivated by cross compilation; see + for exactly what each platform means. + + + The build platform is ignored because it is a mere implementation detail + of the package satisfying the dependency: As a general programming + principle, dependencies are always specified as + interfaces, not concrete implementation. + + + But even if one is not cross compiling, the platforms imply whether or not + the dependency is needed at run-time or build-time, a concept that makes + perfect sense outside of cross compilation. For now, the run-time/build-time + distinction is just a hint for mental clarity, but in the future it perhaps + could be enforced. + -The standard environment provides the following packages: + + The extension of PATH with dependencies, alluded to above, + proceeds according to the relative platforms alone. The process is carried + out only for dependencies whose host platform matches the new derivation's + build platform–i.e. which run on the platform where the new derivation + will be built. + + + Currently, that means for native builds all dependencies are put on the + PATH. But in the future that may not be the case for sake + of matching cross: the platforms would be assumed to be unique for native + and cross builds alike, so only the depsBuild* and + nativeBuildDependencies dependencies would affect the + PATH. + + + For each dependency dep of those dependencies, + dep/bin, if present, is + added to the PATH environment variable. + - + + The dependency is propagated when it forces some of its other-transitive + (non-immediate) downstream dependencies to also take it on as an immediate + dependency. Nix itself already takes a package's transitive dependencies + into account, but this propagation ensures nixpkgs-specific infrastructure + like setup hooks (mentioned above) also are run as if the propagated + dependency. + - The GNU C Compiler, configured with C and C++ - support. + + It is important to note dependencies are not necessary propagated as the + same sort of dependency that they were before, but rather as the + corresponding sort so that the platform rules still line up. The exact rules + for dependency propagation can be given by assigning each sort of dependency + two integers based one how it's host and target platforms are offset from + the depending derivation's platforms. Those offsets are given are given + below in the descriptions of each dependency list attribute. + Algorithmically, we traverse propagated inputs, accumulating every + propagated dep's propagated deps and adjusting them to account for the + "shift in perspective" described by the current dep's platform offsets. This + results in sort a transitive closure of the dependency relation, with the + offsets being approximately summed when two dependency links are combined. + We also prune transitive deps whose combined offsets go out-of-bounds, which + can be viewed as a filter over that transitive closure removing dependencies + that are blatantly absurd. + - GNU coreutils (contains a few dozen standard Unix - commands). - - GNU findutils (contains - find). - - GNU diffutils (contains diff, - cmp). - - GNU sed. - - GNU grep. - - GNU awk. - - GNU tar. - - gzip, bzip2 - and xz. - - GNU Make. It has been patched to provide - nested output that can be fed into the - nix-log2xml command and - log2html stylesheet to create a structured, - readable output of the build steps performed by - Make. - - Bash. This is the shell used for all builders in - the Nix Packages collection. Not using /bin/sh - removes a large source of portability problems. - - The patch - command. - - - - - -On Linux, stdenv also includes the -patchelf utility. - -
- - -
Specifying dependencies - - - As described in the Nix manual, almost any *.drv store path in a derivation's attribute set will induce a dependency on that derivation. - mkDerivation, however, takes a few attributes intended to, between them, include all the dependencies of a package. - This is done both for structure and consistency, but also so that certain other setup can take place. - For example, certain dependencies need their bin directories added to the PATH. - That is built-in, but other setup is done via a pluggable mechanism that works in conjunction with these dependency attributes. - See for details. - - - Dependencies can be broken down along three axes: their host and target platforms relative to the new derivation's, and whether they are propagated. - The platform distinctions are motivated by cross compilation; see for exactly what each platform means. - - The build platform is ignored because it is a mere implementation detail of the package satisfying the dependency: - As a general programming principle, dependencies are always specified as interfaces, not concrete implementation. - - But even if one is not cross compiling, the platforms imply whether or not the dependency is needed at run-time or build-time, a concept that makes perfect sense outside of cross compilation. - For now, the run-time/build-time distinction is just a hint for mental clarity, but in the future it perhaps could be enforced. - - - The extension of PATH with dependencies, alluded to above, proceeds according to the relative platforms alone. - The process is carried out only for dependencies whose host platform matches the new derivation's build platform–i.e. which run on the platform where the new derivation will be built. - - Currently, that means for native builds all dependencies are put on the PATH. - But in the future that may not be the case for sake of matching cross: - the platforms would be assumed to be unique for native and cross builds alike, so only the depsBuild* and nativeBuildDependencies dependencies would affect the PATH. - - For each dependency dep of those dependencies, dep/bin, if present, is added to the PATH environment variable. - - - The dependency is propagated when it forces some of its other-transitive (non-immediate) downstream dependencies to also take it on as an immediate dependency. - Nix itself already takes a package's transitive dependencies into account, but this propagation ensures nixpkgs-specific infrastructure like setup hooks (mentioned above) also are run as if the propagated dependency. - - - It is important to note dependencies are not necessary propagated as the same sort of dependency that they were before, but rather as the corresponding sort so that the platform rules still line up. - The exact rules for dependency propagation can be given by assigning each sort of dependency two integers based one how it's host and target platforms are offset from the depending derivation's platforms. - Those offsets are given are given below in the descriptions of each dependency list attribute. - Algorithmically, we traverse propagated inputs, accumulating every propagated dep's propagated deps and adjusting them to account for the "shift in perspective" described by the current dep's platform offsets. - This results in sort a transitive closure of the dependency relation, with the offsets being approximately summed when two dependency links are combined. - We also prune transitive deps whose combined offsets go out-of-bounds, which can be viewed as a filter over that transitive closure removing dependencies that are blatantly absurd. - - - We can define the process precisely with Natural Deduction using the inference rules. - This probably seems a bit obtuse, but so is the bash code that actually implements it! - - The findInputs function, currently residing in pkgs/stdenv/generic/setup.sh, implements the propagation logic. - - They're confusing in very different ways so...hopefully if something doesn't make sense in one presentation, it does in the other! - + + We can define the process precisely with + Natural + Deduction using the inference rules. This probably seems a bit + obtuse, but so is the bash code that actually implements it! + + + The findInputs function, currently residing in + pkgs/stdenv/generic/setup.sh, implements the + propagation logic. + + + They're confusing in very different ways so...hopefully if something doesn't + make sense in one presentation, it does in the other! + let mapOffset(h, t, i) = i + (if i <= 0 then h else t - 1) propagated-dep(h0, t0, A, B) @@ -239,7 +300,7 @@ h0 + t1 in {-1, 0, 1} propagated-dep(mapOffset(h0, t0, h1), mapOffset(h0, t0, t1), A, C) - + let mapOffset(h, t, i) = i + (if i <= 0 then h else t - 1) dep(h0, _, A, B) @@ -250,255 +311,343 @@ h0 + t1 in {-1, 0, -1} propagated-dep(mapOffset(h0, t0, h1), mapOffset(h0, t0, t1), A, C) - + propagated-dep(h, t, A, B) -------------------------------------- Propagated deps count as deps dep(h, t, A, B) - Some explanation of this monstrosity is in order. - In the common case, the target offset of a dependency is the successor to the target offset: t = h + 1. - That means that: - + Some explanation of this monstrosity is in order. In the common case, the + target offset of a dependency is the successor to the target offset: + t = h + 1. That means that: + let f(h, t, i) = i + (if i <= 0 then h else t - 1) let f(h, h + 1, i) = i + (if i <= 0 then h else (h + 1) - 1) let f(h, h + 1, i) = i + (if i <= 0 then h else h) let f(h, h + 1, i) = i + h - This is where the "sum-like" comes from above: - We can just sum all the host offset to get the host offset of the transitive dependency. - The target offset is the transitive dep is simply the host offset + 1, just as it was with the dependencies composed to make this transitive one; - it can be ignored as it doesn't add any new information. - - - Because of the bounds checks, the uncommon cases are h = t and h + 2 = t. - In the former case, the motivation for mapOffset is that since its host and target platforms are the same, no transitive dep of it should be able to "discover" an offset greater than its reduced target offsets. - mapOffset effectively "squashes" all its transitive dependencies' offsets so that none will ever be greater than the target offset of the original h = t package. - In the other case, h + 1 is skipped over between the host and target offsets. - Instead of squashing the offsets, we need to "rip" them apart so no transitive dependencies' offset is that one. - - -Overall, the unifying theme here is that propagation shouldn't be introducing transitive dependencies involving platforms the needing package is unaware of. -The offset bounds checking and definition of mapOffset together ensure that this is the case. -Discovering a new offset is discovering a new platform, and since those platforms weren't in the derivation "spec" of the needing package, they cannot be relevant. -From a capability perspective, we can imagine that the host and target platforms of a package are the capabilities a package requires, and the depending package must provide the capability to the dependency. - + This is where the "sum-like" comes from above: We can just sum all the host + offset to get the host offset of the transitive dependency. The target + offset is the transitive dep is simply the host offset + 1, just as it was + with the dependencies composed to make this transitive one; it can be + ignored as it doesn't add any new information. + - - Variables specifying dependencies + + Because of the bounds checks, the uncommon cases are h = + t and h + 2 = t. In the former case, the + motivation for mapOffset is that since its host and + target platforms are the same, no transitive dep of it should be able to + "discover" an offset greater than its reduced target offsets. + mapOffset effectively "squashes" all its transitive + dependencies' offsets so that none will ever be greater than the target + offset of the original h = t package. In the other case, + h + 1 is skipped over between the host and target + offsets. Instead of squashing the offsets, we need to "rip" them apart so no + transitive dependencies' offset is that one. + + + Overall, the unifying theme here is that propagation shouldn't be + introducing transitive dependencies involving platforms the needing package + is unaware of. The offset bounds checking and definition of + mapOffset together ensure that this is the case. + Discovering a new offset is discovering a new platform, and since those + platforms weren't in the derivation "spec" of the needing package, they + cannot be relevant. From a capability perspective, we can imagine that the + host and target platforms of a package are the capabilities a package + requires, and the depending package must provide the capability to the + dependency. + + + + Variables specifying dependencies - depsBuildBuild - - - A list of dependencies whose host and target platforms are the new derivation's build platform. - This means a -1 host and -1 target offset from the new derivation's platforms. - They are programs/libraries used at build time that furthermore produce programs/libraries also used at build time. - If the dependency doesn't care about the target platform (i.e. isn't a compiler or similar tool), put it in nativeBuildInputsinstead. - The most common use for this buildPackages.stdenv.cc, the default C compiler for this role. - That example crops up more than one might think in old commonly used C libraries. - - - Since these packages are able to be run at build time, that are always added to the PATH, as described above. - But since these packages are only guaranteed to be able to run then, they shouldn't persist as run-time dependencies. - This isn't currently enforced, but could be in the future. - - - - - - nativeBuildInputs + depsBuildBuild + - - A list of dependencies whose host platform is the new derivation's build platform, and target platform is the new derivation's host platform. - This means a -1 host offset and 0 target offset from the new derivation's platforms. - They are programs/libraries used at build time that, if they are a compiler or similar tool, produce code to run at run time—i.e. tools used to build the new derivation. - If the dependency doesn't care about the target platform (i.e. isn't a compiler or similar tool), put it here, rather than in depsBuildBuild or depsBuildTarget. - This would be called depsBuildHost but for historical continuity. - - - Since these packages are able to be run at build time, that are added to the PATH, as described above. - But since these packages only are guaranteed to be able to run then, they shouldn't persist as run-time dependencies. - This isn't currently enforced, but could be in the future. - - - - - - depsBuildTarget - - - A list of dependencies whose host platform is the new derivation's build platform, and target platform is the new derivation's target platform. - This means a -1 host offset and 1 target offset from the new derivation's platforms. - They are programs used at build time that produce code to run at run with code produced by the depending package. - Most commonly, these would tools used to build the runtime or standard library the currently-being-built compiler will inject into any code it compiles. - In many cases, the currently-being built compiler is itself employed for that task, but when that compiler won't run (i.e. its build and host platform differ) this is not possible. - Other times, the compiler relies on some other tool, like binutils, that is always built separately so the dependency is unconditional. - - - This is a somewhat confusing dependency to wrap ones head around, and for good reason. - As the only one where the platform offsets are not adjacent integers, it requires thinking of a bootstrapping stage two away from the current one. - It and it's use-case go hand in hand and are both considered poor form: - try not to need this sort dependency, and try not avoid building standard libraries / runtimes in the same derivation as the compiler produces code using them. - Instead strive to build those like a normal library, using the newly-built compiler just as a normal library would. - In short, do not use this attribute unless you are packaging a compiler and are sure it is needed. + + A list of dependencies whose host and target platforms are the new + derivation's build platform. This means a -1 host and + -1 target offset from the new derivation's platforms. + They are programs/libraries used at build time that furthermore produce + programs/libraries also used at build time. If the dependency doesn't + care about the target platform (i.e. isn't a compiler or similar tool), + put it in nativeBuildInputsinstead. The most common + use for this buildPackages.stdenv.cc, the default C + compiler for this role. That example crops up more than one might think + in old commonly used C libraries. - Since these packages are able to be run at build time, that are added to the PATH, as described above. - But since these packages only are guaranteed to be able to run then, they shouldn't persist as run-time dependencies. - This isn't currently enforced, but could be in the future. + Since these packages are able to be run at build time, that are always + added to the PATH, as described above. But since these + packages are only guaranteed to be able to run then, they shouldn't + persist as run-time dependencies. This isn't currently enforced, but + could be in the future. - - - - depsHostHost - - A list of dependencies whose host and target platforms match the new derivation's host platform. - This means a both 0 host offset and 0 target offset from the new derivation's host platform. - These are packages used at run-time to generate code also used at run-time. - In practice, that would usually be tools used by compilers for metaprogramming/macro systems, or libraries used by the macros/metaprogramming code itself. - It's always preferable to use a depsBuildBuild dependency in the derivation being built than a depsHostHost on the tool doing the building for this purpose. - - - - - buildInputs + + + nativeBuildInputs + - - A list of dependencies whose host platform and target platform match the new derivation's. - This means a 0 host offset and 1 target offset from the new derivation's host platform. - This would be called depsHostTarget but for historical continuity. - If the dependency doesn't care about the target platform (i.e. isn't a compiler or similar tool), put it here, rather than in depsBuildBuild. - - - These often are programs/libraries used by the new derivation at run-time, but that isn't always the case. - For example, the machine code in a statically linked library is only used at run time, but the derivation containing the library is only needed at build time. - Even in the dynamic case, the library may also be needed at build time to appease the linker. - + + A list of dependencies whose host platform is the new derivation's build + platform, and target platform is the new derivation's host platform. This + means a -1 host offset and 0 target + offset from the new derivation's platforms. They are programs/libraries + used at build time that, if they are a compiler or similar tool, produce + code to run at run time—i.e. tools used to build the new derivation. If + the dependency doesn't care about the target platform (i.e. isn't a + compiler or similar tool), put it here, rather than in + depsBuildBuild or depsBuildTarget. + This would be called depsBuildHost but for historical + continuity. + + + Since these packages are able to be run at build time, that are added to + the PATH, as described above. But since these packages + only are guaranteed to be able to run then, they shouldn't persist as + run-time dependencies. This isn't currently enforced, but could be in the + future. + - - - - depsTargetTarget - - A list of dependencies whose host platform matches the new derivation's target platform. - This means a 1 offset from the new derivation's platforms. - These are packages that run on the target platform, e.g. the standard library or run-time deps of standard library that a compiler insists on knowing about. - It's poor form in almost all cases for a package to depend on another from a future stage [future stage corresponding to positive offset]. - Do not use this attribute unless you are packaging a compiler and are sure it is needed. - - - - - depsBuildBuildPropagated - - The propagated equivalent of depsBuildBuild. - This perhaps never ought to be used, but it is included for consistency [see below for the others]. - - - - - propagatedNativeBuildInputs - - The propagated equivalent of nativeBuildInputs. - This would be called depsBuildHostPropagated but for historical continuity. - For example, if package Y has propagatedNativeBuildInputs = [X], and package Z has buildInputs = [Y], then package Z will be built as if it included package X in its nativeBuildInputs. - If instead, package Z has nativeBuildInputs = [Y], then Z will be built as if it included X in the depsBuildBuild of package Z, because of the sum of the two -1 host offsets. - - - - - depsBuildTargetPropagated - - The propagated equivalent of depsBuildTarget. - This is prefixed for the same reason of alerting potential users. - - - - - depsHostHostPropagated - - The propagated equivalent of depsHostHost. - - - - - propagatedBuildInputs - - The propagated equivalent of buildInputs. - This would be called depsHostTargetPropagated but for historical continuity. - - - - - depsTargetTarget - - The propagated equivalent of depsTargetTarget. - This is prefixed for the same reason of alerting potential users. - - - - - -
- - -
Attributes - - - Variables affecting <literal>stdenv</literal> - initialisation - - - NIX_DEBUG - - A natural number indicating how much information to log. - If set to 1 or higher, stdenv will print moderate debug information during the build. - In particular, the gcc and ld wrapper scripts will print out the complete command line passed to the wrapped tools. - If set to 6 or higher, the stdenv setup script will be run with set -x tracing. - If set to 7 or higher, the gcc and ld wrapper scripts will also be run with set -x tracing. - - - - - - - Variables affecting build properties - - - enableParallelBuilding + + + depsBuildTarget + - If set to true, stdenv will - pass specific flags to make and other build tools to - enable parallel building with up to build-cores - workers. + + A list of dependencies whose host platform is the new derivation's build + platform, and target platform is the new derivation's target platform. + This means a -1 host offset and 1 + target offset from the new derivation's platforms. They are programs used + at build time that produce code to run at run with code produced by the + depending package. Most commonly, these would tools used to build the + runtime or standard library the currently-being-built compiler will + inject into any code it compiles. In many cases, the currently-being + built compiler is itself employed for that task, but when that compiler + won't run (i.e. its build and host platform differ) this is not possible. + Other times, the compiler relies on some other tool, like binutils, that + is always built separately so the dependency is unconditional. + + + This is a somewhat confusing dependency to wrap ones head around, and for + good reason. As the only one where the platform offsets are not adjacent + integers, it requires thinking of a bootstrapping stage + two away from the current one. It and it's use-case + go hand in hand and are both considered poor form: try not to need this + sort dependency, and try not avoid building standard libraries / runtimes + in the same derivation as the compiler produces code using them. Instead + strive to build those like a normal library, using the newly-built + compiler just as a normal library would. In short, do not use this + attribute unless you are packaging a compiler and are sure it is needed. + + + Since these packages are able to be run at build time, that are added to + the PATH, as described above. But since these packages + only are guaranteed to be able to run then, they shouldn't persist as + run-time dependencies. This isn't currently enforced, but could be in the + future. + + + + + depsHostHost + + + + A list of dependencies whose host and target platforms match the new + derivation's host platform. This means a both 0 host + offset and 0 target offset from the new derivation's + host platform. These are packages used at run-time to generate code also + used at run-time. In practice, that would usually be tools used by + compilers for metaprogramming/macro systems, or libraries used by the + macros/metaprogramming code itself. It's always preferable to use a + depsBuildBuild dependency in the derivation being + built than a depsHostHost on the tool doing the + building for this purpose. + + + + + buildInputs + + + + A list of dependencies whose host platform and target platform match the + new derivation's. This means a 0 host offset and + 1 target offset from the new derivation's host + platform. This would be called depsHostTarget but for + historical continuity. If the dependency doesn't care about the target + platform (i.e. isn't a compiler or similar tool), put it here, rather + than in depsBuildBuild. + + + These often are programs/libraries used by the new derivation at + run-time, but that isn't always the case. For + example, the machine code in a statically linked library is only used at + run time, but the derivation containing the library is only needed at + build time. Even in the dynamic case, the library may also be needed at + build time to appease the linker. + + + + + depsTargetTarget + + + + A list of dependencies whose host platform matches the new derivation's + target platform. This means a 1 offset from the new + derivation's platforms. These are packages that run on the target + platform, e.g. the standard library or run-time deps of standard library + that a compiler insists on knowing about. It's poor form in almost all + cases for a package to depend on another from a future stage [future + stage corresponding to positive offset]. Do not use this attribute unless + you are packaging a compiler and are sure it is needed. + + + + + depsBuildBuildPropagated + + + + The propagated equivalent of depsBuildBuild. This + perhaps never ought to be used, but it is included for consistency [see + below for the others]. + + + + + propagatedNativeBuildInputs + + + + The propagated equivalent of nativeBuildInputs. This + would be called depsBuildHostPropagated but for + historical continuity. For example, if package Y has + propagatedNativeBuildInputs = [X], and package + Z has buildInputs = [Y], then + package Z will be built as if it included package + X in its nativeBuildInputs. If + instead, package Z has nativeBuildInputs = + [Y], then Z will be built as if it included + X in the depsBuildBuild of package + Z, because of the sum of the two -1 + host offsets. + + + + + depsBuildTargetPropagated + + + + The propagated equivalent of depsBuildTarget. This is + prefixed for the same reason of alerting potential users. + + + + + depsHostHostPropagated + + + + The propagated equivalent of depsHostHost. + + + + + propagatedBuildInputs + + + + The propagated equivalent of buildInputs. This would + be called depsHostTargetPropagated but for historical + continuity. + + + + + depsTargetTarget + + + + The propagated equivalent of depsTargetTarget. This is + prefixed for the same reason of alerting potential users. + + + + +
+
+ Attributes - Unless set to false, some build systems with good + + Variables affecting <literal>stdenv</literal> initialisation + + NIX_DEBUG + + + + A natural number indicating how much information to log. If set to 1 or + higher, stdenv will print moderate debug information + during the build. In particular, the gcc and + ld wrapper scripts will print out the complete command + line passed to the wrapped tools. If set to 6 or higher, the + stdenv setup script will be run with set + -x tracing. If set to 7 or higher, the gcc + and ld wrapper scripts will also be run with + set -x tracing. + + + + + + + Variables affecting build properties + + enableParallelBuilding + + + + If set to true, stdenv will pass + specific flags to make and other build tools to enable + parallel building with up to build-cores workers. + + + Unless set to false, some build systems with good support for parallel building including cmake, meson, and qmake will set it to - true. + true. + - - - - preferLocalBuild - If set, specifies that the package is so lightweight - in terms of build operations (e.g. write a text file from a Nix string - to the store) that there's no need to look for it in binary caches -- - it's faster to just build it locally. It also tells Hydra and other - facilities that this package doesn't need to be exported in binary - caches (noone would use it, after all). - - - - - - Special variables - - - passthru - This is an attribute set which can be filled with arbitrary - values. For example: + + + preferLocalBuild + + + + If set, specifies that the package is so lightweight in terms of build + operations (e.g. write a text file from a Nix string to the store) that + there's no need to look for it in binary caches -- it's faster to just + build it locally. It also tells Hydra and other facilities that this + package doesn't need to be exported in binary caches (noone would use it, + after all). + + + + + + Special variables + + passthru + + + + This is an attribute set which can be filled with arbitrary values. For + example: passthru = { foo = "bar"; @@ -508,881 +657,1104 @@ passthru = { }; } + + + Values inside it are not passed to the builder, so you can change them + without triggering a rebuild. However, they can be accessed outside of a + derivation directly, as if they were set inside a derivation itself, e.g. + hello.baz.value1. We don't specify any usage or schema + of passthru - it is meant for values that would be + useful outside the derivation in other parts of a Nix expression (e.g. in + other derivations). An example would be to convey some specific + dependency of your derivation which contains a program with plugins + support. Later, others who make derivations with plugins can use + passed-through dependency to ensure that their plugin would be + binary-compatible with built program. + + + + +
+
+ Phases - + + The generic builder has a number of phases. Package + builds are split into phases to make it easier to override specific parts of + the build (e.g., unpacking the sources or installing the binaries). + Furthermore, it allows a nicer presentation of build logs in the Nix build + farm. + - Values inside it are not passed to the builder, so you can change - them without triggering a rebuild. However, they can be accessed outside of a - derivation directly, as if they were set inside a derivation itself, e.g. - hello.baz.value1. We don't specify any usage or - schema of passthru - it is meant for values that would be - useful outside the derivation in other parts of a Nix expression (e.g. in other - derivations). An example would be to convey some specific dependency of your - derivation which contains a program with plugins support. Later, others who - make derivations with plugins can use passed-through dependency to ensure that - their plugin would be binary-compatible with built program. - + + Each phase can be overridden in its entirety either by setting the + environment variable namePhase + to a string containing some shell commands to be executed, or by redefining + the shell function namePhase. + The former is convenient to override a phase from the derivation, while the + latter is convenient from a build script. However, typically one only wants + to add some commands to a phase, e.g. by defining + postInstall or preFixup, as skipping + some of the default actions may have unexpected consequences. + - +
+ Controlling phases -
+ + There are a number of variables that control what phases are executed and + in what order: + + Variables affecting phase control + + phases + + + + Specifies the phases. You can change the order in which phases are + executed, or add new phases, by setting this variable. If it’s not + set, the default value is used, which is $prePhases + unpackPhase patchPhase $preConfigurePhases configurePhase + $preBuildPhases buildPhase checkPhase $preInstallPhases installPhase + fixupPhase $preDistPhases distPhase $postPhases. + + + Usually, if you just want to add a few phases, it’s more convenient + to set one of the variables below (such as + preInstallPhases), as you then don’t specify all + the normal phases. + + + + + prePhases + + + + Additional phases executed before any of the default phases. + + + + + preConfigurePhases + + + + Additional phases executed just before the configure phase. + + + + + preBuildPhases + + + + Additional phases executed just before the build phase. + + + + + preInstallPhases + + + + Additional phases executed just before the install phase. + + + + + preFixupPhases + + + + Additional phases executed just before the fixup phase. + + + + + preDistPhases + + + + Additional phases executed just before the distribution phase. + + + + + postPhases + + + + Additional phases executed after any of the default phases. + + + + + +
+
+ The unpack phase -
Phases + + The unpack phase is responsible for unpacking the source code of the + package. The default implementation of unpackPhase + unpacks the source files listed in the src environment + variable to the current directory. It supports the following files by + default: + + + Tar files + + + These can optionally be compressed using gzip + (.tar.gz, .tgz or + .tar.Z), bzip2 + (.tar.bz2 or .tbz2) or + xz (.tar.xz or + .tar.lzma). + + + + + Zip files + + + Zip files are unpacked using unzip. However, + unzip is not in the standard environment, so you + should add it to buildInputs yourself. + + + + + Directories in the Nix store + + + These are simply copied to the current directory. The hash part of the + file name is stripped, e.g. + /nix/store/1wydxgby13cz...-my-sources would be + copied to my-sources. + + + + + Additional file types can be supported by setting the + unpackCmd variable (see below). + -The generic builder has a number of phases. -Package builds are split into phases to make it easier to override -specific parts of the build (e.g., unpacking the sources or installing -the binaries). Furthermore, it allows a nicer presentation of build -logs in the Nix build farm. + -Each phase can be overridden in its entirety either by setting -the environment variable -namePhase to a string -containing some shell commands to be executed, or by redefining the -shell function -namePhase. The former -is convenient to override a phase from the derivation, while the -latter is convenient from a build script. - -However, typically one only wants to add some -commands to a phase, e.g. by defining postInstall -or preFixup, as skipping some of the default actions -may have unexpected consequences. - - - -
Controlling -phases - -There are a number of variables that control what phases are -executed and in what order: - - - Variables affecting phase control - - - phases - - Specifies the phases. You can change the order in which - phases are executed, or add new phases, by setting this - variable. If it’s not set, the default value is used, which is - $prePhases unpackPhase patchPhase $preConfigurePhases - configurePhase $preBuildPhases buildPhase checkPhase - $preInstallPhases installPhase fixupPhase $preDistPhases - distPhase $postPhases. + + Variables controlling the unpack phase + + srcs / src + + + + The list of source files or directories to be unpacked or copied. One of + these must be set. - - Usually, if you just want to add a few phases, it’s more - convenient to set one of the variables below (such as - preInstallPhases), as you then don’t specify - all the normal phases. - - - - - prePhases - - Additional phases executed before any of the default phases. - - - - - preConfigurePhases - - Additional phases executed just before the configure phase. - - - - - preBuildPhases - - Additional phases executed just before the build phase. - - - - - preInstallPhases - - Additional phases executed just before the install phase. - - - - - preFixupPhases - - Additional phases executed just before the fixup phase. - - - - - preDistPhases - - Additional phases executed just before the distribution phase. - - - - - postPhases - - Additional phases executed after any of the default - phases. - - - - - - - -
- - -
The unpack phase - -The unpack phase is responsible for unpacking the source code of -the package. The default implementation of -unpackPhase unpacks the source files listed in -the src environment variable to the current directory. -It supports the following files by default: - - - - - Tar files - These can optionally be compressed using - gzip (.tar.gz, - .tgz or .tar.Z), - bzip2 (.tar.bz2 or - .tbz2) or xz - (.tar.xz or - .tar.lzma). - - - - Zip files - Zip files are unpacked using - unzip. However, unzip is - not in the standard environment, so you should add it to - buildInputs yourself. - - - - Directories in the Nix store - These are simply copied to the current directory. - The hash part of the file name is stripped, - e.g. /nix/store/1wydxgby13cz...-my-sources - would be copied to - my-sources. - - - - -Additional file types can be supported by setting the -unpackCmd variable (see below). - - - - - Variables controlling the unpack phase - - - srcs / src - The list of source files or directories to be - unpacked or copied. One of these must be set. - - - - sourceRoot - After running unpackPhase, - the generic builder changes the current directory to the directory - created by unpacking the sources. If there are multiple source - directories, you should set sourceRoot to the - name of the intended directory. - - - - setSourceRoot - Alternatively to setting - sourceRoot, you can set - setSourceRoot to a shell command to be - evaluated by the unpack phase after the sources have been - unpacked. This command must set - sourceRoot. - - - - preUnpack - Hook executed at the start of the unpack - phase. - - - - postUnpack - Hook executed at the end of the unpack - phase. - - - - dontMakeSourcesWritable - If set to 1, the unpacked - sources are not made - writable. By default, they are made writable to prevent problems - with read-only sources. For example, copied store directories - would be read-only without this. - - - - unpackCmd - The unpack phase evaluates the string - $unpackCmd for any unrecognised file. The path - to the current source file is contained in the - curSrc variable. - - - - -
- - -
The patch phase - -The patch phase applies the list of patches defined in the -patches variable. - - - Variables controlling the patch phase - - - patches - The list of patches. They must be in the format - accepted by the patch command, and may - optionally be compressed using gzip - (.gz), bzip2 - (.bz2) or xz - (.xz). - - - - patchFlags - Flags to be passed to patch. - If not set, the argument is used, which - causes the leading directory component to be stripped from the - file names in each patch. - - - - prePatch - Hook executed at the start of the patch - phase. - - - - postPatch - Hook executed at the end of the patch - phase. - - - - -
- - -
The configure phase - -The configure phase prepares the source tree for building. The -default configurePhase runs -./configure (typically an Autoconf-generated -script) if it exists. - - - Variables controlling the configure phase - - - configureScript - The name of the configure script. It defaults to - ./configure if it exists; otherwise, the - configure phase is skipped. This can actually be a command (like - perl ./Configure.pl). - - - - configureFlags - A list of strings passed as additional arguments to the - configure script. - - - - configureFlagsArray - A shell array containing additional arguments - passed to the configure script. You must use this instead of - configureFlags if the arguments contain - spaces. - - - - dontAddPrefix - By default, the flag - --prefix=$prefix is added to the configure - flags. If this is undesirable, set this variable to - true. - - - - prefix - The prefix under which the package must be - installed, passed via the option to the - configure script. It defaults to - . - - - - dontAddDisableDepTrack - By default, the flag - --disable-dependency-tracking is added to the - configure flags to speed up Automake-based builds. If this is - undesirable, set this variable to true. - - - - dontFixLibtool - By default, the configure phase applies some - special hackery to all files called ltmain.sh - before running the configure script in order to improve the purity - of Libtool-based packagesIt clears the - sys_lib_*search_path - variables in the Libtool script to prevent Libtool from using - libraries in /usr/lib and - such.. If this is undesirable, set this - variable to true. - - - - dontDisableStatic - By default, when the configure script has - , the option - is added to the configure flags. - If this is undesirable, set this variable to - true. - - - - configurePlatforms - - By default, when cross compiling, the configure script has and passed. - Packages can instead pass [ "build" "host" "target" ] or a subset to control exactly which platform flags are passed. - Compilers and other tools should use this to also pass the target platform, for example. - Eventually these will be passed when in native builds too, to improve determinism: build-time guessing, as is done today, is a risk of impurity. - - - - - preConfigure - Hook executed at the start of the configure - phase. - - - - postConfigure - Hook executed at the end of the configure - phase. - - - - - -
- - -
The build phase - -The build phase is responsible for actually building the package -(e.g. compiling it). The default buildPhase -simply calls make if a file named -Makefile, makefile or -GNUmakefile exists in the current directory (or -the makefile is explicitly set); otherwise it does -nothing. - - - Variables controlling the build phase - - - dontBuild - Set to true to skip the build phase. - - - - makefile - The file name of the Makefile. - - - - makeFlags - A list of strings passed as additional flags to - make. These flags are also used by the default - install and check phase. For setting make flags specific to the - build phase, use buildFlags (see below). - + + + + sourceRoot + + + + After running unpackPhase, the generic builder + changes the current directory to the directory created by unpacking the + sources. If there are multiple source directories, you should set + sourceRoot to the name of the intended directory. + + + + + setSourceRoot + + + + Alternatively to setting sourceRoot, you can set + setSourceRoot to a shell command to be evaluated by + the unpack phase after the sources have been unpacked. This command must + set sourceRoot. + + + + + preUnpack + + + + Hook executed at the start of the unpack phase. + + + + + postUnpack + + + + Hook executed at the end of the unpack phase. + + + + + dontMakeSourcesWritable + + + + If set to 1, the unpacked sources are + not made writable. By default, they are made + writable to prevent problems with read-only sources. For example, copied + store directories would be read-only without this. + + + + + unpackCmd + + + + The unpack phase evaluates the string $unpackCmd for + any unrecognised file. The path to the current source file is contained + in the curSrc variable. + + + + +
+ +
+ The patch phase + + + The patch phase applies the list of patches defined in the + patches variable. + + + + Variables controlling the patch phase + + patches + + + + The list of patches. They must be in the format accepted by the + patch command, and may optionally be compressed using + gzip (.gz), + bzip2 (.bz2) or + xz (.xz). + + + + + patchFlags + + + + Flags to be passed to patch. If not set, the argument + is used, which causes the leading directory + component to be stripped from the file names in each patch. + + + + + prePatch + + + + Hook executed at the start of the patch phase. + + + + + postPatch + + + + Hook executed at the end of the patch phase. + + + + +
+ +
+ The configure phase + + + The configure phase prepares the source tree for building. The default + configurePhase runs ./configure + (typically an Autoconf-generated script) if it exists. + + + + Variables controlling the configure phase + + configureScript + + + + The name of the configure script. It defaults to + ./configure if it exists; otherwise, the configure + phase is skipped. This can actually be a command (like perl + ./Configure.pl). + + + + + configureFlags + + + + A list of strings passed as additional arguments to the configure + script. + + + + + configureFlagsArray + + + + A shell array containing additional arguments passed to the configure + script. You must use this instead of configureFlags + if the arguments contain spaces. + + + + + dontAddPrefix + + + + By default, the flag --prefix=$prefix is added to the + configure flags. If this is undesirable, set this variable to true. + + + + + prefix + + + + The prefix under which the package must be installed, passed via the + option to the configure script. It defaults to + . + + + + + dontAddDisableDepTrack + + + + By default, the flag --disable-dependency-tracking is + added to the configure flags to speed up Automake-based builds. If this + is undesirable, set this variable to true. + + + + + dontFixLibtool + + + + By default, the configure phase applies some special hackery to all + files called ltmain.sh before running the configure + script in order to improve the purity of Libtool-based packages + + + It clears the + sys_lib_*search_path + variables in the Libtool script to prevent Libtool from using + libraries in /usr/lib and such. + + + . If this is undesirable, set this variable to true. + + + + + dontDisableStatic + + + + By default, when the configure script has + , the option + is added to the configure flags. + + + If this is undesirable, set this variable to true. + + + + + configurePlatforms + + + + By default, when cross compiling, the configure script has + and passed. + Packages can instead pass [ "build" "host" "target" ] + or a subset to control exactly which platform flags are passed. + Compilers and other tools should use this to also pass the target + platform, for example. + + + Eventually these will be passed when in native builds too, to improve + determinism: build-time guessing, as is done today, is a risk of + impurity. + + + + + + + preConfigure + + + + Hook executed at the start of the configure phase. + + + + + postConfigure + + + + Hook executed at the end of the configure phase. + + + + +
+ +
+ The build phase + + + The build phase is responsible for actually building the package (e.g. + compiling it). The default buildPhase simply calls + make if a file named Makefile, + makefile or GNUmakefile exists in + the current directory (or the makefile is explicitly + set); otherwise it does nothing. + + + + Variables controlling the build phase + + dontBuild + + + + Set to true to skip the build phase. + + + + + makefile + + + + The file name of the Makefile. + + + + + makeFlags + + + + A list of strings passed as additional flags to make. + These flags are also used by the default install and check phase. For + setting make flags specific to the build phase, use + buildFlags (see below). makeFlags = [ "PREFIX=$(out)" ]; - - The flags are quoted in bash, but environment variables can - be specified by using the make syntax. - - - - makeFlagsArray - A shell array containing additional arguments - passed to make. You must use this instead of - makeFlags if the arguments contain - spaces, e.g. - + + + The flags are quoted in bash, but environment variables can be + specified by using the make syntax. + + + + + + + makeFlagsArray + + + + A shell array containing additional arguments passed to + make. You must use this instead of + makeFlags if the arguments contain spaces, e.g. makeFlagsArray=(CFLAGS="-O0 -g" LDFLAGS="-lfoo -lbar") + Note that shell arrays cannot be passed through environment variables, + so you cannot set makeFlagsArray in a derivation + attribute (because those are passed through environment variables): you + have to define them in shell code. + + + + + buildFlags / buildFlagsArray + + + + A list of strings passed as additional flags to make. + Like makeFlags and makeFlagsArray, + but only used by the build phase. + + + + + preBuild + + + + Hook executed at the start of the build phase. + + + + + postBuild + + + + Hook executed at the end of the build phase. + + + + - Note that shell arrays cannot be passed through environment - variables, so you cannot set makeFlagsArray in - a derivation attribute (because those are passed through - environment variables): you have to define them in shell - code. - + + You can set flags for make through the + makeFlags variable. + - - buildFlags / buildFlagsArray - A list of strings passed as additional flags to - make. Like makeFlags and - makeFlagsArray, but only used by the build - phase. - + + Before and after running make, the hooks + preBuild and postBuild are called, + respectively. + +
- - preBuild - Hook executed at the start of the build - phase. - +
+ The check phase - - postBuild - Hook executed at the end of the build - phase. - + + The check phase checks whether the package was built correctly by running + its test suite. The default checkPhase calls + make check, but only if the doCheck + variable is enabled. + - - - - -You can set flags for make through the -makeFlags variable. - -Before and after running make, the hooks -preBuild and postBuild are -called, respectively. - -
- - -
The check phase - -The check phase checks whether the package was built correctly -by running its test suite. The default -checkPhase calls make check, -but only if the doCheck variable is enabled. - - - Variables controlling the check phase - - - doCheck - - Controls whether the check phase is executed. - By default it is skipped, but if doCheck is set to true, the check phase is usually executed. - Thus you should set doCheck = true; in the derivation to enable checks. - The exception is cross compilation. - Cross compiled builds never run tests, no matter how doCheck is set, - as the newly-built program won't run on the platform used to build it. - - - - - makeFlags / + + Variables controlling the check phase + + doCheck + + + + Controls whether the check phase is executed. By default it is skipped, + but if doCheck is set to true, the check phase is + usually executed. Thus you should set +doCheck = true; + in the derivation to enable checks. The exception is cross compilation. + Cross compiled builds never run tests, no matter how + doCheck is set, as the newly-built program won't run + on the platform used to build it. + + + + + makeFlags / makeFlagsArray / - makefile - See the build phase for details. - + makefile + + + + See the build phase for details. + + + + + checkTarget + + + + The make target that runs the tests. Defaults to + check. + + + + + checkFlags / checkFlagsArray + + + + A list of strings passed as additional flags to make. + Like makeFlags and makeFlagsArray, + but only used by the check phase. + + + + + preCheck + + + + Hook executed at the start of the check phase. + + + + + postCheck + + + + Hook executed at the end of the check phase. + + + + +
- - checkTarget - The make target that runs the tests. Defaults to - check. - +
+ The install phase - - checkFlags / checkFlagsArray - A list of strings passed as additional flags to - make. Like makeFlags and - makeFlagsArray, but only used by the check - phase. - + + The install phase is responsible for installing the package in the Nix + store under out. The default + installPhase creates the directory + $out and calls make install. + - - preCheck - Hook executed at the start of the check - phase. - - - - postCheck - Hook executed at the end of the check - phase. - - - - - -
- - -
The install phase - -The install phase is responsible for installing the package in -the Nix store under out. The default -installPhase creates the directory -$out and calls make -install. - - - Variables controlling the install phase - - - makeFlags / + + Variables controlling the install phase + + makeFlags / makeFlagsArray / - makefile - See the build phase for details. - - - - installTargets - The make targets that perform the installation. - Defaults to install. Example: - + makefile + + + + See the build phase for details. + + + + + installTargets + + + + The make targets that perform the installation. Defaults to + install. Example: installTargets = "install-bin install-doc"; + + + + + installFlags / installFlagsArray + + + + A list of strings passed as additional flags to make. + Like makeFlags and makeFlagsArray, + but only used by the install phase. + + + + + preInstall + + + + Hook executed at the start of the install phase. + + + + + postInstall + + + + Hook executed at the end of the install phase. + + + + +
- - +
+ The fixup phase - - installFlags / installFlagsArray - A list of strings passed as additional flags to - make. Like makeFlags and - makeFlagsArray, but only used by the install - phase. - - - - preInstall - Hook executed at the start of the install - phase. - - - - postInstall - Hook executed at the end of the install - phase. - - - - - -
- - -
The fixup phase - -The fixup phase performs some (Nix-specific) post-processing -actions on the files installed under $out by the -install phase. The default fixupPhase does the -following: - - - - It moves the man/, - doc/ and info/ - subdirectories of $out to - share/. - - It strips libraries and executables of debug - information. - - On Linux, it applies the patchelf - command to ELF executables and libraries to remove unused - directories from the RPATH in order to prevent - unnecessary runtime dependencies. - - It rewrites the interpreter paths of shell scripts - to paths found in PATH. E.g., - /usr/bin/perl will be rewritten to - /nix/store/some-perl/bin/perl - found in PATH. - - - - - - - Variables controlling the fixup phase - - - dontStrip - If set, libraries and executables are not - stripped. By default, they are. - - - dontStripHost - - Like dontStripHost, but only affects the strip command targetting the package's host platform. - Useful when supporting cross compilation, but otherwise feel free to ignore. - - - - dontStripTarget - - Like dontStripHost, but only affects the strip command targetting the packages' target platform. - Useful when supporting cross compilation, but otherwise feel free to ignore. - - - - - dontMoveSbin - If set, files in $out/sbin are not moved - to $out/bin. By default, they are. - - - - stripAllList - List of directories to search for libraries and - executables from which all symbols should be - stripped. By default, it’s empty. Stripping all symbols is - risky, since it may remove not just debug symbols but also ELF - information necessary for normal execution. - - - - stripAllFlags - Flags passed to the strip - command applied to the files in the directories listed in - stripAllList. Defaults to - (i.e. ). - - - - stripDebugList - List of directories to search for libraries and - executables from which only debugging-related symbols should be - stripped. It defaults to lib bin - sbin. - - - - stripDebugFlags - Flags passed to the strip - command applied to the files in the directories listed in - stripDebugList. Defaults to - - (i.e. ). - - - - dontPatchELF - If set, the patchelf command is - not used to remove unnecessary RPATH entries. - Only applies to Linux. - - - - dontPatchShebangs - If set, scripts starting with - #! do not have their interpreter paths - rewritten to paths in the Nix store. - - - - forceShare - The list of directories that must be moved from - $out to $out/share. - Defaults to man doc info. - - - - setupHook - A package can export a setup hook by setting this - variable. The setup hook, if defined, is copied to - $out/nix-support/setup-hook. Environment - variables are then substituted in it using substituteAll. - - - - preFixup - Hook executed at the start of the fixup - phase. - - - - postFixup - Hook executed at the end of the fixup - phase. - - - - separateDebugInfo - If set to true, the standard - environment will enable debug information in C/C++ builds. After - installation, the debug information will be separated from the - executables and stored in the output named - debug. (This output is enabled automatically; - you don’t need to set the outputs attribute - explicitly.) To be precise, the debug information is stored in - debug/lib/debug/.build-id/XX/YYYY…, - where XXYYYY… is the build - ID of the binary — a SHA-1 hash of the contents of - the binary. Debuggers like GDB use the build ID to look up the - separated debug information. - - For example, with GDB, you can add + + The fixup phase performs some (Nix-specific) post-processing actions on the + files installed under $out by the install phase. The + default fixupPhase does the following: + + + + It moves the man/, doc/ and + info/ subdirectories of $out to + share/. + + + + + It strips libraries and executables of debug information. + + + + + On Linux, it applies the patchelf command to ELF + executables and libraries to remove unused directories from the + RPATH in order to prevent unnecessary runtime + dependencies. + + + + + It rewrites the interpreter paths of shell scripts to paths found in + PATH. E.g., /usr/bin/perl will be + rewritten to + /nix/store/some-perl/bin/perl + found in PATH. + + + + + + Variables controlling the fixup phase + + dontStrip + + + + If set, libraries and executables are not stripped. By default, they + are. + + + + + dontStripHost + + + + Like dontStripHost, but only affects the + strip command targetting the package's host platform. + Useful when supporting cross compilation, but otherwise feel free to + ignore. + + + + + dontStripTarget + + + + Like dontStripHost, but only affects the + strip command targetting the packages' target + platform. Useful when supporting cross compilation, but otherwise feel + free to ignore. + + + + + dontMoveSbin + + + + If set, files in $out/sbin are not moved to + $out/bin. By default, they are. + + + + + stripAllList + + + + List of directories to search for libraries and executables from which + all symbols should be stripped. By default, it’s + empty. Stripping all symbols is risky, since it may remove not just + debug symbols but also ELF information necessary for normal execution. + + + + + stripAllFlags + + + + Flags passed to the strip command applied to the + files in the directories listed in stripAllList. + Defaults to (i.e. ). + + + + + stripDebugList + + + + List of directories to search for libraries and executables from which + only debugging-related symbols should be stripped. It defaults to + lib bin sbin. + + + + + stripDebugFlags + + + + Flags passed to the strip command applied to the + files in the directories listed in stripDebugList. + Defaults to (i.e. ). + + + + + dontPatchELF + + + + If set, the patchelf command is not used to remove + unnecessary RPATH entries. Only applies to Linux. + + + + + dontPatchShebangs + + + + If set, scripts starting with #! do not have their + interpreter paths rewritten to paths in the Nix store. + + + + + forceShare + + + + The list of directories that must be moved from + $out to $out/share. Defaults + to man doc info. + + + + + setupHook + + + + A package can export a setup + hook by setting this variable. The setup hook, if defined, is + copied to $out/nix-support/setup-hook. Environment + variables are then substituted in it using + substituteAll. + + + + + preFixup + + + + Hook executed at the start of the fixup phase. + + + + + postFixup + + + + Hook executed at the end of the fixup phase. + + + + + separateDebugInfo + + + + If set to true, the standard environment will enable + debug information in C/C++ builds. After installation, the debug + information will be separated from the executables and stored in the + output named debug. (This output is enabled + automatically; you don’t need to set the outputs + attribute explicitly.) To be precise, the debug information is stored in + debug/lib/debug/.build-id/XX/YYYY…, + where XXYYYY… is the build + ID of the binary — a SHA-1 hash of the contents of the + binary. Debuggers like GDB use the build ID to look up the separated + debug information. + + + For example, with GDB, you can add set debug-file-directory ~/.nix-profile/lib/debug + to ~/.gdbinit. GDB will then be able to find debug + information installed via nix-env -i. + + + + +
- to ~/.gdbinit. GDB will then be able to find - debug information installed via nix-env - -i. +
+ The installCheck phase - - + + The installCheck phase checks whether the package was installed correctly + by running its test suite against the installed directories. The default + installCheck calls make + installcheck. + - + + Variables controlling the installCheck phase + + doInstallCheck + + + + Controls whether the installCheck phase is executed. By default it is + skipped, but if doInstallCheck is set to true, the + installCheck phase is usually executed. Thus you should set +doInstallCheck = true; + in the derivation to enable install checks. The exception is cross + compilation. Cross compiled builds never run tests, no matter how + doInstallCheck is set, as the newly-built program + won't run on the platform used to build it. + + + + + preInstallCheck + + + + Hook executed at the start of the installCheck phase. + + + + + postInstallCheck + + + + Hook executed at the end of the installCheck phase. + + + + +
-
+
+ The distribution phase -
The installCheck phase + + The distribution phase is intended to produce a source distribution of the + package. The default distPhase first calls + make dist, then it copies the resulting source tarballs + to $out/tarballs/. This phase is only executed if the + attribute doDist is set. + -The installCheck phase checks whether the package was installed -correctly by running its test suite against the installed directories. -The default installCheck calls make -installcheck. + + Variables controlling the distribution phase + + distTarget + + + + The make target that produces the distribution. Defaults to + dist. + + + + + distFlags / distFlagsArray + + + + Additional flags passed to make. + + + + + tarballs + + + + The names of the source distribution files to be copied to + $out/tarballs/. It can contain shell wildcards. The + default is *.tar.gz. + + + + + dontCopyDist + + + + If set, no files are copied to $out/tarballs/. + + + + + preDist + + + + Hook executed at the start of the distribution phase. + + + + + postDist + + + + Hook executed at the end of the distribution phase. + + + + +
+
+
+ Shell functions - - Variables controlling the installCheck phase - - - doInstallCheck - - Controls whether the installCheck phase is executed. - By default it is skipped, but if doInstallCheck is set to true, the installCheck phase is usually executed. - Thus you should set doInstallCheck = true; in the derivation to enable install checks. - The exception is cross compilation. - Cross compiled builds never run tests, no matter how doInstallCheck is set, - as the newly-built program won't run on the platform used to build it. - - - - - preInstallCheck - Hook executed at the start of the installCheck - phase. - - - - postInstallCheck - Hook executed at the end of the installCheck - phase. - - - - -
- -
The distribution -phase - -The distribution phase is intended to produce a source -distribution of the package. The default -distPhase first calls make -dist, then it copies the resulting source tarballs to -$out/tarballs/. This phase is only executed if -the attribute doDist is set. - - - Variables controlling the distribution phase - - - distTarget - The make target that produces the distribution. - Defaults to dist. - - - - distFlags / distFlagsArray - Additional flags passed to - make. - - - - tarballs - The names of the source distribution files to be - copied to $out/tarballs/. It can contain - shell wildcards. The default is - *.tar.gz. - - - - dontCopyDist - If set, no files are copied to - $out/tarballs/. - - - - preDist - Hook executed at the start of the distribution - phase. - - - - postDist - Hook executed at the end of the distribution - phase. - - - - - -
- - -
- - -
Shell functions - -The standard environment provides a number of useful -functions. - - - - - - makeWrapper - executable - wrapperfile - args - Constructs a wrapper for a program with various - possible arguments. For example: + + The standard environment provides a number of useful functions. + + + + makeWrapperexecutablewrapperfileargs + + + + Constructs a wrapper for a program with various possible arguments. For + example: # adds `FOOBAR=baz` to `$out/bin/foo`’s environment makeWrapper $out/bin/foo $wrapperfile --set FOOBAR baz @@ -1392,662 +1764,763 @@ makeWrapper $out/bin/foo $wrapperfile --set FOOBAR baz # (via string replacements or in `configurePhase`). makeWrapper $out/bin/foo $wrapperfile --prefix PATH : ${lib.makeBinPath [ hello git ]} - - There’s many more kinds of arguments, they are documented in - nixpkgs/pkgs/build-support/setup-hooks/make-wrapper.sh. - - wrapProgram is a convenience function you probably - want to use most of the time. - + There’s many more kinds of arguments, they are documented in + nixpkgs/pkgs/build-support/setup-hooks/make-wrapper.sh. + + + wrapProgram is a convenience function you probably + want to use most of the time. + - - - - - substitute - infile - outfile - subs - + + + substituteinfileoutfilesubs + - Performs string substitution on the contents of + + Performs string substitution on the contents of infile, writing the result to - outfile. The substitutions in + outfile. The substitutions in subs are of the following form: - - - - - s1 - s2 - Replace every occurrence of the string - s1 by - s2. - - - - - varName - Replace every occurrence of - @varName@ by - the contents of the environment variable - varName. This is useful for - generating files from templates, using - @...@ in the - template as placeholders. - - - - - varName - s - Replace every occurrence of - @varName@ by - the string s. - - - - - - - Example: - + + + s1s2 + + + + Replace every occurrence of the string s1 + by s2. + + + + + varName + + + + Replace every occurrence of + @varName@ by the + contents of the environment variable + varName. This is useful for generating + files from templates, using + @...@ in the template + as placeholders. + + + + + varNames + + + + Replace every occurrence of + @varName@ by the string + s. + + + + + + + Example: substitute ./foo.in ./foo.out \ --replace /usr/bin/bar $bar/bin/bar \ --replace "a string containing spaces" "some other text" \ --subst-var someVar - - - - substitute is implemented using the + + + substitute is implemented using the replace - command. Unlike with the sed command, you - don’t have to worry about escaping special characters. It - supports performing substitutions on binary files (such as - executables), though there you’ll probably want to make sure - that the replacement string is as long as the replaced - string. - + command. Unlike with the sed command, you don’t have + to worry about escaping special characters. It supports performing + substitutions on binary files (such as executables), though there + you’ll probably want to make sure that the replacement string is as + long as the replaced string. + - - - - - substituteInPlace - file - subs - Like substitute, but performs - the substitutions in place on the file - file. - - - - - substituteAll - infile - outfile - Replaces every occurrence of - @varName@, where - varName is any environment variable, in - infile, writing the result to - outfile. For instance, if - infile has the contents - + + + substituteInPlacefilesubs + + + + Like substitute, but performs the substitutions in + place on the file file. + + + + + substituteAllinfileoutfile + + + + Replaces every occurrence of + @varName@, where + varName is any environment variable, in + infile, writing the result to + outfile. For instance, if + infile has the contents #! @bash@/bin/sh PATH=@coreutils@/bin echo @foo@ - - and the environment contains - bash=/nix/store/bmwp0q28cf21...-bash-3.2-p39 - and - coreutils=/nix/store/68afga4khv0w...-coreutils-6.12, - but does not contain the variable foo, then the - output will be - + and the environment contains + bash=/nix/store/bmwp0q28cf21...-bash-3.2-p39 and + coreutils=/nix/store/68afga4khv0w...-coreutils-6.12, + but does not contain the variable foo, then the output + will be #! /nix/store/bmwp0q28cf21...-bash-3.2-p39/bin/sh PATH=/nix/store/68afga4khv0w...-coreutils-6.12/bin echo @foo@ - - That is, no substitution is performed for undefined variables. - - Environment variables that start with an uppercase letter or an - underscore are filtered out, - to prevent global variables (like HOME) or private - variables (like __ETC_PROFILE_DONE) from accidentally - getting substituted. - The variables also have to be valid bash “names”, as - defined in the bash manpage (alphanumeric or _, - must not start with a number). - - - - - - substituteAllInPlace - file - Like substituteAll, but performs - the substitutions in place on the file - file. - - - - - stripHash - path - Strips the directory and hash part of a store - path, outputting the name part to stdout. - For example: - + That is, no substitution is performed for undefined variables. + + + Environment variables that start with an uppercase letter or an + underscore are filtered out, to prevent global variables (like + HOME) or private variables (like + __ETC_PROFILE_DONE) from accidentally getting + substituted. The variables also have to be valid bash “names”, as + defined in the bash manpage (alphanumeric or _, must + not start with a number). + + + + + substituteAllInPlacefile + + + + Like substituteAll, but performs the substitutions + in place on the file file. + + + + + stripHashpath + + + + Strips the directory and hash part of a store path, outputting the name + part to stdout. For example: # prints coreutils-8.24 stripHash "/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24" - - If you wish to store the result in another variable, then the - following idiom may be useful: - + If you wish to store the result in another variable, then the following + idiom may be useful: name="/nix/store/9s9r019176g7cvn2nvcw41gsp862y6b4-coreutils-8.24" someVar=$(stripHash $name) - - - - - - - wrapProgram - executable - makeWrapperArgs - Convenience function for makeWrapper - that automatically creates a sane wrapper file - - It takes all the same arguments as makeWrapper, - except for --argv0. - - It cannot be applied multiple times, since it will overwrite the wrapper - file. + - + + + wrapProgramexecutablemakeWrapperArgs + + + + Convenience function for makeWrapper that + automatically creates a sane wrapper file It takes all the same arguments + as makeWrapper, except for --argv0. + + + It cannot be applied multiple times, since it will overwrite the wrapper + file. + + + + +
+
+ Package setup hooks + + Nix itself considers a build-time dependency merely something that should + previously be built and accessible at build time—packages themselves are + on their own to perform any additional setup. In most cases, that is fine, + and the downstream derivation can deal with it's own dependencies. But for a + few common tasks, that would result in almost every package doing the same + sort of setup work---depending not on the package itself, but entirely on + which dependencies were used. + - + + In order to alleviate this burden, the setup + hook>mechanism was written, where any package can include a + shell script that [by convention rather than enforcement by Nix], any + downstream reverse-dependency will source as part of its build process. That + allows the downstream dependency to merely specify its dependencies, and + lets those dependencies effectively initialize themselves. No boilerplate + mirroring the list of dependencies is needed. + -
+ + The Setup hook mechanism is a bit of a sledgehammer though: a powerful + feature with a broad and indiscriminate area of effect. The combination of + its power and implicit use may be expedient, but isn't without costs. Nix + itself is unchanged, but the spirit of adding dependencies being effect-free + is violated even if the letter isn't. For example, if a derivation path is + mentioned more than once, Nix itself doesn't care and simply makes sure the + dependency derivation is already built just the same—depending is just + needing something to exist, and needing is idempotent. However, a dependency + specified twice will have its setup hook run twice, and that could easily + change the build environment (though a well-written setup hook will + therefore strive to be idempotent so this is in fact not observable). More + broadly, setup hooks are anti-modular in that multiple dependencies, whether + the same or different, should not interfere and yet their setup hooks may + well do so. + + + The most typical use of the setup hook is actually to add other hooks which + are then run (i.e. after all the setup hooks) on each dependency. For + example, the C compiler wrapper's setup hook feeds itself flags for each + dependency that contains relevant libaries and headers. This is done by + defining a bash function, and appending its name to one of + envBuildBuildHooks`, envBuildHostHooks`, + envBuildTargetHooks`, envHostHostHooks`, + envHostTargetHooks`, or envTargetTargetHooks`. + These 6 bash variables correspond to the 6 sorts of dependencies by platform + (there's 12 total but we ignore the propagated/non-propagated axis). + -
Package setup hooks - - - Nix itself considers a build-time dependency merely something that should previously be built and accessible at build time—packages themselves are on their own to perform any additional setup. - In most cases, that is fine, and the downstream derivation can deal with it's own dependencies. - But for a few common tasks, that would result in almost every package doing the same sort of setup work---depending not on the package itself, but entirely on which dependencies were used. - - - In order to alleviate this burden, the setup hook>mechanism was written, where any package can include a shell script that [by convention rather than enforcement by Nix], any downstream reverse-dependency will source as part of its build process. - That allows the downstream dependency to merely specify its dependencies, and lets those dependencies effectively initialize themselves. - No boilerplate mirroring the list of dependencies is needed. - - - The Setup hook mechanism is a bit of a sledgehammer though: a powerful feature with a broad and indiscriminate area of effect. - The combination of its power and implicit use may be expedient, but isn't without costs. - Nix itself is unchanged, but the spirit of adding dependencies being effect-free is violated even if the letter isn't. - For example, if a derivation path is mentioned more than once, Nix itself doesn't care and simply makes sure the dependency derivation is already built just the same—depending is just needing something to exist, and needing is idempotent. - However, a dependency specified twice will have its setup hook run twice, and that could easily change the build environment (though a well-written setup hook will therefore strive to be idempotent so this is in fact not observable). - More broadly, setup hooks are anti-modular in that multiple dependencies, whether the same or different, should not interfere and yet their setup hooks may well do so. - - - The most typical use of the setup hook is actually to add other hooks which are then run (i.e. after all the setup hooks) on each dependency. - For example, the C compiler wrapper's setup hook feeds itself flags for each dependency that contains relevant libaries and headers. - This is done by defining a bash function, and appending its name to one of - envBuildBuildHooks`, - envBuildHostHooks`, - envBuildTargetHooks`, - envHostHostHooks`, - envHostTargetHooks`, or - envTargetTargetHooks`. - These 6 bash variables correspond to the 6 sorts of dependencies by platform (there's 12 total but we ignore the propagated/non-propagated axis). - - - Packages adding a hook should not hard code a specific hook, but rather choose a variable relative to how they are included. - Returning to the C compiler wrapper example, if it itself is an n dependency, then it only wants to accumulate flags from n + 1 dependencies, as only those ones match the compiler's target platform. - The hostOffset variable is defined with the current dependency's host offset targetOffset with its target offset, before it's setup hook is sourced. - Additionally, since most environment hooks don't care about the target platform, - That means the setup hook can append to the right bash array by doing something like - + + Packages adding a hook should not hard code a specific hook, but rather + choose a variable relative to how they are included. + Returning to the C compiler wrapper example, if it itself is an + n dependency, then it only wants to accumulate flags from + n + 1 dependencies, as only those ones match the + compiler's target platform. The hostOffset variable is + defined with the current dependency's host offset + targetOffset with its target offset, before it's setup hook + is sourced. Additionally, since most environment hooks don't care about the + target platform, That means the setup hook can append to the right bash + array by doing something like + addEnvHooks "$hostOffset" myBashFunction - - - The existence of setups hooks has long been documented and packages inside Nixpkgs are free to use these mechanism. - Other packages, however, should not rely on these mechanisms not changing between Nixpkgs versions. - Because of the existing issues with this system, there's little benefit from mandating it be stable for any period of time. - - - Here are some packages that provide a setup hook. - Since the mechanism is modular, this probably isn't an exhaustive list. - Then again, since the mechanism is only to be used as a last resort, it might be. - + - - Bintools Wrapper - + + The existence of setups hooks has long been documented + and packages inside Nixpkgs are free to use these mechanism. Other packages, + however, should not rely on these mechanisms not changing between Nixpkgs + versions. Because of the existing issues with this system, there's little + benefit from mandating it be stable for any period of time. + + + + Here are some packages that provide a setup hook. Since the mechanism is + modular, this probably isn't an exhaustive list. Then again, since the + mechanism is only to be used as a last resort, it might be. + + + Bintools Wrapper + - Bintools Wrapper wraps the binary utilities for a bunch of miscellaneous purposes. - These are GNU Binutils when targetting Linux, and a mix of cctools and GNU binutils for Darwin. - [The "Bintools" name is supposed to be a compromise between "Binutils" and "cctools" not denoting any specific implementation.] - Specifically, the underlying bintools package, and a C standard library (glibc or Darwin's libSystem, just for the dynamic loader) are all fed in, and dependency finding, hardening (see below), and purity checks for each are handled by Bintools Wrapper. - Packages typically depend on CC Wrapper, which in turn (at run time) depends on Bintools Wrapper. + Bintools Wrapper wraps the binary utilities for a bunch of miscellaneous + purposes. These are GNU Binutils when targetting Linux, and a mix of + cctools and GNU binutils for Darwin. [The "Bintools" name is supposed to + be a compromise between "Binutils" and "cctools" not denoting any + specific implementation.] Specifically, the underlying bintools package, + and a C standard library (glibc or Darwin's libSystem, just for the + dynamic loader) are all fed in, and dependency finding, hardening (see + below), and purity checks for each are handled by Bintools Wrapper. + Packages typically depend on CC Wrapper, which in turn (at run time) + depends on Bintools Wrapper. - Bintools Wrapper was only just recently split off from CC Wrapper, so the division of labor is still being worked out. - For example, it shouldn't care about about the C standard library, but just take a derivation with the dynamic loader (which happens to be the glibc on linux). - Dependency finding however is a task both wrappers will continue to need to share, and probably the most important to understand. - It is currently accomplished by collecting directories of host-platform dependencies (i.e. buildInputs and nativeBuildInputs) in environment variables. - Bintools Wrapper's setup hook causes any lib and lib64 subdirectories to be added to NIX_LDFLAGS. - Since CC Wrapper and Bintools Wrapper use the same strategy, most of the Bintools Wrapper code is sparsely commented and refers to CC Wrapper. - But CC Wrapper's code, by contrast, has quite lengthy comments. - Bintools Wrapper merely cites those, rather than repeating them, to avoid falling out of sync. + Bintools Wrapper was only just recently split off from CC Wrapper, so + the division of labor is still being worked out. For example, it + shouldn't care about about the C standard library, but just take a + derivation with the dynamic loader (which happens to be the glibc on + linux). Dependency finding however is a task both wrappers will continue + to need to share, and probably the most important to understand. It is + currently accomplished by collecting directories of host-platform + dependencies (i.e. buildInputs and + nativeBuildInputs) in environment variables. Bintools + Wrapper's setup hook causes any lib and + lib64 subdirectories to be added to + NIX_LDFLAGS. Since CC Wrapper and Bintools Wrapper use + the same strategy, most of the Bintools Wrapper code is sparsely + commented and refers to CC Wrapper. But CC Wrapper's code, by contrast, + has quite lengthy comments. Bintools Wrapper merely cites those, rather + than repeating them, to avoid falling out of sync. - A final task of the setup hook is defining a number of standard environment variables to tell build systems which executables full-fill which purpose. - They are defined to just be the base name of the tools, under the assumption that Bintools Wrapper's binaries will be on the path. - Firstly, this helps poorly-written packages, e.g. ones that look for just gcc when CC isn't defined yet clang is to be used. - Secondly, this helps packages not get confused when cross-compiling, in which case multiple Bintools Wrappers may simultaneously be in use. - - Each wrapper targets a single platform, so if binaries for multiple platforms are needed, the underlying binaries must be wrapped multiple times. - As this is a property of the wrapper itself, the multiple wrappings are needed whether or not the same underlying binaries can target multiple platforms. - - BUILD_- and TARGET_-prefixed versions of the normal environment variable are defined for the additional Bintools Wrappers, properly disambiguating them. + A final task of the setup hook is defining a number of standard + environment variables to tell build systems which executables full-fill + which purpose. They are defined to just be the base name of the tools, + under the assumption that Bintools Wrapper's binaries will be on the + path. Firstly, this helps poorly-written packages, e.g. ones that look + for just gcc when CC isn't defined yet + clang is to be used. Secondly, this helps packages + not get confused when cross-compiling, in which case multiple Bintools + Wrappers may simultaneously be in use. + + + Each wrapper targets a single platform, so if binaries for multiple + platforms are needed, the underlying binaries must be wrapped multiple + times. As this is a property of the wrapper itself, the multiple + wrappings are needed whether or not the same underlying binaries can + target multiple platforms. + + + BUILD_- and TARGET_-prefixed versions of + the normal environment variable are defined for the additional Bintools + Wrappers, properly disambiguating them. - A problem with this final task is that Bintools Wrapper is honest and defines LD as ld. - Most packages, however, firstly use the C compiler for linking, secondly use LD anyways, defining it as the C compiler, and thirdly, only so define LD when it is undefined as a fallback. - This triple-threat means Bintools Wrapper will break those packages, as LD is already defined as the actual linker which the package won't override yet doesn't want to use. - The workaround is to define, just for the problematic package, LD as the C compiler. - A good way to do this would be preConfigure = "LD=$CC". + A problem with this final task is that Bintools Wrapper is honest and + defines LD as ld. Most packages, + however, firstly use the C compiler for linking, secondly use + LD anyways, defining it as the C compiler, and thirdly, + only so define LD when it is undefined as a fallback. + This triple-threat means Bintools Wrapper will break those packages, as + LD is already defined as the actual linker which the package won't + override yet doesn't want to use. The workaround is to define, just for + the problematic package, LD as the C compiler. A good way + to do this would be preConfigure = "LD=$CC". - - - - - CC Wrapper - + + + + CC Wrapper + - CC Wrapper wraps a C toolchain for a bunch of miscellaneous purposes. - Specifically, a C compiler (GCC or Clang), wrapped binary tools, and a C standard library (glibc or Darwin's libSystem, just for the dynamic loader) are all fed in, and dependency finding, hardening (see below), and purity checks for each are handled by CC Wrapper. - Packages typically depend on CC Wrapper, which in turn (at run time) depends on Bintools Wrapper. + CC Wrapper wraps a C toolchain for a bunch of miscellaneous purposes. + Specifically, a C compiler (GCC or Clang), wrapped binary tools, and a C + standard library (glibc or Darwin's libSystem, just for the dynamic + loader) are all fed in, and dependency finding, hardening (see below), + and purity checks for each are handled by CC Wrapper. Packages typically + depend on CC Wrapper, which in turn (at run time) depends on Bintools + Wrapper. - Dependency finding is undoubtedly the main task of CC Wrapper. - This works just like Bintools Wrapper, except that any include subdirectory of any relevant dependency is added to NIX_CFLAGS_COMPILE. - The setup hook itself contains some lengthy comments describing the exact convoluted mechanism by which this is accomplished. + Dependency finding is undoubtedly the main task of CC Wrapper. This + works just like Bintools Wrapper, except that any + include subdirectory of any relevant dependency is + added to NIX_CFLAGS_COMPILE. The setup hook itself + contains some lengthy comments describing the exact convoluted mechanism + by which this is accomplished. - CC Wrapper also like Bintools Wrapper defines standard environment variables with the names of the tools it wraps, for the same reasons described above. - Importantly, while it includes a cc symlink to the c compiler for portability, the CC will be defined using the compiler's "real name" (i.e. gcc or clang). - This helps lousy build systems that inspect on the name of the compiler rather than run it. + CC Wrapper also like Bintools Wrapper defines standard environment + variables with the names of the tools it wraps, for the same reasons + described above. Importantly, while it includes a cc + symlink to the c compiler for portability, the CC will be + defined using the compiler's "real name" (i.e. gcc or + clang). This helps lousy build systems that inspect + on the name of the compiler rather than run it. - - - - - Perl - + + + + Perl + - Adds the lib/site_perl subdirectory of each build input to the PERL5LIB environment variable. - For instance, if buildInputs contains Perl, then the lib/site_perl subdirectory of each input is added to the PERL5LIB environment variable. + Adds the lib/site_perl subdirectory of each build + input to the PERL5LIB environment variable. For instance, + if buildInputs contains Perl, then the + lib/site_perl subdirectory of each input is added + to the PERL5LIB environment variable. - - - - - Python - Adds the - lib/${python.libPrefix}/site-packages subdirectory of - each build input to the PYTHONPATH environment - variable. - - - - pkg-config - Adds the lib/pkgconfig and - share/pkgconfig subdirectories of each - build input to the PKG_CONFIG_PATH environment - variable. - - - - Automake - Adds the share/aclocal - subdirectory of each build input to the ACLOCAL_PATH - environment variable. - - - - Autoconf - The autoreconfHook derivation adds - autoreconfPhase, which runs autoreconf, libtoolize and - automake, essentially preparing the configure script in autotools-based - builds. - - - - libxml2 - Adds every file named - catalog.xml found under the - xml/dtd and xml/xsl - subdirectories of each build input to the - XML_CATALOG_FILES environment - variable. - - - - teTeX / TeX Live - Adds the share/texmf-nix - subdirectory of each build input to the TEXINPUTS - environment variable. - - - - Qt 4 - Sets the QTDIR environment variable - to Qt’s path. - - - - gdk-pixbuf - Exports GDK_PIXBUF_MODULE_FILE - environment variable the the builder. Add librsvg package - to buildInputs to get svg support. - - - - GHC - Creates a temporary package database and registers - every Haskell build input in it (TODO: how?). - - - - GStreamer - Adds the - GStreamer plugins subdirectory of - each build input to the GST_PLUGIN_SYSTEM_PATH_1_0 or - GST_PLUGIN_SYSTEM_PATH environment variable. - - - - paxctl - Defines the paxmark helper for - setting per-executable PaX flags on Linux (where it is available by - default; on all other platforms, paxmark is a no-op). - For example, to disable secure memory protections on the executable - foo: - + + + + Python + + + Adds the lib/${python.libPrefix}/site-packages + subdirectory of each build input to the PYTHONPATH + environment variable. + + + + + pkg-config + + + Adds the lib/pkgconfig and + share/pkgconfig subdirectories of each build input + to the PKG_CONFIG_PATH environment variable. + + + + + Automake + + + Adds the share/aclocal subdirectory of each build + input to the ACLOCAL_PATH environment variable. + + + + + Autoconf + + + The autoreconfHook derivation adds + autoreconfPhase, which runs autoreconf, libtoolize + and automake, essentially preparing the configure script in + autotools-based builds. + + + + + libxml2 + + + Adds every file named catalog.xml found under the + xml/dtd and xml/xsl + subdirectories of each build input to the + XML_CATALOG_FILES environment variable. + + + + + teTeX / TeX Live + + + Adds the share/texmf-nix subdirectory of each build + input to the TEXINPUTS environment variable. + + + + + Qt 4 + + + Sets the QTDIR environment variable to Qt’s path. + + + + + gdk-pixbuf + + + Exports GDK_PIXBUF_MODULE_FILE environment variable the + the builder. Add librsvg package to buildInputs to + get svg support. + + + + + GHC + + + Creates a temporary package database and registers every Haskell build + input in it (TODO: how?). + + + + + GStreamer + + + Adds the GStreamer plugins subdirectory of each build input to the + GST_PLUGIN_SYSTEM_PATH_1_0 or + GST_PLUGIN_SYSTEM_PATH environment variable. + + + + + paxctl + + + Defines the paxmark helper for setting per-executable + PaX flags on Linux (where it is available by default; on all other + platforms, paxmark is a no-op). For example, to + disable secure memory protections on the executable + foo: + postFixup = '' paxmark m $out/bin/foo ''; - The m flag is the most common flag and is typically - required for applications that employ JIT compilation or otherwise need to - execute code generated at run-time. Disabling PaX protections should be - considered a last resort: if possible, problematic features should be - disabled or patched to work with PaX. - + The m flag is the most common flag and is typically + required for applications that employ JIT compilation or otherwise need + to execute code generated at run-time. Disabling PaX protections should + be considered a last resort: if possible, problematic features should be + disabled or patched to work with PaX. + + + + + autoPatchelfHook + + + 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 + runtimeDependencies environment variable are + unconditionally added to executables, which is useful for programs that + use + dlopen + 3 to load libraries at runtime. + + + + + +
+
+ Purity in Nixpkgs - - autoPatchelfHook - 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 - runtimeDependencies environment variable are unconditionally - added to executables, which is useful for programs that use - - dlopen - 3 - - to load libraries at runtime. - + + [measures taken to prevent dependencies on packages outside the store, and + what you can do to prevent them] + - + + GCC doesn't search in locations such as /usr/include. + In fact, attempts to add such directories through the + flag are filtered out. Likewise, the linker (from GNU binutils) doesn't + search in standard locations such as /usr/lib. Programs + built on Linux are linked against a GNU C Library that likewise doesn't + search in the default system locations. + +
+
+ Hardening in Nixpkgs - + + There are flags available to harden packages at compile or link-time. These + can be toggled using the stdenv.mkDerivation parameters + hardeningDisable and hardeningEnable. + -
+ + Both parameters take a list of flags as strings. The special + "all" flag can be passed to + hardeningDisable to turn off all hardening. These flags + can also be used as environment variables for testing or development + purposes. + + + The following flags are enabled by default and might require disabling with + hardeningDisable if the program to package is + incompatible. + -
Purity in Nixpkgs - -[measures taken to prevent dependencies on packages outside the -store, and what you can do to prevent them] - -GCC doesn't search in locations such as -/usr/include. In fact, attempts to add such -directories through the flag are filtered out. -Likewise, the linker (from GNU binutils) doesn't search in standard -locations such as /usr/lib. Programs built on -Linux are linked against a GNU C Library that likewise doesn't search -in the default system locations. - -
- -
Hardening in Nixpkgs - -There are flags available to harden packages at compile or link-time. -These can be toggled using the stdenv.mkDerivation parameters -hardeningDisable and hardeningEnable. - - - -Both parameters take a list of flags as strings. The special -"all" flag can be passed to hardeningDisable -to turn off all hardening. These flags can also be used as environment variables -for testing or development purposes. - - -The following flags are enabled by default and might require disabling with -hardeningDisable if the program to package is incompatible. - - - - - - format - Adds the compiler options. At present, - this warns about calls to printf and - scanf functions where the format string is - not a string literal and there are no format arguments, as in - printf(foo);. This may be a security hole - if the format string came from untrusted input and contains - %n. - - This needs to be turned off or fixed for errors similar to: - - + + + format + + + + Adds the compiler options. At present, this warns + about calls to printf and scanf + functions where the format string is not a string literal and there are + no format arguments, as in printf(foo);. This may be a + security hole if the format string came from untrusted input and contains + %n. + + + This needs to be turned off or fixed for errors similar to: + + /tmp/nix-build-zynaddsubfx-2.5.2.drv-0/zynaddsubfx-2.5.2/src/UI/guimain.cpp:571:28: error: format not a string literal and no format arguments [-Werror=format-security] printf(help_message); ^ cc1plus: some warnings being treated as errors - - - - - stackprotector + + + + + stackprotector + - Adds the - compiler options. This adds safety checks against stack overwrites - rendering many potential code injection attacks into aborting situations. - In the best case this turns code injection vulnerabilities into denial - of service or into non-issues (depending on the application). - - This needs to be turned off or fixed for errors similar to: - - + + Adds the compiler options. This adds safety checks + against stack overwrites rendering many potential code injection attacks + into aborting situations. In the best case this turns code injection + vulnerabilities into denial of service or into non-issues (depending on + the application). + + + This needs to be turned off or fixed for errors similar to: + + bin/blib.a(bios_console.o): In function `bios_handle_cup': /tmp/nix-build-ipxe-20141124-5cbdc41.drv-0/ipxe-5cbdc41/src/arch/i386/firmware/pcbios/bios_console.c:86: undefined reference to `__stack_chk_fail' - - - - - fortify + + + + + fortify + - Adds the compiler - options. During code generation the compiler knows a great deal of - information about buffer sizes (where possible), and attempts to replace - insecure unlimited length buffer function calls with length-limited ones. - This is especially useful for old, crufty code. Additionally, format - strings in writable memory that contain '%n' are blocked. If an application - depends on such a format string, it will need to be worked around. - - - Additionally, some warnings are enabled which might trigger build - failures if compiler warnings are treated as errors in the package build. - In this case, set to - . - - This needs to be turned off or fixed for errors similar to: - - + + Adds the compiler options. + During code generation the compiler knows a great deal of information + about buffer sizes (where possible), and attempts to replace insecure + unlimited length buffer function calls with length-limited ones. This is + especially useful for old, crufty code. Additionally, format strings in + writable memory that contain '%n' are blocked. If an application depends + on such a format string, it will need to be worked around. + + + Additionally, some warnings are enabled which might trigger build + failures if compiler warnings are treated as errors in the package build. + In this case, set to + . + + + This needs to be turned off or fixed for errors similar to: + + malloc.c:404:15: error: return type is an incomplete type malloc.c:410:19: error: storage size of 'ms' isn't known - + strdup.h:22:1: error: expected identifier or '(' before '__extension__' - + strsep.c:65:23: error: register name not specified for 'delim' - + installwatch.c:3751:5: error: conflicting types for '__open_2' - + fcntl2.h:50:4: error: call to '__open_missing_mode' declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments - - - - pic + + + pic + - Adds the compiler options. This options adds - support for position independent code in shared libraries and thus making - ASLR possible. - Most notably, the Linux kernel, kernel modules and other code - not running in an operating system environment like boot loaders won't - build with PIC enabled. The compiler will is most cases complain that - PIC is not supported for a specific build. - - - This needs to be turned off or fixed for assembler errors similar to: - - + + Adds the compiler options. This options adds + support for position independent code in shared libraries and thus making + ASLR possible. + + + Most notably, the Linux kernel, kernel modules and other code not running + in an operating system environment like boot loaders won't build with PIC + enabled. The compiler will is most cases complain that PIC is not + supported for a specific build. + + + This needs to be turned off or fixed for assembler errors similar to: + + ccbLfRgg.s: Assembler messages: ccbLfRgg.s:33: Error: missing or invalid displacement expression `private_key_len@GOTOFF' - - - - strictoverflow + + + strictoverflow + - Signed integer overflow is undefined behaviour according to the C - standard. If it happens, it is an error in the program as it should check - for overflow before it can happen, not afterwards. GCC provides built-in - functions to perform arithmetic with overflow checking, which are correct - and faster than any custom implementation. As a workaround, the option - makes gcc behave as if signed - integer overflows were defined. - - - This flag should not trigger any build or runtime errors. + + Signed integer overflow is undefined behaviour according to the C + standard. If it happens, it is an error in the program as it should check + for overflow before it can happen, not afterwards. GCC provides built-in + functions to perform arithmetic with overflow checking, which are correct + and faster than any custom implementation. As a workaround, the option + makes gcc behave as if signed + integer overflows were defined. + + + This flag should not trigger any build or runtime errors. + - - - - relro + + + relro + - Adds the linker option. During program - load, several ELF memory sections need to be written to by the linker, - but can be turned read-only before turning over control to the program. - This prevents some GOT (and .dtors) overwrite attacks, but at least the - part of the GOT used by the dynamic linker (.got.plt) is still vulnerable. - - - This flag can break dynamic shared object loading. For instance, the - module systems of Xorg and OpenCV are incompatible with this flag. In almost - all cases the bindnow flag must also be disabled and - incompatible programs typically fail with similar errors at runtime. + + Adds the linker option. During program load, + several ELF memory sections need to be written to by the linker, but can + be turned read-only before turning over control to the program. This + prevents some GOT (and .dtors) overwrite attacks, but at least the part + of the GOT used by the dynamic linker (.got.plt) is still vulnerable. + + + This flag can break dynamic shared object loading. For instance, the + module systems of Xorg and OpenCV are incompatible with this flag. In + almost all cases the bindnow flag must also be + disabled and incompatible programs typically fail with similar errors at + runtime. + - - - - bindnow + + + bindnow + - Adds the linker option. During program - load, all dynamic symbols are resolved, allowing for the complete GOT to - be marked read-only (due to relro). This prevents GOT - overwrite attacks. For very large applications, this can incur some - performance loss during initial load while symbols are resolved, but this - shouldn't be an issue for daemons. - - - This flag can break dynamic shared object loading. For instance, the - module systems of Xorg and PHP are incompatible with this flag. Programs - incompatible with this flag often fail at runtime due to missing symbols, - like: - - + + Adds the linker option. During program load, + all dynamic symbols are resolved, allowing for the complete GOT to be + marked read-only (due to relro). This prevents GOT + overwrite attacks. For very large applications, this can incur some + performance loss during initial load while symbols are resolved, but this + shouldn't be an issue for daemons. + + + This flag can break dynamic shared object loading. For instance, the + module systems of Xorg and PHP are incompatible with this flag. Programs + incompatible with this flag often fail at runtime due to missing symbols, + like: + + intel_drv.so: undefined symbol: vgaHWFreeHWRec - + + - + + The following flags are disabled by default and should be enabled with + hardeningEnable for packages that take untrusted input + like network services. + -The following flags are disabled by default and should be enabled -with hardeningEnable for packages that take untrusted -input like network services. - - - - - - pie + + + pie + - Adds the compiler and - linker options. Position Independent Executables are needed to take - advantage of Address Space Layout Randomization, supported by modern - kernel versions. While ASLR can already be enforced for data areas in - the stack and heap (brk and mmap), the code areas must be compiled as - position-independent. Shared libraries already do this with the - pic flag, so they gain ASLR automatically, but binary - .text regions need to be build with pie to gain ASLR. - When this happens, ROP attacks are much harder since there are no static - locations to bounce off of during a memory corruption attack. - + + Adds the compiler and linker + options. Position Independent Executables are needed to take advantage of + Address Space Layout Randomization, supported by modern kernel versions. + While ASLR can already be enforced for data areas in the stack and heap + (brk and mmap), the code areas must be compiled as position-independent. + Shared libraries already do this with the pic flag, so + they gain ASLR automatically, but binary .text regions need to be build + with pie to gain ASLR. When this happens, ROP attacks + are much harder since there are no static locations to bounce off of + during a memory corruption attack. + - - - - -For more in-depth information on these hardening flags and hardening in -general, refer to the -Debian Wiki, -Ubuntu Wiki, -Gentoo Wiki, -and the -Arch Wiki. - - -
+ + + + For more in-depth information on these hardening flags and hardening in + general, refer to the + Debian Wiki, + Ubuntu + Wiki, + Gentoo + Wiki, and the + + Arch Wiki. + +
diff --git a/doc/submitting-changes.xml b/doc/submitting-changes.xml index d3cf221c9b69..ffa3a90b5eb6 100644 --- a/doc/submitting-changes.xml +++ b/doc/submitting-changes.xml @@ -1,447 +1,513 @@ + Submitting changes +
+ Making patches -Submitting changes - -
-Making patches - - - -Read Manual (How to write packages for Nix). - - - -Fork the repository on GitHub. - - - -Create a branch for your future fix. - - - -You can make branch from a commit of your local nixos-version. That will help you to avoid additional local compilations. Because you will receive packages from binary cache. - - - -For example: nixos-version returns 15.05.git.0998212 (Dingo). So you can do: - - - + + + + Read Manual (How to + write packages for Nix). + + + + + Fork the repository on GitHub. + + + + + Create a branch for your future fix. + + + + You can make branch from a commit of your local + nixos-version. That will help you to avoid + additional local compilations. Because you will receive packages from + binary cache. + + + + For example: nixos-version returns + 15.05.git.0998212 (Dingo). So you can do: + + + $ git checkout 0998212 $ git checkout -b 'fix/pkg-name-update' - - - - -Please avoid working directly on the master branch. - - - - - - -Make commits of logical units. - - - -If you removed pkgs, made some major NixOS changes etc., write about them in nixos/doc/manual/release-notes/rl-unstable.xml. - - - - - - -Check for unnecessary whitespace with git diff --check before committing. - - - -Format the commit in a following way: + + + + + Please avoid working directly on the master branch. + + + + + + + + Make commits of logical units. + + + + If you removed pkgs, made some major NixOS changes etc., write about + them in + nixos/doc/manual/release-notes/rl-unstable.xml. + + + + + + + + Check for unnecessary whitespace with git diff --check + before committing. + + + + + Format the commit in a following way: + (pkg-name | nixos/<module>): (from -> to | init at version | refactor | etc) Additional information. + + + + Examples: + + + + nginx: init at 2.0.1 + + + + + firefox: 54.0.1 -> 55.0 + + + + + nixos/hydra: add bazBaz option + + + + + nixos/nginx: refactor config generation + + + + + + + + + + Test your changes. If you work with + + + + nixpkgs: + + + + update pkg -> + + + + nix-env -i pkg-name -f <path to your local nixpkgs + folder> + + + + + + + + add pkg -> + + + + Make sure it's in + pkgs/top-level/all-packages.nix + + + + + nix-env -i pkg-name -f <path to your local nixpkgs + folder> + + + + + + + + If you don't want to install pkg in you + profile. + + + + nix-build -A pkg-attribute-name <path to your local + nixpkgs folder>/default.nix and check results in the + folder result. It will appear in the same + directory where you did nix-build. + + + + + + + + If you did nix-env -i pkg-name you can do + nix-env -e pkg-name to uninstall it from your + system. + + + + + + + + NixOS and its modules: + + + + You can add new module to your NixOS configuration file (usually + it's /etc/nixos/configuration.nix). And do + sudo nixos-rebuild test -I nixpkgs=<path to your local + nixpkgs folder> --fast. + + + + + + + + + + + If you have commits pkg-name: oh, forgot to insert + whitespace: squash commits in this case. Use git rebase + -i. + + + + + Rebase you branch against current master. + + + +
+
+ Submitting changes - - -Examples: - - - - -nginx: init at 2.0.1 - - - - - -firefox: 54.0.1 -> 55.0 - - - - - -nixos/hydra: add bazBaz option - - - - - -nixos/nginx: refactor config generation - - - - - - - - - -Test your changes. If you work with - - - -nixpkgs: - - - -update pkg -> - - - - -nix-env -i pkg-name -f <path to your local nixpkgs folder> - - - - - - - -add pkg -> - - - -Make sure it's in pkgs/top-level/all-packages.nix - - - - - -nix-env -i pkg-name -f <path to your local nixpkgs folder> - - - - - - - - -If you don't want to install pkg in you profile. - - - - -nix-build -A pkg-attribute-name <path to your local nixpkgs folder>/default.nix and check results in the folder result. It will appear in the same directory where you did nix-build. - - - - - - -If you did nix-env -i pkg-name you can do nix-env -e pkg-name to uninstall it from your system. - - - - - - -NixOS and its modules: - - - -You can add new module to your NixOS configuration file (usually it's /etc/nixos/configuration.nix). - And do sudo nixos-rebuild test -I nixpkgs=<path to your local nixpkgs folder> --fast. - - - - - - - - - -If you have commits pkg-name: oh, forgot to insert whitespace: squash commits in this case. Use git rebase -i. - - - -Rebase you branch against current master. - - -
- -
-Submitting changes - - - -Push your changes to your fork of nixpkgs. - - - -Create pull request: - - - -Write the title in format (pkg-name | nixos/<module>): improvement. - - - -If you update the pkg, write versions from -> to. - - - - - - -Write in comment if you have tested your patch. Do not rely much on TravisCI. - - - -If you make an improvement, write about your motivation. - - - -Notify maintainers of the package. For example add to the message: cc @jagajaga @domenkozar. - - - - - -
- -
+ + + + Push your changes to your fork of nixpkgs. + + + + + Create pull request: + + + + Write the title in format (pkg-name | nixos/<module>): + improvement. + + + + If you update the pkg, write versions from -> to. + + + + + + + + Write in comment if you have tested your patch. Do not rely much on + TravisCI. + + + + + If you make an improvement, write about your motivation. + + + + + Notify maintainers of the package. For example add to the message: + cc @jagajaga @domenkozar. + + + + + + +
+
Pull Request Template + - The pull request template helps determine what steps have been made for a - contribution so far, and will help guide maintainers on the status of a - change. The motivation section of the PR should include any extra details - the title does not address and link any existing issues related to the pull - request. + The pull request template helps determine what steps have been made for a + contribution so far, and will help guide maintainers on the status of a + change. The motivation section of the PR should include any extra details + the title does not address and link any existing issues related to the pull + request. - When a PR is created, it will be pre-populated with some checkboxes detailed below: + + + When a PR is created, it will be pre-populated with some checkboxes detailed + below: +
- Tested using sandboxing - - When sandbox builds are enabled, Nix will setup an isolated environment - for each build process. It is used to remove further hidden dependencies - set by the build environment to improve reproducibility. This includes - access to the network during the build outside of - fetch* functions and files outside the Nix store. - Depending on the operating system access to other resources are blocked - as well (ex. inter process communication is isolated on Linux); see Tested using sandboxing + + + When sandbox builds are enabled, Nix will setup an isolated environment for + each build process. It is used to remove further hidden dependencies set by + the build environment to improve reproducibility. This includes access to + the network during the build outside of fetch* + functions and files outside the Nix store. Depending on the operating + system access to other resources are blocked as well (ex. inter process + communication is isolated on Linux); see + build-use-sandbox - in Nix manual for details. - - - Sandboxing is not enabled by default in Nix due to a small performance - hit on each build. In pull requests for nixpkgs people - are asked to test builds with sandboxing enabled (see Tested - using sandboxing in the pull request template) because - in + + + Sandboxing is not enabled by default in Nix due to a small performance hit + on each build. In pull requests for + nixpkgs + people are asked to test builds with sandboxing enabled (see + Tested using sandboxing in the pull request template) + because + inhttps://nixos.org/hydra/ - sandboxing is also used. - - - Depending if you use NixOS or other platforms you can use one of the - following methods to enable sandboxing before building the package: - - - - Globally enable sandboxing on NixOS: - add the following to - configuration.nix - nix.useSandbox = true; - - - - - Globally enable sandboxing on non-NixOS platforms: - add the following to: /etc/nix/nix.conf - build-use-sandbox = true - - - - - + sandboxing is also used. + + + + Depending if you use NixOS or other platforms you can use one of the + following methods to enable sandboxing + before building the package: + + + + Globally enable sandboxing on NixOS: + add the following to configuration.nix +nix.useSandbox = true; + + + + + Globally enable sandboxing on non-NixOS + platforms: add the following to: + /etc/nix/nix.conf +build-use-sandbox = true + + + +
+
- Built on platform(s) - - Many Nix packages are designed to run on multiple - platforms. As such, it's important to let the maintainer know which - platforms your changes have been tested on. It's not always practical to - test a change on all platforms, and is not required for a pull request to - be merged. Only check the systems you tested the build on in this - section. - + Built on platform(s) + + + Many Nix packages are designed to run on multiple platforms. As such, it's + important to let the maintainer know which platforms your changes have been + tested on. It's not always practical to test a change on all platforms, and + is not required for a pull request to be merged. Only check the systems you + tested the build on in this section. +
+
- Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests) - - Packages with automated tests are much more likely to be merged in a - timely fashion because it doesn't require as much manual testing by the - maintainer to verify the functionality of the package. If there are - existing tests for the package, they should be run to verify your changes - do not break the tests. Tests only apply to packages with NixOS modules - defined and can only be run on Linux. For more details on writing and - running tests, see the Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests) + + + Packages with automated tests are much more likely to be merged in a timely + fashion because it doesn't require as much manual testing by the maintainer + to verify the functionality of the package. If there are existing tests for + the package, they should be run to verify your changes do not break the + tests. Tests only apply to packages with NixOS modules defined and can only + be run on Linux. For more details on writing and running tests, see the + section - in the NixOS manual. - + in the NixOS manual. +
+
- Tested compilation of all pkgs that depend on this change using <command>nox-review</command> - - If you are updating a package's version, you can use nox to make sure all - packages that depend on the updated package still compile correctly. This - can be done using the nox utility. The nox-review - utility can look for and build all dependencies either based on - uncommited changes with the wip option or specifying a - github pull request number. - - - review uncommitted changes: - nix-shell -p nox --run "nox-review wip" - - - review changes from pull request number 12345: - nix-shell -p nox --run "nox-review pr 12345" - + Tested compilation of all pkgs that depend on this change using <command>nox-review</command> + + + If you are updating a package's version, you can use nox to make sure all + packages that depend on the updated package still compile correctly. This + can be done using the nox utility. The nox-review + utility can look for and build all dependencies either based on uncommited + changes with the wip option or specifying a github pull + request number. + + + + review uncommitted changes: +nix-shell -p nox --run "nox-review wip" + + + + review changes from pull request number 12345: +nix-shell -p nox --run "nox-review pr 12345" +
+
- Tested execution of all binary files (usually in <filename>./result/bin/</filename>) - - It's important to test any executables generated by a build when you - change or create a package in nixpkgs. This can be done by looking in - ./result/bin and running any files in there, or at a - minimum, the main executable for the package. For example, if you make a change - to texlive, you probably would only check the binaries - associated with the change you made rather than testing all of them. - + Tested execution of all binary files (usually in <filename>./result/bin/</filename>) + + + It's important to test any executables generated by a build when you change + or create a package in nixpkgs. This can be done by looking in + ./result/bin and running any files in there, or at a + minimum, the main executable for the package. For example, if you make a + change to texlive, you probably would only check the + binaries associated with the change you made rather than testing all of + them. +
+
- Meets nixpkgs contribution standards - - The last checkbox is fits Meets nixpkgs contribution standards + + + The last checkbox is fits + CONTRIBUTING.md. - The contributing document has detailed information on standards the Nix - community has for commit messages, reviews, licensing of contributions - you make to the project, etc... Everyone should read and understand the - standards the community has for contributing before submitting a pull - request. - - + The contributing document has detailed information on standards the Nix + community has for commit messages, reviews, licensing of contributions you + make to the project, etc... Everyone should read and understand the + standards the community has for contributing before submitting a pull + request. +
-
- -
-Hotfixing pull requests - - - -Make the appropriate changes in you branch. - - - -Don't create additional commits, do - - - -git rebase -i - - - -git push --force to your branch. - - - - - - -
- -
-Commit policy - - - -Commits must be sufficiently tested before being merged, both for the master and staging branches. - - - -Hydra builds for master and staging should not be used as testing platform, it's a build farm for changes that have been already tested. - - - -When changing the bootloader installation process, extra care must be taken. Grub installations cannot be rolled back, hence changes may break people's installations forever. For any non-trivial change to the bootloader please file a PR asking for review, especially from @edolstra. - - - -
- Master branch +
+
+ Hotfixing pull requests - - - It should only see non-breaking commits that do not cause mass rebuilds. - - + + + Make the appropriate changes in you branch. + + + + + Don't create additional commits, do + + + + git rebase -i + + + + + git push --force to your branch. + + + + + -
- -
- Staging branch +
+
+ Commit policy - - - It's only for non-breaking mass-rebuild commits. That means it's not to - be used for testing, and changes must have been well tested already. - Read policy here. - - - - - If the branch is already in a broken state, please refrain from adding - extra new breakages. Stabilize it for a few days, merge into master, - then resume development on staging. - Keep an eye on the staging evaluations here. - If any fixes for staging happen to be already in master, then master can - be merged into staging. - - + + + Commits must be sufficiently tested before being merged, both for the + master and staging branches. + + + + + Hydra builds for master and staging should not be used as testing + platform, it's a build farm for changes that have been already tested. + + + + + When changing the bootloader installation process, extra care must be + taken. Grub installations cannot be rolled back, hence changes may break + people's installations forever. For any non-trivial change to the + bootloader please file a PR asking for review, especially from @edolstra. + + -
-
- Stable release branches +
+ Master branch - + - - If you're cherry-picking a commit to a stable release branch, always use - git cherry-pick -xe and ensure the message contains a - clear description about why this needs to be included in the stable - branch. - - An example of a cherry-picked commit would look like this: - + + It should only see non-breaking commits that do not cause mass rebuilds. + + + +
+ +
+ Staging branch + + + + + It's only for non-breaking mass-rebuild commits. That means it's not to + be used for testing, and changes must have been well tested already. + Read + policy here. + + + + + If the branch is already in a broken state, please refrain from adding + extra new breakages. Stabilize it for a few days, merge into master, then + resume development on staging. + Keep + an eye on the staging evaluations here. If any fixes for staging + happen to be already in master, then master can be merged into staging. + + + +
+ +
+ Stable release branches + + + + + If you're cherry-picking a commit to a stable release branch, always use + git cherry-pick -xe and ensure the message contains a + clear description about why this needs to be included in the stable + branch. + + + An example of a cherry-picked commit would look like this: + + nixos: Refactor the world. The original commit message describing the reason why the world was torn apart. @@ -451,9 +517,7 @@ Reason: I just had a gut feeling that this would also be wanted by people from the stone age. - -
- -
+ +
+
-