-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
pkgs, | ||
config, | ||
lib, | ||
... | ||
}: | ||
let | ||
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 = with lib; { | ||
enable = mkEnableOption "poetry"; | ||
package = mkOption { | ||
type = types.package; | ||
default = pkgs.poetry; | ||
defaultText = literalExpression "pkgs.poetry"; | ||
description = '' | ||
The poetry package to use. You may enable plugins as follows: | ||
`pkgs.poetry.withPlugins (ps: with ps; [ poetry-plugin-up ])` | ||
''; | ||
}; | ||
settings = mkOption { | ||
type = tomlFormat.type; | ||
default = { }; | ||
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. | ||
''; | ||
example = literalExpression '' | ||
{ | ||
virtualenvs.create = true; | ||
virtualenvs.in-project = true; | ||
} | ||
''; | ||
}; | ||
}; | ||
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; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters