NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.02k stars 14.03k forks source link

Exception handling for systemd-boot fails #138367

Open deifactor opened 3 years ago

deifactor commented 3 years ago

Describe the bug

I was messing around with flake-ifying my install and I made a setup without a kernel by including boot.isContainer = true. Then I fixed it, and realized my mistake... but it still kept failing to generate a boot entry for the kernel-less profile. I was able to get it to work by setting boot.loader.systemd-boot.configurationLimit = 1;.

Steps To Reproduce

Steps to reproduce the behavior:

  1. Try a configuration by setting boot.isContainer = true, and fail. This is expected.
  2. Set it back to false, then try to switch again.
  3. It fails because you still can't generate the old config.

Expected behavior

Screenshots

Traceback (most recent call last):
  File "/nix/store/0fb2wppxw1a0pv2npjkdx8ffyxwldf01-systemd-boot", line 240, in main
    write_entry(*gen, machine_id)
  File "/nix/store/0fb2wppxw1a0pv2npjkdx8ffyxwldf01-systemd-boot", line 99, in write_entry
    kernel = copy_from_profile(profile, generation, "kernel")
  File "/nix/store/0fb2wppxw1a0pv2npjkdx8ffyxwldf01-systemd-boot", line 73, in copy_from_profile
    copy_if_not_exists(store_file_path, "/boot%s" % (efi_file_path))
  File "/nix/store/0fb2wppxw1a0pv2npjkdx8ffyxwldf01-systemd-boot", line 23, in copy_if_not_exists
    shutil.copyfile(source, dest)
  File "/nix/store/dqxic3j7csd4ywn94n4smmnz55p039g3-python3-3.9.6/lib/python3.9/shutil.py", line 264, in copyfile
    with open(src, 'rb') as fsrc, open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: '/nix/store/5m5n42j0a6m987l188sg01rp39fj3w5g-nixos-system-against-all-authority-21.11.20210916.79c444b/kernel'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/nix/store/0fb2wppxw1a0pv2npjkdx8ffyxwldf01-systemd-boot", line 274, in <module>
    main()
  File "/nix/store/0fb2wppxw1a0pv2npjkdx8ffyxwldf01-systemd-boot", line 244, in main
    print("ignoring profile '{}' in the list of boot entries because of the following error:\n{}".format(profile, e), file=sys.stderr)
UnboundLocalError: local variable 'profile' referenced before assignment
warning: error(s) occurred while switching to the new configuration

Additional context

Notify maintainers

Metadata

Please run nix-shell -p nix-info --run "nix-info -m" and paste the result.

❯ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.10.64, NixOS, 21.11 (Porcupine)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.4pre20210908_3c56f62`
 - channels(root): `"nixos-21.11pre312407.8a2ec31e224, home-manager"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute: 
# a list of nixos modules affected by the problem
module: systemd-boot
LukaKon commented 3 years ago

Hi, I have got same error when I wanted to update system after rearranging config files - changing names of files and folders. My system info is same as your.

LukaKon commented 3 years ago

Removed nvtop cudaPackages.cudatoolkit_11 It helped somehow. I can now update flake without error.

stale[bot] commented 2 years ago

I marked this as stale due to inactivity. → More info