mirror of
https://github.com/nix-community/home-manager.git
synced 2024-12-14 11:57:55 +00:00
uv: init module
This commit is contained in:
parent
35b055009a
commit
b9582ba1cf
6 changed files with 88 additions and 0 deletions
|
@ -244,6 +244,7 @@ let
|
|||
./programs/topgrade.nix
|
||||
./programs/translate-shell.nix
|
||||
./programs/urxvt.nix
|
||||
./programs/uv.nix
|
||||
./programs/vdirsyncer.nix
|
||||
./programs/vifm.nix
|
||||
./programs/vim-vint.nix
|
||||
|
|
45
modules/programs/uv.nix
Normal file
45
modules/programs/uv.nix
Normal file
|
@ -0,0 +1,45 @@
|
|||
{ pkgs, config, lib, ... }:
|
||||
|
||||
let
|
||||
|
||||
inherit (lib) mkEnableOption mkPackageOption mkOption literalExpression;
|
||||
|
||||
tomlFormat = pkgs.formats.toml { };
|
||||
cfg = config.programs.uv;
|
||||
|
||||
in {
|
||||
meta.maintainers = with lib.maintainers; [ mirkolenz ];
|
||||
|
||||
options.programs.uv = {
|
||||
enable = mkEnableOption "uv";
|
||||
|
||||
package = mkPackageOption pkgs "uv" { };
|
||||
|
||||
settings = mkOption {
|
||||
type = tomlFormat.type;
|
||||
default = { };
|
||||
example = literalExpression ''
|
||||
{
|
||||
python-downloads = "never";
|
||||
python-preference = "only-system";
|
||||
pip.index-url = "https://test.pypi.org/simple";
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
Configuration written to
|
||||
{file}`$XDG_CONFIG_HOME/uv/uv.toml`.
|
||||
See <https://docs.astral.sh/uv/configuration/files/>
|
||||
and <https://docs.astral.sh/uv/reference/settings/>
|
||||
for more information.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
xdg.configFile."uv/uv.toml" = lib.mkIf (cfg.settings != { }) {
|
||||
source = tomlFormat.generate "uv-config" cfg.settings;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -157,6 +157,7 @@ in import nmtSrc {
|
|||
./modules/programs/tmux
|
||||
./modules/programs/topgrade
|
||||
./modules/programs/translate-shell
|
||||
./modules/programs/uv
|
||||
./modules/programs/vifm
|
||||
./modules/programs/vim-vint
|
||||
./modules/programs/vscode
|
||||
|
|
4
tests/modules/programs/uv/default.nix
Normal file
4
tests/modules/programs/uv/default.nix
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
uv-example-settings = ./example-settings.nix;
|
||||
uv-no-settings = ./no-settings.nix;
|
||||
}
|
27
tests/modules/programs/uv/example-settings.nix
Normal file
27
tests/modules/programs/uv/example-settings.nix
Normal file
|
@ -0,0 +1,27 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
programs.uv = {
|
||||
enable = true;
|
||||
settings = {
|
||||
python-downloads = "never";
|
||||
python-preference = "only-system";
|
||||
pip.index-url = "https://test.pypi.org/simple";
|
||||
};
|
||||
};
|
||||
|
||||
test.stubs.uv = { };
|
||||
|
||||
nmt.script = let
|
||||
expectedConfigPath = "home-files/.config/uv/uv.toml";
|
||||
expectedConfigContent = pkgs.writeText "uv.config-custom.expected" ''
|
||||
python-downloads = "never"
|
||||
python-preference = "only-system"
|
||||
[pip]
|
||||
index-url = "https://test.pypi.org/simple"
|
||||
'';
|
||||
in ''
|
||||
assertFileExists "${expectedConfigPath}"
|
||||
assertFileContent "${expectedConfigPath}" "${expectedConfigContent}"
|
||||
'';
|
||||
}
|
10
tests/modules/programs/uv/no-settings.nix
Normal file
10
tests/modules/programs/uv/no-settings.nix
Normal file
|
@ -0,0 +1,10 @@
|
|||
{ ... }: {
|
||||
programs.uv = { enable = true; };
|
||||
|
||||
test.stubs.uv = { };
|
||||
|
||||
nmt.script = let expectedConfigPath = "home-files/.config/uv/uv.toml";
|
||||
in ''
|
||||
assertPathNotExists "${expectedConfigPath}"
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue