aboutsummaryrefslogtreecommitdiff
path: root/pkgs.nix
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2023-03-21 18:19:32 +0100
committerKarel Kočí <cynerd@email.cz>2023-03-21 20:46:05 +0100
commit7be0acbb1cd6b6d3c4c3df95611cb86be4b46915 (patch)
treefcdca6619a05b1e72ebb8b9ddf0d04586b434e94 /pkgs.nix
parentf0eab21bab34beb657059cf5dfe91ca8072edb35 (diff)
downloadshellrc-7be0acbb1cd6b6d3c4c3df95611cb86be4b46915.tar.gz
shellrc-7be0acbb1cd6b6d3c4c3df95611cb86be4b46915.tar.bz2
shellrc-7be0acbb1cd6b6d3c4c3df95611cb86be4b46915.zip
Drop desktop variant and rework nix packages
Diffstat (limited to 'pkgs.nix')
-rw-r--r--pkgs.nix69
1 files changed, 23 insertions, 46 deletions
diff --git a/pkgs.nix b/pkgs.nix
index 0f5b6a8..ab36908 100644
--- a/pkgs.nix
+++ b/pkgs.nix
@@ -1,36 +1,17 @@
{pkgs}: let
shellrcPkgs = {
- shellrc-generic = pkgs.stdenvNoCC.mkDerivation {
- name = "shellrc-generic";
- src = ./.;
- installPhase = ''
- mkdir -p "$out/etc/shellrc.d"
- cp -r ./shellrc.d/. "$out/etc/shellrc.d/"
- '';
- };
- shellrc-desktop = pkgs.stdenvNoCC.mkDerivation {
- name = "shellrc-desktop";
- src = ./.;
- installPhase = ''
- mkdir -p "$out/etc/shellrc.d"
- cp -r ./shellrc-desktop.d/. "$out/etc/shellrc.d/"
- '';
- };
shellrc-bash = pkgs.stdenvNoCC.mkDerivation {
name = "shellrc-bash";
src = ./.;
nativeBuildInputs = [pkgs.installShellFiles];
installPhase = ''
- mkdir -p "$out/etc/bashrc.d"
- cp -r ./bashrc.d/. "$out/etc/bashrc.d/"
- cat >"$out/etc/bashrc.d/shellrc" <<EOF
- # Load ShellRC files
- for p in \$NIX_PROFILES; do
- for sh in \$p/etc/shellrc.d/*; do
- [ -r "\$sh" ] && . "\$sh"
- done
- done
+ mkdir -p "$out/bin"
+ cat >"$out/bin/shellrc-bash" <<EOF
+ #!/usr/bin/env bash
+ echo source ${./bashrc.d}/*;
+ echo source ${./shellrc.d}/*;
EOF
+ chmod +x "$out/bin/shellrc-bash"
for comp in bash-completion/*; do
installShellCompletion --bash --name "''${comp##*/}.bash" "$comp"
done
@@ -41,35 +22,31 @@
src = ./.;
nativeBuildInputs = [pkgs.installShellFiles];
installPhase = ''
- mkdir -p "$out/etc/zshrc.d"
- cp -r ./zshrc.d/. "$out/etc/zshrc.d/"
- cat >"$out/etc/zshrc.d/shellrc" <<EOF
- # Load ShellRC files
- for profile in \''${=NIX_PROFILES}; do
- for sh in \$profile/etc/shellrc.d/*; do
- [ -r "\$sh" ] && . "\$sh"
- done
+ mkdir -p "$out/bin"
+ cat >"$out/bin/shellrc-zsh" <<"EOF"
+ #!/usr/bin/env zsh
+ for file in ${./zshrc.d}/* ${./shellrc.d}/*; do
+ echo "source $file;"
done
EOF
+ chmod +x "$out/bin/shellrc-zsh"
for comp in zsh-completion/*; do
installShellCompletion --zsh --name "''${comp##*/}" "$comp"
done
'';
};
- shellrc-setup = pkgs.writeScriptBin "shellrc-setup" ''
+ shellrc-user-setup = pkgs.writeScriptBin "shellrc-user-setup" ''
#!/usr/bin/env bash
- cat >~/.bashrc <<EOF
- for sh in ~/.nix-profile/etc/bashrc.d/*; do
- [ -r "\$sh" ] || continue
- source "\$sh"
- done
- EOF
- cat >~/.zshrc <<EOF
- for sh in ~/.nix-profile/etc/zshrc.d/*; do
- [ -r "\$sh" ] || continue
- source "\$sh"
- done
- EOF
+ cmdbash='eval $(shellrc-bash)'
+ cmdzsh='eval $(shellrc-zsh)'
+ if command -v shellrc-bash 2>/dev/null >&2 \
+ && ! grep -xf "$cmdbash" ~/.bashrc; then
+ echo "$cmdbash" >>~/.bashrc
+ fi
+ if command -v shellrc-zsh 2>/dev/null >&2 \
+ && ! grep -xf "$cmdzsh" ~/.zshrc; then
+ echo "$cmdzsh" >>~/.zshrc
+ fi
'';
};
in