Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemd-boot-builder.py: add support for profiles #26318

Merged
merged 2 commits into from Jun 24, 2017

Conversation

KaiHa
Copy link
Contributor

@KaiHa KaiHa commented Jun 2, 2017

This will also list the generations of other profiles than system in
the boot menu. See the documentation of the --profile-name option of
nixos-rebuild for more information on profiles.

Motivation for this change

To boot other profiles with systemd-boot.

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

This will also list the generations of other profiles than `system` in
the boot menu. See the documentation of the `--profile-name` option of
nixos-rebuild for more information on profiles.
@mention-bot
Copy link

@KaiHa, thanks for your PR! By analyzing the history of the files in this pull request, we identified @Mic92, @aszlig and @lheckemann to be potential reviewers.

@grahamc
Copy link
Member

grahamc commented Jun 2, 2017

What is the use case for this?

@Mic92
Copy link
Member

Mic92 commented Jun 3, 2017

Suppose you want to have different kernel version. You can create a profile for each and get a boot menu entry to select them.

for path in glob.iglob("@efiSysMountPoint@/loader/entries/nixos-generation-[1-9]*.conf"):
known_paths.append(copy_from_profile(*gen, "kernel", True))
known_paths.append(copy_from_profile(*gen, "initrd", True))
for path in glob.iglob("@efiSysMountPoint@/loader/entries/nixos-*-generation-[1-9]*.conf"):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would not this fail to match old entries?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right I need to fix this. I will update the PR.


def remove_old_entries(gens):
slice_start = len("@efiSysMountPoint@/loader/entries/nixos-generation-")
slice_end = -1 * len(".conf")
rex_profile = re.compile("^@efiSysMountPoint@/loader/entries/nixos-(.*)-generation-.*\.conf$")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here as well. We need backward-compatible code.

Copy link
Contributor Author

@KaiHa KaiHa Jun 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is with intent. The rex_profile regex is used to decide if it is a system profile or not.

@Mic92
Copy link
Member

Mic92 commented Jun 3, 2017

Currently fails to build, when I give no profile argument to nixos-rebuild switch:

created 10635 symlinks in user environment                                                                                                                                  
install-info: warning: no info dir entry in `/nix/store/1zjrj9rna9gs16d36kc53l6dzy9kkxab-system-path/share/info/time.info'                                                  
building path(s) ‘/nix/store/w9kjfxkm8hfvrfqlxxr0hilfivxl81cn-dbus-1’                                                                                                       
building path(s) ‘/nix/store/y8s1j7cv8maf7i7crjajdmvci4lg5x2v-unit-polkit.service’                                                                                          
building path(s) ‘/nix/store/jqp8b44i1lx82i4h4fpialqxl1qdssdd-unit-systemd-fsck-.service’                                                                                   
building path(s) ‘/nix/store/0p423ar4pj10jxa5277pprm0bn5paavr-unit-dbus.service’                                                                                            
building path(s) ‘/nix/store/6wx3l0v74p32f8icrq9vmkw370m7kdqw-system-units’                                                                                                 
building path(s) ‘/nix/store/h4z06sv1nys9sl6mrndk749np9d76bh2-user-units’                                                                                                   
building path(s) ‘/nix/store/gyxmp1np5zlk7vnilz71qkc3hr5rppmm-etc’                                                                                                          
building path(s) ‘/nix/store/m0w6z41fsj1qdpmw34bxcpq729qngpl8-nixos-system-turingmachine-17.09.git.5334e85’                                                                 
Traceback (most recent call last):                                                                                                                                          
  File "/nix/store/xns7s94x8a7z24hi9qd9jzrsl445sscz-systemd-boot-builder.py", line 182, in <module>                                                                         
    main()                                                                                                                                                                  
  File "/nix/store/xns7s94x8a7z24hi9qd9jzrsl445sscz-systemd-boot-builder.py", line 165, in main                                                                             
    for profile in get_profiles():                                                                                                                                          
  File "/nix/store/xns7s94x8a7z24hi9qd9jzrsl445sscz-systemd-boot-builder.py", line 127, in get_profiles                                                                     
    for x in os.listdir("/nix/var/nix/profiles/system-profiles/")                                                                                                           
FileNotFoundError: [Errno 2] No such file or directory: '/nix/var/nix/profiles/system-profiles/'                                                                            
warning: error(s) occurred while switching to the new configuration 

@KaiHa
Copy link
Contributor Author

KaiHa commented Jun 3, 2017

Currently fails to build, when I give no profile argument to nixos-rebuild switch:

Ohh, I should have checked the case that no profile exists. My bad, I will update the PR but will only have time earliest on Monday to do so.

@KaiHa
Copy link
Contributor Author

KaiHa commented Jun 7, 2017

@Mic92, let me know if there is still something that needs to be fixed.

@Mic92 Mic92 merged commit 9929e83 into NixOS:master Jun 24, 2017
@KaiHa KaiHa deleted the systemd-boot-and-profiles branch October 31, 2020 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants