srid / nixos-config

KISS NixOS configuration based on Flakes & flake-parts (supports macOS too)
433 stars 17 forks source link

Activate remote machines locally from mac #23

Closed srid closed 4 months ago

srid commented 1 year ago

https://github.com/serokell/deploy-rs

Work on my primary machine (macOS) and remotely activate new configuration for Linux machines and such.

srid commented 1 year ago

or,

nix run nixpkgs#nixos-rebuild -- switch --fast --flake .#pinch --target-host root@pinch --build-host root@pinch

https://www.haskellforall.com/2023/01/announcing-nixos-rebuild-new-deployment.html

srid commented 8 months ago

This works for non-trivial configurations:

https://github.com/srid/nixos-config/blob/0196461adb922b294b64b33a4262ab66247636f4/justfile#L4-L9

But not when using certain packages, like nixvim:

https://nixos.zulipchat.com/#narrow/stream/413948-nixos/topic/NixOS.20tutorial.20series/near/422506285

LovingMelody commented 8 months ago

Per nixos-rebuild(8), you may wish to consider dropping "--fast"

       --fast  Equivalent to --no-build-nix.  This  op‐
               tion is useful if you call nixos-rebuild
               frequently  (e.g. if you’re hacking on a
               NixOS module).
srid commented 8 months ago

I'd think --fast actually helps. If I remove it, it will try to build the Linux configuration on macOS (not what I want),

Note that, if --no-build-nix is not specified, Nix will be built both locally and remotely. This is because the configuration will always be evaluated locally even though the building might be per‐ formed remotely.

Indeed, when I remove it - the deployment from mac does fail:

❯ j remote
nixos-rebuild switch --use-remote-sudo --flake .#here --target-host $USER@here --build-host $USER@here
warning: Git tree '/Users/srid/code/nixos-config' is dirty
warning: Ignoring setting 'auto-allocate-uids' because experimental feature 'auto-allocate-uids' is not enabled
warning: Ignoring setting 'impure-env' because experimental feature 'configurable-impure-env' is not enabled
error: a 'aarch64-linux' with features {} is required to build '/nix/store/z2548rnzrzpmx2gynnjrq2lyn10pkfna-nixos-rebuild.drv', but I am a 'aarch64-darwin' with features {apple-virt, benchmark, big-parallel, nixos-test}
error: Recipe `remote` failed on line 9 with exit code 1
srid commented 4 months ago

Resolved in https://github.com/srid/nixos-flake/pull/54