46 lines
		
	
	
	
		
			1.7 KiB
		
	
	
	
		
			Makefile
		
	
	
	
	
	
			
		
		
	
	
			46 lines
		
	
	
	
		
			1.7 KiB
		
	
	
	
		
			Makefile
		
	
	
	
	
	
# Build the nixos configuration and switch to it
 | 
						|
build:
 | 
						|
    sudo echo "sudo check..." && sudo nixos-rebuild --log-format internal-json -v switch --flake .# --show-trace |& nom --json 
 | 
						|
 | 
						|
# Build the nixos configuration bot don't switch to it until a reboot
 | 
						|
boot:
 | 
						|
    sudo echo "sudo check..." && sudo nixos-rebuild --log-format internal-json -v boot --flake .# --show-trace |& nom --json 
 | 
						|
 | 
						|
# Run the nix flake in the nix repl
 | 
						|
run:
 | 
						|
    nix-repl -f flake:nixpkgs
 | 
						|
 | 
						|
# Check the nix configuration for errors
 | 
						|
test:
 | 
						|
    sudo echo "sudo check..." && sudo nix flake check --show-trace --log-format internal-json -v |& nom --json 
 | 
						|
 | 
						|
# Update the flake lock
 | 
						|
update:
 | 
						|
    nix flake update --log-format internal-json -v |& nom --json && zsh
 | 
						|
 | 
						|
# Clean your nix store and optimize it
 | 
						|
clean:
 | 
						|
    sudo nix-collect-garbage
 | 
						|
    sudo nix-store --optimise
 | 
						|
 | 
						|
# Set up the commit hook for testing before doing a commit
 | 
						|
setup:
 | 
						|
    #!/run/current-system/sw/bin/bash -e
 | 
						|
    if [ -s ./.git/hooks/pre-commit ]; then
 | 
						|
        read -p $"This file already contains the following text:
 | 
						|
    $(<./.git/hooks/pre-commit)
 | 
						|
    Do you want to add the test hook (y/N)? (This will NOT delete data)" choice
 | 
						|
        case "$choice" in
 | 
						|
          y|Y ) echo "just test" >> ./.git/hooks/pre-commit && chmod +x ./.git/hooks/pre-commit && echo "Added test hook to pre-commit.";;
 | 
						|
          * ) echo "No test added to pre-commit.";;
 | 
						|
        esac
 | 
						|
    else
 | 
						|
        echo "just test" >> ./.git/hooks/pre-commit && chmod +x ./.git/hooks/pre-commit
 | 
						|
    fi
 | 
						|
 | 
						|
# Make sure all the git actions of pulling, adding all files, committing, and pushing are done in one command
 | 
						|
push:
 | 
						|
    git pull
 | 
						|
    git add *
 | 
						|
    read -p "Commit message: " -r message && git commit -m "$message"
 | 
						|
    git push
 |