diff --git a/config.nix b/config.nix index 7e8293be..a630351e 100644 --- a/config.nix +++ b/config.nix @@ -85,14 +85,31 @@ let autoload -U compinit && compinit + nix () { + cmd=$1 + shift + + case $cmd in + 'b'|'build') nix-build --no-out-link -E "with import {}; $@" ;; + 'e'|'eval') nix-instantiate --eval -E "with import {}; $@" ;; + 'i'|'instantiate') nix-instantiate -E "with import {}; $@" ;; + 'r'|'repl') nix-repl '' ;; + 's'|'shell') nix-shell -E "with import {}; $@" ;; + 'x'|'exec') nix-shell '' -p "$@" --run zsh ;; + 'z'|'zsh') nix-shell '' -A "$@" --run zsh ;; + esac + } + nixdarwin-rebuild () { - case $1 in - 'build') nix-build --no-out-link '' -A nixdarwin.toplevel --show-trace ;; - 'repl') nix-repl "$HOME/.nixpkgs/config.nix" ;; - 'shell') nix-shell '' -p nixdarwin.toplevel --run "${pkgs.lnl.zsh}/bin/zsh -l" ;; - 'switch') nix-env -f '' -iA nixdarwin.toplevel && nix-shell '' -A nixdarwin.toplevel --run 'sudo $out/activate' && exec ${pkgs.lnl.zsh}/bin/zsh -l ;; - "") return 1 ;; - esac + cmd=$1 + shift + + case $cmd in + 'build') nix-build --no-out-link '' -A nixdarwin.toplevel "$@" ;; + 'repl') nix-repl "$HOME/.nixpkgs/config.nix" "$@" ;; + 'shell') nix-shell '' -p nixdarwin.toplevel --run '${pkgs.lnl.zsh}/bin/zsh -l' "$@" ;; + 'switch') nix-env -f '' -iA nixdarwin.toplevel "$@" && nix-shell '' -A nixdarwin.toplevel --run 'sudo $out/activate' && exec ${pkgs.lnl.zsh}/bin/zsh -l ;; + esac } conf=$HOME/src/nixpkgs-config