mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-12-15 17:51:01 +00:00
56 lines
1.2 KiB
Nix
56 lines
1.2 KiB
Nix
{ stdenv, writeScriptBin, coreutils, nix }:
|
|
|
|
{
|
|
darwin-option = writeScriptBin "darwin-option" ''
|
|
#! ${stdenv.shell}
|
|
set -e
|
|
|
|
echo "$0: not implemented" >&2
|
|
exit 1
|
|
'';
|
|
|
|
darwin-rebuild = writeScriptBin "darwin-rebuild" ''
|
|
#! ${stdenv.shell}
|
|
set -e
|
|
|
|
showSyntax() {
|
|
exec man darwin-rebuild
|
|
exit 1
|
|
}
|
|
|
|
# Parse the command line.
|
|
origArgs=("$@")
|
|
action=
|
|
profile=/nix/var/nix/profiles/system
|
|
|
|
while [ "$#" -gt 0 ]; do
|
|
i="$1"; shift 1
|
|
case "$i" in
|
|
--help)
|
|
showSyntax
|
|
;;
|
|
switch|build)
|
|
action="$i"
|
|
;;
|
|
*)
|
|
echo "$0: unknown option \`$i'"
|
|
exit 1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [ -z "$action" ]; then showSyntax; fi
|
|
|
|
export PATH=${coreutils}/bin:$PATH
|
|
|
|
echo "building the system configuration..." >&2
|
|
if [ "$action" = switch -o "$action" = build ]; then
|
|
systemConfig="$(nix-build '<darwin>' --no-out-link -A system)"
|
|
fi
|
|
|
|
if [ "$action" = switch ]; then
|
|
sudo nix-env -p "$profile" --set $systemConfig
|
|
sudo $systemConfig/activate
|
|
fi
|
|
'';
|
|
}
|