Drop support for dir-locals.nix, <nixpkgs>, etc.

In the spirit of Marie Kondo, I'm tidying up!

TL;DR:
- Prefer .envrc `use_nix` and delete all dir-locals.nix files
- Remove ~all references to <nixpkgs>, <unstable>, <depot> and prefer
  referencing each with briefcase.third_party.{pkgs,unstable,depot}
- Delete nixBufferFromShell function since I was only using that in
  dir-locals.nix files
This commit is contained in:
William Carroll 2020-08-18 12:00:17 +01:00
parent 51ec9e0d88
commit 0c71fc9d1d
55 changed files with 102 additions and 118 deletions

12
.envrc
View file

@ -1,10 +1,8 @@
export BRIEFCASE="$(realpath ~/briefcase)" export BRIEFCASE="$(realpath .)"
export DEPOT="$(realpath ~/depot)" # I'm ensuring that $NIX_PATH is mostly empty, so that I only depend on
export NIXPKGS="$(realpath ~/nixpkgs)" # <briefcase> for now.
# I'm ensuring that $NIX_PATH is unset to avoid the anti-pattern of depending on # For more information on the NIX_PATH anti-pattern, see here:
# <nixpkgs>, <briefcase>, <depot>, <unstable>.
# For more information about setting this to "", see:
# https://nix.dev/tutorials/towards-reproducibility-pinning-nixpkgs.html#pinning-nixpkgs # https://nix.dev/tutorials/towards-reproducibility-pinning-nixpkgs.html#pinning-nixpkgs
export NIX_PATH=""; export NIX_PATH="briefcase=$BRIEFCASE";
export DESKTOP="zeno.lon.corp.google.com"; export DESKTOP="zeno.lon.corp.google.com";
export LAPTOP="seneca"; export LAPTOP="seneca";

View file

@ -1 +1,2 @@
source_up
use_nix use_nix

View file

@ -0,0 +1,2 @@
source_up
use_nix

View file

@ -1,3 +0,0 @@
let
briefcase = import <briefcase> {};
in briefcase.utils.nixBufferFromShell ./shell.nix

View file

@ -1,5 +1,6 @@
let let
pkgs = import <nixpkgs> {}; briefcase = import <briefcase> {};
pkgs = briefcase.third_party.pkgs;
in pkgs.mkShell { in pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
leiningen leiningen

2
boilerplate/elm/.envrc Normal file
View file

@ -0,0 +1,2 @@
source_up
use_nix

View file

@ -1,3 +0,0 @@
let
briefcase = import <briefcase> {};
in briefcase.utils.nixBufferFromShell ./shell.nix

View file

@ -1,9 +1,10 @@
let let
pkgs = import <nixpkgs> {}; briefcase = import <briefcase> {};
pkgs = briefcase.third_party.pkgs;
in pkgs.mkShell { in pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs.elmPackages; [
elmPackages.elm elm
elmPackages.elm-format elm-format
elmPackages.elm-live elm-live
]; ];
} }

View file

@ -0,0 +1,2 @@
source_up
use_nix

View file

@ -1,3 +0,0 @@
let
briefcase = import <briefcase> {};
in briefcase.utils.nixBufferFromShell ./shell.nix

View file

