diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 2bcf5a8..b609f70 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ .ruff_cache/ .flatpak-builder/ .ignore/ +.direnv/ # Byte-compiled / optimized / DLL files __pycache__/ diff --git a/README.md b/README.md index 7296033..bbfe33a 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This is a small tool built with fastfetch/neofetch, ffmpeg and chafa. It allows ## Installation -**Quick Links Installation Guide For:** +**Quick Links Installation Guide For:** [Linux](#installation-for-linux-system) • [Windows](#installation-for-windows-winget-or-scoop) • [macOS](#installation-for-macos-homebrew) • [Manual](#manual-installation) • [Development](#developer-installation) @@ -45,12 +45,10 @@ After installation, run this to test if anifetch was installed correctly: anifetch example.mp4 ``` - Please read our [User guide](#user-guide) for more info on how to use anifetch. --- - ### Installation for Windows (Winget or Scoop) Check whether you have winget installed by running `winget` in the windows terminal. If you dont have it, install it [here](https://github.com/microsoft/winget-cli/?tab=readme-ov-file#installing-the-client). If you want, you can use [Scoop](https://scoop.sh/) instead. Just replace the `winget` part with `scoop`. @@ -72,7 +70,6 @@ After installing the necessary dependencies using winget/scoop, install anifetch Please read our [Post installation](#post-installation) and [User guide](#user-guide) for more info on how to use anifetch. - ### Installation for macOS (HomeBrew) Install homebrew if you haven't installed it already by following the guide [here](https://brew.sh/). @@ -128,7 +125,6 @@ You can then run the `anifetch` command directly in your terminal. Since pipx installs packages in an isolated environment, you won't have to worry about dependency conflicts or polluting your global python environment. `anifetch` will behave just like a native cli tool. You can upgrade your installation with `pipx upgrade anifetch` - --- ### Installation for NixOS @@ -137,12 +133,12 @@ Add the anifetch repo as a flake input: ```nix { - inputs = { - anifetch = { - url = "github:Notenlish/anifetch"; - inputs.nixpkgs.follows = "nixpkgs"; - }; + inputs = { + anifetch = { + url = "github:Notenlish/anifetch"; + inputs.nixpkgs.follows = "nixpkgs"; }; + }; } ``` @@ -155,9 +151,9 @@ Remember to add: to your nixos configuration, like I've done here on my system: ```nix - nixosConfigurations = { - Enlil = nixpkgs.lib.nixosSystem { - specialArgs = {inherit inputs outputs;}; + nixosConfigurations = { + Enlil = nixpkgs.lib.nixosSystem { + specialArgs = { inherit inputs outputs; }; ``` #### ❄️ As a package: @@ -165,12 +161,13 @@ to your nixos configuration, like I've done here on my system: Add anifetch to your packages list like so: ```nix -{inputs, pkgs, ...}: { - environment.systemPackages = with pkgs; [ - inputs.anifetch.packages.${pkgs.system}.default - fastfetch # Choose either fastfetch or neofetch to run anifetch with - neofetch - ]; +{ inputs, pkgs, ... }: +{ + environment.systemPackages = with pkgs; [ + inputs.anifetch.packages.${pkgs.stdenv.hostPlatform.system}.default + fastfetch # Choose either fastfetch or neofetch to run anifetch with + neofetch + ]; } ``` @@ -179,18 +176,19 @@ Add anifetch to your packages list like so: Add the overlay to nixpkgs overlays, then add the package to your package list as you would a package from the normal nixpkgs repo. ```nix -{inputs, pkgs, ...}: { - nixpkgs = { - overlays = [ - inputs.anifetch.overlays.anifetch - ]; - }; - - environment.systemPackages = with pkgs; [ - anifetch - fastfetch # Choose either fastfetch or neofetch to run anifetch with - neofetch +{ inputs, pkgs, ... }: +{ + nixpkgs = { + overlays = [ + inputs.anifetch.overlays.default ]; + }; + + environment.systemPackages = with pkgs; [ + anifetch + fastfetch # Choose either fastfetch or neofetch to run anifetch with + neofetch + ]; } ``` @@ -211,7 +209,6 @@ pip install -e . ``` > on windows do this to activate the venv instead: `venv\Scripts\activate`. Also on windows you should use `py` instead of `python3`. - This installs `anifetch` in editable mode within a local virtual environment for development. You can then run the program in two ways: @@ -225,14 +222,13 @@ 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. +To install the package into a devshell. However, it is recommended to use [nix-direnv](https://github.com/nix-community/nix-direnv) to enter the development environment automatically, much like a python venv. ## User Guide -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 at least one of these must be installed, otherwise anifetch won't work. **By default, `anifetch` will use fastfetch**. +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 at least one of these must be installed, otherwise anifetch won't work. **By default, `anifetch` will use fastfetch**. > We dont recommend using neofetch as it is archived. **To use neofetch**, you must append `-nf` to the anifetch command. For some distros you may need to append `--force` to the command too since neofetch is deprecated. @@ -259,7 +255,7 @@ _Note : by default, the video `example.mp4` can directly be used as an example._ - `--cleanup`: Clears the screen on program exit. - `-nf` / `--neofetch`: uses `neofetch` instead of `fastfetch` - `-fr` / `--force-render`: Forcefully re-renders the animation while not caring about the cache. Useful if the cache is broken or the contents of the video file has changed. -- `-i` / `--interval`: Use this to make anifetch update the fetch information over time, sets fetch refresh interval in seconds. Default is -1(never). +- `-i` / `--interval`: Use this to make anifetch update the fetch information over time, sets fetch refresh interval in seconds. Default is -1(never). - `-b` / `--benchmark`: For testing, prints how long it took to process in seconds. - `--force`: Add this argument if you want to use neofetch even if it is deprecated on your system. - `--chroma`: Add this argument to chromakey a hexadecimal color from the video using ffmpeg. Syntax: '--chroma \:\:\' @@ -302,14 +298,12 @@ Add this to the end of `.bashrc`: anifetch [video_file] [other_args_if_needed] ``` - ## Customizing Fastfetch/Neofetch output For customizing fastfetch/neofetch output, you can check out these pages: - [Fastfetch Customization](https://github.com/fastfetch-cli/fastfetch/wiki/Configuration) - [Neofetch Customization](https://github.com/dylanaraps/neofetch/wiki/Customizing-Info) - ## 📊 Benchmarks Here's the benchmark from running each cli 10 times. Tested on Windows 11 with Intel I5-12500H processor. @@ -328,7 +322,7 @@ Make sure to install the dependencies listed on [Prerequisites](#Prerequisites). If weird characters are appearing in your terminal then your terminals font probably can't render some characters. Consider installling [nerdfonts](https://www.nerdfonts.com/). -If your OS is prompting you about `"Anifetch" is requesting special priviliges` or something similiar after pressing a key to stop the running Anifetch instance, add this argument: `--no-input-restore`. The technical reason for this is that Anifetch records the keys you press and enters them back to the terminal on your behalf. That way you can immediately run whatever command you want, without having to re-enter a key or two. Certain OS's have built-in protections against this as a security notice, which is why you might encounter a security prompt. +If your OS is prompting you about `"Anifetch" is requesting special priviliges` or something similiar after pressing a key to stop the running Anifetch instance, add this argument: `--no-input-restore`. The technical reason for this is that Anifetch records the keys you press and enters them back to the terminal on your behalf. That way you can immediately run whatever command you want, without having to re-enter a key or two. Certain OS's have built-in protections against this as a security notice, which is why you might encounter a security prompt. ## Notes diff --git a/flake.lock b/flake.lock index 3ed609e..bffd844 100644 --- a/flake.lock +++ b/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1746663147, - "narHash": "sha256-Ua0drDHawlzNqJnclTJGf87dBmaO/tn7iZ+TCkTRpRc=", + "lastModified": 1780243769, + "narHash": "sha256-x5UQuRsH3MqI0U9afaXSNqzTPSeZlRLvFAav2Ux1pNw=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "dda3dcd3fe03e991015e9a74b22d35950f264a54", + "rev": "331800de5053fcebacf6813adb5db9c9dca22a0c", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index bd0b1ec..50c7279 100644 --- a/flake.nix +++ b/flake.nix @@ -5,51 +5,52 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; }; - outputs = { - self, - nixpkgs, - ... - }: let - inherit (self) outputs; - systems = [ - "x86_64-linux" - "aarch64-linux" - "x86_64-darwin" - "aarch64-darwin" - ]; - forAllSystems = nixpkgs.lib.genAttrs systems; - in { - packages = forAllSystems (system: import ./nix/packages nixpkgs.legacyPackages.${system}); - - overlays = import ./nix/overlays; + outputs = + { + self, + nixpkgs, + ... + }: + let + systems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + forAllSystems = nixpkgs.lib.genAttrs systems; + in + { + packages = forAllSystems ( + system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + default = pkgs.callPackage ./nix/package.nix { }; + anifetch = self.packages.default; + } + ); - formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra); + overlays = { + default = final: _prev: { + anifetch = import ./nix/package.nix final.pkgs; + }; + anifetch = self.overlays.default; + }; - 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 - ]; + formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixfmt-tree); - shellHook = '' - if [ ! -d "${venv}" ]; then - echo "Creating Python venv..." - python3 -m venv ${venv} - fi - echo "Activating venv..." - source ${venv}/bin/activate - ''; - }); - }; + devShell = forAllSystems ( + system: + let + pkgs = import nixpkgs { inherit system; }; + in + pkgs.mkShell { + packages = [ + self.packages.${pkgs.stdenv.hostPlatform.system}.default + ]; + } + ); + }; } diff --git a/nix/overlays/default.nix b/nix/overlays/default.nix deleted file mode 100644 index eff754a..0000000 --- a/nix/overlays/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ - anifetch = final: _prev: { - anifetch = import ../packages/anifetch.nix final.pkgs; - }; -} diff --git a/nix/package.nix b/nix/package.nix new file mode 100644 index 0000000..7fab868 --- /dev/null +++ b/nix/package.nix @@ -0,0 +1,41 @@ +{ + python3Packages, + chafa, + ffmpeg, + lib, + ... +}: +let + fs = lib.fileset; + sourceFiles = ../.; +in +fs.trace sourceFiles python3Packages.buildPythonApplication { + name = "anifetch-wrapped"; + version = "git"; + pyproject = true; + src = fs.toSource { + root = ../.; + fileset = sourceFiles; + }; + + build-system = with python3Packages; [ + setuptools + ]; + + dependencies = with python3Packages; [ + chafa + ffmpeg + platformdirs + wcwidth + rich + pynput + ]; + + meta = with lib; { + description = "neofetch but animated"; + homepage = "https://github.com/Notenlish/anifetch"; + license = licenses.mit; + maintainers = with maintainers; [ Immelancholy ]; + mainProgram = "anifetch"; + }; +} diff --git a/nix/packages/anifetch.nix b/nix/packages/anifetch.nix deleted file mode 100644 index 5f94fa0..0000000 --- a/nix/packages/anifetch.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ - python3Packages, - pkgs, - lib, - ... -}: let - fs = lib.fileset; - sourceFiles = ../../.; -in - fs.trace sourceFiles - python3Packages.buildPythonApplication { - name = "aniftech-wrapped"; - version = "1.0.0"; - pyproject = true; - src = fs.toSource { - root = ../../.; - fileset = sourceFiles; - }; - - build-system = [ - pkgs.python3Packages.setuptools - ]; - - dependencies = [ - pkgs.chafa - pkgs.ffmpeg - pkgs.python3Packages.platformdirs - ]; - - meta = with lib; { - description = "neofetch but animated "; - homepage = "https://github.com/Notenlish/anifetch"; - license = licenses.mit; - maintainers = with maintainers; [Immelancholy]; - }; - } diff --git a/nix/packages/default.nix b/nix/packages/default.nix deleted file mode 100644 index 5600e15..0000000 --- a/nix/packages/default.nix +++ /dev/null @@ -1,4 +0,0 @@ -pkgs: rec { - anifetch = pkgs.callPackage ./anifetch.nix {}; - default = anifetch; -}