Skip to content

Commit 6a66cf7

Browse files
committed
ostree: allow --no-start-daemon and --init none
The ostree planner hard-coded InitSystem::Systemd and always started the daemon, making it impossible to install Nix during container builds where systemd is not running. Add InitSettings to the Ostree planner, mirroring the Linux planner. When init is None, /nix is created directly instead of relying on the bind mount. Remove the unused OstreeError enum. Add a Fedora 42 container test exercising the reported scenario. Closes: #155
1 parent 9d2319d commit 6a66cf7

File tree

4 files changed

+183
-152
lines changed

4 files changed

+183
-152
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ jobs:
313313
distro:
314314
- ubuntu-v22_04
315315
- ubuntu-v24_04
316+
- fedora-v42-ostree
316317
steps:
317318
- name: Checkout repository
318319
uses: actions/checkout@v6

nix/tests/container-test/default.nix

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,35 @@ let
2424
tester = ./default/Dockerfile;
2525
system = "x86_64-linux";
2626
};
27+
28+
# Fedora 42 WSL rootfs – used for the ostree planner container test
29+
# (no systemd, --init none) reproducing
30+
# https://github.com/NixOS/nix-installer/issues/155
31+
# Re-compressed from .tar.xz to .tar.zst because podman import is
32+
# extremely slow at xz decompression inside a VM.
33+
"fedora-v42-ostree" =
34+
let
35+
xzTarball = builtins.fetchurl {
36+
url = "https://dl.fedoraproject.org/pub/fedora/linux/releases/42/Container/x86_64/images/Fedora-WSL-Base-42-1.1.x86_64.tar.xz";
37+
sha256 = "138vibdf0qcln3r0f116qvmq5vx8im9cy0xv2ml7r8ccsw2kvywr";
38+
};
39+
pkgs = forSystem "x86_64-linux" ({ pkgs, ... }: pkgs);
40+
in
41+
{
42+
tarball =
43+
pkgs.runCommand "fedora-42-rootfs.tar.zst"
44+
{
45+
nativeBuildInputs = with pkgs; [
46+
xz
47+
zstd
48+
];
49+
}
50+
''
51+
xz -dc ${xzTarball} | zstd -o $out
52+
'';
53+
tester = ./ostree/Dockerfile;
54+
system = "x86_64-linux";
55+
};
2756
};
2857

2958
makeTest =
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM default
2+
COPY nix-installer /nix-installer
3+
RUN chmod +x /nix-installer/bin/nix-installer
4+
# In a container build there is no systemd, so we need --init none to skip
5+
# daemon setup entirely — this is the scenario from
6+
# https://github.com/NixOS/nix-installer/issues/155
7+
RUN /nix-installer/bin/nix-installer install ostree --logger pretty --log-directive nix_installer=trace --init none --extra-conf "sandbox = false" --no-confirm -vvv
8+
ENV PATH="${PATH}:/nix/var/nix/profiles/default/bin"
9+
RUN nix-build --no-substitute -E 'derivation { name = "foo"; system = "x86_64-linux"; builder = "/bin/sh"; args = ["-c" "echo foobar > $out"]; }'
10+
RUN /nix/nix-installer uninstall --no-confirm

0 commit comments

Comments
 (0)