1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00
home-manager/modules/programs/docker-cli.nix
2025-07-10 15:36:53 -05:00

65 lines
1.4 KiB
Nix

{
lib,
pkgs,
config,
...
}:
let
inherit (lib)
mkIf
mkEnableOption
mkOption
;
cfg = config.programs.docker-cli;
jsonFormat = pkgs.formats.json { };
in
{
meta.maintainers = [ lib.maintainers.friedrichaltheide ];
options.programs.docker-cli = {
enable = mkEnableOption "management of docker client config";
configPath = mkOption {
type = lib.types.str;
default = ".docker/config.json";
description = ''
Relative path to the user's home directory where the Docker CLI settings should be stored.
'';
};
settings = mkOption {
type = jsonFormat.type;
default = { };
example = ''
{
"proxies" = {
"default" = {
"httpProxy" = "http://proxy.example.org:3128";
"httpsProxy" = "http://proxy.example.org:3128";
"noProxy" = "localhost";
};
};
'';
description = ''
Available configuration options for the Docker CLI see:
<https://docs.docker.com/reference/cli/docker/#docker-cli-configuration-file-configjson-properties
'';
};
};
config = mkIf cfg.enable {
home = {
sessionVariables = {
DOCKER_CONFIG = "${config.home.homeDirectory}/${cfg.configPath}";
};
file = {
"${cfg.configPath}" = {
source = jsonFormat.generate "config.json" cfg.settings;
};
};
};
};
}