NixOS + home-manager configs, mirrored from GitLab SaaS. gitlab.com/andreijiroh-dev/nixops-config
nix-flake nixos home-manager nixpkgs nix-flakes
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add utility script for config deployments and update docs

Signed-off-by: Andrei Jiroh Halili <ajhalili2006@andreijiroh.dev>

+68 -1
+49 -1
README.md
··· 22 22 when you have consider partitioning on your drive to ensure that you can roll back 23 23 safely in case things go wrong. 24 24 25 - After installation, proceed with the steps in updating configuration below. 25 + After installation, copy the generated NixOS configuration files from `/etc/nixos` 26 + into a new directory named `hosts/<host-name>`. Note that on the rest of 27 + the README, the placeholder `<host-name>` is used to denote the hostname of a new 28 + or existing machine under Nix flake-based setup. 29 + 30 + ```bash 31 + cp -rv /etc/nixos/ hosts/<host-name>/ 32 + ``` 33 + 34 + On the `flake.nix` file, under the `nixosConfigurations` block, add the new host using the template below 35 + 36 + ```nix 37 + <host-name> = nixpkgs.lib.nixosSystem { 38 + system = "x86_64-linux"; 39 + modules = [ 40 + ./hosts/<host-name>/configuration.nix 41 + 42 + # load Determinate Nix and the rest 43 + determinate.nixosModules.default 44 + home-manager.nixosModules.home-manager 45 + vscode-server.nixosModules.default 46 + nix-ld.nixosModules.nix-ld 47 + 48 + # one-liners? 49 + { programs.nix-ld.dev.enable = true; } 50 + ]; 51 + }; 52 + ``` 53 + 54 + Then on your `hosts/<host-name>/configuration.nix`, add the needed imports 55 + as needed: 56 + 57 + ```nix 58 + imports = [ 59 + ./hardware-configuration.nix 60 + ../../shared/gnupg.nix 61 + ../../shared/meta-configs.nix 62 + ../../shared/server/ssh.nix 63 + ../../shared/server/tailscale.nix 64 + ../../shared/systemd.nix 65 + ../../shared/yubikey.nix 66 + # add more imports here 67 + ] 68 + ``` 69 + 70 + Adjust as needed before running a `nixos-rebuild switch` 26 71 27 72 ### Updating configuration or upgrading NixOS system 28 73 29 74 ```bash 30 75 EDITOR="nano" # or code if you do 31 76 $EDITOR <path/to/nixfile.nix> 77 + git stage <path/to/nixfile.nix> 78 + git commit --signoff 32 79 33 80 # update the flake.lock file manually 34 81 nix flake update 35 82 83 + # on the another machine... 36 84 # change {hostname} to something like stellapent-cier 37 85 sudo nixos-rebuild --flake github:andreijiroh-dev/nixops-config#{hostname} <switch|boot|build> 38 86 ```
+19
script/deploy-config
··· 1 + #!/usr/bin/env bash 2 + # This is a utility wrapper script around nixos-rebuild, intended for use 3 + # within the root directory of the repository as a local copy/clone. 4 + # SPDX-License-Identifier: MPL-2.0 5 + 6 + set -xe 7 + NIXOS_HOSTNAME=${1:HOSTNAME} 8 + SUDO=${SUDO:"sudo"} 9 + 10 + if [[ $EUID != "0" ]]; then 11 + echo "Execing as root instead" 12 + exec $SUDO "$0" 13 + fi 14 + 15 + if [[ $1 == "switch" ]]; then 16 + nixos-rebuild --verbose --show-trace --flake ".#${NIXOS_HOSTNAME}" switch 17 + elif [[ $1 == "boot" ]]; then 18 + nixos-rebuild --verbose --show-trace --flake ".#${NIXOS_HOSTNAME}" boot 19 + fi