Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,25 @@ It is recommended you read Nixpkgs and NixOS documentation on package overlays a

** Contents of the overlay

*** Elpa
This overlay consists of two overlays: =emacs= and =package=.

You can use both of them as a whole overlay or only one of them.

*** =package= overlay

**** Elpa
Daily generations of Elpa.

*** Melpa / Melpa stable
**** Melpa / Melpa stable
Daily generations of Melpa & Melpa stable attribute sets.

*** EXWM & needed dependencies
**** EXWM & needed dependencies
This overlay provides fresh versions of EXWM and dependencies. This is
updated daily.

*** Emacs from Git and latest (including pre-releases)
*** =emacs= overlay

**** Emacs from Git and latest (including pre-releases)
This overlay also provides two versions (latest from git) for Emacs. These
are updated daily.

Expand All @@ -63,7 +71,7 @@ We also provide two attributes named =emacsGit-nox= and =emacsUnstable-nox=
if you wish to have Emacs built without X dependencies.
=emacsPgtk= and =emacsPgtkNativeComp= use the experimental pgtk feature which supports Wayland natively.

** Extra library functionality
**** Extra library functionality
This overlay comes with extra functions to generate an Emacs closure
from various types of dependency declaration. (These are abstractions
on top of =emacsWithPackages=.)
Expand Down
205 changes: 1 addition & 204 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,205 +1,2 @@
self: super:
let
mkExDrv = emacsPackages: name: args:
let
repoMeta = super.lib.importJSON (./repos/exwm/. + "/${name}.json");
in
emacsPackages.melpaBuild (
args // {
pname = name;
ename = name;
version = repoMeta.version;
commit = repoMeta.rev;

recipe = builtins.toFile "recipe" ''
(${name} :fetcher github
:repo "ch11ng/${name}")
'';

src = super.fetchFromGitHub {
owner = "ch11ng";
repo = name;
inherit (repoMeta) rev sha256;
};
}
);

mkGitEmacs = namePrefix: jsonFile: { ... }@args:
let
repoMeta = super.lib.importJSON jsonFile;
fetcher =
if repoMeta.type == "savannah" then
super.fetchFromSavannah
else if repoMeta.type == "github" then
super.fetchFromGitHub
else
throw "Unknown repository type ${repoMeta.type}!";
in
builtins.foldl'
(drv: fn: fn drv)
super.emacs
[

(drv: drv.override ({ srcRepo = true; } // args))

(
drv: drv.overrideAttrs (
old: {
name = "${namePrefix}-${repoMeta.version}";
inherit (repoMeta) version;
src = fetcher (builtins.removeAttrs repoMeta [ "type" "version" ]);

patches = [ ];

postPatch = old.postPatch + ''
substituteInPlace lisp/loadup.el \
--replace '(emacs-repository-get-version)' '"${repoMeta.rev}"' \
--replace '(emacs-repository-get-branch)' '"master"'
'' +
# XXX: remove when https://github.com/NixOS/nixpkgs/pull/193621 is merged
(super.lib.optionalString (old ? NATIVE_FULL_AOT)
(let backendPath = (super.lib.concatStringsSep " "
(builtins.map (x: ''\"-B${x}\"'') [
# Paths necessary so the JIT compiler finds its libraries:
"${super.lib.getLib self.libgccjit}/lib"
"${super.lib.getLib self.libgccjit}/lib/gcc"
"${super.lib.getLib self.stdenv.cc.libc}/lib"

# Executable paths necessary for compilation (ld, as):
"${super.lib.getBin self.stdenv.cc.cc}/bin"
"${super.lib.getBin self.stdenv.cc.bintools}/bin"
"${super.lib.getBin self.stdenv.cc.bintools.bintools}/bin"
]));
in ''
substituteInPlace lisp/emacs-lisp/comp.el --replace \
"(defcustom comp-libgccjit-reproducer nil" \
"(setq native-comp-driver-options '(${backendPath}))
(defcustom comp-libgccjit-reproducer nil"
''));
}
)
)

# reconnect pkgs to the built emacs
(
drv:
let
result = drv.overrideAttrs (old: {
passthru = old.passthru // {
pkgs = self.emacsPackagesFor result;
};
});
in
result
)
];

mkPgtkEmacs = namePrefix: jsonFile: { ... }@args: (mkGitEmacs namePrefix jsonFile args).overrideAttrs (
old: {
configureFlags = (super.lib.remove "--with-xft" old.configureFlags)
++ super.lib.singleton "--with-pgtk";
}
);

emacsGit = mkGitEmacs "emacs-git" ./repos/emacs/emacs-master.json { withSQLite3 = true; withWebP = true; };

emacsNativeComp = super.emacsNativeComp or (mkGitEmacs "emacs-native-comp" ./repos/emacs/emacs-unstable.json { nativeComp = true; });

emacsGitNativeComp = mkGitEmacs "emacs-git-native-comp" ./repos/emacs/emacs-master.json {
withSQLite3 = true;
withWebP = true;
nativeComp = true;
};

emacsPgtk = mkPgtkEmacs "emacs-pgtk" ./repos/emacs/emacs-master.json { withSQLite3 = true; withGTK3 = true; };

emacsPgtkNativeComp = mkPgtkEmacs "emacs-pgtk-native-comp" ./repos/emacs/emacs-master.json { nativeComp = true; withSQLite3 = true; withGTK3 = true; };

emacsUnstable = (mkGitEmacs "emacs-unstable" ./repos/emacs/emacs-unstable.json { });

in
{
inherit emacsGit emacsUnstable;

inherit emacsNativeComp emacsGitNativeComp;

inherit emacsPgtk emacsPgtkNativeComp;

emacsGit-nox = (
(
emacsGit.override {
withNS = false;
withX = false;
withGTK2 = false;
withGTK3 = false;
withWebP = false;
}
).overrideAttrs (
oa: {
name = "${oa.name}-nox";
}
)
);

emacsUnstable-nox = (
(
emacsUnstable.override {
withNS = false;
withX = false;
withGTK2 = false;
withGTK3 = false;
withWebP = false;
}
).overrideAttrs (
oa: {
name = "${oa.name}-nox";
}
)
);

emacsWithPackagesFromUsePackage = import ./elisp.nix { pkgs = self; };

emacsWithPackagesFromPackageRequires = import ./packreq.nix { pkgs = self; };

emacsPackagesFor = emacs: (
(super.emacsPackagesFor emacs).overrideScope' (
eself: esuper:
let
melpaStablePackages = esuper.melpaStablePackages.override {
archiveJson = ./repos/melpa/recipes-archive-melpa.json;
};

melpaPackages = esuper.melpaPackages.override {
archiveJson = ./repos/melpa/recipes-archive-melpa.json;
};

elpaPackages = esuper.elpaPackages.override {
generated = ./repos/elpa/elpa-generated.nix;
};

epkgs = esuper.override {
inherit melpaStablePackages melpaPackages elpaPackages;
};

in
epkgs
// super.lib.optionalAttrs (super.lib.hasAttr "nongnuPackages" esuper) {
nongnuPackages = esuper.nongnuPackages.override {
generated = ./repos/nongnu/nongnu-generated.nix;
};
} // {
xelb = mkExDrv eself "xelb" {
packageRequires = [ eself.cl-generic eself.emacs ];
};

exwm = mkExDrv eself "exwm" {
packageRequires = [ eself.xelb ];
};
}
)
);

} // super.lib.optionalAttrs (super.config.allowAliases or true) {
emacsGcc = builtins.trace "emacsGcc has been renamed to emacsNativeComp, please update your expression." emacsNativeComp;
emacsPgtkGcc = builtins.trace "emacsPgtkGcc has been renamed to emacsPgtkNativeComp, please update your expression." emacsPgtkNativeComp;
}
import ./overlays self super
11 changes: 8 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,19 @@
, flake-utils
}: {
# self: super: must be named final: prev: for `nix flake check` to be happy
overlay = final: prev:
import ./default.nix final prev;
overlays = {
default = final: prev: import ./overlays final prev;
emacs = final: prev: import ./overlays/emacs.nix final prev;
package = final: prev: import ./overlays/package.nix final prev;
};
# for backward compatibility, is safe to delete, not referenced anywhere
overlay = self.overlays.default;
} // flake-utils.lib.eachDefaultSystem (system: (
let
pkgs = import nixpkgs {
inherit system;
config.allowAliases = false;
overlays = [ self.overlay ];
overlays = [ self.overlays.default ];
};
inherit (pkgs) lib;
overlayAttrs = builtins.attrNames (import ./. pkgs pkgs);
Expand Down
10 changes: 10 additions & 0 deletions overlays/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
self: super:
let
inherit (super.lib) foldl' flip extends;
overlays = [
# package overlay must be applied before emacs overlay
(import ./package.nix)
(import ./emacs.nix)
];
in
foldl' (flip extends) (_: super) overlays self
Loading