Refactor full init.el building
This commit is contained in:
parent
9d01c40caf
commit
b16774f129
4 changed files with 46 additions and 27 deletions
34
build-helpers/full-init.nix
Normal file
34
build-helpers/full-init.nix
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
# Copyright 2024 Google LLC
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
|
||||||
|
{
|
||||||
|
callPackage,
|
||||||
|
doomSource,
|
||||||
|
emacs,
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
doomDirWithAllModules = callPackage ./doomscript.nix {
|
||||||
|
name = "doom-full-init";
|
||||||
|
inherit doomSource emacs;
|
||||||
|
script = ./full-init;
|
||||||
|
scriptArgs = "-o $out";
|
||||||
|
};
|
||||||
|
|
||||||
|
doomDirWithAllModulesAndFlags = callPackage ./doomscript.nix {
|
||||||
|
name = "doom-full-init";
|
||||||
|
inherit doomSource emacs;
|
||||||
|
script = ./full-init;
|
||||||
|
scriptArgs = "--flags -o $out";
|
||||||
|
};
|
||||||
|
}
|
||||||
10
checks.nix
10
checks.nix
|
|
@ -13,6 +13,7 @@
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
{
|
{
|
||||||
|
callPackages,
|
||||||
emptyDirectory,
|
emptyDirectory,
|
||||||
lib,
|
lib,
|
||||||
linkFarm,
|
linkFarm,
|
||||||
|
|
@ -22,11 +23,14 @@
|
||||||
writeText,
|
writeText,
|
||||||
writeTextDir,
|
writeTextDir,
|
||||||
|
|
||||||
|
doomSource,
|
||||||
makeDoomPackages,
|
makeDoomPackages,
|
||||||
toInit,
|
toInit,
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (lib.generators) toPretty;
|
inherit (lib.generators) toPretty;
|
||||||
|
inherit (callPackages ./build-helpers/full-init.nix { inherit doomSource; })
|
||||||
|
doomDirWithAllModules doomDirWithAllModulesAndFlags;
|
||||||
common = {
|
common = {
|
||||||
doomLocalDir = "~/.local/share/nix-doom-unstraightened";
|
doomLocalDir = "~/.local/share/nix-doom-unstraightened";
|
||||||
experimentalFetchTree = true;
|
experimentalFetchTree = true;
|
||||||
|
|
@ -34,8 +38,6 @@ let
|
||||||
mkDoom = args: (makeDoomPackages (common // args)).doomEmacs;
|
mkDoom = args: (makeDoomPackages (common // args)).doomEmacs;
|
||||||
mkDoomDir = args: writeTextDir "init.el" (toInit args);
|
mkDoomDir = args: writeTextDir "init.el" (toInit args);
|
||||||
minimalDoomDir = mkDoomDir { config = [ "default" ]; };
|
minimalDoomDir = mkDoomDir { config = [ "default" ]; };
|
||||||
allModsDoomDir = (makeDoomPackages (common // { doomDir = emptyDirectory; })).doomDirWithAllModules;
|
|
||||||
allFlagsDoomDir = (makeDoomPackages (common // { doomDir = emptyDirectory; })).doomDirWithAllModulesAndFlags;
|
|
||||||
doomTest = name: init: doomArgs: testers.testEqualContents {
|
doomTest = name: init: doomArgs: testers.testEqualContents {
|
||||||
assertion = "name = ${name}; modules = ${toPretty {} init}; args = ${toPretty {} doomArgs};";
|
assertion = "name = ${name}; modules = ${toPretty {} init}; args = ${toPretty {} doomArgs};";
|
||||||
expected = writeText "doom-expected" "Doom functions";
|
expected = writeText "doom-expected" "Doom functions";
|
||||||
|
|
@ -68,8 +70,8 @@ in {
|
||||||
doomDir = minimalDoomDir;
|
doomDir = minimalDoomDir;
|
||||||
extraPackages = epkgs: [ epkgs.vterm epkgs.treesit-grammars.with-all-grammars ];
|
extraPackages = epkgs: [ epkgs.vterm epkgs.treesit-grammars.with-all-grammars ];
|
||||||
};
|
};
|
||||||
allModules = mkDoom { doomDir = allModsDoomDir; };
|
allModules = mkDoom { doomDir = doomDirWithAllModules; };
|
||||||
allModulesAndFlags = mkDoom { doomDir = allFlagsDoomDir; };
|
allModulesAndFlags = mkDoom { doomDir = doomDirWithAllModulesAndFlags; };
|
||||||
example = mkDoom { doomDir = ./doomdir; };
|
example = mkDoom { doomDir = ./doomdir; };
|
||||||
example-without-loader = mkDoom {
|
example-without-loader = mkDoom {
|
||||||
doomDir = ./doomdir;
|
doomDir = ./doomdir;
|
||||||
|
|
|
||||||
18
default.nix
18
default.nix
|
|
@ -56,22 +56,6 @@ let
|
||||||
inherit (lib) optionalAttrs optionalString;
|
inherit (lib) optionalAttrs optionalString;
|
||||||
inherit (import ./fetch-overrides.nix) extraPins extraUrls;
|
inherit (import ./fetch-overrides.nix) extraPins extraUrls;
|
||||||
|
|
||||||
# This doesn't belong here: it does not depend on doomDir (only on doomSource).
|
|
||||||
# But this is where all my doomscript execution lives.
|
|
||||||
doomDirWithAllModules = callPackage ./build-helpers/doomscript.nix {
|
|
||||||
name = "doom-full-init";
|
|
||||||
inherit doomSource emacs;
|
|
||||||
script = ./build-helpers/full-init;
|
|
||||||
scriptArgs = "-o $out";
|
|
||||||
};
|
|
||||||
|
|
||||||
doomDirWithAllModulesAndFlags = callPackage ./build-helpers/doomscript.nix {
|
|
||||||
name = "doom-full-init";
|
|
||||||
inherit doomSource emacs;
|
|
||||||
script = ./build-helpers/full-init;
|
|
||||||
scriptArgs = "--flags -o $out";
|
|
||||||
};
|
|
||||||
|
|
||||||
# Step 1: determine which Emacs packages to pull in.
|
# Step 1: determine which Emacs packages to pull in.
|
||||||
#
|
#
|
||||||
# Inputs: Doom, original DOOMDIR (only init.el and packages.el are used).
|
# Inputs: Doom, original DOOMDIR (only init.el and packages.el are used).
|
||||||
|
|
@ -419,5 +403,5 @@ let
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
inherit doomDirWithAllModules doomDirWithAllModulesAndFlags doomEmacs emacsWithDoom;
|
inherit doomEmacs emacsWithDoom;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
11
flake.nix
11
flake.nix
|
|
@ -77,6 +77,7 @@
|
||||||
in {
|
in {
|
||||||
checks = perSystemPackages (pkgs: pkgs.callPackages ./checks.nix {
|
checks = perSystemPackages (pkgs: pkgs.callPackages ./checks.nix {
|
||||||
inherit toInit;
|
inherit toInit;
|
||||||
|
doomSource = doomemacs;
|
||||||
makeDoomPackages = doomFromPackages pkgs;
|
makeDoomPackages = doomFromPackages pkgs;
|
||||||
});
|
});
|
||||||
packages = perSystemPackages (pkgs: {
|
packages = perSystemPackages (pkgs: {
|
||||||
|
|
@ -91,17 +92,15 @@
|
||||||
}).doomEmacs;
|
}).doomEmacs;
|
||||||
# TODO: cache more packages, cache for more Emacsen.
|
# TODO: cache more packages, cache for more Emacsen.
|
||||||
cachix-packages = let
|
cachix-packages = let
|
||||||
# (Shouldn't need doomFromPackages, see doomDirWithAllModules definition)
|
inherit (pkgs.callPackages ./build-helpers/full-init.nix {
|
||||||
fullDoomDir = (doomFromPackages pkgs {
|
doomSource = doomemacs;
|
||||||
doomDir = pkgs.emptyDirectory;
|
}) doomDirWithAllModules;
|
||||||
doomLocalDir = "~/.local/share/nix-doom-unstraightened";
|
|
||||||
}).doomDirWithAllModules;
|
|
||||||
in
|
in
|
||||||
pkgs.linkFarm "unstraightened-cachix-packages" {
|
pkgs.linkFarm "unstraightened-cachix-packages" {
|
||||||
inherit doomemacs;
|
inherit doomemacs;
|
||||||
full-emacs29 = (doomFromPackages pkgs {
|
full-emacs29 = (doomFromPackages pkgs {
|
||||||
emacs = pkgs.emacs29;
|
emacs = pkgs.emacs29;
|
||||||
doomDir = fullDoomDir;
|
doomDir = doomDirWithAllModules;
|
||||||
doomLocalDir = "~/.local/share/nix-doom-unstraightened";
|
doomLocalDir = "~/.local/share/nix-doom-unstraightened";
|
||||||
experimentalFetchTree = true;
|
experimentalFetchTree = true;
|
||||||
}).doomEmacs.emacsWithPackages.deps;
|
}).doomEmacs.emacsWithPackages.deps;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue