Move default.nix into overlays dir

This is to prepare for splitting the overlay into two seperated ones.
This commit is contained in:
Lin Jian 2022-10-04 22:13:26 +08:00
parent 078ea145c9
commit a6329647be
No known key found for this signature in database
GPG key ID: A6698D36434F75A5
2 changed files with 1 additions and 1 deletions

205
overlays/default.nix Normal file
View file

@ -0,0 +1,205 @@
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;
}