mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +01:00
poetry: add module
This commit is contained in:
parent
2846d5230a
commit
670d9ecc3e
7 changed files with 113 additions and 0 deletions
|
@ -1506,6 +1506,16 @@ in {
|
|||
A new module is available: 'services.remmina'.
|
||||
'';
|
||||
}
|
||||
|
||||
{
|
||||
time = "2024-04-21T20:53:09+00:00";
|
||||
message = ''
|
||||
A new module is available: 'programs.poetry'.
|
||||
|
||||
Poetry is a tool that helps you manage Python project dependencies and
|
||||
packages. See https://python-poetry.org/ for more.
|
||||
'';
|
||||
}
|
||||
];
|
||||
};
|
||||
}
|
||||
|
|
|
@ -186,6 +186,7 @@ let
|
|||
./programs/pistol.nix
|
||||
./programs/piston-cli.nix
|
||||
./programs/pls.nix
|
||||
./programs/poetry.nix
|
||||
./programs/powerline-go.nix
|
||||
./programs/pqiv.nix
|
||||
./programs/pubs.nix
|
||||
|
|
55
modules/programs/poetry.nix
Normal file
55
modules/programs/poetry.nix
Normal file
|
@ -0,0 +1,55 @@
|
|||
{ pkgs, config, lib, ... }:
|
||||
|
||||
let
|
||||
|
||||
inherit (lib) mkEnableOption mkPackageOption mkOption literalExpression;
|
||||
|
||||
tomlFormat = pkgs.formats.toml { };
|
||||
|
||||
configDir = if pkgs.stdenv.isDarwin then
|
||||
"Library/Application Support"
|
||||
else
|
||||
config.xdg.configHome;
|
||||
|
||||
cfg = config.programs.poetry;
|
||||
|
||||
in {
|
||||
meta.maintainers = with lib.maintainers; [ mirkolenz ];
|
||||
|
||||
options.programs.poetry = {
|
||||
enable = mkEnableOption "poetry";
|
||||
|
||||
package = mkPackageOption pkgs "poetry" {
|
||||
example = "pkgs.poetry.withPlugins (ps: with ps; [ poetry-plugin-up ])";
|
||||
extraDescription = "May be used to install custom poetry plugins.";
|
||||
};
|
||||
|
||||
settings = mkOption {
|
||||
type = tomlFormat.type;
|
||||
default = { };
|
||||
example = literalExpression ''
|
||||
{
|
||||
virtualenvs.create = true;
|
||||
virtualenvs.in-project = true;
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
Configuration written to
|
||||
{file}`$XDG_CONFIG_HOME/pypoetry/config.toml` on Linux or
|
||||
{file}`$HOME/Library/Application Support/pypoetry/config.toml` on Darwin.
|
||||
See
|
||||
<https://python-poetry.org/docs/configuration/>
|
||||
for more information.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
home.file."${configDir}/pypoetry/config.toml" =
|
||||
lib.mkIf (cfg.settings != { }) {
|
||||
source = tomlFormat.generate "poetry-config" cfg.settings;
|
||||
};
|
||||
};
|
||||
}
|
|
@ -122,6 +122,7 @@ in import nmtSrc {
|
|||
./modules/programs/pet
|
||||
./modules/programs/pistol
|
||||
./modules/programs/pls
|
||||
./modules/programs/poetry
|
||||
./modules/programs/powerline-go
|
||||
./modules/programs/pubs
|
||||
./modules/programs/pyenv
|
||||
|
|
27
tests/modules/programs/poetry/custom-settings.nix
Normal file
27
tests/modules/programs/poetry/custom-settings.nix
Normal file
|
@ -0,0 +1,27 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
programs.poetry = {
|
||||
enable = true;
|
||||
settings = {
|
||||
virtualenvs.create = true;
|
||||
virtualenvs.in-project = true;
|
||||
};
|
||||
};
|
||||
|
||||
test.stubs.poetry = { };
|
||||
|
||||
nmt.script = let
|
||||
expectedConfDir =
|
||||
if pkgs.stdenv.isDarwin then "Library/Application Support" else ".config";
|
||||
expectedConfigPath = "home-files/${expectedConfDir}/pypoetry/config.toml";
|
||||
expectedConfigContent = pkgs.writeText "poetry.config-custom.expected" ''
|
||||
[virtualenvs]
|
||||
create = true
|
||||
in-project = true
|
||||
'';
|
||||
in ''
|
||||
assertFileExists "${expectedConfigPath}"
|
||||
assertFileContent "${expectedConfigPath}" "${expectedConfigContent}"
|
||||
'';
|
||||
}
|
15
tests/modules/programs/poetry/default-settings.nix
Normal file
15
tests/modules/programs/poetry/default-settings.nix
Normal file
|
@ -0,0 +1,15 @@
|
|||
{ pkgs, ... }:
|
||||
|
||||
{
|
||||
programs.poetry = { enable = true; };
|
||||
|
||||
test.stubs.poetry = { };
|
||||
|
||||
nmt.script = let
|
||||
expectedConfDir =
|
||||
if pkgs.stdenv.isDarwin then "Library/Application Support" else ".config";
|
||||
expectedConfigPath = "home-files/${expectedConfDir}/pypoetry/config.toml";
|
||||
in ''
|
||||
assertPathNotExists "${expectedConfigPath}"
|
||||
'';
|
||||
}
|
4
tests/modules/programs/poetry/default.nix
Normal file
4
tests/modules/programs/poetry/default.nix
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
poetry-default-settings = ./default-settings.nix;
|
||||
poetry-custom-settings = ./custom-settings.nix;
|
||||
}
|
Loading…
Reference in a new issue