···2222when you have consider partitioning on your drive to ensure that you can roll back
2323safely in case things go wrong.
24242525-After installation, proceed with the steps in updating configuration below.
2525+After installation, copy the generated NixOS configuration files from `/etc/nixos`
2626+into a new directory named `hosts/<host-name>`. Note that on the rest of
2727+the README, the placeholder `<host-name>` is used to denote the hostname of a new
2828+or existing machine under Nix flake-based setup.
2929+3030+```bash
3131+cp -rv /etc/nixos/ hosts/<host-name>/
3232+```
3333+3434+On the `flake.nix` file, under the `nixosConfigurations` block, add the new host using the template below
3535+3636+```nix
3737+<host-name> = nixpkgs.lib.nixosSystem {
3838+ system = "x86_64-linux";
3939+ modules = [
4040+ ./hosts/<host-name>/configuration.nix
4141+4242+ # load Determinate Nix and the rest
4343+ determinate.nixosModules.default
4444+ home-manager.nixosModules.home-manager
4545+ vscode-server.nixosModules.default
4646+ nix-ld.nixosModules.nix-ld
4747+4848+ # one-liners?
4949+ { programs.nix-ld.dev.enable = true; }
5050+ ];
5151+};
5252+```
5353+5454+Then on your `hosts/<host-name>/configuration.nix`, add the needed imports
5555+as needed:
5656+5757+```nix
5858+imports = [
5959+ ./hardware-configuration.nix
6060+ ../../shared/gnupg.nix
6161+ ../../shared/meta-configs.nix
6262+ ../../shared/server/ssh.nix
6363+ ../../shared/server/tailscale.nix
6464+ ../../shared/systemd.nix
6565+ ../../shared/yubikey.nix
6666+ # add more imports here
6767+]
6868+```
6969+7070+Adjust as needed before running a `nixos-rebuild switch`
26712772### Updating configuration or upgrading NixOS system
28732974```bash
3075EDITOR="nano" # or code if you do
3176$EDITOR <path/to/nixfile.nix>
7777+git stage <path/to/nixfile.nix>
7878+git commit --signoff
32793380# update the flake.lock file manually
3481nix flake update
35828383+# on the another machine...
3684# change {hostname} to something like stellapent-cier
3785sudo nixos-rebuild --flake github:andreijiroh-dev/nixops-config#{hostname} <switch|boot|build>
3886```
+19
script/deploy-config
···11+#!/usr/bin/env bash
22+# This is a utility wrapper script around nixos-rebuild, intended for use
33+# within the root directory of the repository as a local copy/clone.
44+# SPDX-License-Identifier: MPL-2.0
55+66+set -xe
77+NIXOS_HOSTNAME=${1:HOSTNAME}
88+SUDO=${SUDO:"sudo"}
99+1010+if [[ $EUID != "0" ]]; then
1111+ echo "Execing as root instead"
1212+ exec $SUDO "$0"
1313+fi
1414+1515+if [[ $1 == "switch" ]]; then
1616+ nixos-rebuild --verbose --show-trace --flake ".#${NIXOS_HOSTNAME}" switch
1717+elif [[ $1 == "boot" ]]; then
1818+ nixos-rebuild --verbose --show-trace --flake ".#${NIXOS_HOSTNAME}" boot
1919+fi