From dd593a344afb30660b3638f7aaa836c588dbd8b5 Mon Sep 17 00:00:00 2001 From: jim3692 Date: Sun, 12 Jan 2025 23:37:32 +0200 Subject: [PATCH 1/2] Implement Nix Flake Signed-off-by: jim3692 --- flake.nix | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 flake.nix diff --git a/flake.nix b/flake.nix new file mode 100644 index 00000000..43422483 --- /dev/null +++ b/flake.nix @@ -0,0 +1,55 @@ +{ + inputs = { + nixpkgs = { + url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + }; + + outputs = { self, nixpkgs }: + let + supportedSystems = [ + "x86_64-linux" + "aarch64-linux" + ]; + + forAllSystems = nixpkgs.lib.genAttrs supportedSystems; + + mkRamalama = pkgs: with pkgs; + callPackage + ( + { ramalamaOverrides ? { } + , llamaCppOverrides ? { } + }: + python3Packages.buildPythonPackage ({ + name = "ramalama"; + src = ./.; + dependencies = [ (llama-cpp.override llamaCppOverrides) ]; + } // ramalamaOverrides) + ) + { llamaCppOverrides.vulkanSupport = true; } + ; + + ramalama = forAllSystems (system: + let + pkgs = nixpkgs.legacyPackages.${system}; + package = mkRamalama pkgs; + in { + inherit package; + app = { + type = "app"; + program = toString (pkgs.writeShellScript "ramalama" "${package}/bin/ramalama \"$@\""); + }; + } + ); + in { + packages = forAllSystems (system: { + ramalama = ramalama.${system}.package; + default = ramalama.${system}.package; + }); + + apps = forAllSystems (system :{ + ramalama = ramalama.${system}.app; + default = ramalama.${system}.app; + }); + }; +} From f715a32c909dc02b76ae24dc2e417dbfaacc087f Mon Sep 17 00:00:00 2001 From: jim3692 Date: Mon, 13 Jan 2025 00:28:39 +0200 Subject: [PATCH 2/2] Enable Flake for MacOS Signed-off-by: jim3692 --- flake.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flake.nix b/flake.nix index 43422483..53e66619 100644 --- a/flake.nix +++ b/flake.nix @@ -10,6 +10,8 @@ supportedSystems = [ "x86_64-linux" "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" ]; forAllSystems = nixpkgs.lib.genAttrs supportedSystems;