treewide: emacsPackages -> emacs.pkgs & emacsWithPackages -> emacs.pkgs.withPackages

The previous names are now aliases and shouldn't be used anywhere inside nixpkgs.
This commit is contained in:
adisbladis 2020-12-18 04:46:05 +01:00
parent 6347f78fd9
commit 4003f8cbc7
No known key found for this signature in database
GPG Key ID: 110BFAD44C6249B7
12 changed files with 38 additions and 40 deletions

View File

@ -2,12 +2,12 @@
## Configuring Emacs {#sec-emacs-config}
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. `emacs.pkgs.withPackages` 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:
```nix
{
packageOverrides = pkgs: with pkgs; {
myEmacs = emacsWithPackages (epkgs: (with epkgs.melpaStablePackages; [
myEmacs = emacs.pkgs.withPackages (epkgs: (with epkgs.melpaStablePackages; [
company
counsel
flycheck
@ -84,7 +84,7 @@ You can install it like any other packages via `nix-env -iA myEmacs`. However, t
(projectile-global-mode))
'';
myEmacs = emacsWithPackages (epkgs: (with epkgs.melpaStablePackages; [
myEmacs = emacs.pkgs.withPackages (epkgs: (with epkgs.melpaStablePackages; [
(runCommand "default.el" {} ''
mkdir -p $out/share/emacs/site-lisp
cp ${myEmacsConfig} $out/share/emacs/site-lisp/default.el
@ -103,14 +103,14 @@ You can install it like any other packages via `nix-env -iA myEmacs`. However, t
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 `emacs.pkgs.withPackages` 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'`.
```nix
overrides = self: super: rec {
haskell-mode = self.melpaPackages.haskell-mode;
...
};
((emacsPackagesGen emacs).overrideScope' overrides).emacsWithPackages
((emacsPackagesFor emacs).overrideScope' overrides).emacs.pkgs.withPackages
(p: with p; [
# here both these package will use haskell-mode of our own choice
ghc-mod

View File

@ -156,7 +156,7 @@ $ ./result/bin/emacs
let
myEmacs = pkgs.emacs; <co xml:id="ex-emacsNix-2" />
emacsWithPackages = (pkgs.emacsPackagesGen myEmacs).emacsWithPackages; <co xml:id="ex-emacsNix-3" />
emacsWithPackages = (pkgs.emacsPackagesFor myEmacs).emacsWithPackages; <co xml:id="ex-emacsNix-3" />
in
emacsWithPackages (epkgs: (with epkgs.melpaStablePackages; [ <co xml:id="ex-emacsNix-4" />
magit # ; Integrate git &lt;C-x g&gt;
@ -254,10 +254,10 @@ in
<example xml:id="module-services-emacs-querying-packages">
<title>Querying Emacs packages</title>
<programlisting><![CDATA[
nix-env -f "<nixpkgs>" -qaP -A emacsPackages.elpaPackages
nix-env -f "<nixpkgs>" -qaP -A emacsPackages.melpaPackages
nix-env -f "<nixpkgs>" -qaP -A emacsPackages.melpaStablePackages
nix-env -f "<nixpkgs>" -qaP -A emacsPackages.orgPackages
nix-env -f "<nixpkgs>" -qaP -A emacs.pkgs.elpaPackages
nix-env -f "<nixpkgs>" -qaP -A emacs.pkgs.melpaPackages
nix-env -f "<nixpkgs>" -qaP -A emacs.pkgs.melpaStablePackages
nix-env -f "<nixpkgs>" -qaP -A emacs.pkgs.orgPackages
]]></programlisting>
</example>
</para>

View File

@ -48,7 +48,7 @@ in
description = ''
Extra packages available to Emacs. The value must be a
function which receives the attrset defined in
<varname>emacsPackages</varname> as the sole argument.
<varname>emacs.pkgs</varname> as the sole argument.
'';
};
};

View File

@ -5,7 +5,7 @@
To update the list of packages from MELPA,
1. Run `./update-elpa`.
2. Check for evaluation errors: `nix-instantiate ../../../.. -A emacsPackagesNg.elpaPackages`.
2. Check for evaluation errors: `nix-instantiate ../../../.. -A emacs.pkgs.elpaPackages`.
3. `git commit -m "elpa-packages $(date -Idate)" -- elpa-generated.nix`
## Update from overlay

View File

@ -6,8 +6,8 @@ To update the list of packages from MELPA,
1. Run ./update-melpa
2. Check for evaluation errors:
env NIXPKGS_ALLOW_BROKEN=1 nix-instantiate --show-trace ../../../../ -A emacsPackages.melpaStablePackages
env NIXPKGS_ALLOW_BROKEN=1 nix-instantiate --show-trace ../../../../ -A emacsPackages.melpaPackages
env NIXPKGS_ALLOW_BROKEN=1 nix-instantiate --show-trace ../../../../ -A emacs.pkgs..melpaStablePackages
env NIXPKGS_ALLOW_BROKEN=1 nix-instantiate --show-trace ../../../../ -A emacs.pkgs..melpaPackages
3. `git commit -m "melpa-packages: $(date -Idate)" recipes-archive-melpa.json`
## Update from overlay

View File

@ -5,7 +5,7 @@
To update the list of packages from Org (ELPA),
1. Run `./update-org`.
2. Check for evaluation errors: `nix-instantiate ../../../.. -A emacsPackagesNg.orgPackages`.
2. Check for evaluation errors: `nix-instantiate ../../../.. -A emacs.pkgs.orgPackages`.
3. `git commit -m "org-packages $(date -Idate)" -- org-generated.nix`
*/

View File

@ -8,14 +8,14 @@ export NIXPKGS_ALLOW_BROKEN=1
# You can use this to avoid running lengthy code generation jobs locally
curl -s -O https://raw.githubusercontent.com/nix-community/emacs-overlay/master/repos/elpa/elpa-generated.nix
nix-instantiate ../../../.. -A emacsPackagesNg.elpaPackages --show-trace
git diff --exit-code elpa-generated.nix > /dev/null || git commit -m "emacsPackages.elpa-packages: $(date --iso)" -- elpa-generated.nix
nix-instantiate ../../../.. -A emacs.pkgs.elpaPackages --show-trace
git diff --exit-code elpa-generated.nix > /dev/null || git commit -m "emacs.pkgs.elpa-packages: $(date --iso)" -- elpa-generated.nix
curl -s -O https://raw.githubusercontent.com/nix-community/emacs-overlay/master/repos/org/org-generated.nix
nix-instantiate ../../../.. -A emacsPackagesNg.orgPackages --show-trace
git diff --exit-code org-generated.nix > /dev/null || git commit -m "emacsPackages.org-packages: $(date --iso)" -- org-generated.nix
nix-instantiate ../../../.. -A emacs.pkgs.orgPackages --show-trace
git diff --exit-code org-generated.nix > /dev/null || git commit -m "emacs.pkgs.org-packages: $(date --iso)" -- org-generated.nix
curl -s -O https://raw.githubusercontent.com/nix-community/emacs-overlay/master/repos/melpa/recipes-archive-melpa.json
env nix-instantiate --show-trace ../../../../ -A emacsPackages.melpaStablePackages
env nix-instantiate --show-trace ../../../../ -A emacsPackages.melpaPackages
git diff --exit-code recipes-archive-melpa.json > /dev/null || git commit -m "emacsPackages.melpa-packages: $(date --iso)" -- recipes-archive-melpa.json
nix-instantiate --show-trace ../../../../ -A emacs.pkgs.melpaStablePackages
nix-instantiate --show-trace ../../../../ -A emacs.pkgs.melpaPackages
git diff --exit-code recipes-archive-melpa.json > /dev/null || git commit -m "emacs.pkgs.melpa-packages: $(date --iso)" -- recipes-archive-melpa.json

View File

@ -1,7 +1,7 @@
let
pkgs = import ../../../.. {};
emacsEnv = (pkgs.emacsPackagesFor pkgs.emacs).emacsWithPackages (epkgs: let
emacsEnv = pkgs.emacs.withPackages (epkgs: let
promise = epkgs.trivialBuild {
pname = "promise";

View File

@ -2,11 +2,11 @@
# Usage
`emacsWithPackages` takes a single argument: a function from a package
`emacs.pkgs.withPackages` takes a single argument: a function from a package
set to a list of packages (the packages that will be available in
Emacs). For example,
```
emacsWithPackages (epkgs: [ epkgs.evil epkgs.magit ])
emacs.pkgs.withPackages (epkgs: [ epkgs.evil epkgs.magit ])
```
All the packages in the list should come from the provided package
set. It is possible to add any package to the list, but the provided
@ -15,19 +15,19 @@ the correct version of Emacs.
# Overriding
`emacsWithPackages` inherits the package set which contains it, so the
`emacs.pkgs.withPackages` inherits the package set which contains it, so the
correct way to override the provided package set is to override the
set which contains `emacsWithPackages`. For example, to override
`emacsPackages.emacsWithPackages`,
set which contains `emacs.pkgs.withPackages`. For example, to override
`emacs.pkgs.emacs.pkgs.withPackages`,
```
let customEmacsPackages =
emacsPackages.overrideScope' (self: super: {
emacs.pkgs.overrideScope' (self: super: {
# use a custom version of emacs
emacs = ...;
# use the unstable MELPA version of magit
magit = self.melpaPackages.magit;
});
in customEmacsPackages.emacsWithPackages (epkgs: [ epkgs.evil epkgs.magit ])
in customEmacsPackages.emacs.pkgs.withPackages (epkgs: [ epkgs.evil epkgs.magit ])
```
*/

View File

@ -1,14 +1,14 @@
{ stdenv, fetchurl, python, emacsPackages }:
{ stdenv, fetchurl, python, emacs }:
stdenv.mkDerivation rec {
pname = "cask";
inherit (emacsPackages.melpaStablePackages.cask) src version;
inherit (emacs.pkgs.melpaStablePackages.cask) src version;
doCheck = true;
nativeBuildInputs = [ emacsPackages.emacs ];
buildInputs = with emacsPackages; [
nativeBuildInputs = [ emacs ];
buildInputs = with emacs.pkgs; [
s f dash ansi ecukes servant ert-runner el-mock
noflet ert-async shell-split-string git package-build
] ++ [

View File

@ -500,7 +500,7 @@ in
mkShell = callPackage ../build-support/mkshell { };
nixBufferBuilders = import ../build-support/emacs/buffer.nix { inherit (pkgs) lib writeText; inherit (emacsPackages) inherit-local; };
nixBufferBuilders = import ../build-support/emacs/buffer.nix { inherit (pkgs) lib writeText; inherit (emacs.pkgs) inherit-local; };
nix-gitignore = callPackage ../build-support/nix-gitignore { };
@ -9788,7 +9788,7 @@ in
# package. Wishing we could merge it into one irony package, to avoid this issue,
# but its emacs-side expression is autogenerated, and we can't hook into it (other
# than peek into its version).
inherit (emacsPackages.melpaStablePackages) irony;
inherit (emacs.pkgs.melpaStablePackages) irony;
};
hugs = callPackage ../development/interpreters/hugs { };
@ -21424,9 +21424,7 @@ in
elvis = callPackage ../applications/editors/elvis { };
emacs = emacs27;
emacsPackages = emacs27Packages;
emacs-nox = emacs27-nox;
emacsWithPackages = emacsPackages.emacsWithPackages;
emacs27 = callPackage ../applications/editors/emacs/27.nix {
# use override to enable additional features

View File

@ -34,8 +34,8 @@
"nvidiaPackages"
"sourceHanPackages"
"atomPackages"
"emacs26Packages"
"emacs27Packages"
"emacs26.pkgs"
"emacs27.pkgs"
"steamPackages"
"ut2004Packages"
"zeroadPackages"