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

nh: fix auto clean #6325

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

pedorich-n
Copy link
Contributor

@pedorich-n pedorich-n commented Jan 16, 2025

Description

  • Fix PATH environment variable
  • Remove flake path assertion
  • Add warning when HM's nix.gc.automatic is enabled

Checklist

  • Change is backwards compatible.

  • Code formatted with ./format.

  • Code tested through nix-shell --pure tests -A run.all or nix develop --ignore-environment .#all using Flakes.

  • Test cases updated/added. See example.

  • Commit messages are formatted like

    {component}: {description}
    
    {long description}
    

    See CONTRIBUTING for more information and recent commit messages for examples.

  • If this PR adds a new module

    • Added myself as module maintainer. See example.

Maintainer CC

@JohnRTitor

- Fix `PATH` variable
- Remove flake path assertion
- Add warning when HM's `nix.gc.automatic` is enabled
Comment on lines -60 to -63
assertions = [{
assertion = (cfg.flake != null) -> !(lib.hasSuffix ".nix" cfg.flake);
message = "nh.flake must be a directory, not a nix file";
}];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have my HM configuration in a folder called .config.nix. So by this assertion, it can't be used.
IMO home-manager shouldn't try to guess what paths it doesn't have access to in build time are.

@@ -52,15 +52,11 @@ in {
};

config = {
warnings = lib.optionals (!(cfg.clean.enable -> !osConfig.nix.gc.automatic))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

On standalone install osConfig is null, so this fails to evaluate

message = "nh.flake must be a directory, not a nix file";
}];
warnings =
(lib.optional (cfg.clean.enable && (osConfig.nix.gc.automatic or false))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I might be missing something, but we want to raise a warning if both of these values are true, right? Then I think && is easier to read and reason about than !(cfg.clean.enable -> !osConfig.nix.gc.automatic).
Please correct me if there are other cases.

@pedorich-n
Copy link
Contributor Author

@JohnRTitor please have a look 🙇

@JohnRTitor
Copy link
Contributor

Changes mostly look good. I am busy this week due to work, I'll try to look at them in the weekend or next week.

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