infra/README.md
Kaybee 7547a24e9c
All checks were successful
/ Check Nix Flake (push) Successful in 1m45s
Fixed Typo
2025-05-13 00:58:54 +02:00

4.5 KiB

Serverraum-mit-Matratze Infrastructure

license standard-readme compliant

This is the Infrastructure Code for the "Serverraum mit Matratze" shared apartment.

Table of Contents

Requirements

Requirements to do Remote Deployment using NixOS native Tools.

NixOS System (Dev System)

  1. SSH-Access to Target-Host with Sudo Privileges.
  2. Don't forget to Configure your ssh Config! (See Hosts)
  3. This Configuration git clone https://git.kb-one.de/Serverraum-mit-Matratze/infra

Non NixOS System with Nix Package Manager (Dev System)

  1. SSH-Access to Target-Host with Sudo Privileges.
  2. Don't forget to Configure your ssh Config! (See Hosts)
  3. This Configuration git clone https://git.kb-one.de/Serverraum-mit-Matratze/infra
  4. Open Nix-Shell with nixos-rebuild Command available nix-shell -p '(nixos{}).nixos-rebuild'

Remote Deployment

So, you changed the Configuration on your Computer, how can you deploy it to the Server?

Warning

Don't forget to stage Added or Deleted Files! git add . (They will be ignored if you miss this step!)

Now Rebuild the System (on the Server) and Deploy it Remotely to the Server (Example mow0m):

nixos-rebuild switch --flake .#mow0m --build-host master@mow0m --target-host master@mow0m --use-remote-sudo 
View command explanation (click to expand)

nixos-rebuild switch will rebuild a NixOS Configuration and Switch to it immediately, by restarting affected Services.

--flake . specifies the Directory of flake.nix with the NixOS System Configuration.

#mow0m tells it to Build the NixOS-System with the Hostname mow0m of the Flake. (See Hosts)

--build-host master@mow0m specifies the SSH-Connection to the Build-Host. We will build on the Target Host, to avoid messing with Signatures of the Nix-Store.

--target-host master@mow0m specifies the SSH-Connection to the Target-Host to deploy the Configuration to.

--use-remote-sudo this will redirect the Sudo-Prompt on the Target-Host to your Command-Prompt.

Hosts

mow0m

Configuration

User master@mow0m
Cpu Intel(R) Core(TM) i5-6400 (4) @ 3.30 GHz
Ram 32GB
Build
nixos-rebuild switch --flake .#mow0m --target-host master@mow0m --build-host master@mow0m --use-remote-sudo
SSH Config
Host mow0m
  HostName mow0m.lan
  User master
  Port 9553
  IdentityFile ~/.ssh/master@mow0m
Host remoteunlock-mow0m
  HostName mow0m.lan
  User root
  Port 2550
  IdentityFile ~/.ssh/remoteunlock-mow0m

senfnvp

Configuration

User master@senfnvp
Cpu dummy-virt (10)
Ram 16GB
Build
nixos-rebuild switch --flake .#senfnvp --target-host master@senfnvp --build-host master@senfnvp --use-remote-sudo
SSH Config
Host senfnvp
  Port 9553
  User master
  HostName senfnvp.kb-one.de
  IdentityFile ~/.ssh/master@senfnvp
Host remoteunlock-senfnvp
  Port 7299
  User root
  HostName senfnvp.kb-one.de
  IdentityFile ~/.ssh/root@remoteunlock-senfnvp

pkpnafs

Configuration

User master@pkpnafs
Cpu AMD EPYC 7702P 64-Core (4) @ 2.00 GHz
Ram 16GB
Build
nixos-rebuild switch --flake .#pkpnafs --target-host master@pkpnafs --build-host master@pkpnafs --use-remote-sudo
SSH Config
Host pkpnafs
  Port 3422
  User master
  HostName pkpnafs.kb-one.de
  IdentityFile /home/kb/.ssh/master@pkpnafs

License

GPL v2