Skip to content

Commit 622902e

Browse files
committed
feat(python): add python flake template
1 parent 8a3a793 commit 622902e

File tree

5 files changed

+59
-0
lines changed

5 files changed

+59
-0
lines changed

flake.nix

+7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010
welcomeText = builtins.readFile ./rust.md;
1111
};
1212

13+
python = {
14+
description =
15+
"Python flake template with support for adding dependencies.";
16+
path = ./python;
17+
welcomeText = builtins.readFile ./python.md;
18+
};
19+
1320
svelte = {
1421
description =
1522
"Svelte flake template using `adapter-node` with `svelte-server`. Built using `flake-parts`.";

python.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Python flake template
2+
3+
Getting started
4+
5+
## Enter a Python devShell
6+
7+
```bash
8+
nix develop
9+
```
10+
11+
Enter your Python environment as usual
12+
13+
```bash
14+
python
15+
```
16+
17+
The dependencies listed on line 14 of `flake.nix` are available
18+
19+
```python
20+
import pandas as pd
21+
...
22+
```
23+

python/.envrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

python/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
result
2+
.direnv

python/flake.nix

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
description = "Python flake template";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
flake-parts.url = "github:hercules-ci/flake-parts";
7+
};
8+
outputs = inputs@{ self, nixpkgs, flake-parts, ... }:
9+
flake-parts.lib.mkFlake { inherit inputs; } {
10+
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" "x86_64-darwin" ];
11+
perSystem = { pkgs, system, ... }:
12+
let
13+
python = pkgs.python3.withPackages (pp: with pp; [
14+
# Add your packages here:
15+
pandas
16+
]);
17+
in
18+
{
19+
devShells = {
20+
default = pkgs.mkShell {
21+
buildInputs = [ python ];
22+
};
23+
};
24+
};
25+
};
26+
}

0 commit comments

Comments
 (0)