Add python flake

This commit is contained in:
xenia 2023-12-06 20:07:52 +01:00
parent 888ab89260
commit b9eec2fbc9
5 changed files with 87 additions and 0 deletions

1
python/.envrc Normal file
View File

@ -0,0 +1 @@
use flake

1
python/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.direnv

59
python/flake.lock Normal file
View File

@ -0,0 +1,59 @@
{
"nodes": {
"flake-utils": {
"inputs": {
"systems": "systems"
},
"locked": {
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1699155732,
"narHash": "sha256-Wg4RmOGUEO4YCF0fEc/qiQ/3+BGC/f0qywIE8xEkIpY=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "15492ddc2974ba426ea7e17116ea7aa44fc96dcd",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

19
python/flake.nix Normal file
View File

@ -0,0 +1,19 @@
{
description = "A bare python flake";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (sys:
let pkgs = nixpkgs.legacyPackages.${sys};
python = pkgs.python310.withPackages (ps: with ps; [
matplotlib
ipython
]);
in rec {
devShells.default = python;
}
);
}

7
python/main.py Normal file
View File

@ -0,0 +1,7 @@
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([1, 2, 3, -3])
ax.set_xlabel("time")
ax.set_ylabel("swag")
plt.show()