2023-03-19 19:23:48 +00:00
|
|
|
{ config, pkgs, lib, optionalString, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (pkgs.lib) optionalString;
|
|
|
|
|
|
|
|
# not having the attribute users means
|
|
|
|
# we cannot change the default shell (e.g. this is not a NixOS host)
|
|
|
|
exec_zsh = ''
|
|
|
|
if [ -f "$HOME/.bashrc" ]; then
|
|
|
|
. "$HOME/.bashrc"
|
|
|
|
fi
|
|
|
|
|
|
|
|
exec ${pkgs.zsh}/bin/zsh
|
|
|
|
'';
|
|
|
|
|
|
|
|
nix_run_fn = ''
|
|
|
|
function _nr {
|
|
|
|
if [ "$#" -lt 1 ]; then
|
|
|
|
echo "Usage: _nr <pkg>"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
quoted_args=()
|
|
|
|
local pkg=$1
|
|
|
|
shift 1
|
|
|
|
|
|
|
|
for a in "$@"; do
|
|
|
|
quoted_args+=("\"$a\"")
|
|
|
|
done
|
|
|
|
|
|
|
|
echo ''${quoted_args[@]}
|
|
|
|
|
|
|
|
# `nix run nixpkgs#$pkg -- ''${quoted_args[@]}`
|
|
|
|
exec nix run nixpkgs#$pkg "$@"
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
{
|
2021-06-25 12:55:23 +01:00
|
|
|
programs.zsh = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
oh-my-zsh = {
|
|
|
|
enable = true;
|
|
|
|
plugins = [ "git" "sudo" "docker" "docker-compose" "adb" "systemd" ];
|
|
|
|
theme = "bira";
|
|
|
|
};
|
|
|
|
};
|
2023-02-20 18:14:49 +00:00
|
|
|
|
2023-03-19 19:23:48 +00:00
|
|
|
home.file.".bashrc".text = ''
|
|
|
|
${nix_run_fn}
|
|
|
|
|
|
|
|
${optionalString (!builtins.hasAttr "users" config) "${exec_zsh}"}
|
|
|
|
'';
|
2023-02-20 18:14:49 +00:00
|
|
|
|
2023-03-19 19:23:48 +00:00
|
|
|
home.file.".zshrc".text = nix_run_fn;
|
2021-06-25 12:55:23 +01:00
|
|
|
}
|
2023-03-19 19:23:48 +00:00
|
|
|
|