nixos-config/Makefile
Gabriel Arazas 49592d7f01 Use the unstable version for the nth time
I also fixed the long-time occuring error when using the newest version
of the channel (or the unstable one). It turns out to be a simple type
error with the `my.user' attribute. (To be honest the error messages are
quite horrible.)

On another note, I also accidentally bricked my NixOS setup after a
garbage collection and a horrible update. The breakage includes not
being able to use any of the builtin tools of Nix (e.g., nix, nix-env,
nixos-rebuild) due to a shared library error that has been garbage
collected. Which means I have to reinstall it.
(I seem to have a talent for breaking things, if only I'm paid for it.)
2020-10-05 09:38:58 +08:00

51 lines
1.7 KiB
Makefile
Executable File

USER := foo-dogsquared
HOST := zilch
HOME := /home/$(USER)
DOTS := /etc/dotfiles
NIXOS_VERSION := 20.09
NIXOS_PREFIX := $(PREFIX)/etc/nixos
FLAGS := -I "config=$$(pwd)/config" \
-I "modules=$$(pwd)/modules" \
-I "bin=$$(pwd)/bin" \
$(FLAGS)
config: $(NIXOS_PREFIX)/configuration.nix
home: $(HOME)/dotfiles
# 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.
unstable_channels:
@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
channels:
@sudo nix-channel --add "https://nixos.org/channels/nixos-${NIXOS_VERSION}" nixos
@sudo nix-channel --add "https://github.com/rycee/home-manager/archive/release-${NIXOS_VERSION}.tar.gz" home-manager
@sudo nix-channel --add "https://nixos.org/channels/nixpkgs-unstable" nixpkgs-unstable
update:
@sudo nix-channel --update
switch:
@sudo nixos-rebuild $(FLAGS) switch
install: channels update
@sudo nixos-generate-config --root "$(PREFIX)" && sudo cp --update "$(NIXOS_PREFIX)/hardware-configuration.nix" "$$(pwd)/hosts/$(HOST)/hardware-configuration.nix"
@echo "import \"$(DOTS)\" \"$(HOST)\" \"$${USER}\"" | sudo tee "${NIXOS_PREFIX}/configuration.nix"
@sudo nixos-install --root "$(PREFIX)" $(FLAGS)
@sudo cp -r "$(DOTS)" "$(PREFIX)/etc/dotfiles"
@sudo nixos-enter --root "$(PREFIX)" -c chown $(USER):users $(DOTS)
clean:
@sudo nix-collect-garbage -d
upgrade: update switch
rollback:
@sudo nix-env --rollback
test:
@nixos-rebuild $(FLAGS) test