aboutsummaryrefslogtreecommitdiff
path: root/.config/nixpkgs
diff options
context:
space:
mode:
authortdro <tdro@users.noreply.github.com>2022-02-19 01:53:41 -0500
committertdro <tdro@users.noreply.github.com>2022-02-19 02:38:07 -0500
commitb710281b132056105709c03dda1899a6afc68a93 (patch)
treee1a9b2011c57a3d1f713118d33adfed88925cc3e /.config/nixpkgs
parentd10fb65a5d3038810ac4d8bf2a2fbbd5b789c4da (diff)
downloaddotfiles-b710281b132056105709c03dda1899a6afc68a93.tar.gz
dotfiles-b710281b132056105709c03dda1899a6afc68a93.tar.bz2
dotfiles-b710281b132056105709c03dda1899a6afc68a93.zip
.config/nixpkgs/helpers: Add mkShellPure.nix
Diffstat (limited to '.config/nixpkgs')
-rw-r--r--.config/nixpkgs/helpers/mkShellMinimal.nix4
-rw-r--r--.config/nixpkgs/helpers/mkShellPure.nix37
2 files changed, 39 insertions, 2 deletions
diff --git a/.config/nixpkgs/helpers/mkShellMinimal.nix b/.config/nixpkgs/helpers/mkShellMinimal.nix
index dc339ec..057dd6e 100644
--- a/.config/nixpkgs/helpers/mkShellMinimal.nix
+++ b/.config/nixpkgs/helpers/mkShellMinimal.nix
@@ -33,8 +33,8 @@ derivation ({
text = ''
set -e
PATH=
- for p in ${toString packages}; do
- export PATH=$p/bin:$PATH
+ for package in ${toString packages}; do
+ export PATH=$package/bin:$PATH
done
${shellHook}
'';
diff --git a/.config/nixpkgs/helpers/mkShellPure.nix b/.config/nixpkgs/helpers/mkShellPure.nix
new file mode 100644
index 0000000..de44c67
--- /dev/null
+++ b/.config/nixpkgs/helpers/mkShellPure.nix
@@ -0,0 +1,37 @@
+### Pure version of mkShellMinimal that clears all environment variables.
+### Derived Source: https://github.com/NixOS/nixpkgs/commit/459771518d44f60b59a19381d07b12297908215d
+### Article: https://fzakaria.com/2021/08/02/a-minimal-nix-shell.html
+
+{ writeTextFile, writeScript, system }:
+
+{ shellHook ? "", packages ? [ ], ... }@attrs:
+derivation ({
+ inherit system;
+
+ name = "pure-nix-shell";
+
+ "stdenv" = writeTextFile rec {
+ name = "setup";
+ executable = true;
+ destination = "/${name}";
+ text = ''
+ set -e
+ for package in ${toString packages}; do
+ export NEW_PATH=$package/bin:$NEW_PATH
+ done
+ exec /usr/bin/env --ignore-environment /bin/sh -c "
+ export PATH=$NEW_PATH
+ ${shellHook}
+ /bin/sh
+ "
+ '';
+ };
+
+ builder = writeScript "builder.sh" ''
+ #!/bin/sh
+ echo
+ echo "This derivation is not meant to be built, unless you want to capture the dependency closure.";
+ echo
+ export > $out
+ '';
+} // attrs)