diff --git a/nixos/hosts/nixos-server.nix b/nixos/hosts/nixos-server.nix index 980ed34..160b122 100644 --- a/nixos/hosts/nixos-server.nix +++ b/nixos/hosts/nixos-server.nix @@ -3,6 +3,7 @@ # One-time on server: clone repo to /etc/dotfiles (root needs git access). # If private repo: use SSH (ssh:// or git@) and add root's key to GitHub, or use HTTPS + token. # Then: sudo nixos-rebuild switch --flake /etc/dotfiles/nixos#nixos-server +# If sudo git is not found: sudo nix run nixpkgs#git -- -C /etc/dotfiles pull origin main # Timer runs every 15 min: git fetch, pull if origin/main changed, rebuild. { config, lib, pkgs, ... }: diff --git a/nixos/readme.md b/nixos/readme.md index a026554..7193e99 100644 --- a/nixos/readme.md +++ b/nixos/readme.md @@ -40,3 +40,9 @@ Use `git@github.com:DannyDannyDanny/dotfiles.git` if the repo is private (clone SSH keys for danny (not in repo): from your machine `scp ~/.ssh/*.pub danny@server:/tmp/`, then on server `mkdir -p ~/.ssh; cat /tmp/*.pub >> ~/.ssh/authorized_keys`. After that, a timer pulls and rebuilds every 15 min when `main` changes. Config lives in `hosts/nixos-server.nix` and `hosts/nixos-server-hardware.nix`. + +**Pull when git is not in PATH** (e.g. before first rebuild or when `sudo git` says "command not found"): +```bash +sudo nix run nixpkgs#git -- -C /etc/dotfiles pull origin main +``` +Then run `sudo nixos-rebuild switch --flake /etc/dotfiles/nixos#nixos-server` as usual. After that, git is in the system profile; for manual pulls you can use `sudo /run/current-system/sw/bin/git -C /etc/dotfiles pull origin main` if `sudo git` still isn’t in PATH. diff --git a/nixos/server-configuration-with-flakes.nix b/nixos/server-configuration-with-flakes.nix new file mode 100644 index 0000000..9d40e6a --- /dev/null +++ b/nixos/server-configuration-with-flakes.nix @@ -0,0 +1,21 @@ +# One-time: copy to server /etc/nixos/configuration.nix then nixos-rebuild switch (enables flakes for daemon). +{ config, lib, pkgs, ... }: + +{ + imports = [ ./hardware-configuration.nix ]; + + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + networking.hostName = "nixos-server"; + time.timeZone = "Europe/Copenhagen"; + + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + users.users.danny = { + isNormalUser = true; + extraGroups = [ "wheel" ]; + }; + + services.openssh.enable = true; +}