Bring back deploy script for remote bootstrap

And make linode config a regular module.
This commit is contained in:
Henrik Lissner 2020-01-13 19:56:39 -05:00
parent 106c18b9e5
commit 589c1c04a1
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
6 changed files with 92 additions and 22 deletions

View file

@ -5,19 +5,17 @@ FLAGS := -I "my=$(PWD)" $(FLAGS)
COMMAND := test
# The real Labowski
all: channels config secrets.nix
all: channels secrets.nix
@sudo nixos-rebuild $(FLAGS) $(COMMAND)
install: result channels update config
@nixos-generate-config --root "$(PREFIX)"
@nixos-install --root "$(PREFIX)"
install-linode: result channels update
@sudo mkdir -p "$(NIXOS_PREFIX)"
@echo "(import $(PWD)/dotfiles \"linode\") \"$$(hostname)\"" | sudo tee "$(NIXOS_PREFIX)/configuration.nix"
install: channels update config
@sudo nixos-install --root "$(PREFIX)" $(FLAGS)
upgrade: update switch
update:
@sudo nix-channel --update
switch:
@sudo nixos-rebuild $(FLAGS) switch
@ -29,9 +27,6 @@ clean:
# Parts
update:
@sudo nix-channel --update
config: $(NIXOS_PREFIX)/configuration.nix
channels:
@ -40,8 +35,8 @@ channels:
@sudo nix-channel --add "https://nixos.org/channels/nixpkgs-unstable" nixpkgs-unstable
$(NIXOS_PREFIX)/configuration.nix:
@sudo mkdir -p "$(NIXOS_PREFIX)"
@echo "import $(PWD)/dotfiles \"$$(hostname)\"" | sudo tee "$(NIXOS_PREFIX)/configuration.nix"
@sudo nixos-generate-config --root "$(PREFIX)"
@echo "import $(PWD)/dotfiles \"$(HOST)\"" | sudo tee "$(NIXOS_PREFIX)/configuration.nix"
secrets.nix: secrets.nix.gpg
@nix-shell -p gnupg --run "gpg -dq $< > $@"

View file

@ -14,16 +14,41 @@ white whale and annihilate what vestiges of my social life remain.
## Quick start
```sh
# Make sure your partitions are set up by this point
git clone https://github.com/hlissner/dotfiles /etc/dotfiles
HOST=hostname make install
# Assumes your partitions are set up and root is mounted on /mnt
curl https://raw.githubusercontent.com/hlissner/dotfiles/nixos/deploy | sh
```
This is equivalent to:
```sh
DOTFILES=/home/$USER/.dotfiles
git clone https://github.com/hlissner/dotfiles $DOTFILES
ln -s /etc/dotfiles $DOTFILES
chown -R $USER:users $DOTFILES
# make channels
nix-channel --add "https://nixos.org/channels/nixos-${NIXOS_VERSION}" nixos
nix-channel --add "https://github.com/rycee/home-manager/archive/release-${NIXOS_VERSION}.tar.gz" home-manager
nix-channel --add "https://nixos.org/channels/nixpkgs-unstable" nixpkgs-unstable
# make /etc/nixos/configuration.nix
nixos-generate-config --root /mnt
echo "import /etc/dotfiles \"$$(hostname)\"" >/mnt/etc/nixos/configuration.nix
# make secrets.nix
nix-shell -p gnupg --run "gpg -dq secrets.nix.gpg >secrets.nix"
# make install
nixos-install --root /mnt -I "my=/etc/dotfiles"
```
### Management
+ `make` = `nixos-rebuild test`
+ `make switch` = `nixos-rebuild switch`
+ `make upgrade` = `nix-channel --update && nixos-rebuild switch`
+ `make install` = `nixos-generate-config --root $PREFIX && nixos-install
--root $PREFIX`
+ `make install` = `nixos-generate-config --root $PREFIX && nixos-install --root
$PREFIX`
+ `make gc` = `nix-collect-garbage -d` (use sudo to clear system profile)
## Overview
@ -32,7 +57,7 @@ HOST=hostname make install
+ Shell: zsh
+ DE/WM: bspwm + polybar
+ Editor: [Doom Emacs][doom-emacs] (and occasionally [vim][vimrc])
+ Terminal: st + extensions
+ Terminal: st
+ Browser: firefox (waiting for qutebrowser to mature)

View file

@ -3,7 +3,7 @@
device:
{ pkgs, options, lib, config, ... }:
{
networking.hostName = device;
networking.hostName = lib.mkDefault device;
imports = [
<nixpkgs/nixos/modules/installer/scan/not-detected.nix>

29
deploy Normal file
View file

@ -0,0 +1,29 @@
#!/usr/bin/env nix-shell
#! nix-shell -i bash -p git gnumake
set -e # bail if an error occurs
if [ $EUID -nq 0 ]; then
>&2 echo "Must be run as root"
exit 1
fi
USER=${USER:-hlissner}
HOST=${1:-${HOST:-kuro}}
DOTFILES="/home/$USER/.dotfiles"
if [ ! -d /etc/dotfiles ]; then
git clone https://github.com/hlissner/dotfiles "$DOTFILES"
chown -R $USER:users "$DOTFILES"
fi
ln -sf "$DOTFILES" /etc/dotfiles
if [ ! -f "$DOTFILES/machines/$HOST.nix" ]; then
>&2 echo "No configuration exists for host '$HOST'"
exit 1
fi
if [ -n "$LINODE" ]; then
ARGS="\"$HOST\""
HOST=linode
fi
make -C "$DOTFILES" install

23
machines/holo.nix Normal file
View file

@ -0,0 +1,23 @@
# FIXME
{ config, lib, pkgs, ... }:
{
imports = [
<my/modules/linode.nix>
];
networking.hostName = "holo";
time.timeZone = "America/Toronto";
services.nginx = {
# user = config.my.username;
virtualHosts = {
# "domain.com" = {
# default = true;
# enableACME = true;
# forceSSL = true;
# root = "...";
# };
};
};
}

View file

@ -27,7 +27,6 @@
#
# 5. Reboot into profile.
host:
{ config, lib, pkgs, ... }:
{
environment.systemPackages =
@ -39,7 +38,6 @@ host:
<my/modules/shell/git.nix>
<my/modules/shell/zsh.nix>
<my/modules/services/ssh.nix>
"./${host}.nix"
];
# GRUB