Skip to content

Commit

Permalink
bun: add module
Browse files Browse the repository at this point in the history
  • Loading branch information
Jack5079 committed Apr 9, 2024
1 parent 40a9961 commit b00d0e4
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 0 deletions.
6 changes: 6 additions & 0 deletions modules/lib/maintainers.nix
Expand Up @@ -77,6 +77,12 @@
githubId = 32838899;
name = "Daniel Wagenknecht";
};
jack5079 = {
name = "Jack W.";
email = "nix@jack.cab";
github = "jack5079";
githubId = 29169102;
};
jkarlson = {
email = "jekarlson@gmail.com";
github = "jkarlson";
Expand Down
7 changes: 7 additions & 0 deletions modules/misc/news.nix
Expand Up @@ -1469,6 +1469,13 @@ in {
A new module is available: 'services.activitywatch'.
'';
}

{
time = "2024-04-08T21:43:38+00:00";
message = ''
A new module is available: 'programs.bun'.
'';
}
];
};
}
1 change: 1 addition & 0 deletions modules/modules.nix
Expand Up @@ -72,6 +72,7 @@ let
./programs/broot.nix
./programs/browserpass.nix
./programs/btop.nix
./programs/bun.nix
./programs/carapace.nix
./programs/cava.nix
./programs/chromium.nix
Expand Down
59 changes: 59 additions & 0 deletions modules/programs/bun.nix
@@ -0,0 +1,59 @@
{ config, lib, pkgs, ... }:

let
cfg = config.programs.bun;
tomlFormat = pkgs.formats.toml { };
in {
meta.maintainers = [ lib.hm.maintainers.jack5079 ];

options.programs.bun = {
enable = lib.mkEnableOption "Bun JavaScript runtime";

package = lib.mkPackageOption pkgs "bun" { };

settings = lib.mkOption {
type = tomlFormat.type;
default = { };
example = lib.literalExpression ''
{
smol = true;
telemetry = false;
test = {
coverage = true;
coverageThreshold = 0.9;
};
install.lockfile = {
print = "yarn";
};
}
'';
description = ''
Configuration written to
{file}`$XDG_CONFIG_HOME/.bunfig.toml`.
See <https://bun.sh/docs/runtime/bunfig>
for the full list of options.
'';
};

enableGitIntegration = lib.mkEnableOption "Git integration" // {
default = true;
};
};

config = lib.mkIf cfg.enable {
home.packages = [ cfg.package ];

xdg.configFile.".bunfig.toml" = lib.mkIf (cfg.settings != { }) {
source = tomlFormat.generate "bun-config" cfg.settings;
};

# https://bun.sh/docs/install/lockfile#how-do-i-git-diff-bun-s-lockfile
programs.git.attributes =
lib.mkIf cfg.enableGitIntegration [ "*.lockb binary diff=lockb" ];
programs.git.extraConfig.diff.lockb = lib.mkIf cfg.enableGitIntegration {
textconv = lib.getExe cfg.package;
binary = true;
};
};
}

0 comments on commit b00d0e4

Please sign in to comment.