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

Cure existing systemd units #313

Merged
merged 9 commits into from
Mar 8, 2023

Conversation

cole-h
Copy link
Member

@cole-h cole-h commented Mar 7, 2023

Description
Checklist
  • Formatted with cargo fmt
  • Built with nix build
  • Ran flake checks with nix flake check
  • Added or updated relevant tests (leave unchecked if not applicable)
  • Added or updated relevant documentation (leave unchecked if not applicable)
  • Linked to related issues (leave unchecked if not applicable)
Validating with install.determinate.systems

If a maintainer has added the upload to s3 label to this PR, it will become available for installation via install.determinate.systems:

curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix/pr/$PR_NUMBER | sh -s -- install

@cole-h cole-h added this to the v0.6.0 milestone Mar 7, 2023
@cole-h cole-h requested a review from Hoverbear March 7, 2023 22:18
@cole-h cole-h self-assigned this Mar 7, 2023
.await
.map_err(|e| ActionError::Remove(PathBuf::from(SERVICE_DEST), e))?;
}
tokio::fs::symlink(SERVICE_SRC, SERVICE_DEST)
Copy link
Member Author

Choose a reason for hiding this comment

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

Switched to symlink directly because we know where it is and where it should be.

Copy link
Contributor

Choose a reason for hiding this comment

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

I am fairly sure we couldn't do this with the steam deck? Might be worth checking.

Copy link
Member Author

Choose a reason for hiding this comment

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

I validated and this works just fine, it seems.

Installed, ran nix run nixpkgs#hello | nix run nixpkgs#ponysay, rebooted, ran nix run nixpkgs#hello | nix run nixpkgs#ponysay again, worked fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting, for some reason I thought this would give issues with cross mount symlinks...

Copy link
Member Author

)
.await?;
if Path::new(SERVICE_DEST).exists() {
// TODO: ask user if we can remove it...? do we have a way
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we are currently structured to be able to have some interactivity within the plans... We do have a prompt function but that's part of the CLI and it would feel weird putting that in here...

Copy link
Contributor

Choose a reason for hiding this comment

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

We have discussed adding some UX for curing to prompt users, but as of right now -- no support.

src/action/common/configure_init_service.rs Outdated Show resolved Hide resolved
@cole-h
Copy link
Member Author

cole-h commented Mar 7, 2023

I also explicitly do not consider unit overrides, since that would be a huge nightmare to handle (AFAIK, the only way to know about overrides is to do something like systemctl cat the unit and look at the comments that tell you what came from which file).

If there was an easy way to detect, we could at least warn or error about it, but I don't see an easy way to do that...

systemctl status can kinda show this, but I'd be very much against trying to parse that output:

● nix-daemon.service - Nix Daemon
     Loaded: loaded (/etc/systemd/system/nix-daemon.service; linked; preset: enabled)
    Drop-In: /etc/systemd/system.control/nix-daemon.service.d
             └─50-CPUWeight.conf
             /nix/store/z19lfwkg4bcrvq4llrqyv18n4nkjvlw1-system-units/nix-daemon.service.d
             └─overrides.conf

@cole-h
Copy link
Member Author

cole-h commented Mar 8, 2023

re: overrides -- apparently there's a dbus API we could use, but for now I'm going with "best effort" and checking the place where the overrides are likely to appear.

@cole-h cole-h marked this pull request as ready for review March 8, 2023 19:19
@cole-h cole-h changed the title WIP: Cure existing systemd units Cure existing systemd units Mar 8, 2023
if the link_dest and unit_src were the same, we'd still error that the
file exists
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants