From 96473722027815100ca2626a2607be6199578b04 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Wed, 24 Feb 2021 14:37:34 +0100 Subject: [PATCH 1/5] emacs.pkgs: Get rid of `external` from all-packages.nix This was a strange construct that made these attrsets more difficult to work with. It's simpler to just use pkgs. --- .../editors/emacs-modes/manual-packages.nix | 32 +++++++------- .../editors/emacs-modes/melpa-packages.nix | 44 +++++++++---------- pkgs/top-level/all-packages.nix | 9 ---- pkgs/top-level/emacs-packages.nix | 5 +-- 4 files changed, 40 insertions(+), 50 deletions(-) diff --git a/pkgs/applications/editors/emacs-modes/manual-packages.nix b/pkgs/applications/editors/emacs-modes/manual-packages.nix index d684c1ef94f5..a2963f19225c 100644 --- a/pkgs/applications/editors/emacs-modes/manual-packages.nix +++ b/pkgs/applications/editors/emacs-modes/manual-packages.nix @@ -1,4 +1,4 @@ -{ lib, external, pkgs }: self: with self; with lib.licenses; { +{ lib, pkgs }: self: with self; with lib.licenses; { elisp-ffi = melpaBuild rec { pname = "elisp-ffi"; @@ -9,7 +9,7 @@ rev = version; sha256 = "0z2n3h5l5fj8wl8i1ilfzv11l3zba14sgph6gz7dx7q12cnp9j22"; }; - buildInputs = [ external.libffi ]; + buildInputs = [ pkgs.libffi ]; preBuild = "make"; recipe = pkgs.writeText "recipe" '' (elisp-ffi @@ -29,15 +29,15 @@ }; }; - agda2-mode = with external; trivialBuild { + agda2-mode = trivialBuild { pname = "agda-mode"; - version = Agda.version; + version = pkgs.haskellPackages.Agda.version; phases = [ "buildPhase" "installPhase" ]; # already byte-compiled by Agda builder buildPhase = '' - agda=`${Agda}/bin/agda-mode locate` + agda=`${pkgs.haskellPackages.Agda}/bin/agda-mode locate` cp `dirname $agda`/*.el* . ''; @@ -47,21 +47,21 @@ Wrapper packages that liberates init.el from `agda-mode locate` magic. Simply add this to user profile or systemPackages and do `(require 'agda2)` in init.el. ''; - homepage = Agda.meta.homepage; - license = Agda.meta.license; + homepage = pkgs.haskellPackages.Agda.meta.homepage; + license = pkgs.haskellPackages.Agda.meta.license; }; }; agda-input = self.trivialBuild { pname = "agda-input"; - inherit (external.Agda) src version; + inherit (pkgs.haskellPackages.Agda) src version; postUnpack = "mv $sourceRoot/src/data/emacs-mode/agda-input.el $sourceRoot"; meta = { description = "Standalone package providing the agda-input method without building Agda."; - inherit (external.Agda.meta) homepage license; + inherit (pkgs.haskellPackages.Agda.meta) homepage license; }; }; @@ -74,10 +74,10 @@ ghc-mod = melpaBuild { pname = "ghc"; - version = external.ghc-mod.version; - src = external.ghc-mod.src; + version = pkgs.haskellPackages.ghc-mod.version; + src = pkgs.haskellPackages.ghc-mod.src; packageRequires = [ haskell-mode ]; - propagatedUserEnvPkgs = [ external.ghc-mod ]; + propagatedUserEnvPkgs = [ pkgs.haskellPackages.ghc-mod ]; recipe = pkgs.writeText "recipe" '' (ghc-mod :repo "DanielG/ghc-mod" :fetcher github :files ("elisp/*.el")) ''; @@ -115,7 +115,7 @@ llvm-mode = trivialBuild { pname = "llvm-mode"; - inherit (external.llvmPackages.llvm) src version; + inherit (pkgs.llvmPackages.llvm) src version; dontConfigure = true; buildPhase = '' @@ -123,7 +123,7 @@ ''; meta = { - inherit (external.llvmPackages.llvm.meta) homepage license; + inherit (pkgs.llvmPackages.llvm.meta) homepage license; description = "Major mode for the LLVM assembler language."; }; }; @@ -134,13 +134,13 @@ ott-mode = self.trivialBuild { pname = "ott-mod"; - inherit (external.ott) src version; + inherit (pkgs.ott) src version; postUnpack = "mv $sourceRoot/emacs/ott-mode.el $sourceRoot"; meta = { description = "Standalone package providing ott-mode without building ott and with compiled bytecode."; - inherit (external.Agda.meta) homepage license; + inherit (pkgs.haskellPackages.Agda.meta) homepage license; }; }; diff --git a/pkgs/applications/editors/emacs-modes/melpa-packages.nix b/pkgs/applications/editors/emacs-modes/melpa-packages.nix index 305d60aa305a..06480f8ce267 100644 --- a/pkgs/applications/editors/emacs-modes/melpa-packages.nix +++ b/pkgs/applications/editors/emacs-modes/melpa-packages.nix @@ -22,7 +22,7 @@ instantenous and formats commits for you. */ -{ lib, external, pkgs }: variant: self: +{ lib, pkgs }: variant: self: let dontConfigure = pkg: if pkg != null then pkg.override (args: { @@ -53,7 +53,7 @@ let }); fix-rtags = pkg: - if pkg != null then dontConfigure (externalSrc pkg external.rtags) + if pkg != null then dontConfigure (externalSrc pkg pkgs.rtags) else null; generateMelpa = lib.makeOverridable ({ archiveJson ? ./recipes-archive-melpa.json @@ -79,9 +79,9 @@ let }; auto-complete-clang-async = super.auto-complete-clang-async.overrideAttrs (old: { - buildInputs = old.buildInputs ++ [ external.llvmPackages.llvm ]; - CFLAGS = "-I${external.llvmPackages.clang}/include"; - LDFLAGS = "-L${external.llvmPackages.clang}/lib"; + buildInputs = old.buildInputs ++ [ pkgs.llvmPackages.llvm ]; + CFLAGS = "-I${pkgs.llvmPackages.clang}/include"; + LDFLAGS = "-L${pkgs.llvmPackages.clang}/lib"; }); # part of a larger package @@ -132,8 +132,8 @@ let flycheck-rtags = fix-rtags super.flycheck-rtags; pdf-tools = super.pdf-tools.overrideAttrs (old: { - nativeBuildInputs = [ external.pkg-config ]; - buildInputs = with external; old.buildInputs ++ [ autoconf automake libpng zlib poppler ]; + nativeBuildInputs = [ pkgs.pkg-config ]; + buildInputs = with pkgs; old.buildInputs ++ [ autoconf automake libpng zlib poppler ]; preBuild = "make server/epdfinfo"; recipe = pkgs.writeText "recipe" '' (pdf-tools @@ -143,7 +143,7 @@ let }); # Build same version as Haskell package - hindent = (externalSrc super.hindent external.hindent).overrideAttrs (attrs: { + hindent = (externalSrc super.hindent pkgs.haskellPackages.hindent).overrideAttrs (attrs: { packageRequires = [ self.haskell-mode ]; }); @@ -169,7 +169,7 @@ let dontUseCmakeBuildDir = true; doCheck = true; packageRequires = [ self.emacs ]; - nativeBuildInputs = [ external.cmake external.llvmPackages.llvm external.llvmPackages.clang ]; + nativeBuildInputs = [ pkgs.cmake pkgs.llvmPackages.llvm pkgs.llvmPackages.clang ]; }); # tries to write a log file to $HOME @@ -286,18 +286,18 @@ let # part of a larger package notmuch = dontConfigure super.notmuch; - rtags = dontConfigure (externalSrc super.rtags external.rtags); + rtags = dontConfigure (externalSrc super.rtags pkgs.rtags); rtags-xref = dontConfigure super.rtags; shm = super.shm.overrideAttrs (attrs: { - propagatedUserEnvPkgs = [ external.structured-haskell-mode ]; + propagatedUserEnvPkgs = [ pkgs.haskellPackages.structured-haskell-mode ]; }); # Telega has a server portion for it's network protocol telega = super.telega.overrideAttrs (old: { buildInputs = old.buildInputs ++ [ pkgs.tdlib ]; - nativeBuildInputs = [ external.pkg-config ]; + nativeBuildInputs = [ pkgs.pkg-config ]; postBuild = '' cd source/server @@ -314,12 +314,12 @@ let treemacs-magit = super.treemacs-magit.overrideAttrs (attrs: { # searches for Git at build time nativeBuildInputs = - (attrs.nativeBuildInputs or [ ]) ++ [ external.git ]; + (attrs.nativeBuildInputs or [ ]) ++ [ pkgs.git ]; }); vdiff-magit = super.vdiff-magit.overrideAttrs (attrs: { nativeBuildInputs = - (attrs.nativeBuildInputs or [ ]) ++ [ external.git ]; + (attrs.nativeBuildInputs or [ ]) ++ [ pkgs.git ]; }); zmq = super.zmq.overrideAttrs (old: { @@ -328,11 +328,11 @@ let make ''; nativeBuildInputs = [ - external.autoconf - external.automake - external.pkg-config - external.libtool - (external.zeromq.override { enableDrafts = true; }) + pkgs.autoconf + pkgs.automake + pkgs.pkg-config + pkgs.libtool + (pkgs.zeromq.override { enableDrafts = true; }) ]; postInstall = '' mv $out/share/emacs/site-lisp/elpa/zmq-*/src/.libs/emacs-zmq.so $out/share/emacs/site-lisp/elpa/zmq-* @@ -415,7 +415,7 @@ let window-numbering = markBroken super.window-numbering; editorconfig = super.editorconfig.overrideAttrs (attrs: { - propagatedUserEnvPkgs = [ external.editorconfig-core-c ]; + propagatedUserEnvPkgs = [ pkgs.editorconfig-core-c ]; }); # missing dependencies @@ -433,7 +433,7 @@ let racer = super.racer.overrideAttrs (attrs: { postPatch = attrs.postPatch or "" + '' substituteInPlace racer.el \ - --replace /usr/local/src/rust/src ${external.rustPlatform.rustcSrc} + --replace /usr/local/src/rust/src ${pkgs.rustPlatform.rustcSrc} ''; }); @@ -462,7 +462,7 @@ let w3m = super.w3m.override (args: { melpaBuild = drv: args.melpaBuild (drv // { prePatch = - let w3m = "${lib.getBin external.w3m}/bin/w3m"; in + let w3m = "${lib.getBin pkgs.w3m}/bin/w3m"; in '' substituteInPlace w3m.el \ --replace 'defcustom w3m-command nil' \ diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 6f1dc0cf1da0..157064f58c58 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -21960,15 +21960,6 @@ in melpaBuild = callPackage ../build-support/emacs/melpa.nix { inherit emacs; }; - - external = { - inherit (haskellPackages) - ghc-mod structured-haskell-mode Agda hindent; - inherit - autoconf automake editorconfig-core-c git libffi libpng pkg-config - poppler rtags w3m zlib substituteAll rustPlatform cmake llvmPackages - libtool zeromq openssl ott; - }; }; inherit (gnome3) empathy; diff --git a/pkgs/top-level/emacs-packages.nix b/pkgs/top-level/emacs-packages.nix index 329fb5725829..c883a5fd549b 100644 --- a/pkgs/top-level/emacs-packages.nix +++ b/pkgs/top-level/emacs-packages.nix @@ -38,7 +38,6 @@ , trivialBuild , melpaBuild -, external , pkgs }: @@ -50,7 +49,7 @@ let # Contains both melpa stable & unstable melpaGeneric = import ../applications/editors/emacs-modes/melpa-packages.nix { - inherit external lib pkgs; + inherit lib pkgs; }; mkMelpaStablePackages = melpaGeneric "stable"; mkMelpaPackages = melpaGeneric "unstable"; @@ -64,7 +63,7 @@ let }; mkManualPackages = import ../applications/editors/emacs-modes/manual-packages.nix { - inherit external lib pkgs; + inherit lib pkgs; }; in lib.makeScope newScope (self: lib.makeOverridable ({ From b673be833616a92677fb3fdffa8e1a85c74af1d0 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Wed, 24 Feb 2021 14:54:25 +0100 Subject: [PATCH 2/5] emacsPackagesFor: Internalise trivialBuild/melpaBuild I want less strangeness that's not obviously overrideable. --- pkgs/top-level/all-packages.nix | 8 -------- pkgs/top-level/emacs-packages.nix | 10 ++++++++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 157064f58c58..1790312c7313 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -21952,14 +21952,6 @@ in inherit fetchFromGitHub fetchurl; inherit emacs texinfo makeWrapper runCommand writeText; inherit (xorg) lndir; - - trivialBuild = callPackage ../build-support/emacs/trivial.nix { - inherit emacs; - }; - - melpaBuild = callPackage ../build-support/emacs/melpa.nix { - inherit emacs; - }; }; inherit (gnome3) empathy; diff --git a/pkgs/top-level/emacs-packages.nix b/pkgs/top-level/emacs-packages.nix index c883a5fd549b..076e67a1e740 100644 --- a/pkgs/top-level/emacs-packages.nix +++ b/pkgs/top-level/emacs-packages.nix @@ -35,14 +35,20 @@ { lib, newScope, stdenv, fetchurl, fetchFromGitHub, runCommand, writeText , emacs, texinfo, lndir, makeWrapper -, trivialBuild -, melpaBuild , pkgs }: let + trivialBuild = pkgs.callPackage ../build-support/emacs/trivial.nix { + inherit emacs; + }; + + melpaBuild = pkgs.callPackage ../build-support/emacs/melpa.nix { + inherit emacs; + }; + mkElpaPackages = import ../applications/editors/emacs-modes/elpa-packages.nix { inherit lib stdenv texinfo writeText; }; From c68c81fb0150b251b2e72d9cdd5d735403c3df50 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Wed, 24 Feb 2021 15:01:08 +0100 Subject: [PATCH 3/5] emacsPackagesFor: Remove all pkgs inherits from call site --- pkgs/top-level/all-packages.nix | 7 +------ pkgs/top-level/emacs-packages.nix | 15 ++++++--------- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1790312c7313..fcabf57cf4b2 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -21947,12 +21947,7 @@ in stdenv = if stdenv.cc.isClang then llvmPackages_6.stdenv else stdenv; }; - emacsPackagesFor = emacs: import ./emacs-packages.nix { - inherit lib newScope stdenv pkgs; - inherit fetchFromGitHub fetchurl; - inherit emacs texinfo makeWrapper runCommand writeText; - inherit (xorg) lndir; - }; + emacsPackagesFor = emacs: import ./emacs-packages.nix { inherit pkgs lib emacs; }; inherit (gnome3) empathy; diff --git a/pkgs/top-level/emacs-packages.nix b/pkgs/top-level/emacs-packages.nix index 076e67a1e740..d3c62b3ff779 100644 --- a/pkgs/top-level/emacs-packages.nix +++ b/pkgs/top-level/emacs-packages.nix @@ -32,12 +32,7 @@ # `meta` with `platforms` and `homepage` set to something you are # unlikely to want to override for most packages -{ lib, newScope, stdenv, fetchurl, fetchFromGitHub, runCommand, writeText - -, emacs, texinfo, lndir, makeWrapper - -, pkgs -}: +{ pkgs, lib ? pkgs.lib, emacs }: let @@ -50,7 +45,8 @@ let }; mkElpaPackages = import ../applications/editors/emacs-modes/elpa-packages.nix { - inherit lib stdenv texinfo writeText; + inherit (pkgs) stdenv texinfo writeText; + inherit lib; }; # Contains both melpa stable & unstable @@ -65,14 +61,15 @@ let }; emacsWithPackages = import ../build-support/emacs/wrapper.nix { - inherit lib lndir makeWrapper runCommand; + inherit (pkgs) lndir makeWrapper runCommand; + inherit lib; }; mkManualPackages = import ../applications/editors/emacs-modes/manual-packages.nix { inherit lib pkgs; }; -in lib.makeScope newScope (self: lib.makeOverridable ({ +in lib.makeScope pkgs.newScope (self: lib.makeOverridable ({ elpaPackages ? mkElpaPackages self , melpaStablePackages ? mkMelpaStablePackages self , melpaPackages ? mkMelpaPackages self From 2b84cf6e185281d2c644f73528c20b371e384325 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Wed, 24 Feb 2021 15:25:48 +0100 Subject: [PATCH 4/5] emacs-packages: Make pkgs & lib overrideable With these changes it's possible to override pkgs & lib by: ``` emacs.pkgs.override { pkgs = fooPkgs; } ``` and get them to coherently apply to all emacs packages. --- pkgs/top-level/all-packages.nix | 6 ++- pkgs/top-level/emacs-packages.nix | 73 ++++++++++++++++--------------- 2 files changed, 43 insertions(+), 36 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index fcabf57cf4b2..918dde2e2230 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -21947,7 +21947,11 @@ in stdenv = if stdenv.cc.isClang then llvmPackages_6.stdenv else stdenv; }; - emacsPackagesFor = emacs: import ./emacs-packages.nix { inherit pkgs lib emacs; }; + emacsPackagesFor = emacs: import ./emacs-packages.nix { + inherit (lib) makeScope makeOverridable; + inherit emacs; + pkgs' = pkgs; # default pkgs used for bootstrapping the emacs package set + }; inherit (gnome3) empathy; diff --git a/pkgs/top-level/emacs-packages.nix b/pkgs/top-level/emacs-packages.nix index d3c62b3ff779..cb81a5308410 100644 --- a/pkgs/top-level/emacs-packages.nix +++ b/pkgs/top-level/emacs-packages.nix @@ -32,49 +32,42 @@ # `meta` with `platforms` and `homepage` set to something you are # unlikely to want to override for most packages -{ pkgs, lib ? pkgs.lib, emacs }: +{ pkgs', makeScope, makeOverridable, emacs }: let - trivialBuild = pkgs.callPackage ../build-support/emacs/trivial.nix { - inherit emacs; - }; - - melpaBuild = pkgs.callPackage ../build-support/emacs/melpa.nix { - inherit emacs; - }; - - mkElpaPackages = import ../applications/editors/emacs-modes/elpa-packages.nix { + mkElpaPackages = { pkgs, lib }: import ../applications/editors/emacs-modes/elpa-packages.nix { inherit (pkgs) stdenv texinfo writeText; inherit lib; }; # Contains both melpa stable & unstable - melpaGeneric = import ../applications/editors/emacs-modes/melpa-packages.nix { - inherit lib pkgs; - }; - mkMelpaStablePackages = melpaGeneric "stable"; - mkMelpaPackages = melpaGeneric "unstable"; - - mkOrgPackages = import ../applications/editors/emacs-modes/org-packages.nix { - inherit lib; - }; - - emacsWithPackages = import ../build-support/emacs/wrapper.nix { - inherit (pkgs) lndir makeWrapper runCommand; - inherit lib; - }; - - mkManualPackages = import ../applications/editors/emacs-modes/manual-packages.nix { + melpaGeneric = { pkgs, lib }: import ../applications/editors/emacs-modes/melpa-packages.nix { inherit lib pkgs; }; -in lib.makeScope pkgs.newScope (self: lib.makeOverridable ({ - elpaPackages ? mkElpaPackages self - , melpaStablePackages ? mkMelpaStablePackages self - , melpaPackages ? mkMelpaPackages self - , orgPackages ? mkOrgPackages self - , manualPackages ? mkManualPackages self + mkOrgPackages = { lib }: import ../applications/editors/emacs-modes/org-packages.nix { + inherit lib; + }; + + mkManualPackages = { pkgs, lib }: import ../applications/editors/emacs-modes/manual-packages.nix { + inherit lib pkgs; + }; + + emacsWithPackages = { pkgs, lib }: import ../build-support/emacs/wrapper.nix { + inherit (pkgs) makeWrapper runCommand; + inherit (pkgs.xorg) lndir; + inherit lib; + }; + +in makeScope pkgs'.newScope (self: makeOverridable ({ + pkgs ? pkgs' + , lib ? pkgs.lib + , elpaPackages ? mkElpaPackages { inherit pkgs lib; } self + , melpaStablePackages ? melpaGeneric { inherit pkgs lib; } "stable" self + , melpaPackages ? melpaGeneric { inherit pkgs lib; } "unstable" self + , orgPackages ? mkOrgPackages { inherit lib; } self + , manualPackages ? mkManualPackages { inherit pkgs lib; } self }: ({} // elpaPackages // { inherit elpaPackages; } // melpaStablePackages // { inherit melpaStablePackages; } @@ -82,8 +75,18 @@ in lib.makeScope pkgs.newScope (self: lib.makeOverridable ({ // orgPackages // { inherit orgPackages; } // manualPackages // { inherit manualPackages; } // { - inherit emacs melpaBuild trivialBuild; - emacsWithPackages = emacsWithPackages self; - withPackages = emacsWithPackages self; + + inherit emacs; + + trivialBuild = pkgs.callPackage ../build-support/emacs/trivial.nix { + inherit (self) emacs; + }; + + melpaBuild = pkgs.callPackage ../build-support/emacs/melpa.nix { + inherit (self) emacs; + }; + + emacsWithPackages = emacsWithPackages { inherit pkgs lib; } self; + withPackages = emacsWithPackages { inherit pkgs lib; } self; }) ) {}) From 1f18e81fd6bd8c28274acfd07ec7f4fda779e033 Mon Sep 17 00:00:00 2001 From: adisbladis Date: Wed, 24 Feb 2021 15:42:20 +0100 Subject: [PATCH 5/5] emacs-packages: Remove old `FOR CONTRIBUTORS` comment It doesn't apply any more. --- pkgs/top-level/emacs-packages.nix | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/pkgs/top-level/emacs-packages.nix b/pkgs/top-level/emacs-packages.nix index cb81a5308410..d708a97a65c1 100644 --- a/pkgs/top-level/emacs-packages.nix +++ b/pkgs/top-level/emacs-packages.nix @@ -21,17 +21,6 @@ (package-initialize) */ -## FOR CONTRIBUTORS -# -# When adding a new package here please note that -# * please use `elpaBuild` for pre-built package.el packages and -# `melpaBuild` or `trivialBuild` if the package must actually -# be built from the source. -# * lib.licenses are `with`ed on top of the file here -# * both trivialBuild and melpaBuild will automatically derive a -# `meta` with `platforms` and `homepage` set to something you are -# unlikely to want to override for most packages - { pkgs', makeScope, makeOverridable, emacs }: let