From b0fa416121ab036ed83a625bee0b5ad507347eec Mon Sep 17 00:00:00 2001 From: arunoruto Date: Sun, 13 Oct 2024 22:52:00 +0200 Subject: [PATCH] Move programming related stuff to a module --- modules/nixos/environment/default.nix | 4 +- modules/nixos/environment/programming.nix | 21 ------ .../nixos/environment/programming/default.nix | 35 ++++++++++ .../nixos/environment/programming/python.nix | 49 +++++++++++++ modules/nixos/environment/python.nix | 70 ------------------- 5 files changed, 86 insertions(+), 93 deletions(-) delete mode 100644 modules/nixos/environment/programming.nix create mode 100644 modules/nixos/environment/programming/default.nix create mode 100644 modules/nixos/environment/programming/python.nix delete mode 100644 modules/nixos/environment/python.nix diff --git a/modules/nixos/environment/default.nix b/modules/nixos/environment/default.nix index a799fba..1bc37e1 100644 --- a/modules/nixos/environment/default.nix +++ b/modules/nixos/environment/default.nix @@ -5,14 +5,13 @@ }: { imports = [ ./gui + ./programming ./packages.nix ./cachix.nix ./fonts.nix ./latex.nix ./ld.nix - ./programming.nix - ./python.nix ./amd ./intel.nix @@ -21,6 +20,7 @@ cachix.enable = lib.mkDefault false; gui.enable = lib.mkDefault true; latex.enable = lib.mkDefault false; + programming.enable = lib.mkDefault true; amd.enable = lib.mkDefault false; intel.enable = lib.mkDefault false; diff --git a/modules/nixos/environment/programming.nix b/modules/nixos/environment/programming.nix deleted file mode 100644 index 345308d..0000000 --- a/modules/nixos/environment/programming.nix +++ /dev/null @@ -1,21 +0,0 @@ -{pkgs, ...}: { - environment = { - systemPackages = with pkgs; [ - gfortran - gcc - gcc-unwrapped - gnumake - julia-bin - python3 - #unstable.ruff - #ruff - - # rust - cargo - rustc - - # misc - hyperfine - ]; - }; -} diff --git a/modules/nixos/environment/programming/default.nix b/modules/nixos/environment/programming/default.nix new file mode 100644 index 0000000..c7a68d9 --- /dev/null +++ b/modules/nixos/environment/programming/default.nix @@ -0,0 +1,35 @@ +{ + pkgs, + lib, + config, + ... +}: { + imports = [ + ./python.nix + ]; + + options.programming.enable = lib.mkEnableOption "Setup programming tools"; + + config = lib.mkIf config.programming.enable { + python.enable = lib.mkDefault true; + + environment = { + systemPackages = with pkgs; [ + gfortran + gcc + gcc-unwrapped + gnumake + julia-bin + #unstable.ruff + #ruff + + # rust + cargo + rustc + + # misc + hyperfine + ]; + }; + }; +} diff --git a/modules/nixos/environment/programming/python.nix b/modules/nixos/environment/programming/python.nix new file mode 100644 index 0000000..89060b4 --- /dev/null +++ b/modules/nixos/environment/programming/python.nix @@ -0,0 +1,49 @@ +{ + pkgs, + lib, + config, + ... +}: let + packages = ps: + with ps; [ + # Jupyter + jupyter + ipython + python-lsp-server + # Must + jax + matplotlib + numba + numba-scipy + numpy + pandas + plotly + streamlit + # Misc + manim + psutil + # Optional + # opencv4 + # pillow + # requests + # scikit-image + ]; +in { + options.python.enable = lib.mkEnableOption "Setup a python environment"; + + config = lib.mkIf config.python.enable { + environment = { + systemPackages = with pkgs; [ + (python3.withPackages packages) + manim + manim-slides + mkdocs + poetry + ]; + + sessionVariables = { + PYTHON_KEYRING_BACKEND = "keyring.backends.null.Keyring"; + }; + }; + }; +} diff --git a/modules/nixos/environment/python.nix b/modules/nixos/environment/python.nix deleted file mode 100644 index 3c9d768..0000000 --- a/modules/nixos/environment/python.nix +++ /dev/null @@ -1,70 +0,0 @@ -{pkgs, ...}: let - packages = ps: - with ps; [ - # Jupyter - jupyter - ipython - python-lsp-server - # Must - matplotlib - numba - numba-scipy - numpy - pandas - plotly - streamlit - # Misc - psutil - # Optional - # opencv4 - # pillow - # requests - # scikit-image - # ( - # buildPythonPackage rec { - # pname = "streamlit"; - # version = "1.21.0"; - # src = fetchPypi { - # inherit pname version; - # sha256 = "sha256-xy2WOVCGecXkEdH4htITd3dZUB0Bl1KFwEncMNtGPBo="; - # }; - # doCheck = false; - # propagatedBuildInputs = [ - # # Specify dependencies - # #pkgs.python3Packages.numpy - # pkgs.python3Packages.python-dateutil - # pkgs.python3Packages.click - # pkgs.python3Packages.pillow - # pkgs.python3Packages.rich - # pkgs.python3Packages.pympler - # pkgs.python3Packages.protobuf - # ]; - # } - # ) - ]; -in { - environment = { - systemPackages = with pkgs; [ - (python3.withPackages packages) - poetry - mkdocs - ]; - - sessionVariables = { - PYTHON_KEYRING_BACKEND = "keyring.backends.null.Keyring"; - }; - }; - # home = { - # packages = with pkgs; [ - # (python3.withPackages packages) - # poetry - # mkdocs - # #pkgs.streamlit - # ]; - - # sessionVariables = { - # # https://github.com/python-poetry/poetry/issues/8623#issuecomment-1793624371 - # PYTHON_KEYRING_BACKEND = "keyring.backends.null.Keyring"; - # }; - # }; -}