diff --git a/doom.nix b/doom.nix index a7baf18..7e39e66 100644 --- a/doom.nix +++ b/doom.nix @@ -242,21 +242,29 @@ let mkdir $out/doomdir/snippets fi rm $out/doomdir/init.el + if [[ -z "${profileName}" ]]; then + setProfile="(setq doom-profile-dir \"$out/profile\")" + else + setProfile="" + fi substitute ${./init.el} $out/doomdir/init.el \ + --subst-var-by maybe-set-profile-dir "$setProfile" \ --subst-var-by user-init "${doomDir}/init.el" \ --subst-var-by straight-base-dir $out ln -sf ${doomIntermediates}/packages.el $out/doomdir/ export DOOMDIR=$out/doomdir - export DOOMPROFILELOADFILE=$out/loader/init.el # DOOMLOCALDIR must be writable, Doom creates some subdirectories. export DOOMLOCALDIR=$(mktemp -d) - ${runtimeShell} ${doomSource}/bin/doomscript ${./build-helpers/build-profile-loader} \ - -n "${profileName}" -b "$out" ${optionalString noProfileHack "-u"} + if [[ -n "${profileName}" ]]; then + export DOOMPROFILELOADFILE=$out/loader/init.el + ${runtimeShell} ${doomSource}/bin/doomscript ${./build-helpers/build-profile-loader} \ + -n "${profileName}" -b "$out" ${optionalString noProfileHack "-u"} - # With DOOMPROFILE set, doom-state-dir and friends are HOME-relative. - export HOME=$(mktemp -d) - export DOOMPROFILE='${profileName}'; + # With DOOMPROFILE set, doom-state-dir and friends are HOME-relative. + export HOME=$(mktemp -d) + export DOOMPROFILE='${profileName}'; + fi ${runtimeShell} ${doomSource}/bin/doomscript ${./build-helpers/build-profile} # Similar to audit-tmpdir.sh in nixpkgs. @@ -270,9 +278,16 @@ let doomEmacs = runCommand "doom-emacs" { nativeBuildInputs = [ makeBinaryWrapper ]; } '' + if [[ -z "${profileName}" ]]; then + profileArgs=() + else + profileArgs=( + --set DOOMPROFILELOADFILE ${doomProfile}/loader/init.el + --set DOOMPROFILE ${profileName} + ) + fi makeWrapper ${emacsWithPackages}/bin/emacs $out/bin/doom-emacs \ - --set DOOMPROFILELOADFILE ${doomProfile}/loader/init.el \ - --set DOOMPROFILE ${profileName} \ + "''${profileArgs[@]}" \ --set DOOMDIR ${doomProfile}/doomdir \ --set-default DOOMLOCALDIR "${doomLocalDir}" \ --add-flags "--init-directory=${doomSource}" diff --git a/flake.nix b/flake.nix index a3bfa67..04262e1 100644 --- a/flake.nix +++ b/flake.nix @@ -47,6 +47,10 @@ doom-minimal = (pkgsWithEmacsOverlay.callPackages ./doom.nix (common // { doomDir = ./doomdirs/minimal; })).doomEmacs; doom-full = (pkgsWithEmacsOverlay.callPackages ./doom.nix (common // { full = true; doomDir = ./doomdirs/minimal; })).doomEmacs; doom-example = (pkgsWithEmacsOverlay.callPackages ./doom.nix (common // { doomDir = ./doomdirs/example; })).doomEmacs; + doom-example-without-loader = (pkgsWithEmacsOverlay.callPackages ./doom.nix (common // { + doomDir = ./doomdirs/example; + profileName = ""; + })).doomEmacs; }); overlays.default = final: prev: let diff --git a/init.el b/init.el index d8d5761..4958548 100644 --- a/init.el +++ b/init.el @@ -17,6 +17,8 @@ ;; Extra initialization code for nix-doom-emacs-unstraightened, run before the ;; normal `init.el'. +@maybe-set-profile-dir@ + (defadvice! nix-doom-skip-core-packages (&rest _) "HACK: don't install straight and core packages.