Skip to content

Commit 7c1e289

Browse files
committed
feat(home): add ty module
1 parent 1d40e77 commit 7c1e289

File tree

3 files changed

+60
-1
lines changed

3 files changed

+60
-1
lines changed

home/mlenz/common/packages/workstation.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ lib.mkIf config.custom.profile.isWorkstation {
7171
pythonWithPackages
7272
pylyzer
7373
basedpyright
74-
ty-bin
7574
zuban
7675
# other apps
7776
uv-apps

home/mlenz/common/programs/ty.nix

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{ pkgs, ... }:
2+
{
3+
programs.ty = {
4+
enable = true;
5+
package = pkgs.ty-bin;
6+
# https://docs.astral.sh/ty/reference/configuration/
7+
settings = { };
8+
};
9+
}

home/options/ty.nix

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
pkgs,
3+
config,
4+
lib,
5+
...
6+
}:
7+
let
8+
inherit (lib)
9+
mkEnableOption
10+
mkPackageOption
11+
mkOption
12+
literalExpression
13+
;
14+
15+
tomlFormat = pkgs.formats.toml { };
16+
cfg = config.programs.ty;
17+
in
18+
{
19+
meta.maintainers = with lib.maintainers; [ mirkolenz ];
20+
21+
options.programs.ty = {
22+
enable = mkEnableOption "ty";
23+
24+
package = mkPackageOption pkgs "ty" { nullable = true; };
25+
26+
settings = mkOption {
27+
type = tomlFormat.type;
28+
default = { };
29+
example = literalExpression ''
30+
{
31+
rules.index-out-of-bounds = "ignore";
32+
}
33+
'';
34+
description = ''
35+
Configuration written to
36+
{file}`$XDG_CONFIG_HOME/ty/ty.toml`.
37+
See <https://docs.astral.sh/ty/configuration/>
38+
and <https://docs.astral.sh/ty/reference/configuration/>
39+
for more information.
40+
'';
41+
};
42+
};
43+
44+
config = lib.mkIf cfg.enable {
45+
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
46+
47+
xdg.configFile."ty/ty.toml" = lib.mkIf (cfg.settings != { }) {
48+
source = tomlFormat.generate "ty-config.toml" cfg.settings;
49+
};
50+
};
51+
}

0 commit comments

Comments
 (0)