From 0285392ceb4b00ab87e3ab7486b7c2cc06773ecf Mon Sep 17 00:00:00 2001 From: Immelancholy Date: Fri, 27 Jun 2025 01:06:26 +0100 Subject: [PATCH 1/2] feat: add devShell to flake.nix Includes a development shell with Python and common utilities. - Sets up a Python virtual environment. - Adds bc, chafa, and ffmpeg to packages. - Automates venv creation and activation. --- flake.nix | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/flake.nix b/flake.nix index 57353be..bd0b1ec 100644 --- a/flake.nix +++ b/flake.nix @@ -24,5 +24,32 @@ overlays = import ./nix/overlays; formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra); + + devShell = forAllSystems (system: let + pkgs = nixpkgs.legacyPackages.${system}; + myPython = pkgs.python3; + pythonWithPkgs = myPython.withPackages (ps: [ + ps.pip + ps.setuptools + ]); + venv = "venv"; + in + pkgs.mkShell { + packages = [ + pythonWithPkgs + pkgs.bc + pkgs.chafa + pkgs.ffmpeg + ]; + + shellHook = '' + if [ ! -d "${venv}" ]; then + echo "Creating Python venv..." + python3 -m venv ${venv} + fi + echo "Activating venv..." + source ${venv}/bin/activate + ''; + }); }; } From d93f3f1a0c10f607f3487c235b8ecfb5610502ab Mon Sep 17 00:00:00 2001 From: Immelancholy Date: Fri, 27 Jun 2025 01:16:01 +0100 Subject: [PATCH 2/2] docs: Add Nix installation instructions to README Enables users on Nix systems to install and run anifetch using Nix development environments and pip. --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 48d2907..0228990 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,15 @@ You can then run the program in two ways: ⚠️ Please avoid using `pip install` outside a virtual environment on systems like Ubuntu. This is restricted by [PEP 668](https://peps.python.org/pep-0668/) to protect the system Python. +On Nix you can run: + +```bash +nix develop +pip install -e . +``` + +inside the anifetch dir after cloning the repo. This creates a python venv you can re-enter by running `nix develop` inside the project dir. + ## ▶️ How to Use It You don't need to configure anything for `fastfetch` or `neofetch`. If they already work on your machine, `anifetch` will detect and use them automatically. Please note that one of these must be installed, otherwise anifetch won't work. To use **fastfetch**, you must append `-ff` to the anifetch command.