!PSmBFWNKoXmlQBzUQf:helsinki-systems.de

Stage 1 systemd

86 Members
systemd in NixOs's stage 1, replacing the current bash tooling https://github.com/NixOS/nixpkgs/projects/5128 Servers

Load older messages


SenderMessageTime
23 May 2023
@arianvp:matrix.orgArian nikstur: are you building against systemd master to get repart working in the sandbox? 12:46:16
@nikstur:matrix.org@nikstur:matrix.org

I'm doing something way nastier:

systemd-repart = pkgsUnstable.systemdMinimal.overrideAttrs (finalAttrs: previousAttrs: {
      src = prev.fetchFromGitHub {
        owner = "systemd";
        repo = "systemd";
        rev = "1eb86ddde4f36165a99732b53cc97cef1acc3aa7";
        hash = "sha256-Frf0QwJCw/fG+YQ/+frqq8aD2Jv32Ozw1JMwjZSBTHc=";
      };

      # Only this patch is necessary to build systemd. This package will not be
      # usable as a general replacement of systemd for NixOS but the tools like
      # systemd-repart will work.
      patches = [ (builtins.elemAt previousAttrs.patches 10) ];
    });
13:46:59
@nikstur:matrix.org@nikstur:matrix.orgpkgsUnstable is nixos-unstable13:47:14
@arianvp:matrix.orgArianI see14:03:16
@arianvp:matrix.orgArianRedacted or Malformed Event14:03:20
@arianvp:matrix.orgArianNote that systemd-repart does not change the UIDs/GIDs of any copied files and directories. When running systemd-repart as an unprivileged user to build an image of files and directories owned by the same user, you can run systemd-repart in a user namespace with the current user mapped to the root user to make sure the files and directories in the image are owned by the root user.14:03:31
@arianvp:matrix.orgArianwe don't support user namespaces inside the build sandbox do we? or do we these days?14:03:53
@arianvp:matrix.orgArian because I want th uid to be 0. not the uid of nixbld 14:04:30
@arianvp:matrix.orgArianfor files in the image14:04:36
@nikstur:matrix.org@nikstur:matrix.orgI call systemd-repart with fakeroot14:05:35
@nikstur:matrix.org@nikstur:matrix.orgAnd then there are quite a few things you need to do to make it reproducibleish14:05:58
@arianvp:matrix.orgArianyou have this code somewhere?14:06:14
@nikstur:matrix.org@nikstur:matrix.org

Not yet in the wild. This is what I currently do:

fakeroot systemd-repart \
              --dry-run=no \
              --empty=create \
              --size=auto \
              --root=buildroot \
              --definitions="$repartDefinitions" \
              --split=true \
              image.raw

which is definetely not enough for reproducibility

14:07:33
@arianvp:matrix.orgArianwhat is unreproducible about it?14:07:43
@elvishjerricco:matrix.org@elvishjerricco:matrix.org
In reply to @arianvp:matrix.org
we don't support user namespaces inside the build sandbox do we? or do we these days?
we do
14:07:51
@nikstur:matrix.org@nikstur:matrix.orgIf there is no machine-id systemd-repart creates random UUIDs for partitions14:08:06
@nikstur:matrix.org@nikstur:matrix.organd I think timestamps might be an issue14:08:13
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgin fact I've used that to do FHS style builds in a nix build14:08:14
@elvishjerricco:matrix.org@elvishjerricco:matrix.org
In reply to @nikstur:matrix.org
If there is no machine-id systemd-repart creates random UUIDs for partitions
You can also pass --seed
14:09:04
@arianvp:matrix.orgArian oh yeh that stuff. Just put a /buildroot/etc/machine-id file . should work 14:09:28
@arianvp:matrix.orgArian or --seed. yheh 14:09:33
@arianvp:matrix.orgArian

hmmmm without fakeroot my build fails with:

 > Failed to copy symlink 'sbin', ignoring: Permission denied
       > Failed to copy '/nix/store/049705cr0z1mzjfngjr4vlybp3z5n1wx-bcache-tools-1.0.7' to '/build/.#repartabde6bac7950c286/nix/store/049705cr0z1mzjfngjr4vlybp3z5n1wx-bcache-tools-1.0.7': Invalid argument
14:11:01
@arianvp:matrix.orgArian but works with fakeroot woohoo. (What does fakeroot do? 14:14:06
@janne.hess:helsinki-systems.de@janne.hess:helsinki-systems.de
In reply to @arianvp:matrix.org
but works with fakeroot woohoo. (What does fakeroot do?
It pretends you're root
14:15:06
@arianvp:matrix.orgArian that I understand. but how does it do that? 14:15:25
@janne.hess:helsinki-systems.de@janne.hess:helsinki-systems.de
In reply to @arianvp:matrix.org
that I understand. but how does it do that?

This is done by setting LD_PRELOAD to libfakeroot.so, which provides wrappers around getuid, chown, chmod, mknod, stat, and so on, thereby creating a fake root environment.

14:15:56
@mberndt:matrix.org@mberndt:matrix.org ElvishJerricco, thanks for your review. I've responded to your comments…
https://github.com/NixOS/nixpkgs/pull/229767
14:19:15
@elvishjerricco:matrix.org@elvishjerricco:matrix.orguser namespaces are better though. Are there still holdout distros that disable that?14:21:27
@aloisw:kde.org@aloisw:kde.org
In reply to @elvishjerricco:matrix.org
user namespaces are better though. Are there still holdout distros that disable that?
Our own "hardened" kernel does that, at least.
14:36:43
@aloisw:kde.org@aloisw:kde.org There's also proot -0. 14:37:49

Show newer messages


Back to Room ListRoom Version: 6