From eb0e1d8c5d9cd1c1f316797f51720456a2f92f9e Mon Sep 17 00:00:00 2001 From: William Carroll Date: Wed, 26 Aug 2020 23:01:35 +0100 Subject: Prefer builtins.path Following the advice of Domen's nix.dev anti-patterns, I'm preferring something like... ```nix builtins.path { path = /path/to/some.where; name = "some.where"; } ``` ...to ```nix /path/to/some/where ``` While the former is more verbose, it will fail to build when the path doesn't exist, which I prefer. --- emacs/default.nix | 31 ++++++++++++++++++++++++++----- tools/simple_vim/default.nix | 7 ++++++- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/emacs/default.nix b/emacs/default.nix index 493782e8394a..22ac6d31e703 100644 --- a/emacs/default.nix +++ b/emacs/default.nix @@ -114,6 +114,26 @@ let magit ])); + vendorDir = builtins.path { + path = ./.emacs.d/vendor; + name = "emacs-vendor"; + }; + + wpcDir = builtins.path { + path = ./.emacs.d/wpc; + name = "emacs-libs"; + }; + + wpcPackageEl = builtins.path { + path = ./.emacs.d/wpc/wpc-package.el; + name = "wpc-package.el"; + }; + + initEl = builtins.path { + path = ./.emacs.d/init.el; + name = "init.el"; + }; + withEmacsPath = emacsBin: pkgs.writeShellScriptBin "wpcarros-emacs" '' # TODO: Is this the best way to handle environment variables using Nix? export XMODIFIERS=emacs @@ -126,11 +146,12 @@ let --debug-init \ --no-site-file \ --no-site-lisp \ - --directory ${ ./.emacs.d/vendor } \ - --directory ${ ./.emacs.d/wpc } \ - --load ${ ./.emacs.d/wpc/wpc-package.el } \ - --load ${ ./.emacs.d/init.el } \ - --no-init-file $@ + --directory ${vendorDir} \ + --directory ${wpcDir} \ + --load ${wpcPackageEl} \ + --load ${initEl} \ + --no-init-file \ + $@ ''; in { # Use `nix-env -f '' emacs.glinux` to install `wpcarro-emacs` on diff --git a/tools/simple_vim/default.nix b/tools/simple_vim/default.nix index 7132a649232d..f8f965f2c024 100644 --- a/tools/simple_vim/default.nix +++ b/tools/simple_vim/default.nix @@ -1,8 +1,13 @@ { pkgs, ... }: let + configVim = builtins.path { + path = ./config.vim; + name = "config.vim"; + }; + script = pkgs.writeShellScriptBin "simple_vim" '' - ${pkgs.vim}/bin/vim -u ${./config.vim} + ${pkgs.vim}/bin/vim -u ${configVim} ''; in pkgs.stdenv.mkDerivation { name = "simple_vim"; -- cgit 1.4.1