default.nix: run nixfmt
This commit is contained in:
99
default.nix
99
default.nix
@@ -1,14 +1,15 @@
|
||||
{ # The files would be going to ~/.config/doom (~/.doom.d)
|
||||
doomPrivateDir
|
||||
/* Extra packages to install
|
||||
doomPrivateDir
|
||||
/* Extra packages to install
|
||||
|
||||
Useful for non-emacs packages containing emacs bindings (e.g.
|
||||
mu4e).
|
||||
|
||||
Example:
|
||||
extraPackages = epkgs: [ pkgs.mu ];
|
||||
*/
|
||||
, extraPackages ? epkgs: []
|
||||
*/
|
||||
, extraPackages ? epkgs:
|
||||
[ ]
|
||||
/* Extra configuration to source during initialization
|
||||
|
||||
Use this to refer other nix derivations.
|
||||
@@ -24,7 +25,7 @@
|
||||
Only used to get emacs package, if `bundledPackages` is set.
|
||||
*/
|
||||
, emacsPackages
|
||||
/* Overlay to customize emacs (elisp) dependencies
|
||||
/* Overlay to customize emacs (elisp) dependencies
|
||||
|
||||
See overrides.nix for addition examples.
|
||||
|
||||
@@ -34,8 +35,9 @@
|
||||
buildInputs = esuper.buildInputs ++ [ pkgs.git ];
|
||||
});
|
||||
};
|
||||
*/
|
||||
, emacsPackagesOverlay ? self: super: { }
|
||||
*/
|
||||
, emacsPackagesOverlay ? self: super:
|
||||
{ }
|
||||
/* Use bundled revision of github.com/nix-community/emacs-overlay
|
||||
as `emacsPackages`.
|
||||
*/
|
||||
@@ -52,38 +54,31 @@
|
||||
"emacs-overlay" = fetchFromGitHub { owner = /* ...*\/; };
|
||||
};
|
||||
*/
|
||||
, dependencyOverrides ? { }
|
||||
, lib
|
||||
, pkgs
|
||||
, stdenv
|
||||
, buildEnv
|
||||
, makeWrapper
|
||||
, runCommand
|
||||
, fetchFromGitHub
|
||||
, substituteAll
|
||||
, writeShellScript
|
||||
, writeShellScriptBin
|
||||
, writeTextDir }:
|
||||
, dependencyOverrides ? { }, lib, pkgs, stdenv, buildEnv, makeWrapper
|
||||
, runCommand, fetchFromGitHub, substituteAll, writeShellScript
|
||||
, writeShellScriptBin, writeTextDir }:
|
||||
|
||||
assert (lib.assertMsg (
|
||||
(builtins.isPath doomPrivateDir) ||
|
||||
(lib.isDerivation doomPrivateDir) ||
|
||||
(lib.isStorePath doomPrivateDir)) "doomPrivateDir must be either a path, a derivation or a stringified store path");
|
||||
assert (lib.assertMsg ((builtins.isPath doomPrivateDir)
|
||||
|| (lib.isDerivation doomPrivateDir) || (lib.isStorePath doomPrivateDir))
|
||||
"doomPrivateDir must be either a path, a derivation or a stringified store path");
|
||||
|
||||
let
|
||||
flake = import ./flake-compat-helper.nix { src=./.; };
|
||||
lock = p: if dependencyOverrides ? ${p}
|
||||
then dependencyOverrides.${p}
|
||||
else flake.inputs.${p};
|
||||
flake = import ./flake-compat-helper.nix { src = ./.; };
|
||||
lock = p:
|
||||
if dependencyOverrides ? ${p} then
|
||||
dependencyOverrides.${p}
|
||||
else
|
||||
flake.inputs.${p};
|
||||
# Packages we need to get the default doom configuration run
|
||||
overrides = self: super:
|
||||
(pkgs.callPackage ./overrides.nix { inherit lock; } self super) // (emacsPackagesOverlay self super);
|
||||
(pkgs.callPackage ./overrides.nix { inherit lock; } self super)
|
||||
// (emacsPackagesOverlay self super);
|
||||
|
||||
# Stage 1: prepare source for byte-compilation
|
||||
doomSrc = stdenv.mkDerivation {
|
||||
name = "doom-src";
|
||||
src = lock "doom-emacs";
|
||||
phases = ["unpackPhase" "patchPhase" "installPhase"];
|
||||
phases = [ "unpackPhase" "patchPhase" "installPhase" ];
|
||||
patches = [
|
||||
(substituteAll {
|
||||
src = ./fix-paths.patch;
|
||||
@@ -97,32 +92,26 @@ let
|
||||
};
|
||||
|
||||
fmt = {
|
||||
reset=''\\033[0m'';
|
||||
bold=''\\033[1m'';
|
||||
red=''\\033[31m'';
|
||||
green=''\\033[32m'';
|
||||
reset = "\\\\033[0m";
|
||||
bold = "\\\\033[1m";
|
||||
red = "\\\\033[31m";
|
||||
green = "\\\\033[32m";
|
||||
};
|
||||
|
||||
# Bundled version of `emacs-overlay`
|
||||
emacs-overlay = import (lock "emacs-overlay") pkgs pkgs;
|
||||
|
||||
# Stage 2: install dependencies and byte-compile prepared source
|
||||
doomLocal =
|
||||
let
|
||||
doomLocal = let
|
||||
straight-env = pkgs.callPackage (lock "nix-straight") {
|
||||
emacsPackages =
|
||||
if bundledPackages then
|
||||
let
|
||||
epkgs = emacs-overlay.emacsPackagesFor emacsPackages.emacs;
|
||||
emacsPackages = if bundledPackages then
|
||||
let epkgs = emacs-overlay.emacsPackagesFor emacsPackages.emacs;
|
||||
in epkgs.overrideScope' overrides
|
||||
else
|
||||
emacsPackages.overrideScope' overrides;
|
||||
emacs = emacsPackages.emacsWithPackages extraPackages;
|
||||
emacsLoadFiles = [ ./advice.el ];
|
||||
emacsArgs = [
|
||||
"--"
|
||||
"install"
|
||||
];
|
||||
emacsArgs = [ "--" "install" ];
|
||||
|
||||
# Need to reference a store path here, as byte-compilation will bake-in
|
||||
# absolute path to source files.
|
||||
@@ -220,9 +209,7 @@ let
|
||||
(load "${doom-emacs}/early-init.el"))
|
||||
(load "${doom-emacs}/init.el")
|
||||
'';
|
||||
in (emacsPackages.emacsWithPackages (epkgs: [
|
||||
load-config-from-site
|
||||
]));
|
||||
in (emacsPackages.emacsWithPackages (epkgs: [ load-config-from-site ]));
|
||||
|
||||
build-summary = writeShellScript "build-summary" ''
|
||||
printf "\n${fmt.green}Successfully built nix-doom-emacs!${fmt.reset}\n"
|
||||
@@ -230,9 +217,9 @@ let
|
||||
printf "${fmt.bold} ==> private configuration is installed to ${doomDir}${fmt.reset}\n"
|
||||
printf "${fmt.bold} ==> Dependencies are installed to ${doomLocal}${fmt.reset}\n"
|
||||
'';
|
||||
in
|
||||
emacs.overrideAttrs (esuper:
|
||||
let cmd = ''
|
||||
in emacs.overrideAttrs (esuper:
|
||||
let
|
||||
cmd = ''
|
||||
wrapEmacs() {
|
||||
wrapProgram $1 \
|
||||
--set DOOMDIR ${doomDir} \
|
||||
@@ -262,15 +249,9 @@ emacs.overrideAttrs (esuper:
|
||||
ln -s ${esuper.emacs}/share $out
|
||||
${build-summary}
|
||||
'';
|
||||
in
|
||||
if esuper ? buildCommand then
|
||||
{
|
||||
in if esuper ? buildCommand then {
|
||||
buildCommand = esuper.buildCommand + cmd;
|
||||
}
|
||||
else if esuper ? installPhase then
|
||||
{
|
||||
} else if esuper ? installPhase then {
|
||||
installPhase = esuper.installPhase + cmd;
|
||||
}
|
||||
else
|
||||
abort "emacsWithPackages uses unknown derivation type"
|
||||
)
|
||||
} else
|
||||
abort "emacsWithPackages uses unknown derivation type")
|
||||
|
Reference in New Issue
Block a user