From 6c324863f58e2336c7dc09e8414e98da7d8f47b5 Mon Sep 17 00:00:00 2001 From: shivaraj-bh Date: Mon, 8 Apr 2024 17:17:12 +0530 Subject: [PATCH 1/6] github-actions: add ci.yaml supports linux and macos --- .github/workflows/ci.yaml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..3ac5ad3 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,20 @@ +name: "CI" +on: + push: + branches: + - main + pull_request: +jobs: + checks: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, macos-14 ] + steps: + - uses: actions/checkout@v3 + - uses: cachix/install-nix-action@v25 + - uses: DeterminateSystems/magic-nix-cache-action@main + - uses: yaxitech/nix-install-pkgs-action@v3 + with: + packages: "github:srid/nixci" + - run: nixci \ No newline at end of file From ed21a440b5cd7bc5ec4db59c752cc6adc4742b35 Mon Sep 17 00:00:00 2001 From: shivaraj-bh Date: Mon, 8 Apr 2024 17:18:30 +0530 Subject: [PATCH 2/6] it is `nixci build` --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3ac5ad3..07fff69 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -17,4 +17,4 @@ jobs: - uses: yaxitech/nix-install-pkgs-action@v3 with: packages: "github:srid/nixci" - - run: nixci \ No newline at end of file + - run: nixci build \ No newline at end of file From 1dfaec5351762e52d67c0f4e1404543b4b6602e0 Mon Sep 17 00:00:00 2001 From: shivaraj-bh Date: Mon, 8 Apr 2024 23:30:43 +0530 Subject: [PATCH 3/6] `open-webui/backend` doesn't have a pyproject.toml or setup.py we only need the pyEnv anyway, so let's only output packages that we need --- flake.nix | 130 +++++++++++++++++++++++++++---------------------- nix/ollama.nix | 2 +- 2 files changed, 72 insertions(+), 60 deletions(-) diff --git a/flake.nix b/flake.nix index c4f6b8c..fb98040 100644 --- a/flake.nix +++ b/flake.nix @@ -20,71 +20,83 @@ inputs.process-compose-flake.flakeModule ]; debug = true; - perSystem = { self', pkgs, config, system, ... }: { - _module.args.pkgs = import inputs.nixpkgs { - inherit system; - # Required for CUDA - config.allowUnfree = true; - overlays = [ - (self: _: with self; { - open-webui-frontend = callPackage (import ./nix/open-webui-frontend.nix { inherit inputs; }) { }; - }) - ]; - }; - packages.open-webui-backend = inputs.dream2nix.lib.evalModules { - packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system}; - specialArgs = { inherit inputs; }; - modules = [ - ./nix/open-webui-backend + perSystem = { self', pkgs, config, system, ... }: + let + open-webui-backend-module = inputs.dream2nix.lib.evalModules { + packageSets.nixpkgs = inputs.dream2nix.inputs.nixpkgs.legacyPackages.${system}; + specialArgs = { inherit inputs; }; + modules = [ + ./nix/open-webui-backend + { + paths.projectRoot = ./.; + # can be changed to ".git" or "flake.nix" to get rid of .project-root + paths.projectRootFile = "flake.nix"; + paths.package = ./nix/open-webui-backend; + } + ]; + }; + in + { + _module.args.pkgs = import inputs.nixpkgs { + inherit system; + # Required for CUDA + config.allowUnfree = true; + overlays = [ + (self: _: with self; { + open-webui-frontend = callPackage (import ./nix/open-webui-frontend.nix { inherit inputs; }) { }; + }) + ]; + }; + + packages = { + # Generate the `pdm.lock` file in `nix/open-webui-backend` + open-webui-backend-lock = open-webui-backend-module.lock; + # Generate the `pyproject.toml` file in `nix/open-webui-backend` + open-webui-backend-req2py = open-webui-backend-module.req2py; + open-webui-backend-pyEnv = open-webui-backend-module.pyEnv; + }; + + process-compose = + let + common = { ... }: { + imports = [ + inputs.services-flake.processComposeModules.default + (import ./nix/ollama.nix { inherit self' inputs; }) + ]; + services.ollama-stack.enable = true; + }; + in { - paths.projectRoot = ./.; - # can be changed to ".git" or "flake.nix" to get rid of .project-root - paths.projectRootFile = "flake.nix"; - paths.package = ./nix/open-webui-backend; - } - ]; - }; - process-compose = - let - common = { ... }: { - imports = [ - inputs.services-flake.processComposeModules.default - (import ./nix/ollama.nix { inherit self' inputs; }) - ]; - services.ollama-stack.enable = true; - }; - in - { - default = { - imports = [ common ]; - services.ollama-stack.open-webui.enable = true; - }; - cuda = { - imports = [ common ]; - services.ollama-stack.extraOllamaConfig = { - package = pkgs.ollama.override { acceleration = "cuda"; }; - extraEnvs = { - # # See https://github.com/ollama/ollama/blob/9768e2dc7574c36608bb04ac39a3b79e639a837f/docs/gpu.md?plain=1#L32-L38 - # CUDA_VISIBLE_DEVICES = "0,2"; + default = { + imports = [ common ]; + services.ollama-stack.open-webui.enable = true; + }; + cuda = { + imports = [ common ]; + services.ollama-stack.extraOllamaConfig = { + package = pkgs.ollama.override { acceleration = "cuda"; }; + extraEnvs = { + # # See https://github.com/ollama/ollama/blob/9768e2dc7574c36608bb04ac39a3b79e639a837f/docs/gpu.md?plain=1#L32-L38 + # CUDA_VISIBLE_DEVICES = "0,2"; + }; }; }; - }; - rocm = { - imports = [ common ]; - services.ollama-stack.extraOllamaConfig = { - package = pkgs.ollama.override { acceleration = "rocm"; }; - extraEnvs = { - # # See https://github.com/ollama/ollama/blob/9768e2dc7574c36608bb04ac39a3b79e639a837f/docs/gpu.md?plain=1#L55-L86 - # HSA_OVERRIDE_GFX_VERSION = “10.3.0”; - # # See docs: https://rocm.docs.amd.com/en/latest/conceptual/gpu-isolation.html#rocr-visible-devices - # ROCR_VISIBLE_DEVICES = "0,GPU-DEADBEEFDEADBEEF"; - # # See https://rocm.docs.amd.com/en/latest/conceptual/gpu-isolation.html#hip-visible-devices - # HIP_VISIBLE_DEVICES = "0,2"; + rocm = { + imports = [ common ]; + services.ollama-stack.extraOllamaConfig = { + package = pkgs.ollama.override { acceleration = "rocm"; }; + extraEnvs = { + # # See https://github.com/ollama/ollama/blob/9768e2dc7574c36608bb04ac39a3b79e639a837f/docs/gpu.md?plain=1#L55-L86 + # HSA_OVERRIDE_GFX_VERSION = “10.3.0”; + # # See docs: https://rocm.docs.amd.com/en/latest/conceptual/gpu-isolation.html#rocr-visible-devices + # ROCR_VISIBLE_DEVICES = "0,GPU-DEADBEEFDEADBEEF"; + # # See https://rocm.docs.amd.com/en/latest/conceptual/gpu-isolation.html#hip-visible-devices + # HIP_VISIBLE_DEVICES = "0,2"; + }; }; }; }; - }; - }; + }; }; } diff --git a/nix/ollama.nix b/nix/ollama.nix index 39dbc35..e859489 100644 --- a/nix/ollama.nix +++ b/nix/ollama.nix @@ -49,7 +49,7 @@ { command = pkgs.writeShellApplication { name = "open-webui"; - runtimeInputs = [ self'.packages.open-webui-backend.pyEnv ]; + runtimeInputs = [ self'.packages.open-webui-backend-pyEnv ]; text = '' set -x # TODO: make a service and give it a dataDir option From 592bfac2f812546dd8410d181f927634cfb565a4 Mon Sep 17 00:00:00 2001 From: shivaraj-bh Date: Mon, 8 Apr 2024 23:30:52 +0530 Subject: [PATCH 4/6] ci.yaml fmt --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 07fff69..9144338 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -9,7 +9,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-latest, macos-latest, macos-14 ] + os: [ ubuntu-latest, macos-latest, macos-14 ] steps: - uses: actions/checkout@v3 - uses: cachix/install-nix-action@v25 From a97d0c4b135a35318969716bcd1576bcb314256d Mon Sep 17 00:00:00 2001 From: shivaraj-bh Date: Mon, 8 Apr 2024 23:36:36 +0530 Subject: [PATCH 5/6] also change readme --- nix/open-webui-backend/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nix/open-webui-backend/README.md b/nix/open-webui-backend/README.md index 660c2bd..53ea2b4 100644 --- a/nix/open-webui-backend/README.md +++ b/nix/open-webui-backend/README.md @@ -5,12 +5,12 @@ This package depends on `pyproject.toml` and `pdm.lock` file. The `pyproject.tom To generate the `pyproject.toml` run: ```sh -nix run .#open-webui-backend.req2py +nix run .#open-webui-backend-req2py ``` And to generate the `pdm.lock` file: ```sh -nix run .#open-webui-backend.lock +nix run .#open-webui-backend-lock ``` From 071bf457c4a64d8d95e012b9edae1628e4641324 Mon Sep 17 00:00:00 2001 From: shivaraj-bh Date: Mon, 8 Apr 2024 23:52:27 +0530 Subject: [PATCH 6/6] rm github-actions; enter garnix --- .github/workflows/ci.yaml | 20 -------------------- garnix.yaml | 4 ++++ 2 files changed, 4 insertions(+), 20 deletions(-) delete mode 100644 .github/workflows/ci.yaml create mode 100644 garnix.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index 9144338..0000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,20 +0,0 @@ -name: "CI" -on: - push: - branches: - - main - pull_request: -jobs: - checks: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ ubuntu-latest, macos-latest, macos-14 ] - steps: - - uses: actions/checkout@v3 - - uses: cachix/install-nix-action@v25 - - uses: DeterminateSystems/magic-nix-cache-action@main - - uses: yaxitech/nix-install-pkgs-action@v3 - with: - packages: "github:srid/nixci" - - run: nixci build \ No newline at end of file diff --git a/garnix.yaml b/garnix.yaml new file mode 100644 index 0000000..d98688d --- /dev/null +++ b/garnix.yaml @@ -0,0 +1,4 @@ +builds: + include: + - "*.aarch64-darwin.*" + - "*.x86_64-linux.*"