diff --git a/Justfile b/Justfile index 22f9c91..a794d9d 100755 --- a/Justfile +++ b/Justfile @@ -31,7 +31,7 @@ _render_templates: echo No route to WAN. Skipping template rendering... else source $(just -v _get_nix_path {{invocation_directory()}}/nix/variables/versions.nix) - nix/scripts/pre-eval-fixed.sh nix/home-manager/profiles/dotfiles/vcsh{.tmpl,}.nix + # nix/scripts/pre-eval-fixed.sh nix/home-manager/profiles/dotfiles/vcsh{.tmpl,}.nix fi _rebuild-device dir rebuildarg="dry-activate" +moreargs="": _render_templates diff --git a/README.md b/README.md index b2d77ad..fc6658a 100644 --- a/README.md +++ b/README.md @@ -30,12 +30,16 @@ In the unlikely case that you actually read this and have any questions please d - [x] declare shell.nix with runtime deps - [x] partition/encrypt/format disks - [ ] Document bootstrap process + - [ ] `apt install sudo cryptsetup` as a requirements on a deb admin machine - [ ] a new machine - [ ] an install media - [ ] Design disaster recovery - [ ] Automatic synchronization of other state files - see https://gitlab.com/steveeJ/nix-expressions/issues/2 - [ ] Recycle *\_archived* - [x] Maybe make this a nix-overlay +- [ ] container migrations + - [ ] ensure DDNS is updated _before_ the containers are started + ## Bugs - [ ] home-manager leaves ~/.gnupg at 0755 @@ -66,3 +70,11 @@ just --list 2. disconnect remove the previous drive 3. replace the driveId in the device's hw.nix 4. run the `just disk-relabel nix/os/devices/ ` command to rename the filesystem and volume group + +## Backup + +### Copy existing subvolumes to new backup target + +``` +`systemctl cat bkp-run | grep ExecStart | awk -F '=' '{print $2}'` --verbose --progress archive /var/lib/container-volumes ssh://[IP]:[PORT]/mnt/backup/container-volumes/ +``` diff --git a/nix/os/containers/backup-target.nix b/nix/os/containers/backup-target.nix index d868939..68fb0e4 100644 --- a/nix/os/containers/backup-target.nix +++ b/nix/os/containers/backup-target.nix @@ -1,7 +1,7 @@ { hostAddress, localAddress, containerBackupCfg -, sshPort ? containerBackupCfg.portInt }: { +, sshPort ? containerBackupCfg.portInt, autoStart ? false }: { config = { config, pkgs, lib, ... }: { - system.stateVersion = "21.11"; # Did you read the comment? + system.stateVersion = "22.05"; # Did you read the comment? imports = [ ../profiles/containers/configuration.nix ]; @@ -50,7 +50,7 @@ }; }; - autoStart = true; + inherit autoStart; bindMounts = { "/${containerBackupCfg.targetPath}" = { @@ -59,6 +59,8 @@ }; }; + extraFlags = [ "--resolv-conf=bind-host" ]; + privateNetwork = true; forwardPorts = [{ # ssh diff --git a/nix/os/containers/backup.nix b/nix/os/containers/backup.nix index a18926a..16b8719 100644 --- a/nix/os/containers/backup.nix +++ b/nix/os/containers/backup.nix @@ -1,9 +1,5 @@ -<<<<<<< HEAD -{ config, hostAddress, localAddress, subvolumes, targetPathSuffix ? "" }: -======= { config, hostAddress, localAddress, subvolumes, targetPathSuffix ? "" , autoStart ? false }: ->>>>>>> 82ff04b (chore: nixfmt *) let passwords = import ../../variables/passwords.crypt.nix; @@ -89,7 +85,7 @@ in { }; }; - autoStart = true; + inherit autoStart; bindMounts = { "${subvolumeParentDir}" = { @@ -113,11 +109,8 @@ in { modifier = "rw"; }]; -<<<<<<< HEAD -======= extraFlags = [ "--resolv-conf=bind-host" ]; ->>>>>>> 82ff04b (chore: nixfmt *) privateNetwork = true; forwardPorts = [ ]; diff --git a/nix/os/containers/mailserver.nix b/nix/os/containers/mailserver.nix index 6494094..3c1d882 100644 --- a/nix/os/containers/mailserver.nix +++ b/nix/os/containers/mailserver.nix @@ -1,4 +1,5 @@ -{ hostAddress, localAddress, imapsPort ? 993, sievePort ? 4190 }: +{ hostAddress, localAddress, imapsPort ? 993, sievePort ? 4190 +, autoStart ? false }: let passwords = import ../../variables/passwords.crypt.nix; @@ -124,7 +125,7 @@ in { }; }; - autoStart = true; + inherit autoStart; bindMounts = { "/etc/secrets/" = { @@ -138,6 +139,8 @@ in { }; }; + extraFlags = [ "--resolv-conf=bind-host" ]; + privateNetwork = true; forwardPorts = [ { diff --git a/nix/os/containers/syncthing.nix b/nix/os/containers/syncthing.nix index c36bfac..d07bd73 100644 --- a/nix/os/containers/syncthing.nix +++ b/nix/os/containers/syncthing.nix @@ -1,5 +1,5 @@ { hostAddress, localAddress, syncthingPort ? 22000 -, syncthingLocalAnnouncePort ? 21027 }: +, syncthingLocalAnnouncePort ? 21027, autoStart ? false }: { @@ -21,7 +21,7 @@ }; }; - autoStart = true; + inherit autoStart; bindMounts = { "/var/lib/syncthing/" = { @@ -30,6 +30,8 @@ }; }; + extraFlags = [ "--resolv-conf=bind-host" ]; + privateNetwork = true; forwardPorts = [ { diff --git a/nix/os/containers/webserver.nix b/nix/os/containers/webserver.nix index e606a96..9d7345d 100644 --- a/nix/os/containers/webserver.nix +++ b/nix/os/containers/webserver.nix @@ -1,4 +1,5 @@ -{ hostAddress, localAddress, httpPort ? 80, httpsPort ? 443 }: +{ hostAddress, localAddress, httpPort ? 80, httpsPort ? 443, autoStart ? false +}: let passwords = import ../../variables/passwords.crypt.nix; in { @@ -121,7 +122,7 @@ in { }; }; - autoStart = true; + inherit autoStart; bindMounts = { "/etc/secrets/" = { @@ -145,6 +146,8 @@ in { }; }; + extraFlags = [ "--resolv-conf=bind-host" ]; + privateNetwork = true; forwardPorts = [ { diff --git a/nix/os/devices/disk.nix b/nix/os/devices/disk.nix index 3df0be9..81310d7 100644 --- a/nix/os/devices/disk.nix +++ b/nix/os/devices/disk.nix @@ -50,7 +50,7 @@ in rec { [[ -e "''${NIXOS_CONFIG}" ]] [[ -e "${mntRootVol}/nixos" ]] - sudo -E $SHELL <''; + }; + +in { + inherit nixpkgs; + "channels-nixos-stable" = nixpkgs; + "nixpkgs-master" = { + url = "https://github.com/NixOS/nixpkgs/"; + ref = "master"; + rev = '' + <% git ls-remote https://github.com/NixOS/nixpkgs.git master | head -n1 | awk '{ print $1 }' | tr -d ' + ' -%>''; + }; + "home-manager-module" = { + url = "https://github.com/nix-community/home-manager"; + ref = "release-22.05"; + rev = '' + <% git ls-remote https://github.com/nix-community/home-manager.git release-22.05 | awk '{ print $1 }' | tr -d ' + ' -%>''; + }; +} diff --git a/nix/os/devices/vmd32387.contaboserver.net/pkg.nix b/nix/os/devices/vmd32387.contaboserver.net/pkg.nix index 5b88997..a792e72 100644 --- a/nix/os/devices/vmd32387.contaboserver.net/pkg.nix +++ b/nix/os/devices/vmd32387.contaboserver.net/pkg.nix @@ -31,7 +31,7 @@ }; services.gitlab-runner = { - enable = true; + enable = false; extraPackages = with pkgs; [ bash gitlab-runner nix gitFull git-crypt ]; diff --git a/nix/os/devices/vmd32387.contaboserver.net/system.nix b/nix/os/devices/vmd32387.contaboserver.net/system.nix index 5caa064..cb9e5ce 100644 --- a/nix/os/devices/vmd32387.contaboserver.net/system.nix +++ b/nix/os/devices/vmd32387.contaboserver.net/system.nix @@ -98,13 +98,7 @@ in { networking.useHostResolvConf = true; - containers = { - bkpTarget = import ../../containers/backup-target.nix { - hostAddress = "192.168.100.18"; - localAddress = "192.168.100.19"; - containerBackupCfg = passwords.storage.backupTarget; - }; - }; + containers = { }; # This value determines the NixOS release from which the default # settings for stateful data, like file locations and database versions diff --git a/nix/os/devices/vmd32387.contaboserver.net/versions.tmpl.nix b/nix/os/devices/vmd32387.contaboserver.net/versions.tmpl.nix index 866290f..623673e 100644 --- a/nix/os/devices/vmd32387.contaboserver.net/versions.tmpl.nix +++ b/nix/os/devices/vmd32387.contaboserver.net/versions.tmpl.nix @@ -1,51 +1,15 @@ let nixpkgs = { url = "https://github.com/NixOS/nixpkgs/"; - ref = "nixos-21.11"; + ref = "nixos-22.05"; rev = '' - <% git ls-remote https://github.com/nixos/nixpkgs nixos-21.11 | awk '{ print $1 }' | tr -d ' + <% git ls-remote https://github.com/nixos/nixpkgs nixos-22.05 | awk '{ print $1 }' | tr -d ' ' -%>''; }; in { inherit nixpkgs; - nixos = nixpkgs // { suffix = "/nixos"; }; "channels-nixos-stable" = nixpkgs; - "channels-nixos-21.05" = { - url = "https://github.com/NixOS/nixpkgs/"; - ref = "nixos-21.05"; - rev = '' - <% git ls-remote https://github.com/nixos/nixpkgs nixos-20.05 | awk '{ print $1 }' | tr -d ' - ' -%>''; - }; - "channels-nixos-20.09" = { - url = "https://github.com/NixOS/nixpkgs/"; - ref = "nixos-20.09"; - rev = '' - <% git ls-remote https://github.com/nixos/nixpkgs nixos-20.09 | awk '{ print $1 }' | tr -d ' - ' -%>''; - }; - "channels-nixos-20.03" = { - url = "https://github.com/NixOS/nixpkgs/"; - ref = "nixos-20.03"; - rev = '' - <% git ls-remote https://github.com/nixos/nixpkgs nixos-20.03 | awk '{ print $1 }' | tr -d ' - ' -%>''; - }; - "channels-nixos-19.09" = { - url = "https://github.com/NixOS/nixpkgs/"; - ref = "nixos-19.09"; - rev = '' - <% git ls-remote https://github.com/nixos/nixpkgs nixos-19.09 | awk '{ print $1 }' | tr -d ' - ' -%>''; - }; - "channels-nixos-unstable" = { - url = "https://github.com/NixOS/nixpkgs/"; - ref = "nixos-unstable"; - rev = '' - <% git ls-remote https://github.com/nixos/nixpkgs nixos-unstable | awk '{ print $1 }' | tr -d ' - ' -%>''; - }; "nixpkgs-master" = { url = "https://github.com/NixOS/nixpkgs/"; ref = "master"; @@ -55,9 +19,9 @@ in { }; "home-manager-module" = { url = "https://github.com/nix-community/home-manager"; - ref = "release-21.05"; + ref = "release-22.05"; rev = '' - <% git ls-remote https://github.com/nix-community/home-manager.git release-21.05 | awk '{ print $1 }' | tr -d ' + <% git ls-remote https://github.com/nix-community/home-manager.git release-22.05 | awk '{ print $1 }' | tr -d ' ' -%>''; }; } diff --git a/shell.nix b/shell.nix index 1595779..a0bfe3b 100644 --- a/shell.nix +++ b/shell.nix @@ -23,6 +23,7 @@ in pkgs.stdenv.mkDerivation { git nixUnstable niv + nixos-install-tools vncdo tesseract