From 1a3dcb516a1eed83dbf6d8a6bc62559590c1ca71 Mon Sep 17 00:00:00 2001 From: John Lancaster <32917998+jsl12@users.noreply.github.com> Date: Sat, 28 Dec 2024 23:54:16 -0600 Subject: [PATCH] jupyter works through uv command in devenv shell --- README.md | 32 +++++++++++++++++++------------- configuration.nix | 2 ++ flake.nix | 27 +++++++++++++++------------ 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index ff4ab88..8b49bf8 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,21 @@ -NixOS Configuration for AppDaemon Development +# NixOS Configuration for AppDaemon Development -Needs a `git.nix` file. Example below: +## Objectives -```shell -{ ... }: -{ - programs.git = { - enable = true; - extraConfig.credential.helper = "store --file ~/.git-credentials"; - userName = "John Lancaster"; - userEmail = "32917998+jsl12@users.noreply.github.com"; - }; -} -``` +- Use flakes +- `devenv`-based workflow + - Shell + - Build +- SSH remote with VSCode +- Jupyter through VSCode + - `autoreload` must work with editable install of the dev version + +## Usage + +### `nfs` + +Used to rebuild the ad-nix system. + +### `ads` + +Used to enter the development shell. Be careful, as this will create a `.devenv` directory and venv wherever it's entered. \ No newline at end of file diff --git a/configuration.nix b/configuration.nix index 195cb7f..251f719 100644 --- a/configuration.nix +++ b/configuration.nix @@ -15,6 +15,8 @@ in nix.settings.trusted-users = [ "root" "@wheel" ]; nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + programs.nix-ld.enable = true; sops.defaultSopsFile = ./secrets/secrets.yaml; sops.defaultSopsFormat = "yaml"; diff --git a/flake.nix b/flake.nix index 2301be8..8418558 100644 --- a/flake.nix +++ b/flake.nix @@ -72,6 +72,7 @@ ]; }; + # https://devenv.sh/guides/using-with-flakes/#the-flakenix-file packages.${systemSettings.system} = { devenv-up = self.devShells.${systemSettings.system}.default.config.procfileScript; devenv-test = self.devShells.${systemSettings.system}.default.config.test; @@ -87,16 +88,19 @@ ({ pkgs, config, ... }: { # This is your devenv configuration + # https://devenv.sh/reference/options/#pre-commithooks pre-commit.hooks = { end-of-file-fixer.enable = true; trim-trailing-whitespace.enable = true; }; + # https://devenv.sh/supported-languages/python/ languages.python = { enable = true; version = systemSettings.pythonVersion; uv = { enable = true; + package = pkgs.uv; sync = { enable = true; allExtras = true; @@ -107,20 +111,19 @@ packages = with pkgs; [ git - # (writeShellScriptBin "full-build" '' - # cd ${adPath} - # ${pkgs.uv}/bin/uv build --wheel - # docker build -t acockburn/appdaemon:local-dev ${adPath} - # '') - # (pkgs.python312.withPackages (python-pkgs: with python-pkgs; [ - # pip - # setuptools - # wheel - # ipykernel - # rich - # ])) + (pkgs.python312.withPackages (python-pkgs: with python-pkgs; [ + pip + setuptools + wheel + notebook + rich + ])) ]; + processes = { + my-jup.exec = "uv run jupyter notebook"; + }; + enterShell = '' alias appdaemon="${pkgs.uv}/bin/uv run --frozen python -m appdaemon" alias ad="appdaemon"