From 9642cd7ae24f0ba79ce5647c709b35ae8f06a285 Mon Sep 17 00:00:00 2001 From: Jasper Ras Date: Sun, 19 Jan 2025 21:14:51 +0100 Subject: vault backup: 2025-01-19 21:14:51 --- 3 Resources/Nix/Shell.nix.md | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 3 Resources/Nix/Shell.nix.md (limited to '3 Resources/Nix/Shell.nix.md') diff --git a/3 Resources/Nix/Shell.nix.md b/3 Resources/Nix/Shell.nix.md new file mode 100644 index 0000000..13715c2 --- /dev/null +++ b/3 Resources/Nix/Shell.nix.md @@ -0,0 +1,42 @@ +#nix #shell + +--- +Can be used to set up per dir environments, e.g using direnv to automatically activate them. +## Python +https://nixos.org/manual/nixpkgs/stable/#python + +```nix +{ pkgs ? import {}}: + +pkgs.mkShell { + packages = [ pkgs.virtualenv ]; +} +``` + +```nix +with import {}; +let + my_toolz = python311.pkgs.buildPythonPackage rec { + pname = "toolz"; + version = "0.10.0"; + pyproject = true; + src = fetchPypi { + inherit pname version; + hash = "sha256-CP3V73yWSArRHBLUct4hrNMjWZlvaaUlkpm1QP66RWA="; + }; + nativeBuildInputs = [ + python311.pkgs.setuptools + python311.pkgs.wheel + ]; # has no tests + doCheck = false; + meta = { + homepage = "https://github.com/pytoolz/toolz/"; + description = "List processing tools and functional utilities"; + # [...] + }; + }; +in python311.withPackages (ps: with ps; [ numpy my_toolz ]) ).env +``` + +The [[Import]] is required here because imports a nix expression from another source, in this case nixpkgs. +It is not required at line two, because python310Packages itself is already in the local scope. \ No newline at end of file -- cgit v1.2.3