From ecb9f386ce15a2b8a9f473829d69f829be2a5bdb Mon Sep 17 00:00:00 2001 From: Danilo Reyes Date: Fri, 18 Apr 2025 20:57:36 -0600 Subject: [PATCH] migrating dev environments to output --- base.nix | 1 + flake.nix | 4 ++ hosts/shell/configuration.nix | 7 ++++ modules/dev/python.nix | 76 ++++++++++++++++++++++------------- 4 files changed, 60 insertions(+), 28 deletions(-) create mode 100644 hosts/shell/configuration.nix diff --git a/base.nix b/base.nix index 2409a54..c68718a 100644 --- a/base.nix +++ b/base.nix @@ -3,6 +3,7 @@ pkgs, inputs, outputs, + config, ... }: { diff --git a/flake.nix b/flake.nix index 01bd4af..0a04bee 100644 --- a/flake.nix +++ b/flake.nix @@ -84,6 +84,10 @@ workstation = createConfig "workstation" inputs.nixpkgs; miniserver = createConfig "miniserver" inputs.nixpkgs-small; server = createConfig "server" inputs.nixpkgs-small; + shell = createConfig "shell" inputs.nixpkgs; + }; + devShells.${system} = { + python = self.nixosConfigurations.shell.config.devShells.python; }; }; } diff --git a/hosts/shell/configuration.nix b/hosts/shell/configuration.nix new file mode 100644 index 0000000..7a0c8a7 --- /dev/null +++ b/hosts/shell/configuration.nix @@ -0,0 +1,7 @@ +{ ... }: +{ + imports = [ + ../../base.nix + ../../stylix.nix + ]; +} diff --git a/modules/dev/python.nix b/modules/dev/python.nix index 304bb87..a2c595f 100644 --- a/modules/dev/python.nix +++ b/modules/dev/python.nix @@ -4,34 +4,54 @@ pkgs, ... }: +let + python = pkgs.python3.withPackages ( + ps: + builtins.attrValues { + inherit (ps) + black # Python code formatter + editorconfig # follow rules of contributin + flake8 # wraper for pyflakes, pycodestyle and mccabe + isort # sort Python imports + pyflakes # checks source code for errors + pylint # bug and style checker for python + pytest # tests + speedtest-cli # check internet speed from the comand line + ; + } + ); + packages = + [ python ] + ++ builtins.attrValues { + inherit (pkgs) + pipenv # python development workflow for humans + pyright # LSP + ; + }; +in { - options.my.dev.python.enable = lib.mkEnableOption "enable"; - config = lib.mkIf config.my.dev.python.enable { - home-manager.users.jawz.xdg.configFile."python/pythonrc".source = ../../dotfiles/pythonrc; - environment.variables.PYTHONSTARTUP = "\${XDG_CONFIG_HOME}/python/pythonrc"; - users.users.jawz.packages = - builtins.attrValues { - inherit (pkgs) - pipenv # python development workflow for humans - pyright # LSP - ; - } - ++ [ - (pkgs.python3.withPackages ( - ps: - builtins.attrValues { - inherit (ps) - black # Python code formatter - editorconfig # follow rules of contributin - flake8 # wraper for pyflakes, pycodestyle and mccabe - isort # sort Python imports - pyflakes # checks source code for errors - pylint # bug and style checker for python - pytest # tests - speedtest-cli # check internet speed from the comand line - ; - } - )) - ]; + options = { + my.dev.python.enable = lib.mkEnableOption "Install Python tools globally"; + devShells.python = lib.mkOption { + type = lib.types.package; + default = pkgs.mkShell { + inherit packages; + name = "python-dev-shell"; + shellHook = '' + echo "🐍 Python dev environment" + which python + ''; + description = "Python development shell"; + }; + }; }; + config = lib.mkMerge [ + (lib.mkIf config.my.dev.python.enable { + users.users.jawz.packages = packages; + }) + { + home-manager.users.jawz.xdg.configFile."python/pythonrc".source = ../../dotfiles/pythonrc; + environment.variables.PYTHONSTARTUP = "\${XDG_CONFIG_HOME}/python/pythonrc"; + } + ]; }