Commit Graph

35 Commits

Author SHA1 Message Date
Charlotte Van Petegem
a2c0cb0db7 nixos-rebuild: Don't pass --impure to realization when building flake remotely and impurely
It doesn't work and it's not required for building.
2022-02-11 14:20:42 +01:00
K900
dd37d07ccf nixos-rebuild: also forward the long version of -L
Mostly for more readability in shell scripts.
2022-02-08 11:56:35 -08:00
Thiago Kenji Okada
c75bc3abc7 nixos-rebuild: remove jq
Was only used in the code removed in commit
c274d045ac.
2022-01-04 20:02:47 -03:00
Thiago Kenji Okada
c274d045ac nixos-rebuild: do not resolve flake path
The removed lines converted the flake path passed by the command line
from `/some/path` to `git+file:///some/path`.

This technically shouldn't cause any issues, however running
`nixos-rebuild switch` inside a directory `/nix/store` will cause the
switch to fail and leave a partially construct generation (see issue #144811
for details).

By itself this shouldn't be too much of an issue, however thanks to
another issue in `systemd-boot-builder.py` this can leave the system
in a broken state for those using `boot.loader.systemd-boot` (AFAIK the
default), where future `nixos-rebuild switch` will fail
(see issue #93694 for details).

The issue can be fixed by running
`nix-env -p /nix/var/nix/profiles/system --delete-generations old`,
however this makes newbies very confused and it is showing in our
support threads in Matrix and Discourse (see
https://discourse.nixos.org/t/need-help-on-failure-of-building-my-configuration/16842).

Keep in mind this is a workaround. The actual issue seems to be in nix
itself (see: https://github.com/NixOS/nix/issues/5510).

See also #150065 for an alternative fix that caused other issues.

Kudos for @figsoda for figuring out this fix.
2022-01-04 18:31:08 -03:00
Thiago Kenji Okada
e6ca3fc976 Revert "nixos-rebuild: switch to tmpDir during rebuilds"
This seems to break
`boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages`
causing it to use `linuxPackages`.
2021-12-16 14:47:07 -03:00
Thiago Kenji Okada
f88bd76fcd nixos-rebuild: switch to tmpDir during rebuilds
This is a workaround for issue #144811 until this issue is either fixed
on nix itself.
2021-12-10 10:50:46 -03:00
Victor Engmark
82b9b42682
Fix some nixos-rebuild lints (#147449) 2021-11-29 05:48:23 +02:00
Anund
bc5a610cb7 nixos-rebuild: fix --install-bootloader
nixos-rebuild relies on setting an environment variable to change
behaviour during nixos-rebuild boot/switch between calling update or
install via systemd bootctl. Adding sudo -- as a prefix to various exec
calls does not preserve the environment breaking this mechanism.

This is a some what ugly fix that works.

Closes https://github.com/NixOS/nixpkgs/pull/144429
2021-11-17 09:28:05 +02:00
Timothy DeHerrera
6dbeb3190d
Merge pull request #126544 from jonringer/nixos-rebuild-use-substitutes
nixos-rebuild: add --use-substitutes option
2021-09-09 13:53:37 -06:00
Sandro
78566493e8
Merge pull request #126614 from jonringer/nixos-rebuild-prefer-localhost
nixos-rebuild: default buildHost to localhost
2021-08-20 22:33:22 +02:00
brprice
9b0a99f64c
nixos-rebuild: print run-*-vm location with bootloader (#130385)
Previously when doing a nixos-rebuild build-vm we see a message saying how to
run the VM, but with nixos-rebuild build-vm-with-bootloader we did not. We
now show it in both cases.
2021-07-31 16:54:37 +02:00
Eelco Dolstra
0ad27c8653 nixos-rebuild: Set inherit_errexit
Without this, failure of nixBuild() and nixFlakeBuild() was ignored
(since bash doesn't inherit 'set -e' in subshells by default), so the
script would proceed with a bogus ./result link, e.g.

  ++ readlink -f /tmp/nixos-rebuild.NfHKxx/result
  + pathToConfig='/nix/store/m7dvk6an18cpr95qn5wnig2600qhv6w7-nix-2.4pre20210727_706777a/bin/nix
  /tmp/nixos-rebuild.NfHKxx/result'
  + '[' test = switch -o test = boot ']'
  + copyToTarget '/nix/store/m7dvk6an18cpr95qn5wnig2600qhv6w7-nix-2.4pre20210727_706777a/bin/nix
  /tmp/nixos-rebuild.NfHKxx/result'
  + '[' '' = '' ']'
  + '[' test = switch -o test = boot -o test = test -o test = dry-activate ']'
  + targetHostCmd /nix/store/m7dvk6an18cpr95qn5wnig2600qhv6w7-nix-2.4pre20210727_706777a/bin/nix /tmp/nixos-rebuild.NfHKxx/result/bin/switch-to-configuration test
  + '[' -z '' ']'
  + sudo -- /nix/store/m7dvk6an18cpr95qn5wnig2600qhv6w7-nix-2.4pre20210727_706777a/bin/nix /tmp/nixos-rebuild.NfHKxx/result/bin/switch-to-configuration test
  error: '/tmp/nixos-rebuild.NfHKxx/result/bin/switch-to-configuration' is not a recognised command
  Try '/nix/store/m7dvk6an18cpr95qn5wnig2600qhv6w7-nix-2.4pre20210727_706777a/bin/nix --help' for more information.
  + echo 'warning: error(s) occurred while switching to the new configuration'
  warning: error(s) occurred while switching to the new configuration
2021-07-28 17:13:01 +02:00
rnhmjoj
35a8d78e44
nixos-rebuild: fix --use-remote-sudo
Currently fails with:

  $ nixos-rebuild test --target-host myhost --use-remote-sudo
  building Nix...
  sudo: /run/current-system/sw/bin/sudo must be owned by uid 0 and have the setuid bit set

It seems setting an explicit PATH in the ssh command overrides the
remote setuid wrappers.
2021-06-18 02:55:21 +02:00
Samuel Gräfenstein
ff3b3e696a nixos-rebuild: fix creating ./result symlink for flakes 2021-06-15 08:15:31 -07:00
Jonathan Ringer
bf185eaa69
nixos-rebuild: add --use-substitutes option 2021-06-11 12:46:16 -07:00
Jonathan Ringer
971eb04341 nixos-rebuild: fix extraBuildFlags usage with flakes 2021-06-11 10:35:14 -07:00
Jonathan Ringer
d6a829e7b7 nixos-rebuild: remove unused variable: remotePATH 2021-06-11 10:35:14 -07:00
Jonathan Ringer
07da819bcf nixos-rebuild: prevent wordsplitting 2021-06-11 10:35:14 -07:00
Jonathan Ringer
0e8e7968d1 nixos-rebuild: prevent masking return value with declaration 2021-06-11 10:35:14 -07:00
Jonathan Ringer
ea5956a2ed nixos-rebuild: remove repair, never used 2021-06-11 10:35:14 -07:00
Jonathan Ringer
3d34fe9f2b
nixos-rebuild: default buildHost to localhost
Prior to #119540, the toplevel output was built
locally then pushed to the remote host when using
the command:

nixos-rebuild --flake <flake> --target-host remote.host

However, buildHost would default to targetHost when
only --target-host was supplied. This caused the .drv
closure to always be transferred unless --build-host=localhost
is supplied.

This change restores the previous build local default behavior.
TargetHost can still build the outputs, if explicitly mentioned:

nixos-rebuild --flake <flake> \
  --target-host remote.host \
  --build-host  remote.host
2021-06-11 10:01:21 -07:00
Chuck
1c80856545 nixos-rebuild: Pass flakes flags when doing local flakes build 2021-06-10 10:27:32 -07:00
Eelco Dolstra
4cffb1212a nixos-rebuild --fast: Don't imply --show-trace
There is no logical reason for --fast to imply --show-trace, and this
seems to be a historical accident. Using --show-trace by default is
bad UX since it can give very long error messages (e.g. 550 lines for
a non-existent attribute in environment.systemPackages).
2021-06-03 19:01:09 +02:00
Robert Hensing
3c6fcc9073
Merge pull request #122987 from alyssais/nixos-rebuild-aarch64
nixos-rebuild: support prebuilt Nix on aarch64
2021-05-16 22:00:39 +02:00
Théophane Hufschmitt
601ceec28d
nixos-rebuild: Don’t reset the experimental features
Make sure that the Nix `experimental-features` set by a user aren’t overwritten when running `nixos-rebuild --flake` by using `--extra-experimental-features` rather than `--experimental-features`.

Fix https://github.com/NixOS/nix/issues/4784
2021-05-16 16:17:42 +02:00
Alyssa Ross
341836ced2
nixos-rebuild: support prebuilt Nix on aarch64
We have a fallback hashes entry for aarch64-linux, but it was unused
by nixos-rebuild.
2021-05-14 12:53:57 +00:00
Charlotte Van Petegem
fa827f3f62
nixos-rebuild: Use old-style nix command when building flake on a remote host 2021-04-16 12:42:26 +02:00
Charlotte Van Petegem
456aa2db49
nixos-rebuild: Allow remote building when using flakes 2021-04-16 11:59:21 +02:00
Cole Helbling
85f5d9a6ed
nixos-rebuild: nix flake info -> nix flake metadata
As of
66fa1c7375,
the `nix flake info` and `nix flake list-inputs` commands were merged into
`nix flake metadata`.
2021-03-18 17:26:51 -07:00
Jörg Thalheim
e7c8a73390
Merge pull request #108879 from kreisys/nixos-rebuild-no-systemctl
nixos-rebuild: Remove ambient systemctl dependency
2021-03-07 14:09:39 +00:00
fricklerhandwerk
283eaaff3e nixos-rebuild: use remote $PATH in buildHostCmd
this fixes the issue when using

    nixos-rebuild switch --target-host <target> --use-remote-sudo

when the local machine does not have anything in `$PATH` that would
resolve to `sudo` on the remote machine.

the single quotes prevent expansion of `$PATH` on the local machine,
such that the remote machine's value of that variable is used.
2021-02-10 23:13:37 -08:00
Domen Kožar
9e1c01f500
--no-net is now --offline 2021-02-05 11:57:42 +00:00
Shay Bergmann
4cf09dd98c
Remove unnecessary check that uses systemctl
The use of systemctl makes this incompatible with darwin even though
building/deploying a nixos closure from darwin is a perfectly valid use case.

NIX_DAEMON is pretty much unnecessary nowadays as nix uses other
indicators for deciding whether to use the daemon or not.
2021-02-02 10:26:50 -05:00
Dominik Xaver Hörl
e9abfbde62 nixos-rebuild: put some important dependencies in PATH 2021-01-16 13:24:18 +01:00
Domen Kožar
c32f5b22f1
move nixos-rebuild into pkgs 2021-01-15 20:07:38 +01:00