Files
Nikolaos Karaolidis 184aa4da8f Update
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
2025-07-13 23:33:27 +01:00

63 lines
1.3 KiB
Nix

{ user, home }:
{
lib,
inputs,
system,
...
}:
{
home-manager.users.${user}.programs.zsh = {
shellAliases.nd = "nix-develop";
initContent =
let
devShells = lib.strings.concatStringsSep " " (
lib.attrsets.mapAttrsToList (key: _: key) inputs.self.devShells.${system}
);
in
''
nix-develop() {
local devshell=""
while getopts "s:" opt; do
case $opt in
s)
devshell=$OPTARG
;;
*)
echo "Usage: nix-develop [-s <devshell>]"
return 1
;;
esac
done
if [[ -z "$devshell" ]]; then
if [ ! -f flake.nix ]; then
cp "${./template.nix}" flake.nix
chmod 755 flake.nix
fi
if [ ! treefmt.nix ]; then
cp "${./treefmt.nix}" treefmt.nix
chmod 755 treefmt.nix
fi
nix develop -c "$SHELL"
else
nix develop self#"$devshell" -c "$SHELL"
fi
}
_nix-develop_completion() {
local options=(
'-s[Dev shell from root flake]:shell:(${devShells})'
)
_arguments -s $options
}
compdef _nix-develop_completion nix-develop
'';
};
}