Skip to content

Commit

Permalink
Avoid mktemp
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
marienz committed Jul 21, 2024
1 parent d81e519 commit 51e61c2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
6 changes: 3 additions & 3 deletions build-helpers/build-doom-profile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 \
Expand Down
4 changes: 2 additions & 2 deletions build-helpers/doomscript.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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}
''
6 changes: 4 additions & 2 deletions elisp-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 51e61c2

Please sign in to comment.