mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-19 06:43:01 +00:00
Can generate the config without installing application through home-manager. Helpful when a package is broken (or not provided) on a specific platform through nixpkgs and needs to be installed through other means but you still can benefit from the declarative configuration.
56 lines
1.4 KiB
Nix
56 lines
1.4 KiB
Nix
{ 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" {
|
|
nullable = true;
|
|
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 = lib.mkIf (cfg.package != null) [ cfg.package ];
|
|
|
|
home.file."${configDir}/pypoetry/config.toml" =
|
|
lib.mkIf (cfg.settings != { }) {
|
|
source = tomlFormat.generate "poetry-config" cfg.settings;
|
|
};
|
|
};
|
|
}
|