lazydocker: add module

This commit is contained in:
hauskens 2024-07-08 20:43:44 +02:00
parent df3d433e62
commit db092a0650
No known key found for this signature in database
GPG key ID: 809F79389CB18650
8 changed files with 106 additions and 0 deletions

View file

@ -140,6 +140,7 @@ let
./programs/khard.nix
./programs/kitty.nix
./programs/kodi.nix
./programs/lazydocker.nix
./programs/lazygit.nix
./programs/ledger.nix
./programs/less.nix

View file

@ -0,0 +1,62 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.programs.lazydocker;
yamlFormat = pkgs.formats.yaml { };
inherit (pkgs.stdenv.hostPlatform) isDarwin;
in {
meta.maintainers = [ hm.maintainers.hausken ];
options.programs.lazydocker = {
enable = mkEnableOption
"lazydocker, a simple terminal UI for both docker and docker compose";
package = mkPackageOption pkgs "lazydocker" { };
settings = mkOption {
type = yamlFormat.type;
default = {
commandTemplates.dockerCompose =
"docker compose"; # Lazydocker uses docker-compose by default which will not work
};
example = literalExpression ''
{
gui.theme = {
activeBorderColor = ["red" "bold"];
inactiveBorderColor = ["blue"];
};
commandTemplates.dockerCompose = "docker compose compose -f docker-compose.yml";
}
'';
description = ''
Configuration written to
{file}`$XDG_CONFIG_HOME/lazydocker/config.yml`
on Linux or on Darwin if [](#opt-xdg.enable) is set, otherwise
{file}`~/Library/Application Support/jesseduffield/lazydocker/config.yml`.
See
<https://github.com/jesseduffield/lazydocker/blob/master/docs/Config.md>
for supported values.
'';
};
};
config = mkIf cfg.enable {
home.packages = [ cfg.package ];
home.file."Library/Application Support/jesseduffield/lazydocker/config.yml" =
mkIf (cfg.settings != { } && (isDarwin && !config.xdg.enable)) {
source = yamlFormat.generate "lazydocker-config" cfg.settings;
};
xdg.configFile."lazydocker/config.yml" =
mkIf (cfg.settings != { } && !(isDarwin && !config.xdg.enable)) {
source = yamlFormat.generate "lazydocker-config" cfg.settings;
};
};
}

View file

@ -96,6 +96,7 @@ in import nmtSrc {
./modules/programs/khard
./modules/programs/kitty
./modules/programs/ledger
./modules/programs/lazydocker
./modules/programs/less
./modules/programs/lf
./modules/programs/lsd

View file

@ -0,0 +1,17 @@
{ ... }: {
programs.lazydocker = {
enable = true;
settings = {
commandTemplates.dockerCompose = "docker compose";
gui.theme = {
activeBorderColor = [ "red" "bold" ];
inactiveBorderColor = [ "blue" ];
};
};
};
nmt.script = ''
assertFileExists home-files/.config/lazydocker/config.yml
assertFileContent home-files/.config/lazydocker/config.yml \
${./custom-settings.yml}
'';
}

View file

@ -0,0 +1,9 @@
commandTemplates:
dockerCompose: docker compose
gui:
theme:
activeBorderColor:
- red
- bold
inactiveBorderColor:
- blue

View file

@ -0,0 +1,9 @@
{ ... }: {
programs.lazydocker.enable = true;
nmt.script = ''
assertFileExists home-files/.config/lazydocker/config.yml
assertFileContent home-files/.config/lazydocker/config.yml \
${./default.yml}
'';
}

View file

@ -0,0 +1,5 @@
{
lazydocker-default-settings = ./default-settings.nix;
lazydocker-custom-settings = ./custom-settings.nix;
}

View file

@ -0,0 +1,2 @@
commandTemplates:
dockerCompose: docker compose