commit 2e4848288bd1450e0ba9a470ec14210dc2d6ffc9
parent ab3aba334cdea3571d3fe3df9b96baeb24c23c66
Author: maydayv7 <maydayv7@gmail.com>
Date: Mon, 8 Dec 2025 21:09:23 +0530
Add Nix Flake
Diffstat:
7 files changed, 246 insertions(+), 3 deletions(-)
diff --git a/INSTALL.md b/INSTALL.md
@@ -17,6 +17,9 @@ To build the app from source, read the rest of this document.
Ensure that all these programs with the correct versions are installed on your system before using this repository
+> [!NOTE]
+> For [Nix](https://nixos.org/) users, a [Flake](./flake.nix) for the development shell is provided
+
# Setup
### 1. Download Models
diff --git a/flake.lock b/flake.lock
@@ -0,0 +1,60 @@
+{
+ "nodes": {
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1763966396,
+ "narHash": "sha256-6eeL1YPcY1MV3DDStIDIdy/zZCDKgHdkCmsrLJFiZf0=",
+ "owner": "flox",
+ "repo": "nixpkgs",
+ "rev": "5ae3b07d8d6527c42f17c876e404993199144b6a",
+ "type": "github"
+ },
+ "original": {
+ "owner": "flox",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "nixpkgs": "nixpkgs",
+ "utils": "utils"
+ }
+ },
+ "systems": {
+ "locked": {
+ "lastModified": 1681028828,
+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+ "owner": "nix-systems",
+ "repo": "default",
+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-systems",
+ "repo": "default",
+ "type": "github"
+ }
+ },
+ "utils": {
+ "inputs": {
+ "systems": "systems"
+ },
+ "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"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
@@ -0,0 +1,50 @@
+{
+ description = "CreekUI Development";
+
+ inputs = {
+ nixpkgs.url = "github:flox/nixpkgs";
+ utils.url = "github:numtide/flake-utils";
+ };
+
+ outputs =
+ {
+ self,
+ nixpkgs,
+ utils,
+ }:
+ utils.lib.eachDefaultSystem (
+ system:
+ let
+ pkgs = import nixpkgs {
+ inherit system;
+ config = {
+ allowUnfree = true;
+ cudaSupport = true;
+ };
+ };
+ in
+ {
+ devShells = rec {
+ default = app;
+ app = import ./shell.nix { inherit pkgs; };
+ server = import ./flask/shell.nix { inherit pkgs; };
+ };
+ }
+ );
+
+ # Binary Cache
+ nixConfig = {
+ trusted-substituters = [
+ "https://cache.nixos.org"
+ "https://nixpkgs-unfree.cachix.org"
+ "https://nix-community.cachix.org"
+ "https://cache.flox.dev"
+ ];
+ trusted-public-keys = [
+ "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
+ "nixpkgs-unfree.cachix.org-1:hqvoInulhbV4nJ9yJOEr+4wxhDV4xq2d1DK7S6Nj6rs="
+ "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
+ "flox-cache-public-1:7F4OyH7ZCnFhcze3fJdfyXYLQw/aV7GEed86nQ7IsOs="
+ ];
+ };
+}
diff --git a/flask/README.md b/flask/README.md
@@ -31,7 +31,7 @@ modal deploy modal_app.py
# Setup
> [!NOTE]
-> Python 3.11 is the preferred version for running the backend
+> For [Nix](https://nixos.org/) users, a [Flake](./flake.nix) for the development shell is provided
## Models
@@ -46,5 +46,5 @@ FAL_KEY=<Fal.ai API Key>
SHARED_SECRET_KEY=<Base64 Security Key>
```
-> [!NOTE]
+> [!CAUTION]
> You must update the root [`.env`](../.env) file for the app to recognize the deployed backend
diff --git a/flask/index.py b/flask/index.py
@@ -879,4 +879,7 @@ def sketch_api():
if __name__ == "__main__":
- app.run(host="0.0.0.0", port=5000)
+ PORT = os.getenv("PORT")
+ if not PORT:
+ PORT = 5000
+ app.run(host="0.0.0.0", port=PORT)
diff --git a/flask/shell.nix b/flask/shell.nix
@@ -0,0 +1,65 @@
+{
+ pkgs ? import <nixpkgs> {
+ config = {
+ allowUnfree = true;
+ cudaSupport = true;
+ };
+ },
+}:
+
+pkgs.mkShell {
+ nativeBuildInputs =
+ let
+ fal-client =
+ with pkgs.python3Packages;
+ buildPythonPackage rec {
+ pname = "fal_client";
+ version = "0.10.0";
+ pyproject = true;
+ src = fetchPypi {
+ inherit pname version;
+ hash = "sha256-UwNtAwgRerLaddWLTQnpUQk2Oob3sW/FmhhidgKYZh8=";
+ };
+ propagatedBuildInputs = [
+ httpx
+ httpx-sse
+ msgpack
+ setuptools
+ setuptools-scm
+ websockets
+ ];
+ };
+ in
+ [
+ pkgs.python3
+ (pkgs.python3.withPackages (
+ p: with p; [
+ accelerate
+ bitsandbytes
+ diffusers
+ einops
+ fal-client
+ flask
+ flask-cors
+ hf-xet
+ kornia
+ numpy
+ opencv4
+ pillow
+ pip
+ pycryptodome
+ python-dotenv
+ requests
+ scipy
+ tblib
+ timm
+ toml
+ torch
+ torchvision
+ transformers
+ ]
+ ))
+ ];
+
+ LD_LIBRARY_PATH = "${pkgs.stdenv.cc.cc.lib}/lib";
+}
diff --git a/shell.nix b/shell.nix
@@ -0,0 +1,62 @@
+{
+ pkgs ? import <nixpkgs> { allowUnfree = true; },
+}:
+
+let
+ androidEnv = pkgs.callPackage "${toString pkgs.path}/pkgs/development/mobile/androidenv" {
+ inherit pkgs;
+ licenseAccepted = true;
+ };
+
+ buildTools = "35.0.0";
+ inherit
+ (androidEnv.composeAndroidPackages {
+ cmdLineToolsVersion = "8.0";
+ toolsVersion = "26.1.1";
+ platformToolsVersion = "35.0.2";
+ buildToolsVersions = [ buildTools ];
+ includeEmulator = false;
+ platformVersions = [
+ "33"
+ "34"
+ "35"
+ "36"
+ ];
+ includeSystemImages = false;
+ includeSources = false;
+ cmakeVersions = [ "3.22.1" ];
+ includeNDK = true;
+ ndkVersions = [
+ "27.0.12077973"
+ "26.3.11579264"
+ ];
+ extraLicenses = [
+ "android-sdk-license"
+ "android-sdk-preview-license"
+ ];
+ })
+ androidsdk
+ ;
+
+in
+pkgs.mkShell rec {
+ name = "Android";
+ packages = with pkgs; [
+ jdk
+ kotlin
+ gradle
+ flutter
+
+ androidsdk
+ pkg-config
+ ];
+
+ shellHook = ''echo "## Android Development Shell ##"'';
+ JAVA_HOME = pkgs.jdk;
+ GRADLE_HOME = "${pkgs.gradle}/lib/gradle";
+ GRADLE_OPTS = "-Dorg.gradle.project.android.aapt2FromMavenOverride=${androidsdk}/libexec/android-sdk/build-tools/${buildTools}/aapt2";
+ FLUTTER_ROOT = pkgs.flutter;
+ DART_ROOT = "${FLUTTER_ROOT}/bin/cache/dart-sdk";
+ ANDROID_SDK_ROOT = "${androidsdk}/libexec/android-sdk";
+ ANDROID_NDK_ROOT = "${ANDROID_SDK_ROOT}/ndk-bundle";
+}