From c903947f00d951f2ca54ea1ffabd973675d8a65c Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Wed, 6 Nov 2024 19:03:19 -0800 Subject: [PATCH] Expose pythonEnv from flake --- .gitignore | 4 +++- Makefile | 3 +++ flake.nix | 44 +++++++++++++++++++++----------------------- 3 files changed, 27 insertions(+), 24 deletions(-) diff --git a/.gitignore b/.gitignore index 13a0ce3..14c1033 100644 --- a/.gitignore +++ b/.gitignore @@ -159,6 +159,8 @@ cython_debug/ # option (not recommended) you can uncomment the following to ignore the entire idea folder. #.idea/ +venv + # nixos-shell nixos.qcow2 @@ -166,4 +168,4 @@ nixos.qcow2 result # test sources -tests/**/*.item \ No newline at end of file +tests/**/*.item diff --git a/Makefile b/Makefile index cafa6a3..ba57d2e 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,9 @@ help: ## display this help @awk 'BEGIN{FS = ":.*##"; printf "\033[1m\nUsage\n \033[1;92m make\033[0;36m \033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } ' $(MAKEFILE_LIST) +venv: ## link the python dev environment to ./venv + nix build .#pythonEnv -o venv + lint: ## run linters nix fmt black **/*.py diff --git a/flake.nix b/flake.nix index 7e5c31b..058ecb0 100644 --- a/flake.nix +++ b/flake.nix @@ -23,6 +23,14 @@ let inherit (nixpkgs.lib) makeOverridable nixosSystem; system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + pythonEnv = pkgs.python3.withPackages ( + pypkgs: with pypkgs; [ + flask + black + pytest + ] + ); in { formatter.${system} = nixpkgs.legacyPackages.${system}.nixfmt-rfc-style; @@ -39,32 +47,22 @@ { default = self.packages.${system}.intake; inherit (pkgs) intake; + inherit pythonEnv; }; devShells.${system} = { - default = - let - pkgs = nixpkgs.legacyPackages.${system}; - pythonEnv = pkgs.python3.withPackages ( - pypkgs: with pypkgs; [ - flask - black - pytest - ] - ); - in - pkgs.mkShell { - packages = [ - pythonEnv - pkgs.gnumake - pkgs.nixos-shell - # We only take this dependency for htpasswd, which is a little unfortunate - pkgs.apacheHttpd - ]; - shellHook = '' - PS1="(develop) $PS1" - ''; - }; + default = pkgs.mkShell { + packages = [ + pythonEnv + pkgs.gnumake + pkgs.nixos-shell + # We only take this dependency for htpasswd, which is a little unfortunate + pkgs.apacheHttpd + ]; + shellHook = '' + PS1="(develop) $PS1" + ''; + }; }; overlays.default = final: prev: {