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

nixos/nix-gc: add persistent and randomizeDelaySec options #107959

Merged
merged 1 commit into from Feb 28, 2021

Conversation

tex
Copy link
Contributor

@tex tex commented Dec 30, 2020

Motivation for this change

I am complaining about nix-gc not correctly working in laptop environment where laptop is turned on and off unpredictable causing those timers never expire and this service never executed.

Here is my fix.

I think that current situation is making this service unusable on laptops.

One can add this to his configuration.nix: systemd.timers.nix-gc.timerConfig.Persistent = true; but it is not apparent for users...

#15689
#75861

#107805

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@tex tex changed the title add persistent and randomizeDelaySec options nixos/nix-gx: add persistent and randomizeDelaySec options Dec 30, 2020
Copy link
Member

@bbjubjub2494 bbjubjub2494 left a comment

Choose a reason for hiding this comment

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

LGTM

@Mic92 Mic92 changed the title nixos/nix-gx: add persistent and randomizeDelaySec options nixos/nix-gc: add persistent and randomizeDelaySec options Dec 30, 2020
Copy link
Contributor

@thiagokokada thiagokokada left a comment

Choose a reason for hiding this comment

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

LGTM.

@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-already-reviewed/2617/317

@thiagokokada
Copy link
Contributor

I decided to give a try and test the PR to make sure everything is alright. My /etc/nixos/configuration.nix:

{
  # Backport module from unstable.
  imports = [
    /home/thiagoko/Projects/nixpkgs/nixos/modules/services/misc/nix-gc.nix
  ];
  disabledModules = [ "services/misc/nix-gc.nix" ];
  # Enable NixOS auto-upgrade.
  system.autoUpgrade = {
    enable = true;
    dates = "daily";
  };
}

And this is the result:

❯ systemctl cat nix-gc.timer                      
# /nix/store/4y61sz2gg2h7cs1bky41qaphbz08q0z2-unit-nix-gc.timer/nix-gc.timer
[Unit]

[Timer]
OnCalendar=weekly
Persistent=true
RandomizedDelaySec=0


~
❯ systemctl cat nix-gc.service
# /nix/store/4fhwmqacnq0vgx6x55j95jlyp5lh1ip4-unit-nix-gc.service/nix-gc.service
[Unit]
Description=Nix Garbage Collector

[Service]
Environment="LOCALE_ARCHIVE=/nix/store/a2px4kdz1jm03f8ifr1pzir0csfmyrlv-glibc-locales-2.31/lib/locale/locale-archive"
Environment="PATH=/nix/store/z1qvlavy35wanw5k54fvvfffws5bvigj-coreutils-8.31/bin:/nix/store/3fvzxz59gacagpwyzpfdiinc1yv46hw1-findutils-4>
Environment="TZDIR=/nix/store/w1g27pgslf28nh1py1szj7lk4xksdhqq-tzdata-2020c/share/zoneinfo"



ExecStart=/nix/store/9gvh04r9wsw0hhi2l1r2vzfs9pvg9a4b-unit-script-nix-gc-start/bin/nix-gc-start 

So, 💯 .

@thiagokokada
Copy link
Contributor

@tex Can you fix the merge conflict?

Copy link
Contributor

@thiagokokada thiagokokada left a comment

Choose a reason for hiding this comment

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

LGTM.

@SuperSandro2000 Can we have this merged?

@SuperSandro2000
Copy link
Member

@SuperSandro2000 Can we have this merged?

I don't know systemd that well.

@Mic92 If you could take another look then I think it should be fine.

Copy link
Member

@Mic92 Mic92 left a comment

Choose a reason for hiding this comment

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

Looks good. Please merge when evaluation is finished.

@tomberek tomberek merged commit df3d560 into NixOS:master Feb 28, 2021
@tex tex deleted the nixos/nix-gc branch February 28, 2021 17:56
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.

None yet

7 participants