Skip to content

Commit

Permalink
darwin-rebuild: add ~/.config/darwin/ as default flake location
Browse files Browse the repository at this point in the history
  • Loading branch information
bouk committed Feb 18, 2024
1 parent 0e6857f commit a41f5ce
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkgs/nix-tools/darwin-rebuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ showSyntax() {
echo " [--keep-going] [-k] [--keep-failed] [-K] [--fallback] [--show-trace]" >&2
echo " [-I path] [--option name value] [--arg name value] [--argstr name value]" >&2
echo " [--flake flake] [--update-input input flake] [--impure] [--recreate-lock-file]" >&2
echo " [--no-update-lock-file] [--refresh] ..." >&2
echo " [--no-update-lock-file] [--refresh] [--no-flake] ..." >&2
exit 1
}

Expand All @@ -33,6 +33,7 @@ extraProfileFlags=()
profile=@profile@
action=
flake=
noFlake=

while [ $# -gt 0 ]; do
i=$1; shift 1
Expand Down Expand Up @@ -76,6 +77,9 @@ while [ $# -gt 0 ]; do
flake=$1
shift 1
;;
--no-flake)
noFlake=1
;;
-L|-vL|--print-build-logs|--impure|--recreate-lock-file|--no-update-lock-file|--no-write-lock-file|--no-registries|--commit-lock-file|--refresh)
extraLockFlags+=("$i")
;;
Expand Down Expand Up @@ -127,6 +131,11 @@ if [ -z "$action" ]; then showSyntax; fi

flakeFlags=(--extra-experimental-features 'nix-command flakes')

# Use ~/.config/darwin/flake.nix if it exists. It can be a symlink to the actual flake.
if [[ -z $flake && -e ~/.config/darwin/flake.nix && -z $noFlake ]]; then
flake="$(dirname "$(readlink -f ~/.config/darwin/flake.nix)")"
fi

if [ -n "$flake" ]; then
# Offical regex from https://www.rfc-editor.org/rfc/rfc3986#appendix-B
if [[ "${flake}" =~ ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))? ]]; then
Expand Down

0 comments on commit a41f5ce

Please sign in to comment.