16 Mar 2022 |
bobvanderlinden | * Janne Heß: Indeed. I also realized that it could take a long time before everyone agrees on all the changes that I have made in #164016. That is why I split off the most important change to https://github.com/NixOS/nixpkgs/pull/164317. I can keep working on making initramfs's systemd as nice and reusable as possible. Since it will be under a boot.initramfs.systemd.enable -option it'll be easier to merge already. Once it is settled that the reusable parts are indeed the right way to go, we can slowly merge them into the systemd and systemd.user modules. | 19:08:43 |
| @janne.hess:helsinki-systems.de invited Mic92. | 19:17:02 |
| Mic92 joined the room. | 19:17:12 |
19 Mar 2022 |
bobvanderlinden | ElvishJerricco: my branch where I worked on your work is here: https://github.com/bobvanderlinden/nixpkgs/commits/rewrite-initrd-systemd the most notable things I did:
- Merged nixos-unstable and made sure things are working again
- Renamed the make-initramfs-ng tool to find-dependencies. Now it doesn't copy files, but solely output paths for cpio's stdin. This should make it a bit faster.
- Added functionality to find /nix/store/XXX paths in non-ELF files. So it can recursively find dependencies in config files (like .service files).
- Make sure the nixos/tests/systemd.nix succeeded.
- Moved everything from nixos/modules/boot/stage-1.nix into nixos/modules/boot/initramfs/default.nix and nixos/modules/boot/initramfs/systemd/default.nix. This reverted stage-1.nix back to its original content, so that
boot.initrd.enable can work. This adds boot.initramfs.enable and boot.initramfs.systemd.enable .
| 09:25:08 |
@elvishjerricco:matrix.org | Oh boy, I've got some catching up to do... | 09:26:33 |
@elvishjerricco:matrix.org | bobvanderlinden: TBH I've basically restarted again to heavily clean up the module API so that it's almost just boot.initrd.systemd.objects and boot.initrd.systemd.<unit-type> | 09:27:25 |
bobvanderlinden | that is mostly where I left off. The next thing I was working on was to remove systemd-units.nix and reuse the units, services, mounts from nixos/modules/boot/systemd.nix. That's why I was refactoring nixos/modules/boot/systemd.nix in a separate PR. | 09:27:49 |
@elvishjerricco:matrix.org | Plus switching to an enable thing so that you can choose between old initrd (default) and systemd initrd | 09:27:52 |
@elvishjerricco:matrix.org | bobvanderlinden: Yea that's what I'm doing literally right now on my branch | 09:28:17 |
bobvanderlinden | yes, that was a good step to take. However, since we reworked the way initrd (aka initramfs) is being built, I gathered it might be safer to move that also to a separate option. | 09:29:37 |
bobvanderlinden | reusable systemd can be found here: https://github.com/bobvanderlinden/nixpkgs/commits/pr-reusable-systemd-module | 09:29:49 |
bobvanderlinden | I wanted to do that in stages, so that it will be easier to merge for people ☝️ | 09:30:31 |
bobvanderlinden | Moving systemd helper functions to systemd-lib.nix: https://github.com/NixOS/nixpkgs/pull/164317
Split up systemd.nix into systemd/{user,journald,coredump,...}.nix: https://github.com/NixOS/nixpkgs/pull/164016 | 09:31:51 |
@elvishjerricco:matrix.org | wait... is your version of the rust program copying any nix path to show up in any file? | 09:32:02 |
@elvishjerricco:matrix.org | That's very likely to be excessive | 09:32:15 |
bobvanderlinden | no, it only outputs to stdout the paths of the /nix/store/* files | 09:32:42 |
bobvanderlinden | the tool doesn't write to files/directories anymore | 09:33:06 |
@elvishjerricco:matrix.org | bobvanderlinden: Sure, but that's not what I meant | 09:34:19 |
@elvishjerricco:matrix.org | it's just searching for any /nix/store/XXXXXXX... path in any file and adding that to the list, right? | 09:34:34 |
bobvanderlinden | ah, yes, if it is not an ELF file, it will do that. I gathered it can be optimized a bit by detecting a text-file for instance | 09:35:20 |
bobvanderlinden | * ah, yes, if it is not an ELF file, it will do that. I gathered it can be optimized a bit by detecting a text-file for instance, but I haven't implemented that yet. | 09:35:38 |
@elvishjerricco:matrix.org | Hmm... I dunno whether or not that's a good idea | 09:35:39 |
@elvishjerricco:matrix.org | It could definitely lead to excessive inclusions | 09:35:51 |
@elvishjerricco:matrix.org | and initramfs really needs to be lean | 09:36:03 |
@elvishjerricco:matrix.org | Not even close to as bad as copying whole nix closure of course, but I'd be curious to know if it tends to make the initramfs noticeably bigger | 09:36:55 |
bobvanderlinden | Well, the idea was that if you refer to files in initramfs.systemd.services (directly or indirectly), it'll copy those automatically. You only need to add things to initramfs.contents if those files were missed. That shouldn't happen that often. | 09:37:32 |
@elvishjerricco:matrix.org | yea, I was going to add stuff specifically for parsing Exec* options in service files to make sure it was as minimal as possible, rather than just any referenced path | 09:38:14 |
bobvanderlinden | I see that as an optimization ;) it's good to do so. My solution is crude indeed, but it does get the job done, also for things like initramfs.systemd.services.myservice.script = "... ${somePackage}/bin/something ..."; where ExecStart refers to a bash script, that refers to a bin file. It can go deep I guess 😅 | 09:40:43 |
@elvishjerricco:matrix.org | we'll have to play with it and see the size consequences | 09:41:35 |
bobvanderlinden | The initramfs of mine was 30M last time I ran it | 09:41:56 |