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

ostree planner does not understand --no-start-daemon/$NIX_INSTALLER_START_DAEMON=false #1297

Open
lina-bh opened this issue Nov 18, 2024 · 4 comments
Labels
Containerized Related to Docker, Podman, or LXC (etc) Linux ostree

Comments

@lina-bh
Copy link

lina-bh commented Nov 18, 2024

I am attempting to add Nix to a universal blue image (https://github.com/ublue-os/image-template), but I cannot stop the installer from erroring out when it does not see a running systemd. Installing on a live system works fine. No combination of --no-start-daemon or $NIX_INSTALLER_START_DAEMON=false will get it to start installing.

ENV NIX_INSTALLER_EXTRA_CONF="extra-trusted-users = @wheel\n"
ENV NIX_INSTALLER_NO_CONFIRM=true
ENV NIX_INSTALLER_START_DAEMON=false
RUN set -o pipefail && \
    curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | \
    sh -s -- install ostree --no-start-daemon
[2/2] STEP 8/16: RUN set -o pipefail &&     curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix |     sh -s -- install ostree --no-start-daemon
info: downloading installer (https://install.determinate.systems/nix/tag/v0.28.0/nix-installer-x86_64-linux)
error: unexpected argument '--no-start-daemon' found

Usage: nix-installer install ostree [OPTIONS]

For more information, try '--help'.
Error: building at STEP "RUN set -o pipefail &&     curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix |     sh -s -- install ostree --no-start-daemon": while running runtime: exit status 1
@cole-h
Copy link
Member

cole-h commented Nov 18, 2024

Have you tried with --init none instead of --no-start-daemon?

What do you mean when you say "I cannot stop the installer from erroring out when it does not see a running systemd" -- do you have those errors handy?

@lina-bh
Copy link
Author

lina-bh commented Nov 19, 2024

Some minimal reproducers, you don't need anything but podman (i suspect docker works too). Using the linux planner does not succeed because of missing directories, either way the /nix directory will be wiped out.

bare

FROM ghcr.io/ublue-os/base-main:41

ADD https://github.com/DeterminateSystems/nix-installer/releases/download/v0.28.0/nix-installer-x86_64-linux /tmp/nix
RUN chmod +x /tmp/nix && \
    /tmp/nix install && \
    rm /tmp/nix && \
    ostree container commit
STEP 1/3: FROM ghcr.io/ublue-os/base-main:41
STEP 2/3: ADD https://github.com/DeterminateSystems/nix-installer/releases/download/v0.28.0/nix-installer-x86_64-linux /tmp/nix
--> Using cache dfc89506dadbfbaa14ddb0e04812d94a09cb972ead789d1703e522928d09b37d
--> dfc89506dadb
STEP 3/3: RUN chmod +x /tmp/nix &&     /tmp/nix install &&     rm /tmp/nix &&     ostree container commit
 INFO nix-installer v0.28.0
systemd was not active.

If it will be started later consider, passing `--no-start-daemon`.

To use a `root`-only Nix install, consider passing `--init none`.
Error: building at STEP "RUN chmod +x /tmp/nix &&     /tmp/nix install &&     rm /tmp/nix &&     ostree container commit": while running runtime: exit status 1

--no-start-daemon

RUN chmod +x /tmp/nix && \
    /tmp/nix install --no-start-daemon && \
    rm /tmp/nix && \
    ostree container commit
STEP 3/3: RUN chmod +x /tmp/nix &&     /tmp/nix install --no-start-daemon &&     rm /tmp/nix &&     ostree container commit
error: unexpected argument '--no-start-daemon' found

  tip: to pass '--no-start-daemon' as a value, use '-- --no-start-daemon'

Usage: nix install [OPTIONS] [PLAN]
       nix install <COMMAND>

For more information, try '--help'.
Error: building at STEP "RUN chmod +x /tmp/nix &&     /tmp/nix install --no-start-daemon &&     rm /tmp/nix &&     ostree container commit": while running runtime: exit status 2

--init none

RUN chmod +x /tmp/nix && \
    /tmp/nix install --init none && \
    rm /tmp/nix && \
    ostree container commit
STEP 3/3: RUN chmod +x /tmp/nix &&     /tmp/nix install --init none &&     rm /tmp/nix &&     ostree container commit
error: unexpected argument '--init' found

  tip: to pass '--init' as a value, use '-- --init'

Usage: nix install [OPTIONS] [PLAN]
       nix install <COMMAND>

For more information, try '--help'.
Error: building at STEP "RUN chmod +x /tmp/nix &&     /tmp/nix install --init none &&     rm /tmp/nix &&     ostree container commit": while running runtime: exit status 2

@cole-h
Copy link
Member

cole-h commented Nov 19, 2024

Ah, OK, that's my bad -- I completely skipped over the fact this was a containerized environment, sorry!

Right now, the ostree planner only supports systems with a running systemd (it does all the setup necessary for the ostree environment via systemd units).

I can easily add the no-start-daemon argument, but that won't help in this case, as systemd isn't running at all in the container, so all the tasks that rely on systemd being available would still fail...

I can't think of a way to get this working, but if you feel like poking around, here's the diff that adds --no-start-daemon to the ostree planner:

diff --git a/src/planner/ostree.rs b/src/planner/ostree.rs
index f92d7d9..8654b0d 100644
--- a/src/planner/ostree.rs
+++ b/src/planner/ostree.rs
@@ -1,3 +1,6 @@
+#[cfg(feature = "cli")]
+use clap::ArgAction;
+
 use crate::{
     action::{
         base::{CreateDirectory, CreateFile, RemoveDirectory},
@@ -33,6 +36,19 @@ pub struct Ostree {
     /// Where `/nix` will be bind mounted to.
     #[cfg_attr(feature = "cli", clap(long, default_value = "/var/home/nix"))]
     persistence: PathBuf,
+    /// Start the daemon (if not `--init none`)
+    #[cfg_attr(
+        feature = "cli",
+        clap(
+            value_parser,
+            action(ArgAction::SetFalse),
+            env = "NIX_INSTALLER_START_DAEMON",
+            default_value_t = true,
+            long = "no-start-daemon"
+        )
+    )]
+    pub start_daemon: bool,
+
     #[cfg_attr(feature = "cli", clap(flatten))]
     pub settings: CommonSettings,
 }
@@ -44,6 +60,7 @@ impl Planner for Ostree {
         Ok(Self {
             persistence: PathBuf::from("/var/home/nix"),
             settings: CommonSettings::default().await?,
+            start_daemon: true,
         })
     }
 
@@ -232,7 +249,7 @@ impl Planner for Ostree {
         );
 
         plan.push(
-            ConfigureUpstreamInitService::plan(InitSystem::Systemd, true)
+            ConfigureUpstreamInitService::plan(InitSystem::Systemd, self.start_daemon)
                 .await
                 .map_err(PlannerError::Action)?
                 .boxed(),
@@ -263,6 +280,7 @@ impl Planner for Ostree {
         let Self {
             persistence,
             settings,
+            start_daemon,
         } = self;
         let mut map = HashMap::default();
 
@@ -271,6 +289,10 @@ impl Planner for Ostree {
             "persistence".to_string(),
             serde_json::to_value(persistence)?,
         );
+        map.insert(
+            "start_daemon".to_string(),
+            serde_json::to_value(start_daemon)?,
+        );
 
         Ok(map)
     }

@cole-h cole-h added the Containerized Related to Docker, Podman, or LXC (etc) label Nov 19, 2024
@lina-bh
Copy link
Author

lina-bh commented Nov 20, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Containerized Related to Docker, Podman, or LXC (etc) Linux ostree
Projects
None yet
Development

No branches or pull requests

2 participants