Files
nix-flake/modules/features/applications/cli/nh.nix
T

44 lines
1.7 KiB
Nix

{ inputs, self, ... }: let
mkNhAttrs = config: {
enable = true;
flake = config.info.rootPath;
clean = config.features.applications.cli.nh.clean;
};
in {
imports = [ (inputs.helpers.mkMirroredModulesFlakeModule "globalOptions" ({ lib, ... }: {
options.features.applications.cli.nh = {
enable = lib.mkEnableOption "NH: Yet another Nix CLI helper";
clean = {
enable = lib.mkEnableOption "automatic cleaning of the system with `nh clean`";
dates = lib.mkOption {
type = lib.types.str;
description = "Defines when the cleaning job should run, in the format of [`systemd.time` calendar events](https://www.man7.org/linux/man-pages/man7/systemd.time.7.html#CALENDAR_EVENTS).";
default = "daily";
example = "Sun 05:00";
};
extraArgs = lib.mkOption {
type = lib.types.str;
description = "Any extra arguments that should be passed to the `nh clean` command when it is called by this service.";
default = "--keep 10 --keep-since 7d --optimise";
};
};
};
})) ];
flake.nixosModules.global = { pkgs, config, lib, ... }: {
config = lib.mkIf (config.features.applications.cli.nh.enable) {
programs.nh = mkNhAttrs config;
home-manager.users.${config.info.userName} = lib.mkIf (config.features.nixos.home-manager.enable) {
features.applications.cli.nh = lib.mkDefault config.features.applications.cli.nh;
};
};
};
flake.homeModules.global = { pkgs, config, lib, ... }: {
config = lib.mkIf (config.features.applications.cli.nh.enable && config.info.isStandalone) {
programs.nh = mkNhAttrs config;
};
};
}