From 3d99eea85208d4f491e3a5c241b03d2c8d0c4125 Mon Sep 17 00:00:00 2001 From: Aneesh Agrawal Date: Sun, 30 Oct 2016 12:35:57 -0400 Subject: [PATCH] docs: use overrideAttrs instead of overrideDerivation --- .../configuration/customizing-packages.xml | 25 ++++++++++--------- nixos/modules/config/debug-info.nix | 6 ++--- nixos/modules/services/editors/emacs.xml | 6 ++--- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/nixos/doc/manual/configuration/customizing-packages.xml b/nixos/doc/manual/configuration/customizing-packages.xml index 6ee7a95dc6fa..f938d6dd67ed 100644 --- a/nixos/doc/manual/configuration/customizing-packages.xml +++ b/nixos/doc/manual/configuration/customizing-packages.xml @@ -42,29 +42,30 @@ construction, so without them, elements.) Even greater customisation is possible using the function -overrideDerivation. While the +overrideAttrs. While the override mechanism above overrides the arguments of -a package function, overrideDerivation allows -changing the result of the function. This +a package function, overrideAttrs allows +changing the attributes of the function. This permits changing any aspect of the package, such as the source code. For instance, if you want to override the source code of Emacs, you can say: -environment.systemPackages = - [ (pkgs.lib.overrideDerivation pkgs.emacs (attrs: { - name = "emacs-25.0-pre"; - src = /path/to/my/emacs/tree; - })) - ]; +environment.systemPackages = [ + (pkgs.emacs.overrideAttrs (oldAttrs: { + name = "emacs-25.0-pre"; + src = /path/to/my/emacs/tree; + })) +]; -Here, overrideDerivation takes the Nix derivation +Here, overrideAttrs takes the Nix derivation specified by pkgs.emacs and produces a new derivation in which the original’s name and src attribute have been replaced by the given -values. The original attributes are accessible via -attrs. +values by re-calling stdenv.mkDerivation. +The original attributes are accessible via the function argument, +which is conventionally named oldAttrs. The overrides shown above are not global. They do not affect the original package; other packages in Nixpkgs continue to depend on diff --git a/nixos/modules/config/debug-info.nix b/nixos/modules/config/debug-info.nix index 671a59f52f6d..49991d22a933 100644 --- a/nixos/modules/config/debug-info.nix +++ b/nixos/modules/config/debug-info.nix @@ -17,12 +17,10 @@ with lib; where tools such as gdb can find them. If you need debug symbols for a package that doesn't provide them by default, you can enable them as follows: - nixpkgs.config.packageOverrides = pkgs: { - hello = pkgs.lib.overrideDerivation pkgs.hello (attrs: { - outputs = attrs.outputs or ["out"] ++ ["debug"]; - buildInputs = attrs.buildInputs ++ [<nixpkgs/pkgs/build-support/setup-hooks/separate-debug-info.sh>]; + hello = pkgs.hello.overrideAttrs (oldAttrs: { + separateDebugInfo = true; }); }; diff --git a/nixos/modules/services/editors/emacs.xml b/nixos/modules/services/editors/emacs.xml index bcaa8b8df3d8..e03f6046de8e 100644 --- a/nixos/modules/services/editors/emacs.xml +++ b/nixos/modules/services/editors/emacs.xml @@ -356,14 +356,14 @@ https://nixos.org/nixpkgs/manual/#sec-modify-via-packageOverrides {} }: let - myEmacs = pkgs.lib.overrideDerivation (pkgs.emacs.override { + myEmacs = (pkgs.emacs.override { # Use gtk3 instead of the default gtk2 withGTK3 = true; withGTK2 = false; - }) (attrs: { + }).overrideAttrs (attrs: { # I don't want emacs.desktop file because I only use # emacsclient. - postInstall = attrs.postInstall + '' + postInstall = (attrs.postInstall or "") + '' rm $out/share/applications/emacs.desktop ''; });