First real commit
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
nix_direnv_watch_file requirements.txt
|
||||
use flake
|
||||
@@ -0,0 +1,3 @@
|
||||
__pycache__
|
||||
|
||||
/.direnv
|
||||
@@ -0,0 +1,45 @@
|
||||
# python-shell
|
||||
|
||||
## Using
|
||||
|
||||
- dev shell: `nix develop`
|
||||
- edit `requirements.txt` for dev shell requirements
|
||||
|
||||
## Jupyter in VSCode
|
||||
|
||||
To use jupyter in VSCode add these requirements:
|
||||
|
||||
```
|
||||
ipykernel
|
||||
nbformat
|
||||
ipywidgets
|
||||
```
|
||||
|
||||
## Updating mach-nix pypi deps db
|
||||
|
||||
Add to inputs:
|
||||
|
||||
```nix
|
||||
pypi-deps-db = {
|
||||
url = "github:davhau/pypi-deps-db/0000000000000000000000000000000000000000";
|
||||
flake = false;
|
||||
};
|
||||
mach-nix.inputs.pypi-deps-db.follows = "pypi-deps-db";
|
||||
```
|
||||
|
||||
## Adding git dependency
|
||||
|
||||
Add to mkPython ([more info](https://github.com/DavHau/mach-nix/blob/master/examples.md)):
|
||||
|
||||
```nix
|
||||
packagesExtra = [
|
||||
(mach.buildPythonPackage
|
||||
{
|
||||
src = builtins.fetchGit {
|
||||
url = "https://github.com/user/repo";
|
||||
ref = "branch";
|
||||
rev = "0000000000000000000000000000000000000000";
|
||||
};
|
||||
})
|
||||
];
|
||||
```
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
description = "Python shell flake";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
mach-nix.url = "github:davhau/mach-nix";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, mach-nix, flake-utils, ... }:
|
||||
let
|
||||
pythonVersion = "python39";
|
||||
in
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
mach = mach-nix.lib.${system};
|
||||
|
||||
pythonEnv = mach.mkPython {
|
||||
python = pythonVersion;
|
||||
requirements = builtins.readFile ./requirements.txt;
|
||||
};
|
||||
in
|
||||
{
|
||||
devShells.default = pkgs.mkShellNoCC {
|
||||
packages = [ pythonEnv ];
|
||||
|
||||
shellHook = ''
|
||||
export PYTHONPATH="${pythonEnv}/bin/python"
|
||||
'';
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
print("Hello world!")
|
||||
Reference in New Issue
Block a user