Skip to content

Commit

Permalink
feat: add poetry module
Browse files Browse the repository at this point in the history
  • Loading branch information
mirkolenz committed Feb 24, 2024
1 parent 6adbf05 commit 6be5972
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
50 changes: 50 additions & 0 deletions home/poetry.nix
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;
};
};
}
7 changes: 6 additions & 1 deletion home/programs.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{ pkgs, config, ... }:
{
home.packages = with pkgs; [
poetry
python3
maven
gradle
Expand All @@ -12,6 +11,12 @@
bash.enable = true;
git.enable = true;
chromium.enable = true;
poetry = {
enable = true;
settings = {
virtualenvs.in-project = true;
};
};
neovim = {
enable = true;
viAlias = true;
Expand Down

0 comments on commit 6be5972

Please sign in to comment.