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.
This commit is contained in:
William Carroll 2020-08-26 23:01:35 +01:00
parent ea0788fd62
commit eb0e1d8c5d
2 changed files with 32 additions and 6 deletions

View file

@ -114,6 +114,26 @@ let
magit 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" '' withEmacsPath = emacsBin: pkgs.writeShellScriptBin "wpcarros-emacs" ''
# TODO: Is this the best way to handle environment variables using Nix? # TODO: Is this the best way to handle environment variables using Nix?
export XMODIFIERS=emacs export XMODIFIERS=emacs
@ -126,11 +146,12 @@ let
--debug-init \ --debug-init \
--no-site-file \ --no-site-file \
--no-site-lisp \ --no-site-lisp \
--directory ${ ./.emacs.d/vendor } \ --directory ${vendorDir} \
--directory ${ ./.emacs.d/wpc } \ --directory ${wpcDir} \
--load ${ ./.emacs.d/wpc/wpc-package.el } \ --load ${wpcPackageEl} \
--load ${ ./.emacs.d/init.el } \ --load ${initEl} \
--no-init-file $@ --no-init-file \
$@
''; '';
in { in {
# Use `nix-env -f '<briefcase>' emacs.glinux` to install `wpcarro-emacs` on # Use `nix-env -f '<briefcase>' emacs.glinux` to install `wpcarro-emacs` on

View file

@ -1,8 +1,13 @@
{ pkgs, ... }: { pkgs, ... }:
let let
configVim = builtins.path {
path = ./config.vim;
name = "config.vim";
};
script = pkgs.writeShellScriptBin "simple_vim" '' script = pkgs.writeShellScriptBin "simple_vim" ''
${pkgs.vim}/bin/vim -u ${./config.vim} ${pkgs.vim}/bin/vim -u ${configVim}
''; '';
in pkgs.stdenv.mkDerivation { in pkgs.stdenv.mkDerivation {
name = "simple_vim"; name = "simple_vim";