2020-08-16 08:33:44 +00:00
USER := foo-dogsquared
HOST := zilch
HOME := /home/$( USER)
DOTS := /etc/dotfiles
2020-10-05 01:38:58 +00:00
NIXOS_VERSION := 20.09
2020-08-16 08:33:44 +00:00
NIXOS_PREFIX := $( PREFIX) /etc/nixos
FLAGS := -I " config= $$ (pwd)/config " \
2020-10-06 22:56:04 +00:00
-I " modules= $$ (pwd)/modules " \
-I " bin= $$ (pwd)/bin " \
$( FLAGS)
2020-08-16 08:33:44 +00:00
config : $( NIXOS_PREFIX ) /configuration .nix
home : $( HOME ) /dotfiles
2020-08-18 16:48:02 +00:00
# The channels will be used on certain modules like in `packages/default.nix` where it will be referred to install certain packages from the unstable channel.
2020-10-06 22:56:04 +00:00
channels :
2020-10-05 01:38:58 +00:00
@sudo nix-channel --add "https://nixos.org/channels/nixos-unstable" nixos
@sudo nix-channel --add "https://github.com/rycee/home-manager/archive/master.tar.gz" home-manager
@sudo nix-channel --add "https://nixos.org/channels/nixpkgs-unstable" nixpkgs-unstable
2020-08-16 08:33:44 +00:00
update :
@sudo nix-channel --update
switch :
@sudo nixos-rebuild $( FLAGS) switch
2020-10-06 22:56:04 +00:00
# 'boot' and 'switch' are somewhat the same except 'boot' takes care of setting the kernel so use this if you've changed the kernel settings.
boot :
@sudo nixos-rebuild $( FLAGS) boot
2020-08-16 08:33:44 +00:00
install : channels update
2020-10-06 22:56:04 +00:00
@sudo nixos-generate-config --root " $( PREFIX) "
2020-08-18 16:48:02 +00:00
@echo " import \" $( DOTS) \" \" $( HOST) \" \" $$ {USER}\" " | sudo tee " ${ NIXOS_PREFIX } /configuration.nix "
2020-08-16 08:33:44 +00:00
@sudo nixos-install --root " $( PREFIX) " $( FLAGS)
2020-08-28 07:58:17 +00:00
@sudo cp -r " $( DOTS) " " $( PREFIX) /etc/dotfiles "
2020-10-06 22:56:04 +00:00
@sudo nixos-enter --root " $( PREFIX) " --command " chown $( USER) :users $( DOTS) --recursive "
@sudo nixos-enter --root " $( PREFIX) " --command " make -C $( DOTS) channels "
@echo " Set password for $( USER) " && sudo nixos-enter --root " $( PREFIX) " --command " passwd $( USER) "
2020-08-16 08:33:44 +00:00
2020-08-28 07:58:17 +00:00
clean :
2020-10-06 22:56:04 +00:00
@nix-collect-garbage -d
2020-08-28 07:58:17 +00:00
2020-08-16 08:33:44 +00:00
upgrade : update switch
2020-08-24 15:56:31 +00:00
rollback :
@sudo nix-env --rollback
2020-09-05 20:50:16 +00:00
test :
@nixos-rebuild $( FLAGS) test