Tweak toInit input structure
Using an attrset instead of a list allows using Nix's shorthand for nested attrsets, which is much more readable for the simple cases toInit is used for.
This commit is contained in:
parent
c61cd622b7
commit
f8012b8785
2 changed files with 19 additions and 13 deletions
14
checks.nix
14
checks.nix
|
|
@ -37,7 +37,7 @@ 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 = true; };
|
||||||
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";
|
||||||
|
|
@ -77,14 +77,14 @@ in {
|
||||||
doomDir = ./doomdir;
|
doomDir = ./doomdir;
|
||||||
profileName = "";
|
profileName = "";
|
||||||
};
|
};
|
||||||
interactive = doomTest "nix-profile" { config = [ "default" ]; } { };
|
interactive = doomTest "nix-profile" { config.default = true; } { };
|
||||||
interactive-without-loader = doomTest "no-profile" { config = [ "default" ]; } { profileName = ""; };
|
interactive-without-loader = doomTest "no-profile" { config.default = true; } { profileName = ""; };
|
||||||
interactive-no-profile-hack = doomTest "no-profile" { config = [ "default" ]; } { noProfileHack = true; };
|
interactive-no-profile-hack = doomTest "no-profile" { config.default = true; } { noProfileHack = true; };
|
||||||
|
|
||||||
org-re-reveal = doomTest "org-re-reveal" { lang = [ [ "org" "+present" ] ]; } { };
|
org-re-reveal = doomTest "org-re-reveal" { lang.org = [ "+present" ]; } { };
|
||||||
|
|
||||||
# Various tests of module combinations.
|
# Various tests of module combinations.
|
||||||
unpinned-org = doomTest "external-org" { app = [ [ "rss" "+org" ] ]; } { };
|
unpinned-org = doomTest "external-org" { app.rss = [ "+org" ]; } { };
|
||||||
|
|
||||||
extraPackages = doomTest "extraPackages" { config = [ "default" ]; } { extraPackages = epkgs: [ epkgs.vterm ]; };
|
extraPackages = doomTest "extraPackages" { config.default = true; } { extraPackages = epkgs: [ epkgs.vterm ]; };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
18
flake.nix
18
flake.nix
|
|
@ -52,8 +52,14 @@
|
||||||
in
|
in
|
||||||
pkgs.callPackages self mergedArgs;
|
pkgs.callPackages self mergedArgs;
|
||||||
|
|
||||||
|
# Convert a Nix expression to a `doom!` block suitable for init.el.
|
||||||
|
#
|
||||||
|
# Input: a nested attribute set.
|
||||||
|
# The keys of the first level are categories (like `lang`).
|
||||||
|
# The keys of the second level are module names (like `nix`).
|
||||||
|
# The values are lists of module flags, or `true` for no flags.
|
||||||
toInit = let
|
toInit = let
|
||||||
inherit (nixpkgs.lib) concatLines concatStringsSep isList isString mapAttrsToList toPretty;
|
inherit (nixpkgs.lib) concatLines concatStringsSep isList mapAttrsToList toPretty;
|
||||||
in
|
in
|
||||||
attrs:
|
attrs:
|
||||||
concatLines (
|
concatLines (
|
||||||
|
|
@ -62,11 +68,11 @@
|
||||||
cat: modules:
|
cat: modules:
|
||||||
(concatLines (
|
(concatLines (
|
||||||
[ (":" + cat) ]
|
[ (":" + cat) ]
|
||||||
++ (map (
|
++ (mapAttrsToList (
|
||||||
mod:
|
mod: value:
|
||||||
if isString mod then mod
|
if value == true then mod
|
||||||
else if isList mod then "(" + (concatStringsSep " " mod) + ")"
|
else if isList value then "(${mod} ${concatStringsSep " " value})"
|
||||||
else abort "${toPretty mod} not supported"
|
else abort "${toPretty value} not supported"
|
||||||
))
|
))
|
||||||
modules
|
modules
|
||||||
))
|
))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue