From 51e61c24fe03cc1221791ef2a72814b717ba6399 Mon Sep 17 00:00:00 2001 From: Marien Zwart Date: Sat, 20 Jul 2024 15:11:36 +1000 Subject: [PATCH] Avoid mktemp Nix promises to run us in an (empty) temporary directory. So we should not need mktemp, we can just use deterministic names. Our temporary directory should already not be leaking into the output (and we enforce that for the profile), so this should just be cleanup that makes debugging slightly easier. --- build-helpers/build-doom-profile.sh | 6 +++--- build-helpers/doomscript.nix | 4 ++-- elisp-packages.nix | 6 ++++-- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/build-helpers/build-doom-profile.sh b/build-helpers/build-doom-profile.sh index 288034a..7fd0ef1 100644 --- a/build-helpers/build-doom-profile.sh +++ b/build-helpers/build-doom-profile.sh @@ -14,7 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -mkdir $out $out/loader $out/doomdir $out/profile $out/straight +mkdir $out $out/loader $out/doomdir $out/profile $out/straight doomlocaldir home ln -s $doomDir/* $out/doomdir/ # yasnippet logs an error at startup if snippets/ does not exist. if ! [[ -e $out/doomdir/snippets ]]; then @@ -35,14 +35,14 @@ ln -sf $doomIntermediates/packages.el $out/doomdir/ export DOOMDIR=$out/doomdir # DOOMLOCALDIR must be writable, Doom creates some subdirectories. -export DOOMLOCALDIR=$(mktemp -d) +export DOOMLOCALDIR="$PWD/doomlocaldir" if [[ -n "$profileName" ]]; then export DOOMPROFILELOADFILE=$out/loader/init.el $runtimeShell $doomSource/bin/doomscript $buildProfileLoader \ ${noProfileHack:+-u} -n "$profileName" -b "$out" # With DOOMPROFILE set, doom-state-dir and friends are HOME-relative. - export HOME=$(mktemp -d) + export HOME="$PWD/home" export DOOMPROFILE="$profileName"; fi $runtimeShell $doomSource/bin/doomscript $buildProfile \ diff --git a/build-helpers/doomscript.nix b/build-helpers/doomscript.nix index 853402a..8133755 100644 --- a/build-helpers/doomscript.nix +++ b/build-helpers/doomscript.nix @@ -36,7 +36,7 @@ runCommandLocal name ) # Set DOOMLOCALDIR somewhere harmless to stop Doom from trying to create it somewhere read-only. '' - mkdir $out - export DOOMLOCALDIR=$(mktemp -d) + mkdir $out doomlocaldir + export DOOMLOCALDIR="$PWD/doomlocaldir" $runtimeShell $doomSource/bin/doomscript $script ${scriptArgs} '' diff --git a/elisp-packages.nix b/elisp-packages.nix index b5453e8..f3f2120 100644 --- a/elisp-packages.nix +++ b/elisp-packages.nix @@ -40,7 +40,8 @@ # TODO: figure out why this is necessary (there may be a better # solution). preBuild = '' - export HOME=$(mktemp -d) + mkdir home + export HOME="$PWD/home" ''; # TODO: set this properly (melpa2nix requires it). commit = "unset"; @@ -208,7 +209,8 @@ # Make it byte-compile (see auctex) company-auctex = esuper.company-auctex.overrideAttrs (attrs: { preBuild = (attrs.preBuild or "") + '' - export HOME=$(mktemp -d) + mkdir home + export HOME="$PWD/home" ''; }); # Make it byte-compile.