From d92214bd4e6a2fc23672c7404d8863255e55a78e Mon Sep 17 00:00:00 2001 From: morgan Date: Tue, 5 Dec 2023 10:41:58 +0800 Subject: [PATCH] add python dependencies and update flake py: add requirements.txt flake: add pip hook & update to 23.11 flake: add flake lock --- flake.lock | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 31 +++++++++++++++--------- requirements.txt | 11 +++++++++ 3 files changed, 92 insertions(+), 11 deletions(-) create mode 100644 flake.lock create mode 100644 requirements.txt diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..7f2ff4a --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "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": 1701539137, + "narHash": "sha256-nVO/5QYpf1GwjvtpXhyxx5M3U/WN0MwBro4Lsk+9mL0=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "933d7dc155096e7575d207be6fb7792bc9f34f6d", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-23.11", + "repo": "nixpkgs", + "type": "github" + } + }, + "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/flake.nix b/flake.nix index c631529..753d03f 100644 --- a/flake.nix +++ b/flake.nix @@ -1,7 +1,6 @@ { inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; - nixpkgs_stable.url = "github:NixOS/nixpkgs/nixpkgs-23.05-darwin"; + nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11"; flake-utils.url = "github:numtide/flake-utils"; }; outputs = { nixpkgs, flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system: @@ -10,19 +9,29 @@ inherit system; }; - pypkgs = ps: [ - ps.pip - ps.scipy - ps.numpy - ps.matplotlib - ]; - in rec { devShell = pkgs.mkShell { name = "WRPLL-sim"; - buildInputs = with pkgs; [ - (python3.withPackages pypkgs) + venvDir = "./.venv"; + buildInputs = with pkgs.python3Packages; [ + python + numba + numpy + notebook # use jupyter notebook without missing libstdc++.so.6 + venvShellHook ]; + + # Only run once when venv is created + postVenvCreation = '' + unset SOURCE_DATE_EPOCH + pip install -r requirements.txt + ''; + + postShellHook = '' + # allow pip to install wheels + unset SOURCE_DATE_EPOCH + ''; + }; } ); diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..04419a6 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,11 @@ +scipy +numpy +ipykernel +ipywidgets +jupyter +jupyterlab +notebook +numba +pandas +plotly +plotly-resampler \ No newline at end of file