Skip to content

treewide: consolidate logic in platform-specific commands #281

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

NotAShelf
Copy link
Collaborator

Welcome back funny PR.

Something something consolidates duplicate platform logic something. Hopefully not a breaking change but I'm pushing this while incredibly sick and will go back to bed right after.

@NotAShelf
Copy link
Collaborator Author

I have neither standalone HM nor a Darwin configuration in my flake, so I can only hope those continue to work as intended. @khaneliman if you could see if this PR resolves the previous warning, that'd be neat. Feel free to also test other Darwin functionality.

For now I'm going back to bed, this can probably be merged after proper testing and some rustdoc added to new functions (since they're a part of the util module.)

@NotAShelf
Copy link
Collaborator Author

mfw regressed again, god dammit

@NotAShelf NotAShelf force-pushed the consolidate-logic branch from 61c4ef9 to 40025c3 Compare May 11, 2025 06:48
@NotAShelf NotAShelf force-pushed the consolidate-logic branch from 40025c3 to 9bfb22f Compare May 11, 2025 08:06
@NotAShelf NotAShelf self-assigned this May 11, 2025
@NotAShelf NotAShelf added this to the 4.1.0 milestone May 11, 2025
@NotAShelf
Copy link
Collaborator Author

This should be "stable" enough for testing now. As I haven't tested HM and Darwin functionality (knowing there are those who track the master branch) I am not merging this until I can get some test results. If only we had regression testing...

@khaneliman
Copy link
Contributor

I don't use a standalone home-manager, but I can test darwin and nixos. Seems to have resolved the warning about guessing hostname and building for a VM. But, it still has no diff output between generations.

@NotAShelf
Copy link
Collaborator Author

I've disabled diff in Darwin until I implement the new differ, though I might bring it back before this is merged. Does it not display diffs in current master? I'm off my computer and can't really look into the code rn.

@khaneliman
Copy link
Contributor

I've disabled diff in Darwin until I implement the new differ, though I might bring it back before this is merged. Does it not display diffs in current master? I'm off my computer and can't really look into the code rn.

Nah, it doesn't on master either. I didn't realize it was a conscious choice, thought it was an accident. But, this does resolve the warning.

@NotAShelf
Copy link
Collaborator Author

It shouldn't be broken on master, at least I haven't noticed that it was. If you could bisect, I might be able to submit a patch later today or most likely tomorrow. Either way I'll bring it back with the new differ (#282) once I get to it.

@khaneliman
Copy link
Contributor

khaneliman commented May 11, 2025

It shouldn't be broken on master, at least I haven't noticed that it was. If you could bisect, I might be able to submit a patch later today or most likely tomorrow. Either way I'll bring it back with the new differ (#282) once I get to it.

When I bisected it was on that PR I made the comment on, I think 477b751 ? . Right now I'm just pinning my flake input to the commit before it, merging the darwin root activation support.

@NotAShelf NotAShelf mentioned this pull request May 12, 2025
20 tasks
use crate::installable::Installable;

/// Resolves an Installable from an environment variable, or falls back to the provided one.
pub fn resolve_env_installable(var: &str, fallback: Installable) -> Installable {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Bikeshed: this should return an Option<Installable>, as the callsites favour doing platform::resolve_env_installable("NH_OS_FLAKE").unwrap_or(self.installable)

/// - `config_name`: Optional configuration name (e.g. username@hostname)
/// - `push_drv`: Whether to push the drv path (platform-specific)
/// - `extra_args`: Extra args for nix eval (for config detection)
pub fn extend_installable_for_platform(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe could have some unit tests.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'll probably rebase the tests PR on top of this one so that we can have unit tests, regression tests and property tests

///
/// The path to the built configuration, which can be used for activation
#[allow(clippy::too_many_arguments)]
pub fn handle_rebuild_workflow(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like doing a Builder for commands with many options, but this can go for now.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What can go? The warning or the function?

@cdo256
Copy link
Contributor

cdo256 commented May 25, 2025

Thank you for doing all of this 'manual labor', Raf. I agree something had to be done.

One point that might cause an issue is that currently platform::get_target_hostname() does both the job of getting the hostname attr, as well as doing the check to decide whether to run nvd. Issue #299 would require the latter logic to be performed after the derivation is built. platform::get_target_hostname() would have to be split into say platform::get_target_hostname() and platform::should_run_nvd().

Then I'd could implement a fix for #299 on this branch.

What do you think? Is it worth the extra complexity?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants