-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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: add module #5304
base: master
Are you sure you want to change the base?
nh: add module #5304
Conversation
fe38e36
to
11b0c04
Compare
Note: this home manager module can also run garbage collection systemd service. However it is only limited to user scope, unlike its NixOS sibling module. |
services.nh-clean = { | ||
description = "Nh clean (user)"; | ||
script = | ||
"exec ${lib.getExe cfg.package} clean user ${cfg.clean.extraArgs}"; | ||
startAt = cfg.clean.dates; | ||
path = [ config.nix.package ]; | ||
serviceConfig.Type = "oneshot"; | ||
}; | ||
|
||
timers.nh-clean = { timerConfig = { Persistent = true; }; }; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume this is coming from some NixOS module. It will not work on HM since it does not use the same option naming for systemd units.
I would suggest creating some test case that enables the nh-clean service and then tests the content of the generated unit files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestions. Indeed this is coming from a NixOS module.
I am trying to recreate the following in Home Manager syntax. How do I set these? LOCALE_ARCHIVE, variable, for example. I am new to NixOS and Nix syntax.
The following is the content of nh-clean.service.
[Service]
Environment="LOCALE_ARCHIVE=/nix/store/zbn9jsvqg4gp6dsa01gmfwald132fk49-glibc-locales-2.39-31/lib/locale/locale-archive"
Environment="PATH=/nix/store/5dyaxm5ksj6956xbnssyr2pwm4bq9jkf-nix-2.18.2/bin:/nix/store/hq8765g3p1i7qbargnqli5mn0jpsdbfl-coreutils-9.5/bin:/nix/store/d1v47ybpl5cv9ycffgbfagfhvbvj8xdx-findutils-4.9.0/bin:/nix/store/wy37jk2hirzqzx0666w1849kjdgzdam6-gnugrep-3.11/bin:/nix/store/4cps736z7in3d37qc801lwv9z0ib67ps-gnused-4.9/bin:/nix/store/7kq9hvrhcy8g1v0jd07nr54279asg9vc-systemd-255.4/bin:/nix/store/5dyaxm5ksj6956xbnssyr2pwm4bq9jkf-nix-2.18.2/sbin:/nix/store/hq8765g3p1i7qbargnqli5mn0jpsdbfl-coreutils-9.5/sbin:/nix/store/d1v47ybpl5cv9ycffgbfagfhvbvj8xdx-findutils-4.9.0/sbin:/nix/store/wy37jk2hirzqzx0666w1849kjdgzdam6-gnugrep-3.11/sbin:/nix/store/4cps736z7in3d37qc801lwv9z0ib67ps-gnused-4.9/sbin:/nix/store/7kq9hvrhcy8g1v0jd07nr54279asg9vc-systemd-255.4/sbin"
Environment="TZDIR=/nix/store/7lzfzr3xsdgscccnfl9rykiwncwwvhbi-tzdata-2024a/share/zoneinfo"
ExecStart=/nix/store/8454db7gv30ls496k5cam45j1amykrnn-unit-script-nh-clean-start/bin/nh-clean-start
Type=oneshot
I was able to convert the timers config :)
timers.nh-clean = {
Timer = {
OnCalendar = cfg.clean.dates;
Persistent = true;
};
};
Or we can simply remove the service part and get it going.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rycee any suggestions?
Thanks for the contribution! I've added a few comments. |
Add nh to news
Description
nh is a Nix CLI helper designed to provide beautiful outputs when rebuilding system or garbage collecting. Module already exists for NixOS, and so should for home manager too.
This PR
programs.nh
optionChecklist
Change is backwards compatible.
Code formatted with
./format
.Code tested through
nix-shell --pure tests -A run.all
ornix develop --ignore-environment .#all
using Flakes.If this PR adds a new module
Maintainer CC
initial PR, I'll be maintaining this HM module