Nix : Cleanup.
This commit is contained in:
parent
f3a7815971
commit
3f7ce3a1a6
|
@ -1,23 +1,3 @@
|
|||
# Find Nix package path.
|
||||
# Usage: nix_find <PACKAGE>
|
||||
function nix_find() {
|
||||
local IFS=$'\n'
|
||||
local package="${1}"
|
||||
|
||||
if [[ "${package}" = "" ]]; then
|
||||
help find_nix
|
||||
return 2
|
||||
fi
|
||||
|
||||
local found=$(ls --classify /nix/store/ | grep "${package}".*/)
|
||||
|
||||
if [[ "${found}" != "" ]]; then
|
||||
echo "/nix/store/${found%/}"
|
||||
else
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
# Rebuild system.
|
||||
# Optionally force the hostname.
|
||||
# Usage: nix_rebuild [HOSTNAME]
|
||||
|
@ -26,7 +6,7 @@ function nix_rebuild() {
|
|||
[[ "${target}" = "" ]] && target="${HOSTNAME}"
|
||||
|
||||
cd ${HOME}/.config/linux/system
|
||||
nixos-rebuild boot --flake .#${target}
|
||||
nixos-rebuild boot --flake ".#${target}"
|
||||
cd -
|
||||
}
|
||||
|
||||
|
@ -37,19 +17,15 @@ function nix_switch() {
|
|||
local target="${1}"
|
||||
[[ "${target}" = "" ]] && target="${HOSTNAME}"
|
||||
|
||||
cd ${HOME}/.config/linux/system
|
||||
nixos-rebuild switch --flake .#${target}
|
||||
cd "${HOME}/.config/linux/system"
|
||||
nixos-rebuild switch --flake ".#${target}"
|
||||
cd -
|
||||
}
|
||||
|
||||
# Update system.
|
||||
# Optionally force the hostname.
|
||||
# Usage: nix_update [HOSTNAME]
|
||||
# Update system versions.
|
||||
# Usage: nix_update
|
||||
function nix_update() {
|
||||
local target="${1}"
|
||||
[[ "${target}" = "" ]] && target="${HOSTNAME}"
|
||||
|
||||
cd ${HOME}/.config/linux/system
|
||||
cd "${HOME}/.config/linux/system"
|
||||
nix flake update
|
||||
cd -
|
||||
}
|
||||
|
@ -64,13 +40,10 @@ function nix_clean() {
|
|||
# Uses flake.nix in current dir by default.
|
||||
# Usage: nix_shell [NAME]
|
||||
function nix_shell() {
|
||||
local name="${1,,}"
|
||||
local target="${1}"
|
||||
[[ "${target}" = "" ]] && target="default"
|
||||
|
||||
if [[ "${name}" = "" ]]; then
|
||||
NIX_SHELL=$(parse_alnum "${PWD##*/}") nix develop
|
||||
else
|
||||
NIX_SHELL="${name}" nix develop -f ~/.config/linux/shell/"${name^}".nix
|
||||
fi
|
||||
NIX_SHELL="${target}" nix develop ".#${target}"
|
||||
}
|
||||
alias shell="nix_shell"
|
||||
|
||||
|
@ -102,13 +75,4 @@ function _comp_hosts() {
|
|||
_autocomplete_first ${targets[@]}
|
||||
}
|
||||
|
||||
# Autocomplete with available shells.
|
||||
function _comp_shells() {
|
||||
local IFS=$'\n'
|
||||
local targets=($(ls ~/.config/linux/shell/ | sed -e "s/.nix$//" | tr '[:upper:]' '[:lower:]'))
|
||||
|
||||
_autocomplete_first ${targets[@]}
|
||||
}
|
||||
|
||||
complete -F _comp_hosts nix_update nix_switch nix_rebuild
|
||||
complete -F _comp_shells nix_shell shell
|
||||
complete -F _comp_hosts nix_switch nix_rebuild
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Use flakes here with devShell
|
Reference in a new issue