feat: initial functionality

This commit is contained in:
Vir Chaudhury 2022-12-31 18:02:46 +08:00
commit a3de422c13
No known key found for this signature in database
GPG Key ID: 25B242ED74B61B15
5 changed files with 111 additions and 0 deletions

21
README.md Normal file
View File

@ -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).

43
flake.lock Normal file
View File

@ -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
}

21
flake.nix Normal file
View File

@ -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;
}
);
}

25
impl.nix Normal file
View File

@ -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"
'';
}

1
shell.nix Normal file
View File

@ -0,0 +1 @@
let pkgs = import <nixpkgs> {}; in import ./impl.nix pkgs pkgs.lib