#!/bin/sh print_help() { echo echo "dot - manage, update and deploy configuration with Nix." echo echo "USAGE:" echo " dot update" echo " dot (system | home) []" echo " dot -h | --help" echo echo "where:" echo " update" echo " update 'flake.lock' file." echo " system:" echo " deploy system configuration (NixOS only). Requires root access." echo " home:" echo " deploy user configuration." echo " help:" echo " print this help" echo } command=${1:-help} if [ "$command" = "update" ]; then nix flake update git add flake.lock elif [ "$command" = "system" ]; then profile=${2:-$(hostname)} sudo nixos-rebuild switch --flake .#"$profile" elif [ "$command" = "home" ]; then profile=${2:-$(hostname)} nix build --show-trace .#homeConfigurations."$profile".activationPackage && \ ./result/activate elif [ "$command" = "help" ]; then print_help else printf "Invalid command '%s'\n\n" "$command" print_help exit 1 fi