fstrim: Add service
This commit is contained in:
parent
1d56c2fa43
commit
a996fe849f
|
@ -283,6 +283,7 @@
|
||||||
./services/misc/etcd.nix
|
./services/misc/etcd.nix
|
||||||
./services/misc/felix.nix
|
./services/misc/felix.nix
|
||||||
./services/misc/folding-at-home.nix
|
./services/misc/folding-at-home.nix
|
||||||
|
./services/misc/fstrim.nix
|
||||||
./services/misc/gammu-smsd.nix
|
./services/misc/gammu-smsd.nix
|
||||||
./services/misc/geoip-updater.nix
|
./services/misc/geoip-updater.nix
|
||||||
#./services/misc/gitit.nix
|
#./services/misc/gitit.nix
|
||||||
|
|
45
nixos/modules/services/misc/fstrim.nix
Normal file
45
nixos/modules/services/misc/fstrim.nix
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
|
||||||
|
let
|
||||||
|
|
||||||
|
cfg = config.services.fstrim;
|
||||||
|
|
||||||
|
in {
|
||||||
|
|
||||||
|
options = {
|
||||||
|
|
||||||
|
services.fstrim = {
|
||||||
|
enable = mkEnableOption "periodic SSD TRIM of mounted partitions in background";
|
||||||
|
|
||||||
|
interval = mkOption {
|
||||||
|
type = types.string;
|
||||||
|
default = "weekly";
|
||||||
|
description = ''
|
||||||
|
How often we run fstrim. For most desktop and server systems
|
||||||
|
a sufficient trimming frequency is once a week.
|
||||||
|
|
||||||
|
The format is described in
|
||||||
|
<citerefentry><refentrytitle>systemd.time</refentrytitle>
|
||||||
|
<manvolnum>7</manvolnum></citerefentry>.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
|
||||||
|
systemd.packages = [ pkgs.utillinux ];
|
||||||
|
|
||||||
|
systemd.timers.fstrim = {
|
||||||
|
timerConfig = {
|
||||||
|
OnCalendar = cfg.interval;
|
||||||
|
};
|
||||||
|
wantedBy = [ "timers.target" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
|
@ -29,6 +29,10 @@ stdenv.mkDerivation rec {
|
||||||
preConfigure = "export scanf_cv_type_modifier=ms";
|
preConfigure = "export scanf_cv_type_modifier=ms";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
preConfigure = lib.optionalString (systemd != null) ''
|
||||||
|
configureFlags+="--with-systemd --with-systemdsystemunitdir=$bin/lib/systemd/system/"
|
||||||
|
'';
|
||||||
|
|
||||||
# !!! It would be better to obtain the path to the mount helpers
|
# !!! It would be better to obtain the path to the mount helpers
|
||||||
# (/sbin/mount.*) through an environment variable, but that's
|
# (/sbin/mount.*) through an environment variable, but that's
|
||||||
# somewhat risky because we have to consider that mount can setuid
|
# somewhat risky because we have to consider that mount can setuid
|
||||||
|
@ -40,10 +44,6 @@ stdenv.mkDerivation rec {
|
||||||
--disable-use-tty-group
|
--disable-use-tty-group
|
||||||
--enable-fs-paths-default=/run/wrappers/bin:/var/run/current-system/sw/bin:/sbin
|
--enable-fs-paths-default=/run/wrappers/bin:/var/run/current-system/sw/bin:/sbin
|
||||||
${if ncurses == null then "--without-ncurses" else ""}
|
${if ncurses == null then "--without-ncurses" else ""}
|
||||||
${if systemd == null then "" else ''
|
|
||||||
--with-systemd
|
|
||||||
--with-systemdsystemunitdir=$out/lib/systemd/system/
|
|
||||||
''}
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
makeFlags = "usrbin_execdir=$(bin)/bin usrsbin_execdir=$(bin)/sbin";
|
makeFlags = "usrbin_execdir=$(bin)/bin usrsbin_execdir=$(bin)/sbin";
|
||||||
|
|
Loading…
Reference in a new issue