29027fd1e1
Using pkgs.lib on the spine of module evaluation is problematic because the pkgs argument depends on the result of module evaluation. To prevent an infinite recursion, pkgs and some of the modules are evaluated twice, which is inefficient. Using ‘with lib’ prevents this problem.
36 lines
623 B
Nix
36 lines
623 B
Nix
# Global configuration for atop.
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let cfg = config.programs.atop;
|
|
|
|
in
|
|
{
|
|
###### interface
|
|
|
|
options = {
|
|
|
|
programs.atop = {
|
|
|
|
settings = mkOption {
|
|
type = types.attrs;
|
|
default = {};
|
|
example = {
|
|
flags = "a1f";
|
|
interval = 5;
|
|
};
|
|
description = ''
|
|
Parameters to be written to <filename>/etc/atoprc</filename>
|
|
'';
|
|
};
|
|
|
|
};
|
|
};
|
|
|
|
config = mkIf (cfg.settings != {}) {
|
|
environment.etc."atoprc".text =
|
|
concatStrings (mapAttrsToList (n: v: "${n} ${toString v}\n") cfg.settings);
|
|
};
|
|
}
|