From a3de422c136ef4c43ae05481b84dfa84230f1c99 Mon Sep 17 00:00:00 2001 From: Vir Chaudhury Date: Sat, 31 Dec 2022 18:02:46 +0800 Subject: [PATCH] feat: initial functionality --- README.md | 21 +++++++++++++++++++++ flake.lock | 43 +++++++++++++++++++++++++++++++++++++++++++ flake.nix | 21 +++++++++++++++++++++ impl.nix | 25 +++++++++++++++++++++++++ shell.nix | 1 + 5 files changed, 111 insertions(+) create mode 100644 README.md create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 impl.nix create mode 100644 shell.nix diff --git a/README.md b/README.md new file mode 100644 index 0000000..7cd9414 --- /dev/null +++ b/README.md @@ -0,0 +1,21 @@ +# [AUTOMATIC1111/stable-diffusion-webui] for CUDA on NixOS + +This is literally just a `shell.nix` and a `flake.nix` for stable-diffusion-webui using CUDA on NixOS. +This currently doesn't support AMD cards (I don't have one) but feel free to contribute. + +## Usage +```bash +git clone https://github.com/AUTOMATIC1111/stable-diffusion-webui +git clone https://github.com/virchau13/automatic1111-webui-nix +cp automatic1111-webui-nix-flake/*.nix stable-diffusion-webui/ +cd stable-diffusion-webui +nix shell # or `nix-shell` if you're not using flakes +# just use `./webui.sh` to run it, it'll install all the rest automatically +# follow the tutorials at the original project for setting up Stable Diffusion / GFPGAN / whatever +``` + +You might want to switch to high performance mode on battery-powered devices. + +## Credits +- AUTOMATIC1111 for obvious reasons. +- polypoyo for [the original draft of this](https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/4736). diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..3cbf13e --- /dev/null +++ b/flake.lock @@ -0,0 +1,43 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1672350804, + "narHash": "sha256-jo6zkiCabUBn3ObuKXHGqqORUMH27gYDIFFfLq5P4wg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "677ed08a50931e38382dbef01cba08a8f7eac8f6", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..3512370 --- /dev/null +++ b/flake.nix @@ -0,0 +1,21 @@ +{ + description = "AUTOMATIC1111/stable-diffusion-webui flake"; + + inputs = { + nixpkgs.url = github:NixOS/nixpkgs/nixos-unstable; + flake-utils.url = github:numtide/flake-utils; + }; + + outputs = { self, nixpkgs, flake-utils }: let + isLinux = system: builtins.match ".*linux.*" system != null; + linuxSystems = builtins.filter isLinux flake-utils.lib.defaultSystems; + in flake-utils.lib.eachSystem linuxSystems (system: let + pkgs = import nixpkgs { + inherit system; + config.allowUnfree = true; + }; + in { + devShells.default = import ./impl.nix pkgs; + } + ); +} diff --git a/impl.nix b/impl.nix new file mode 100644 index 0000000..17bcacc --- /dev/null +++ b/impl.nix @@ -0,0 +1,25 @@ +pkgs: + +pkgs.mkShell rec { + name = "stable-diffusion-webui"; + buildInputs = with pkgs; [ + git # The program instantly crashes if git is not present, even if everything is already downloaded + python310 + stdenv.cc.cc.lib + stdenv.cc + ncurses5 + binutils + gitRepo gnupg autoconf curl + procps gnumake util-linux m4 gperf unzip + cudatoolkit linuxPackages.nvidia_x11 + libGLU libGL + xorg.libXi xorg.libXmu freeglut + xorg.libXext xorg.libX11 xorg.libXv xorg.libXrandr zlib + glib + ]; + shellHook = '' + export LD_LIBRARY_PATH="${pkgs.lib.makeLibraryPath buildInputs}" + export CUDA_PATH=${pkgs.cudatoolkit} + export EXTRA_LDFLAGS="-L${pkgs.linuxPackages.nvidia_x11}/lib" + ''; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..5edcb66 --- /dev/null +++ b/shell.nix @@ -0,0 +1 @@ +let pkgs = import {}; in import ./impl.nix pkgs pkgs.lib