From 953c4c450bd42dd0651ae51bae71ca735b398141 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 6 Apr 2020 23:04:29 -0400 Subject: [PATCH] Modularize dev/python.nix --- modules/dev/default.nix | 2 +- modules/dev/python.nix | 62 ++++++++++++++++++++++++----------------- 2 files changed, 37 insertions(+), 27 deletions(-) diff --git a/modules/dev/default.nix b/modules/dev/default.nix index 9c547e0f..1574a3df 100644 --- a/modules/dev/default.nix +++ b/modules/dev/default.nix @@ -11,7 +11,7 @@ # ./latex.nix # ./love2d.nix # ./node.nix - # ./python.nix + ./python.nix ./rust.nix ./scala.nix # ./unity3d.nix diff --git a/modules/dev/python.nix b/modules/dev/python.nix index 2a3279f6..aee24ac2 100644 --- a/modules/dev/python.nix +++ b/modules/dev/python.nix @@ -4,35 +4,45 @@ # me. The Py2->3 transition make trainwrecks jealous. But SciPy, NumPy, iPython # and Jupyter can have my babies. Every single one. -{ lib, pkgs, ... }: +{ config, options, lib, pkgs, ... }: +with lib; { - my = { - packages = with pkgs; [ - python37 - python37Packages.pip - python37Packages.ipython - python37Packages.black - python37Packages.setuptools - python37Packages.pylint - python37Packages.poetry - ]; + options.modules.dev.python = { + enable = mkOption { + type = types.bool; + default = false; + }; + }; - env.IPYTHONDIR = "$XDG_CONFIG_HOME/ipython"; - env.PIP_CONFIG_FILE = "$XDG_CONFIG_HOME/pip/pip.conf"; - env.PIP_LOG_FILE = "$XDG_DATA_HOME/pip/log"; - env.PYLINTHOME = "$XDG_DATA_HOME/pylint"; - env.PYLINTRC = "$XDG_CONFIG_HOME/pylint/pylintrc"; - env.PYTHONSTARTUP = "$XDG_CONFIG_HOME/python/pythonrc"; - env.PYTHON_EGG_CACHE = "$XDG_CACHE_HOME/python-eggs"; - env.JUPYTER_CONFIG_DIR = "$XDG_CONFIG_HOME/jupyter"; + config = mkIf config.modules.dev.python.enable { + my = { + packages = with pkgs; [ + python37 + python37Packages.pip + python37Packages.ipython + python37Packages.black + python37Packages.setuptools + python37Packages.pylint + python37Packages.poetry + ]; - zsh.rc = lib.readFile ; + env.IPYTHONDIR = "$XDG_CONFIG_HOME/ipython"; + env.PIP_CONFIG_FILE = "$XDG_CONFIG_HOME/pip/pip.conf"; + env.PIP_LOG_FILE = "$XDG_DATA_HOME/pip/log"; + env.PYLINTHOME = "$XDG_DATA_HOME/pylint"; + env.PYLINTRC = "$XDG_CONFIG_HOME/pylint/pylintrc"; + env.PYTHONSTARTUP = "$XDG_CONFIG_HOME/python/pythonrc"; + env.PYTHON_EGG_CACHE = "$XDG_CACHE_HOME/python-eggs"; + env.JUPYTER_CONFIG_DIR = "$XDG_CONFIG_HOME/jupyter"; - alias.py = "python"; - alias.py2 = "python2"; - alias.py3 = "python3"; - alias.po = "poetry"; - alias.ipy = "ipython --no-banner"; - alias.ipylab = "ipython --pylab=qt5 --no-banner"; + zsh.rc = lib.readFile ; + + alias.py = "python"; + alias.py2 = "python2"; + alias.py3 = "python3"; + alias.po = "poetry"; + alias.ipy = "ipython --no-banner"; + alias.ipylab = "ipython --pylab=qt5 --no-banner"; + }; }; }