Last active
February 2, 2022 15:00
-
-
Save damianbaar/57aff242d06c75444dbd36bf5400060e to your computer and use it in GitHub Desktop.
nix expression that provides a way to copy your zsh configuration files
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs ? import <nixpkgs> {} | |
, zdotdir ? import (builtins.fetchurl { | |
url = "https://gist.githubusercontent.com/damianbaar/57aff242d06c75444dbd36bf5400060e/raw/83d074d45c81a18402146cadc595a20b91bb1985/zdotdir.nix"; | |
}) { inherit pkgs; } | |
}: | |
pkgs.stdenv.mkDerivation { | |
name = "withZshEnv"; | |
shellHook= zdotdir { | |
zshenv = builtins.path { path = ./zdotdir/zshenv; }; | |
zshrc = builtins.path { path = ./zdotdir/zshrc; }; | |
shellHook= '' | |
echo "welcome welcome" | |
''; | |
}; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ pkgs ? import <nixpkgs> {} | |
, lib ? import <nixpkgs/lib> | |
}: | |
{ zshenv ? "" | |
, zshrc ? "" | |
, shellHook ? "" | |
}: | |
let | |
getContentOfFile = content: | |
if lib.strings.isStorePath content | |
then builtins.readFile content | |
else content; | |
mkZshDotFile = fileName: content: builtins.toFile fileName content; | |
zshrcContent = getContentOfFile zshrc; | |
zshenvContent = getContentOfFile zshenv; | |
zDotDir = pkgs.stdenv.mkDerivation { | |
name = "ZDOTDIR"; | |
phases = ["installPhase"]; | |
installPhase = '' | |
mkdir $out | |
cp ${mkZshDotFile "zshenv" zshenvContent} $out/.zshenv | |
cp ${mkZshDotFile "zshrc" zshrcContent} $out/.zshrc | |
''; | |
}; | |
in '' | |
export ZDOTDIR=${zDotDir} | |
${shellHook} | |
'' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment