aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2023-03-16 13:22:29 +0100
committerKarel Kočí <cynerd@email.cz>2023-03-16 22:00:43 +0100
commitda54fd0a08cb5d29cf0d52f1688736634ebe03cb (patch)
treefb78ec2353cab663b49497a599aa4dee4f865e8c
parentf4e8372bc0cd143ea30cd3c28ec581b73649cfe0 (diff)
downloadshellrc-da54fd0a08cb5d29cf0d52f1688736634ebe03cb.tar.gz
shellrc-da54fd0a08cb5d29cf0d52f1688736634ebe03cb.tar.bz2
shellrc-da54fd0a08cb5d29cf0d52f1688736634ebe03cb.zip
pkgs: fix build failure
-rw-r--r--nixos.nix35
-rw-r--r--pkgs.nix14
2 files changed, 29 insertions, 20 deletions
diff --git a/nixos.nix b/nixos.nix
index 77b272c..4dc23c9 100644
--- a/nixos.nix
+++ b/nixos.nix
@@ -7,16 +7,6 @@ overlays: {
with lib; let
cnf = config.programs.shellrc;
zshEnable = config.programs.zsh.enable;
-
- # Source all files in an appropriate shell directory in every profile
- shellInit = dir: ''
- for p in $NIX_PROFILES; do
- for file in $p/etc/${dir}/*; do
- [ -f "$file" ] || continue
- . "$file"
- done
- done
- '';
in {
options = {
programs.shellrc = {
@@ -37,12 +27,31 @@ in {
{
nixpkgs.overlays = overlays;
- programs.bash.interactiveShellInit = shellInit "bashrc.d";
- programs.zsh.interactiveShellInit = mkIf zshEnable (shellInit "zshrc.d");
+ environment.pathsToLink = ["/etc/shellrc.d" "/etc/bashrc.d"] ++ optional zshEnable "/etc/zshrc.d";
+ programs.bash.interactiveShellInit = ''
+ # Load files provided by packages
+ for p in $NIX_PROFILES; do
+ [ -e $p/etc/bashrc.d ] || continue
+ for file in $p/etc/bashrc.d/*; do
+ [ -f "$file" ] || continue
+ . "$file"
+ done
+ done
+ '';
+ programs.zsh.interactiveShellInit = mkIf zshEnable ''
+ # Load files provided by packages
+ for p in ''${=NIX_PROFILES}; do
+ [ -e $p/etc/zshrc.d ] || continue
+ for file in $p/etc/zshrc.d/*; do
+ [ -f "$file" ] || continue
+ . "$file"
+ done
+ done
+ '';
}
(mkIf cnf.enable {
environment.systemPackages =
- [pkgs.shellrc-bash]
+ [pkgs.shellrc-generic pkgs.shellrc-bash]
++ optional cnf.desktop pkgs.shellrc-desktop
++ optional zshEnable pkgs.shellrc-zsh;
diff --git a/pkgs.nix b/pkgs.nix
index f171859..ec5be7f 100644
--- a/pkgs.nix
+++ b/pkgs.nix
@@ -19,14 +19,14 @@
shellrc-bash = pkgs.stdenvNoCC.mkDerivation {
name = "shellrc-bash";
src = ./.;
- propagatedBuildInputs = [shellrcPkgs.shellrc-generic];
+ 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
+ for p in \$NIX_PROFILES; do
+ for sh in \$p/etc/shellrc.d/*; do
[ -r "\$sh" ] && . "\$sh"
done
done
@@ -36,17 +36,17 @@
done
'';
};
- shellrc-zsh = pkgs.stdenvNoCC.mkDerivation {
+ shellrc-zsh= pkgs.stdenvNoCC.mkDerivation {
name = "shellrc-zsh";
src = ./.;
- propagatedBuildInputs = [shellrcPkgs.shellrc-generic];
+ 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 p in $NIX_PROFILES; do
- for sh in $p/etc/shellrc.d/*; do
+ for profile in \''${=NIX_PROFILES}; do
+ for sh in \$profile/etc/shellrc.d/*; do
[ -r "\$sh" ] && . "\$sh"
done
done