aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2022-10-13 14:10:55 +0200
committerKarel Kočí <cynerd@email.cz>2022-10-13 14:32:31 +0200
commit5d9f7dbec2660c6975d8150d01fab5bc9961b0ec (patch)
treedc9c6a2e25bb1ace3554bc29faac4bc9bc61c4dd
parente80598cdfdde033efdc7b26c603b7646ea1c31ca (diff)
downloadshellrc-5d9f7dbec2660c6975d8150d01fab5bc9961b0ec.tar.gz
shellrc-5d9f7dbec2660c6975d8150d01fab5bc9961b0ec.tar.bz2
shellrc-5d9f7dbec2660c6975d8150d01fab5bc9961b0ec.zip
Add ability to include this in profile
The modification to load bashrc and zshrc from profiles is required. The following code show the required settings in NixOS to make this work. shellInit = dir: concatMapStrings (v: '' for file in ${v}/etc/${dir}/*; do [ -f "$file" ] || continue . "$file" done '') config.environment.profiles; environment.etc."bashrc.local".text = shellInit "bashrc.d"; environment.etc."zshrc.local".text = shellInit "zshrc.d";
-rw-r--r--flake.nix44
1 files changed, 42 insertions, 2 deletions
diff --git a/flake.nix b/flake.nix
index 0ecb3f5..5acb8dc 100644
--- a/flake.nix
+++ b/flake.nix
@@ -15,7 +15,43 @@
zshrc = loadrc ./zshrc.d;
packages = pkgs: rec {
- shellrc-completion = pkgs.stdenv.mkDerivation {
+ shellrc-generic = pkgs.stdenvNoCC.mkDerivation {
+ name = "shellrc-profile";
+ src = ./.;
+ installPhase = ''
+ mkdir -p "$out/etc/shellrc"
+ cp -r ./shellrc.d/. "$out/etc/shellrc/"
+ '';
+ };
+ shellrc-bashrc = pkgs.stdenvNoCC.mkDerivation {
+ name = "shellrc-profile-bash";
+ src = ./.;
+ shellrc = shellrc-generic;
+ installPhase = ''
+ mkdir -p "$out/etc/bashrc.d"
+ cp -r ./bashrc.d/. "$out/etc/bashrc.d/"
+ cat >"$out/etc/bashrc.d/shellrc" <<EOF
+ for sh in $shellrc/etc/shellrc/*; do
+ [ -r "\$sh" ] && . "\$sh"
+ done
+ EOF
+ '';
+ };
+ shellrc-zshrc = pkgs.stdenvNoCC.mkDerivation {
+ name = "shellrc-profile-zsh";
+ src = ./.;
+ shellrc = shellrc-generic;
+ installPhase = ''
+ mkdir -p "$out/etc/zshrc.d"
+ cp -r ./zshrc.d/. "$out/etc/zshrc.d/"
+ cat >"$out/etc/zshrc.d/shellrc" <<EOF
+ for sh in $shellrc/etc/shellrc/*; do
+ [ -r "\$sh" ] && . "\$sh"
+ done
+ EOF
+ '';
+ };
+ shellrc-completion = pkgs.stdenvNoCC.mkDerivation {
name = "shellrc-completion";
src = ./.;
nativeBuildInputs = [ pkgs.installShellFiles ];
@@ -28,7 +64,11 @@
done
'';
};
- default = shellrc-completion;
+ shellrc = pkgs.symlinkJoin {
+ name = "shellrc";
+ paths = [ shellrc-bashrc shellrc-zshrc shellrc-completion ];
+ };
+ default = shellrc;
};
in {