diff options
author | Jasper Ras <jras@hostnet.nl> | 2025-01-19 21:14:51 +0100 |
---|---|---|
committer | Jasper Ras <jras@hostnet.nl> | 2025-01-19 21:14:51 +0100 |
commit | 9642cd7ae24f0ba79ce5647c709b35ae8f06a285 (patch) | |
tree | ae25c3b0db7ae4c23186b294c6d000073f085c2d /3 Resources/Nix/Shell.nix.md | |
parent | 969b96c2531fb986f6c7f21fd544391b439defd7 (diff) |
vault backup: 2025-01-19 21:14:51
Diffstat (limited to '3 Resources/Nix/Shell.nix.md')
-rw-r--r-- | 3 Resources/Nix/Shell.nix.md | 42 |
1 files changed, 42 insertions, 0 deletions
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 <nixpkgs> {}}: + +pkgs.mkShell { + packages = [ pkgs.virtualenv ]; +} +``` + +```nix +with import <nixpkgs> {}; +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 |