From c274d045ac254afe96b1f8139e974ada2c42059e Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Tue, 4 Jan 2022 18:07:46 -0300 Subject: [PATCH 1/2] 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. --- pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh b/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh index e5e40dca086e..1de783a55930 100755 --- a/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh +++ b/pkgs/os-specific/linux/nixos-rebuild/nixos-rebuild.sh @@ -343,11 +343,6 @@ if [[ -n $flake ]]; then fi fi -# Resolve the flake. -if [[ -n $flake ]]; then - flake=$(nix "${flakeFlags[@]}" flake metadata --json "${extraBuildFlags[@]}" "${lockFlags[@]}" -- "$flake" | jq -r .url) -fi - # Find configuration.nix and open editor instead of building. if [ "$action" = edit ]; then if [[ -z $flake ]]; then From c75bc3abc760a07eb7afc0be26eb1813a9867a84 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Tue, 4 Jan 2022 20:02:47 -0300 Subject: [PATCH 2/2] nixos-rebuild: remove jq Was only used in the code removed in commit c274d045ac254afe96b1f8139e974ada2c42059e. --- pkgs/os-specific/linux/nixos-rebuild/default.nix | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pkgs/os-specific/linux/nixos-rebuild/default.nix b/pkgs/os-specific/linux/nixos-rebuild/default.nix index b317c5a1fbfd..08bba5a428d1 100644 --- a/pkgs/os-specific/linux/nixos-rebuild/default.nix +++ b/pkgs/os-specific/linux/nixos-rebuild/default.nix @@ -3,7 +3,6 @@ , coreutils , gnused , gnugrep -, jq , nix , lib }: @@ -19,5 +18,5 @@ substituteAll { nix_x86_64_linux = fallback.x86_64-linux; nix_i686_linux = fallback.i686-linux; nix_aarch64_linux = fallback.aarch64-linux; - path = lib.makeBinPath [ coreutils jq gnused gnugrep ]; + path = lib.makeBinPath [ coreutils gnused gnugrep ]; }