|
1 | 1 | { |
2 | | - description = "A Nix-flake-based Python development environment"; |
| 2 | + description = "Parsers and algorithms for computational chemistry logfiles (regression data)"; |
3 | 3 |
|
4 | | - inputs.nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1"; |
| 4 | + inputs = { |
| 5 | + nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; |
| 6 | + flake-utils.url = "github:numtide/flake-utils"; |
| 7 | + }; |
5 | 8 |
|
6 | | - outputs = inputs: |
| 9 | + outputs = |
| 10 | + { |
| 11 | + self, |
| 12 | + nixpkgs, |
| 13 | + flake-utils, |
| 14 | + }: |
7 | 15 | let |
8 | | - supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; |
9 | | - forEachSupportedSystem = f: inputs.nixpkgs.lib.genAttrs supportedSystems (system: f { |
10 | | - pkgs = import inputs.nixpkgs { inherit system; }; |
11 | | - }); |
12 | | - |
13 | 16 | /* |
14 | | - * Change this value ({major}.{min}) to |
15 | | - * update the Python virtual-environment |
16 | | - * version. When you do this, make sure |
17 | | - * to delete the `.venv` directory to |
18 | | - * have the hook rebuild it for the new |
19 | | - * version, since it won't overwrite an |
20 | | - * existing one. After this, reload the |
21 | | - * development shell to rebuild it. |
22 | | - * You'll see a warning asking you to |
23 | | - * do this when version mismatches are |
24 | | - * present. For safety, removal should |
25 | | - * be a manual step, even if trivial. |
26 | | - */ |
| 17 | + Change this value ({major}.{min}) to |
| 18 | + update the Python virtual-environment |
| 19 | + version. When you do this, make sure |
| 20 | + to delete the `.venv` directory to |
| 21 | + have the hook rebuild it for the new |
| 22 | + version, since it won't overwrite an |
| 23 | + existing one. After this, reload the |
| 24 | + development shell to rebuild it. |
| 25 | + You'll see a warning asking you to |
| 26 | + do this when version mismatches are |
| 27 | + present. For safety, removal should |
| 28 | + be a manual step, even if trivial. |
| 29 | + */ |
27 | 30 | version = "3.13"; |
28 | 31 | in |
29 | | - { |
30 | | - devShells = forEachSupportedSystem ({ pkgs }: |
31 | | - let |
32 | | - concatMajorMinor = v: |
33 | | - pkgs.lib.pipe v [ |
34 | | - pkgs.lib.versions.splitVersion |
35 | | - (pkgs.lib.sublist 0 2) |
36 | | - pkgs.lib.concatStrings |
37 | | - ]; |
38 | | - |
39 | | - python = pkgs."python${concatMajorMinor version}"; |
40 | | - in |
41 | | - { |
42 | | - default = pkgs.mkShell { |
| 32 | + flake-utils.lib.eachDefaultSystem ( |
| 33 | + system: |
| 34 | + let |
| 35 | + pkgs = import nixpkgs { inherit system; }; |
| 36 | + in |
| 37 | + { |
| 38 | + devShells.default = |
| 39 | + let |
| 40 | + concatMajorMinor = |
| 41 | + v: |
| 42 | + pkgs.lib.pipe v [ |
| 43 | + pkgs.lib.versions.splitVersion |
| 44 | + (pkgs.lib.sublist 0 2) |
| 45 | + pkgs.lib.concatStrings |
| 46 | + ]; |
| 47 | + python = pkgs."python${concatMajorMinor version}"; |
| 48 | + in |
| 49 | + pkgs.mkShellNoCC { |
43 | 50 | venvDir = ".venv"; |
44 | 51 |
|
45 | 52 | postShellHook = '' |
46 | | - venvVersionWarn() { |
47 | | - local venvVersion |
48 | | - venvVersion="$("$venvDir/bin/python" -c 'import platform; print(platform.python_version())')" |
| 53 | + venvVersionWarn() { |
| 54 | + local venvVersion |
| 55 | + venvVersion="$("$venvDir/bin/python" -c 'import platform; print(platform.python_version())')" |
49 | 56 |
|
50 | | - [[ "$venvVersion" == "${python.version}" ]] && return |
| 57 | + [[ "$venvVersion" == "${python.version}" ]] && return |
51 | 58 |
|
52 | | - cat <<EOF |
| 59 | + cat <<EOF |
53 | 60 | Warning: Python version mismatch: [$venvVersion (venv)] != [${python.version}] |
54 | 61 | Delete '$venvDir' and reload to rebuild for version ${python.version} |
55 | 62 | EOF |
|
58 | 65 | venvVersionWarn |
59 | 66 | ''; |
60 | 67 |
|
61 | | - packages = with python.pkgs; [ |
62 | | - venvShellHook |
63 | | - pip |
64 | | - |
65 | | - /* Add whatever else you'd like here. */ |
66 | | - # pkgs.basedpyright |
67 | | - |
68 | | - # pkgs.black |
69 | | - /* or */ |
70 | | - # python.pkgs.black |
71 | | - |
72 | | - # pkgs.ruff |
73 | | - /* or */ |
74 | | - # python.pkgs.ruff |
| 68 | + packages = [ |
| 69 | + python.pkgs.pip |
| 70 | + python.pkgs.ruamel-yaml |
| 71 | + python.pkgs.venvShellHook |
75 | 72 | ]; |
76 | 73 | }; |
77 | | - }); |
78 | | - }; |
| 74 | + } |
| 75 | + ); |
79 | 76 | } |
0 commit comments