From 2100857817274435beb17496b87b16da06d996bf Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Tue, 20 May 2025 19:48:19 +0800 Subject: [PATCH] feat(homeModules): add stableDiffusionWebUi --- flake.lock | 84 +++++++++++++++++++++++++++++++- flake.nix | 5 ++ modules/home/desktop/default.nix | 25 +++++++--- 3 files changed, 105 insertions(+), 9 deletions(-) diff --git a/flake.lock b/flake.lock index 1679b9f..9def1e5 100644 --- a/flake.lock +++ b/flake.lock @@ -109,6 +109,24 @@ "type": "github" } }, + "flake-utils_3": { + "inputs": { + "systems": "systems_4" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ @@ -295,6 +313,31 @@ "type": "github" } }, + "python-flexseal": { + "inputs": { + "flake-utils": [ + "stable-diffusion-webui-nix", + "flake-utils" + ], + "nixpkgs": [ + "stable-diffusion-webui-nix", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1734836319, + "narHash": "sha256-h/Jiq852WJyyAL037sIxjPDScjeH8sUoZVZBWlciXaw=", + "owner": "Janrupf", + "repo": "python-flexseal", + "rev": "fdd313f7b9a5c9545c015acaf0729b01f708118a", + "type": "github" + }, + "original": { + "owner": "Janrupf", + "repo": "python-flexseal", + "type": "github" + } + }, "root": { "inputs": { "disko": "disko", @@ -305,7 +348,8 @@ "nixspect": "nixspect", "nvf": "nvf", "snowfall-lib": "snowfall-lib", - "sops-nix": "sops-nix" + "sops-nix": "sops-nix", + "stable-diffusion-webui-nix": "stable-diffusion-webui-nix" } }, "rust-overlay": { @@ -372,6 +416,29 @@ "type": "github" } }, + "stable-diffusion-webui-nix": { + "inputs": { + "flake-utils": "flake-utils_3", + "nixpkgs": [ + "nixpkgs" + ], + "python-flexseal": "python-flexseal" + }, + "locked": { + "lastModified": 1746840548, + "narHash": "sha256-NjKmOjkSMVx+z35L4lTEhYg/eJaNrRqaKwAEdnRJusY=", + "owner": "Janrupf", + "repo": "stable-diffusion-webui-nix", + "rev": "74a71ad10cc6525bc0dbb90ae47a19715a316344", + "type": "github" + }, + "original": { + "owner": "Janrupf", + "ref": "main", + "repo": "stable-diffusion-webui-nix", + "type": "github" + } + }, "systems": { "locked": { "lastModified": 1681028828, @@ -416,6 +483,21 @@ "repo": "default", "type": "github" } + }, + "systems_4": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 14ba931..915e69d 100644 --- a/flake.nix +++ b/flake.nix @@ -15,6 +15,8 @@ nvf.url = "github:notashelf/nvf"; nvf.inputs.nixpkgs.follows = "nixpkgs"; nixspect.url = "github:rrvsh/nixspect"; + stable-diffusion-webui-nix.url = "github:Janrupf/stable-diffusion-webui-nix/main"; + stable-diffusion-webui-nix.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = @@ -23,6 +25,9 @@ inherit inputs; src = ./.; snowfall.namespace = "pantheon"; + overlays = with inputs; [ + stable-diffusion-webui-nix.overlays.default + ]; systems.modules.nixos = with inputs; [ disko.nixosModules.disko impermanence.nixosModules.impermanence diff --git a/modules/home/desktop/default.nix b/modules/home/desktop/default.nix index 35dc813..374906a 100644 --- a/modules/home/desktop/default.nix +++ b/modules/home/desktop/default.nix @@ -2,6 +2,7 @@ config, lib, osConfig, + pkgs, ... }: { @@ -11,12 +12,20 @@ terminal = lib.pantheon.mkStrOption; }; - config = { - assertions = [ - { - assertion = (osConfig.desktop.windowManager == config.desktop.windowManager); - message = "You have set your home window manager to one that is not installed on this system."; - } - ]; - }; + config = lib.mkMerge [ + { + assertions = [ + { + assertion = (osConfig.desktop.windowManager == config.desktop.windowManager); + message = "You have set your home window manager to one that is not installed on this system."; + } + ]; + } + (lib.mkIf (osConfig.hardware.gpu == "nvidia") { + home.packages = [ pkgs.stable-diffusion-webui.forge.cuda ]; + home.persistence."/persist/home/${config.snowfallorg.user.name}".directories = [ + ".local/share/stable-diffusion-webui" + ]; + }) + ]; }