From c77d7a0c83777a9724701788879e5f8bf92c4b5d Mon Sep 17 00:00:00 2001 From: luc Date: Tue, 15 Oct 2024 10:25:28 -0400 Subject: [PATCH] refactor: Clean up flake.nix and reorganize Nix-related files - Update project description to "topos-cli" - Reorganize overlays and services into a dedicated 'nix' directory - Simplify service configurations: - Remove commented-out Kafka settings - Standardize service naming (e.g., "ollama" instead of "ollama1") - Update TOPOS_CONFIG_PATH to use ~/.topos instead of ~/.config/topos - Remove unused tkinter overlay - Adjust data directory paths for consistency - Clean up comments and whitespace These changes improve the maintainability of our Nix configuration and provide a cleaner structure for future development. --- flake.nix | 35 ++++++------------ {overlays => nix/overlays}/pystray/build.nix | 0 .../overlays}/pystray/default.nix | 0 .../services/topos-service.nix | 0 overlays/tkinter/default.nix | 36 ------------------- 5 files changed, 10 insertions(+), 61 deletions(-) rename {overlays => nix/overlays}/pystray/build.nix (100%) rename {overlays => nix/overlays}/pystray/default.nix (100%) rename topos-service.nix => nix/services/topos-service.nix (100%) delete mode 100644 overlays/tkinter/default.nix diff --git a/flake.nix b/flake.nix index d8c95ab..ae86be5 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "topos"; + description = "topos-cli"; inputs = { flake-parts.url = "github:hercules-ci/flake-parts"; @@ -26,7 +26,7 @@ toposPoetryEnv = final.callPackage toposPoetryEnv { }; pythonPackagesExtensions = prev.pythonPackagesExtensions ++ [ (python-final: python-prev: { - pystray = python-final.callPackage ./overlays/pystray/default.nix { }; + pystray = python-final.callPackage ./nix/overlays/pystray/default.nix { }; }) ]; }) @@ -78,7 +78,7 @@ # if one is not already set in the user's .config directory. toposSetupHook = '' export $(cat ${envFile} | xargs) - export TOPOS_CONFIG_PATH="$HOME/.config/topos/config.yaml" + export TOPOS_CONFIG_PATH="$HOME/.topos/config.yaml" mkdir -p "$(dirname "$TOPOS_CONFIG_PATH")" if [ ! -f "$TOPOS_CONFIG_PATH" ]; then echo "Creating new config file at $TOPOS_CONFIG_PATH" @@ -98,18 +98,19 @@ process-compose."services-flake-topos" = { config, ... }: { imports = [ inputs.services-flake.processComposeModules.default - (import ./topos-service.nix { inherit pkgs lib config; topos = self'.packages.topos; }) + (import ./nix/services/topos-service.nix { inherit pkgs lib config; topos = self'.packages.topos; }) ]; - services = let dataDirBase = "$HOME/.services-flake/llm"; in { + services = let dataDirBase = "$HOME/.topos"; in { # Backend service to perform inference on LLM models - ollama."ollama1" = { + ollama."ollama" = { enable = true; # The models are usually huge, downloading them in every project # directory can lead to a lot of duplication. Change here to a # directory where the Ollama models can be stored and shared across # projects. - dataDir = "${dataDirBase}/ollama1"; + + # dataDir = "${dataDirBase}/ollama"; # Define the models to download when our app starts # @@ -125,7 +126,7 @@ package = pkgs.postgresql_16.withPackages (p: [ p.pgvector ]); port = 5432; listen_addresses = "127.0.0.1"; - + # dataDir = "${dataDirBase}/pg"; initialDatabases = [ { name = "${envVars.POSTGRES_DB}"; } ]; @@ -172,27 +173,11 @@ apache-kafka."kafka" = { enable = true; port = 9092; + # dataDir = "${dataDirBase}/kafka"; settings = { "offsets.topic.replication.factor" = 1; "zookeeper.connect" = [ "localhost:2181" ]; }; - # settings = { - # "broker.id" = 1; - # "log.dirs" = [ "/tmp/kraft-combined-logs/server-1" ]; - # "listeners" = [ "PLAINTEXT://localhost:9092" "CONTROLLER://localhost:9091" ]; - # "listener.security.protocol.map" = "CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT"; - # "advertised.listeners" = "PLAINTEXT://localhost:9092"; - # "controller.quorum.voters" = "1@localhost:9091"; - # "controller.listener.names" = "CONTROLLER"; - # "process.roles" = "broker,controller"; - # "node.id" = 1; - # "offsets.topic.replication.factor" = 1; - # "transaction.state.log.replication.factor" = 1; - # "transaction.state.log.min.isr" = 1; - # "auto.create.topics.enable" = true; - # "num.partitions" = 1; - # }; - # clusterId = "$(${pkgs.apacheKafka}/bin/kafka-storage.sh random-uuid)"; formatLogDirs = true; formatLogDirsIgnoreFormatted = true; jvmOptions = [ diff --git a/overlays/pystray/build.nix b/nix/overlays/pystray/build.nix similarity index 100% rename from overlays/pystray/build.nix rename to nix/overlays/pystray/build.nix diff --git a/overlays/pystray/default.nix b/nix/overlays/pystray/default.nix similarity index 100% rename from overlays/pystray/default.nix rename to nix/overlays/pystray/default.nix diff --git a/topos-service.nix b/nix/services/topos-service.nix similarity index 100% rename from topos-service.nix rename to nix/services/topos-service.nix diff --git a/overlays/tkinter/default.nix b/overlays/tkinter/default.nix deleted file mode 100644 index a473a2f..0000000 --- a/overlays/tkinter/default.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ lib -, stdenv -, buildPythonPackage -, python -, isPyPy -}: - -buildPythonPackage { - pname = "tkinter"; - version = python.version; - format = "other"; - - disabled = isPyPy; - - installPhase = - '' - # Move the tkinter module - mkdir -p $out/${python.sitePackages} - mv lib/${python.libPrefix}/lib-dynload/_tkinter* $out/${python.sitePackages}/ - '' - + lib.optionalString (!stdenv.isDarwin) '' - # Update the rpath to point to python without x11Support - old_rpath=$(patchelf --print-rpath $out/${python.sitePackages}/_tkinter*) - new_rpath=$(sed "s#${python}#${python}#g" <<< "$old_rpath" ) - patchelf --set-rpath $new_rpath $out/${python.sitePackages}/_tkinter* - ''; - - meta = python.meta // { - description = "The standard Python interface to the Tcl/Tk GUI toolkit"; - longDescription = '' - The tkinter package ("Tk interface") is the standard Python interface to - the Tcl/Tk GUI toolkit. Both Tk and tkinter are available on most Unix - platforms, including macOS, as well as on Windows systems. - ''; - }; -}