|  |  |  | GSF=git submodule foreach | 
					
						
							|  |  |  | TIME=time | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | CHRONY_STATUS=chronyc tracking | 
					
						
							|  |  |  | CHRONY_STATS=chronyc sources -v | 
					
						
							|  |  |  | CHRONY_STATS_SOURCES=chronyc sourcestats | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | all: rebuild-switch | 
					
						
							|  |  |  | 	date | 
					
						
							|  |  |  | ##--------- Commandes spécifiques pour NixOS
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | clean: | 
					
						
							|  |  |  | 	$(TIME) nix-collect-garbage -d --delete-older-than 15d | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | clean-aggressive: | 
					
						
							|  |  |  | 	$(TIME) nix-collect-garbage -d --delete-older-than 1d | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | clean-total: | 
					
						
							|  |  |  | 	$(TIME) nix-collect-garbage -d | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | clean-log: | 
					
						
							|  |  |  | 	journalctl --flush --rotate | 
					
						
							|  |  |  | 	journalctl --vacuum-size=1G | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | full-auto: submodules-update upgrade clean optimise | 
					
						
							|  |  |  | 	@date | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | list-installed-packages: | 
					
						
							|  |  |  | 	@# source : https://functor.tokyo/blog/2018-02-20-show-packages-installed-on-nixos | 
					
						
							|  |  |  | 	@# https://www.domenkozar.com/2014/01/02/getting-started-with-nix-package-manager/ | 
					
						
							|  |  |  | 	@#nixos-option environment.systemPackages | 
					
						
							|  |  |  | 	nixos-option environment.systemPackages | head -2 | tail -1 | sed -e 's/ /\n/g' | cut -d- -f2- | sort | uniq| sed -e 's/"$$//' | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | optimise: | 
					
						
							|  |  |  | 	$(TIME) nix optimise-store | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | rebuild-build: | 
					
						
							|  |  |  | 	nix-channel --add https://nixos.org/channels/nixos-unstable nixos | 
					
						
							|  |  |  | 	$(TIME) time nixos-rebuild build --fallback  --show-trace | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | rebuild-switch: | 
					
						
							|  |  |  | 	$(TIME) time nixos-rebuild switch --fallback  --show-trace | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | show-blackholed: | 
					
						
							|  |  |  | 	-@ip route |grep blackhole |wc -l| awk '{print "Il y a "$$1" route(s) en blackhole sur";system("hostname ")}' |cowsay | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | show-diff-with-current: | 
					
						
							|  |  |  | 	-diff /run/current-system/configuration.nix /etc/nixos/configuration.nix | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | show-roots: | 
					
						
							|  |  |  | 	nix-store --gc --print-roots | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | show-time: | 
					
						
							|  |  |  | 	-@$(CHRONY_STATUS) && $(CHRONY_STATS) | 
					
						
							|  |  |  | 	-@watch -d -n 2 "$(CHRONY_STATUS) && echo "-- Statistiques générales :" && $(CHRONY_STATS) && echo "-- Statistiques sur les sources :" && $(CHRONY_STATS_SOURCES) && echo "-- Statistiques sur les clients :" && chronyc clients" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | store-repair: | 
					
						
							|  |  |  | 	$(TIME) nix-store --verify --check-contents --repair | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | upgrade: | 
					
						
							|  |  |  | 	nix-channel --add https://nixos.org/channels/nixos-unstable nixos | 
					
						
							|  |  |  | 	$(TIME) nixos-rebuild switch --upgrade --fallback --show-trace | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ##--------- Commandes spécifiques pour NixOS -- Opérations non courantes
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | download-sources: | 
					
						
							|  |  |  | 	# https://nixos.org/wiki/Download_all_sources | 
					
						
							|  |  |  | 	nix-store -r $$(grep -l outputHash $$(nix-store -qR $$(nix-instantiate '<nixpkgs>' -A geeqie) | grep '.drv$$')) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | build-iso: | 
					
						
							|  |  |  | 	nix-build '<nixpkgs/nixos>' -A config.system.build.isoImage -I nixos-config=/etc/nixos/base/iso-image/livecd-minimal.nix | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ##--------- Commandes spécifiques pour GIT
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | push: submodules-push | 
					
						
							|  |  |  | 	git push --all | 
					
						
							|  |  |  | 	git push --tags | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | submodules-update: | 
					
						
							|  |  |  | 	#git submodule update --remote | 
					
						
							|  |  |  | 	#$(GSF) git co master | 
					
						
							|  |  |  | 	$(GSF) git ff | 
					
						
							|  |  |  | 	$(GSF) git gc --auto | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | submodules-push: | 
					
						
							|  |  |  | 	$(GSF) git push --all | 
					
						
							|  |  |  | 	$(GSF) git push --tags | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | submodules-tag: | 
					
						
							|  |  |  | 	$(GSF) git tag -f "$$(date +%F)-$$(hostname -s)" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | template: | 
					
						
							|  |  |  | 	find . -name "*.nix" -exec meld /etc/nixos/base/module-template.nix {} \; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | tag: submodules-tag | 
					
						
							|  |  |  | 	git tag -f "$$(date +%F)-$$(hostname -s)" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ##--------- Munin
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | munin: | 
					
						
							|  |  |  | 	pushd /var/www/munin/ ; python -m SimpleHTTPServer 8000 | 
					
						
							|  |  |  | ##--------- Gestion d'un système de fichier monté en mémoire
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | tmpfs-create: | 
					
						
							|  |  |  | 	mkdir -p /mnt/tmpfs | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | tmpfs-mount: tmpfs-create | 
					
						
							|  |  |  | 	mount -t tmpfs -o size=10G tmpfs /mnt/tmpfs | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | tmpfs-umount: | 
					
						
							|  |  |  | 	umount /mnt/tmpfs | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | tmpfs-destroy: tmpfs-umount | 
					
						
							|  |  |  | 	rmdir /mnt/tmpfs | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ##- Test awesome
 | 
					
						
							|  |  |  | test-awesome: | 
					
						
							|  |  |  | 	Xephyr :5 & sleep 1; DISPLAY=:5 awesome |