treewide: implement auto importing for modules
Reduce maintenance burden and increase efficiency by automatically importing modules following a specific convention. Co-authored-by: awwpotato <awwpotato@voidq.com> Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
parent
fefeb0e928
commit
4fca600cb1
461 changed files with 72 additions and 474 deletions
72
modules/programs/bun/default.nix
Normal file
72
modules/programs/bun/default.nix
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
{
|
||||
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" { nullable = true; };
|
||||
|
||||
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 {
|
||||
warnings = lib.optional (cfg.package == null && cfg.enableGitIntegration) ''
|
||||
You have enabled git integration for `bun` but have not set `package`.
|
||||
|
||||
Git integration will not be configured.
|
||||
'';
|
||||
|
||||
home.packages = lib.mkIf (cfg.package != null) [ 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 && (cfg.package != null)) [
|
||||
"*.lockb binary diff=lockb"
|
||||
];
|
||||
programs.git.extraConfig.diff.lockb = lib.mkIf (cfg.enableGitIntegration && (cfg.package != null)) {
|
||||
textconv = lib.getExe cfg.package;
|
||||
binary = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue