From b9eec2fbc9af3d7d660c25439b09290e8685f027 Mon Sep 17 00:00:00 2001 From: xenia Date: Wed, 6 Dec 2023 20:07:52 +0100 Subject: [PATCH] Add python flake --- python/.envrc | 1 + python/.gitignore | 1 + python/flake.lock | 59 +++++++++++++++++++++++++++++++++++++++++++++++ python/flake.nix | 19 +++++++++++++++ python/main.py | 7 ++++++ 5 files changed, 87 insertions(+) create mode 100644 python/.envrc create mode 100644 python/.gitignore create mode 100644 python/flake.lock create mode 100644 python/flake.nix create mode 100644 python/main.py diff --git a/python/.envrc b/python/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/python/.envrc @@ -0,0 +1 @@ +use flake diff --git a/python/.gitignore b/python/.gitignore new file mode 100644 index 0000000..92b2793 --- /dev/null +++ b/python/.gitignore @@ -0,0 +1 @@ +.direnv diff --git a/python/flake.lock b/python/flake.lock new file mode 100644 index 0000000..02c2ee8 --- /dev/null +++ b/python/flake.lock @@ -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 +} diff --git a/python/flake.nix b/python/flake.nix new file mode 100644 index 0000000..e24da9b --- /dev/null +++ b/python/flake.nix @@ -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; + } + ); +} diff --git a/python/main.py b/python/main.py new file mode 100644 index 0000000..d5042b0 --- /dev/null +++ b/python/main.py @@ -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()