@ -1,5 +1,6 @@
let let
pkgs = import <nixpkgs> {}; briefcase = import <briefcase> {};
pkgs = briefcase.third_party.pkgs;
in pkgs.mkShell { in pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
nodejs nodejs

View file

@ -2,9 +2,10 @@
# name: shell.nix boilerplate # name: shell.nix boilerplate
# key: import # key: import
# -- # --
with import <nixpkgs> {}; let
briefcase = with import <briefcase> {};
stdenv.mkDerivation { pkgs = briefcase.third_party.pkgs;
in stdenv.mkDerivation {
name = "$1"; name = "$1";
buildInputs = [ buildInputs = [
$2 $2

View file

@ -59,7 +59,7 @@ This function was taken from @tazjin's depot and adapted for my monorepo.
(interactive "sAttribute: ") (interactive "sAttribute: ")
(lexical-let* ((outbuf (get-buffer-create (format "*briefcase-out/%s*" attribute))) (lexical-let* ((outbuf (get-buffer-create (format "*briefcase-out/%s*" attribute)))
(errbuf (get-buffer-create (format "*briefcase-errors/%s*" attribute))) (errbuf (get-buffer-create (format "*briefcase-errors/%s*" attribute)))
(expression (format "let depot = import <depot> {}; briefcase = import <briefcase> {}; in depot.nix.buildLisp.sbclWith [ briefcase.%s ]" attribute)) (expression (format "let briefcase = import <briefcase> {}; in briefcase.third_party.depot.nix.buildLisp.sbclWith [ briefcase.%s ]" attribute))
(command (list "nix-build" "-E" expression))) (command (list "nix-build" "-E" expression)))
(message "Acquiring Lisp for <briefcase>.%s" attribute) (message "Acquiring Lisp for <briefcase>.%s" attribute)
(make-process :name (format "nix-build/%s" attribute) (make-process :name (format "nix-build/%s" attribute)

View file

@ -1 +1,2 @@
source_up source_up
use_nix

View file

@ -1,3 +0,0 @@
let
briefcase = import <briefcase> {};
in briefcase.utils.nixBufferFromShell ./shell.nix

View file

@ -1,9 +1,10 @@
let let
pkgs = import <nixpkgs> {}; briefcase = import <briefcase> {};
pkgs = briefcase.third_party.pkgs;
in pkgs.mkShell { in pkgs.mkShell {
buildInputs = [ buildInputs = with pkgs; [
pkgs.go go
pkgs.goimports goimports
pkgs.godef godef
]; ];
} }

2
haskell-file/.envrc Normal file
View file

@ -0,0 +1,2 @@
source_up
use_nix

View file

@ -1,9 +1,5 @@
with import <nixpkgs> {}; let
briefcase = import <briefcase> {};
stdenv.mkDerivation { in briefcase.buildHaskell.shell {
name = "f-hs"; deps = hpkgs: [];
buildInputs = [
(pkgs.haskellPackages.ghcWithPackages (pkgs: [
]))
];
} }

View file

@ -1,8 +1,4 @@
{ { pkgs, depot, ... }:
pkgs ? import <nixpkgs> {},
depot ? import <depot> {},
...
}:
pkgs.dockerTools.buildLayeredImage { pkgs.dockerTools.buildLayeredImage {
name = "gemma"; name = "gemma";

View file

@ -1 +1,2 @@
source_up source_up
use_nix

View file

@ -1,3 +0,0 @@
let
briefcase = import <briefcase> {};
in briefcase.utils.nixBufferFromShell ./shell.nix

View file

@ -1,5 +1,6 @@
let let
pkgs = import <nixpkgs> {}; briefcase = import <briefcase> {};
pkgs = briefcase.third_party.pkgs;
in pkgs.mkShell { in pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
nodejs nodejs

2
scratch/groceries/.envrc Normal file
View file

@ -0,0 +1,2 @@
source_up
use_nix

View file

@ -1,8 +1,5 @@
let let
pkgs = import <unstable> {}; briefcase = import <briefcase> {};
in pkgs.mkShell { in briefcase.buildHaskell.shell {
buildInputs = with pkgs; [ deps = hpkgs: [];
(haskellPackages.ghcWithPackages (hpkgs: with hpkgs; [
]))
];
} }

View file

@ -0,0 +1,2 @@
source_up
use_nix

View file

@ -1,10 +1,8 @@
let let
pkgs = import <unstable> {}; briefcase = import <briefcase> {};
in pkgs.mkShell { in briefcase.buildHaskell.shell {
buildInputs = with pkgs; [ deps = hpkgs: with hpkgs; [
(haskellPackages.ghcWithPackages (hpkgs: with hpkgs; [ quickcheck-simple
hpkgs.quickcheck-simple checkers
hpkgs.checkers
]))
]; ];
} }

View file

@ -1,4 +1,5 @@
source_up source_up
use_nix
export monzo_client_id="$(pass show finance/monzo/client-id)" export monzo_client_id="$(pass show finance/monzo/client-id)"
export monzo_client_secret="$(pass show finance/monzo/client-secret)" export monzo_client_secret="$(pass show finance/monzo/client-secret)"
export ynab_personal_access_token="$(pass show finance/youneedabudget.com/personal-access-token)" export ynab_personal_access_token="$(pass show finance/youneedabudget.com/personal-access-token)"

View file

@ -1,3 +0,0 @@
let
briefcase = import <briefcase> {};
in briefcase.utils.nixBufferFromShell ./shell.nix

View file

@ -1,5 +1,6 @@
let let
pkgs = import <nixpkgs> {}; briefcase = import <briefcase> {};
pkgs = briefcase.third_party.pkgs;
in pkgs.mkShell { in pkgs.mkShell {
buildInputs = [ buildInputs = [
pkgs.go pkgs.go

View file

@ -1 +1,2 @@
source_up source_up
use_nix

View file

@ -1,3 +0,0 @@
let
briefcase = import <briefcase> {};
in briefcase.utils.nixBufferFromShell ./shell.nix

View file

@ -1,5 +1,6 @@
let let
pkgs = import <nixpkgs> {}; briefcase = import <briefcase> {};
pkgs = briefcase.third_party.pkgs;
in pkgs.mkShell { in pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
go go

View file

@ -1 +1,2 @@
source_up source_up
use_nix

View file

@ -1,8 +1,6 @@
{ ... }: { pkgs, ... }:
let let
pkgs = import <unstable> {};
ghc = pkgs.haskellPackages.ghcWithPackages (hpkgs: [ ghc = pkgs.haskellPackages.ghcWithPackages (hpkgs: [
hpkgs.time hpkgs.time
hpkgs.aeson hpkgs.aeson

View file

@ -1,12 +1,10 @@
let let
pkgs = import <unstable> {}; briefcase = import <briefcase> {};
in pkgs.mkShell { in briefcase.buildHaskell.shell {
buildInputs = with pkgs; [ deps = hpkgs: with hpkgs; [
(haskellPackages.ghcWithPackages (hpkgs: with hpkgs; [
time time
aeson aeson
either either
hspec hspec
]))
]; ];
} }

View file

@ -11,10 +11,4 @@
wrapNonNixProgram = { path, as }: pkgs.writeShellScriptBin as '' wrapNonNixProgram = { path, as }: pkgs.writeShellScriptBin as ''
exec ${path} "$@" exec ${path} "$@"
''; '';
# Expose the buildInputs from a Nix shell to an Emacs buffer. Intended to be
# called from dir-locals.nix files.
nixBufferFromShell = path: let
shell = import path;
in pkgs.nixBufferBuilders.withPackages shell.buildInputs;
} }

View file

@ -1 +1,2 @@
source_up source_up
use_nix

View file

@ -1,7 +1,7 @@
let let
pkgs = import <nixpkgs> {}; briefcase = import <briefcase> {};
in pkgs = briefcase.third_party.pkgs;
pkgs.mkShell { in pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
hugo hugo
]; ];

View file

@ -0,0 +1,2 @@
source_up
use_nix

View file

@ -1,3 +0,0 @@
let
briefcase = import <briefcase> {};
in briefcase.utils.nixBufferFromShell ./shell.nix

View file

@ -1,5 +1,6 @@
let let
pkgs = import <nixpkgs> {}; briefcase = import <briefcase> {};
pkgs = briefcase.third_party.pkgs;
in pkgs.mkShell { in pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
nodejs nodejs

2
website/goals/.envrc Normal file
View file

@ -0,0 +1,2 @@
source_up
use_nix

View file

@ -1,3 +0,0 @@
let
briefcase = import <briefcase> {};
in briefcase.utils.nixBufferFromShell ./shell.nix

View file

@ -1,5 +1,6 @@
let let
pkgs = import <nixpkgs> {}; briefcase = import <briefcase> {};
pkgs = briefcase.third_party.pkgs;
in pkgs.mkShell { in pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
nodejs nodejs

View file

@ -0,0 +1,2 @@
source_up
use_nix

View file

@ -1,3 +0,0 @@
let
briefcase = import <briefcase> {};
in briefcase.utils.nixBufferFromShell ./shell.nix

View file

@ -1,5 +1,6 @@
let let
pkgs = import <nixpkgs> {}; briefcase = import <briefcase> {};
pkgs = briefcase.third_party.pkgs;
in pkgs.mkShell { in pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
nodejs nodejs

View file

@ -1,3 +1,4 @@
source_up source_up
use_nix
export CONTENTFUL_SPACE_ID="$(pass show programming/contentful/space-id)" export CONTENTFUL_SPACE_ID="$(pass show programming/contentful/space-id)"
export CONTENTFUL_ACCESS_TOKEN="$(pass show programming/contentful/access-token)" export CONTENTFUL_ACCESS_TOKEN="$(pass show programming/contentful/access-token)"

View file

@ -1,6 +1,6 @@
let { pkgs, ... }:
pkgs = import <nixpkgs> {};
in pkgs.stdenv.mkDerivation { pkgs.stdenv.mkDerivation {
name = "ideal-website"; name = "ideal-website";
src = builtins.path { path = ./.; name = "contentful"; }; src = builtins.path { path = ./.; name = "contentful"; };
buildInputs = with pkgs; [ buildInputs = with pkgs; [

View file

@ -1,5 +1,6 @@
let let
pkgs = import <nixpkgs> {}; briefcase = import <briefcase> {};
pkgs = briefcase.third_party.pkgs;
in pkgs.mkShell { in pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
nodejs nodejs

View file

@ -1,5 +1,6 @@
let let
pkgs = import <nixpkgs> {}; briefcase = import <briefcase> {};
pkgs = briefcase.third_party.pkgs;
in pkgs.mkShell { in pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
yarn yarn

View file

@ -0,0 +1,2 @@
source_up
use_nix

View file

@ -1,3 +0,0 @@
let
briefcase = import <briefcase> {};
in briefcase.utils.nixBufferFromShell ./shell.nix

View file

@ -2,9 +2,9 @@ let
briefcase = import <briefcase> {}; briefcase = import <briefcase> {};
pkgs = briefcase.third_party.pkgs; pkgs = briefcase.third_party.pkgs;
in pkgs.mkShell { in pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs.elmPackages; [
elmPackages.elm elm
elmPackages.elm-format elm-format
elmPackages.elm-live elm-live
]; ];
} }

View file

@ -1 +1,2 @@
source_up
use_nix use_nix