dot

vizie's NixOS desktop: Hyprland, CachyOS kernel and gaming tweaks

d6f793e

rebuild/update: build as you, sudo only for the switch

By Gustaf Granström

As root, Nix refuses to read the checkout in ~/git/dot because you own it
("repository path ... is not owned by current user"). nixos-rebuild --sudo
evaluates and builds as you and uses sudo only to activate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

2 files changed +6 −4

modifiedREADME.md
@@ -37,7 +37,7 @@
3737 ## Everyday use
3838
3939 ```bash
40-sudo nixos-rebuild switch --flake ~/git/dot # apply changes (alias: rebuild)
40+nixos-rebuild switch --sudo --flake ~/git/dot # apply changes (alias: rebuild)
4141 nix flake update --flake ~/git/dot # newer packages; then rebuild (alias: update)
4242 ```
4343
@@ -55,9 +55,11 @@
5555 tb = "nc termbin.com 9999";
5656 jctl = "journalctl -p 3 -xb";
5757
58- # The pacman ones, for NixOS.
59- update = "nix flake update --flake ${config.dot.repoPath} && sudo nixos-rebuild switch --flake ${config.dot.repoPath}";
60- rebuild = "sudo nixos-rebuild switch --flake ${config.dot.repoPath}";
58+ # The pacman ones, for NixOS. Built as you, with sudo only for the switch:
59+ # Nix won't read a git checkout owned by someone else, so a root build
60+ # of this one fails.
61+ update = "nix flake update --flake ${config.dot.repoPath} && nixos-rebuild switch --sudo --flake ${config.dot.repoPath}";
62+ rebuild = "nixos-rebuild switch --sudo --flake ${config.dot.repoPath}";
6163 cleanup = "sudo nix-collect-garbage --delete-older-than 14d";
6264 };
6365