From 2b382e499aa2fa7ac78bdf1cee079d45fb3a0334 Mon Sep 17 00:00:00 2001 From: Hoang Nguyen Date: Sat, 22 Feb 2025 07:04:35 +0000 Subject: [PATCH] earthly: init module (#6265) Earthly is a build configuration framework utilizing buildkit and Dockerfile-like syntax for simplicity and fast builds. --- modules/lib/maintainers.nix | 6 +++ modules/misc/news.nix | 10 +++++ modules/modules.nix | 1 + modules/programs/earthly.nix | 40 +++++++++++++++++++ tests/default.nix | 1 + tests/modules/programs/earthly/default.nix | 1 + .../programs/earthly/earthly-settings.nix | 21 ++++++++++ .../programs/earthly/earthly-settings.yml | 6 +++ 8 files changed, 86 insertions(+) create mode 100644 modules/programs/earthly.nix create mode 100644 tests/modules/programs/earthly/default.nix create mode 100644 tests/modules/programs/earthly/earthly-settings.nix create mode 100644 tests/modules/programs/earthly/earthly-settings.yml diff --git a/modules/lib/maintainers.nix b/modules/lib/maintainers.nix index 52da8f0b0764..428d30e3bd2d 100644 --- a/modules/lib/maintainers.nix +++ b/modules/lib/maintainers.nix @@ -667,4 +667,10 @@ fingerprint = "AD32 73D4 5E0E 9478 E826 543F EDB2 C634 166A E6AD"; }]; }; + folliehiyuki = { + name = "Hoang Nguyen"; + email = "folliekazetani@protonmail.com"; + github = "folliehiyuki"; + githubId = 67634026; + }; } diff --git a/modules/misc/news.nix b/modules/misc/news.nix index a2614da83d04..d332797853fb 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -2084,6 +2084,16 @@ in { screen brightness based on the screen contents and amount of ambient light around you. ''; } + + { + time = "2025-02-21T16:53:20+00:00"; + message = '' + A new module is available: 'programs.earthly'. + + Earthly is a build configuration framework utilizing buildkit and + Dockerfile-like syntax for fast builds and simplicity. + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 12b367510221..e88176f6fdac 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -90,6 +90,7 @@ let ./programs/dircolors.nix ./programs/direnv.nix ./programs/discocss.nix + ./programs/earthly.nix ./programs/eclipse.nix ./programs/emacs.nix ./programs/eww.nix diff --git a/modules/programs/earthly.nix b/modules/programs/earthly.nix new file mode 100644 index 000000000000..e4e2a19f0e01 --- /dev/null +++ b/modules/programs/earthly.nix @@ -0,0 +1,40 @@ +{ config, lib, pkgs, ... }: + +let + + cfg = config.programs.earthly; + + yamlFormat = pkgs.formats.yaml { }; + +in { + meta.maintainers = [ lib.hm.maintainers.folliehiyuki ]; + + options.programs.earthly = { + enable = lib.mkEnableOption "earthly"; + + package = lib.mkPackageOption pkgs "earthly" { }; + + settings = lib.mkOption { + type = yamlFormat.type; + default = { }; + description = '' + Configuration written to ~/.earthly/config.yml file. + See https://docs.earthly.dev/docs/earthly-config for supported values. + ''; + example = lib.literalExpression '' + global = { + disable_analytics = true; + disable_log_sharing = true; + }; + ''; + }; + }; + + config = lib.mkIf cfg.enable { + home.packages = [ cfg.package ]; + + home.file.".earthly/config.yml" = lib.mkIf (cfg.settings != { }) { + source = yamlFormat.generate "earthly-config" cfg.settings; + }; + }; +} diff --git a/tests/default.nix b/tests/default.nix index 459808b89789..8a9a5120bb46 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -146,6 +146,7 @@ in import nmtSrc { ./modules/programs/darcs ./modules/programs/dircolors ./modules/programs/direnv + ./modules/programs/earthly ./modules/programs/emacs ./modules/programs/fastfetch ./modules/programs/feh diff --git a/tests/modules/programs/earthly/default.nix b/tests/modules/programs/earthly/default.nix new file mode 100644 index 000000000000..5606289c177e --- /dev/null +++ b/tests/modules/programs/earthly/default.nix @@ -0,0 +1 @@ +{ earthly-settings = ./earthly-settings.nix; } diff --git a/tests/modules/programs/earthly/earthly-settings.nix b/tests/modules/programs/earthly/earthly-settings.nix new file mode 100644 index 000000000000..1710e5a4c10c --- /dev/null +++ b/tests/modules/programs/earthly/earthly-settings.nix @@ -0,0 +1,21 @@ +{ + programs.earthly = { + enable = true; + + settings = { + global.disable_analytics = true; + + git."github.com" = { + auth = "ssh"; + user = "username"; + }; + }; + }; + + test.stubs.earthly = { }; + + nmt.script = '' + assertFileExists home-files/.earthly/config.yml + assertFileContent home-files/.earthly/config.yml ${./earthly-settings.yml} + ''; +} diff --git a/tests/modules/programs/earthly/earthly-settings.yml b/tests/modules/programs/earthly/earthly-settings.yml new file mode 100644 index 000000000000..182f011b2975 --- /dev/null +++ b/tests/modules/programs/earthly/earthly-settings.yml @@ -0,0 +1,6 @@ +git: + github.com: + auth: ssh + user: username +global: + disable_analytics: true