diff --git a/flake.nix b/flake.nix index e06aedd..b83b587 100644 --- a/flake.nix +++ b/flake.nix @@ -219,9 +219,17 @@ }; in testPkgs.testers.runNixOSTest ./tests/run/synapse.nix; - open-webui-oci-test = pkgs.testers.runNixOSTest ./tests/run/open-webui-oci.nix; - # librechat-oci-test = pkgs.testers.runNixOSTest ./tests/run/librechat-oci.nix; # FIXME: unable to copy from source docker://quay.io/mongo:7.0 + + # NOTE: disabled for now since the test takes too long to execute + # open-webui-oci-test = + # let + # testPkgs = import nixpkgs { + # inherit system; + # }; + # in + # testPkgs.testers.runNixOSTest ./tests/run/open-webui-oci.nix; } + ); hydraJobs = { diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index 89d0f42..60c31b9 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -14,7 +14,6 @@ i2pd = import ./i2pd; jellyfin = import ./jellyfin; jirafeau = import ./jirafeau; - librechat-oci = import ./librechat-oci; mailserver = import ./mailserver; matrix-synapse = import ./matrix-synapse; maubot = import ./maubot; diff --git a/modules/nixos/librechat-oci/default.nix b/modules/nixos/librechat-oci/default.nix deleted file mode 100644 index afbdd2b..0000000 --- a/modules/nixos/librechat-oci/default.nix +++ /dev/null @@ -1,247 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: - -let - cfg = config.services.librechat-oci; - - image = pkgs.dockerTools.pullImage { - imageName = "ghcr.io/danny-avila/librechat"; - imageDigest = "sha256:a46254938507971e0d4f7ed3f9d116bd9b118f4810b5b75eb716baf575645068"; - hash = "sha256-zevUN6vrs3hymwCGFmk/YXlUzYjN37H+EO5aLxYchyc="; - finalImageName = "ghcr.io/danny-avila/librechat"; - finalImageTag = "v0.8.5"; - }; - - defaultEnv = { - HOST = "0.0.0.0"; - PORT = "3080"; - NO_INDEX = "true"; - DEBUG_LOGGING = "false"; - CONSOLE_JSON = "false"; - ALLOW_REGISTRATION = "true"; - ALLOW_EMAIL_LOGIN = "true"; - SEARCH = "true"; - MEILI_NO_ANALYTICS = "true"; - }; - - inherit (lib) - literalExpression - mkEnableOption - mkIf - mkOption - mkOverride - types - ; -in -{ - options.services.librechat-oci = { - enable = mkEnableOption "LibreChat container with Podman."; - image = mkOption { - type = types.package; - default = image; - description = "The Docker image to use (`pkgs.dockerTools.pullImage`)."; - }; - externalUrl = mkOption { - type = types.nullOr types.str; - default = null; - example = literalExpression "http://${config.networking.domain}"; - description = "Public URL to configure for LibreChat."; - }; - port = mkOption { - type = types.port; - default = 3080; - description = "Which port the LibreChat server listens to."; - }; - environment = mkOption { - default = { }; - type = types.attrsOf types.str; - description = '' - Extra environment variables for LibreChat. - For more details see - ''; - }; - environmentFile = mkOption { - description = "Environment file to be passed to the LibreChat container."; - type = types.nullOr types.path; - default = null; - example = "config.sops.templates.librechat-env.path"; - }; - }; - - config = mkIf cfg.enable { - virtualisation.podman = { - enable = true; - autoPrune.enable = true; - dockerCompat = true; - }; - - networking.firewall.interfaces = - let - matchAll = if !config.networking.nftables.enable then "podman+" else "podman*"; - in - { - "${matchAll}".allowedUDPPorts = [ 53 ]; - }; - - virtualisation.oci-containers.backend = "podman"; - - virtualisation.oci-containers.containers."librechat-mongodb" = { - image = "mongo:7.0"; - environment = { - MONGO_INITDB_ROOT_USERNAME = "root"; - MONGO_INITDB_ROOT_PASSWORD = "librechat"; - MONGO_INITDB_DATABASE = "LibreChat"; - }; - volumes = [ - "librechat_mongodb_data:/data/db:rw" - ]; - log-driver = "journald"; - extraOptions = [ - "--network=host" - ]; - }; - - virtualisation.oci-containers.containers.librechat = { - image = toString cfg.image; - environment = - defaultEnv - // { - MONGO_URI = "mongodb://root:librechat@localhost:27017/LibreChat?authSource=admin"; - } - // cfg.environment; - volumes = [ - "librechat_data:/app/client/data:rw" - "librechat_images:/app/client/public/images:rw" - "librechat_uploads:/app/api/server/files/uploads:rw" - "librechat_logs:/app/logs:rw" - ]; - ports = [ - "${toString cfg.port}:${toString cfg.port}" - ]; - log-driver = "journald"; - extraOptions = [ - "--network=host" - ]; - }; - - systemd.services."podman-librechat-mongodb" = { - serviceConfig = { - Restart = mkOverride 90 "always"; - }; - after = [ - "podman-volume-librechat_mongodb_data.service" - ]; - requires = [ - "podman-volume-librechat_mongodb_data.service" - ]; - partOf = [ - "podman-compose-librechat-root.target" - ]; - wantedBy = [ - "podman-compose-librechat-root.target" - ]; - }; - - systemd.services."podman-librechat" = { - serviceConfig = { - Restart = mkOverride 90 "always"; - }; - after = [ - "podman-volume-librechat_data.service" - "podman-volume-librechat_images.service" - "podman-volume-librechat_uploads.service" - "podman-volume-librechat_logs.service" - "podman-librechat-mongodb.service" - ]; - requires = [ - "podman-volume-librechat_data.service" - "podman-volume-librechat_images.service" - "podman-volume-librechat_uploads.service" - "podman-volume-librechat_logs.service" - "podman-librechat-mongodb.service" - ]; - partOf = [ - "podman-compose-librechat-root.target" - ]; - wantedBy = [ - "podman-compose-librechat-root.target" - ]; - }; - - systemd.services."podman-volume-librechat_data" = { - path = [ pkgs.podman ]; - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = true; - }; - script = '' - podman volume inspect librechat_data || podman volume create librechat_data - ''; - partOf = [ "podman-compose-librechat-root.target" ]; - wantedBy = [ "podman-compose-librechat-root.target" ]; - }; - - systemd.services."podman-volume-librechat_images" = { - path = [ pkgs.podman ]; - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = true; - }; - script = '' - podman volume inspect librechat_images || podman volume create librechat_images - ''; - partOf = [ "podman-compose-librechat-root.target" ]; - wantedBy = [ "podman-compose-librechat-root.target" ]; - }; - - systemd.services."podman-volume-librechat_uploads" = { - path = [ pkgs.podman ]; - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = true; - }; - script = '' - podman volume inspect librechat_uploads || podman volume create librechat_uploads - ''; - partOf = [ "podman-compose-librechat-root.target" ]; - wantedBy = [ "podman-compose-librechat-root.target" ]; - }; - - systemd.services."podman-volume-librechat_logs" = { - path = [ pkgs.podman ]; - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = true; - }; - script = '' - podman volume inspect librechat_logs || podman volume create librechat_logs - ''; - partOf = [ "podman-compose-librechat-root.target" ]; - wantedBy = [ "podman-compose-librechat-root.target" ]; - }; - - systemd.services."podman-volume-librechat_mongodb_data" = { - path = [ pkgs.podman ]; - serviceConfig = { - Type = "oneshot"; - RemainAfterExit = true; - }; - script = '' - podman volume inspect librechat_mongodb_data || podman volume create librechat_mongodb_data - ''; - partOf = [ "podman-compose-librechat-root.target" ]; - wantedBy = [ "podman-compose-librechat-root.target" ]; - }; - - systemd.targets."podman-compose-librechat-root" = { - unitConfig = { - Description = "Root target generated by compose2nix."; - }; - wantedBy = [ "multi-user.target" ]; - }; - }; -} diff --git a/modules/nixos/mcpo/default.nix b/modules/nixos/mcpo/default.nix index 86e943f..89e0e29 100644 --- a/modules/nixos/mcpo/default.nix +++ b/modules/nixos/mcpo/default.nix @@ -28,12 +28,6 @@ in default = null; }; - port = mkOption { - type = types.port; - default = 8000; - description = "Port on which the mcpo service should listen."; - }; - user = mkOption { type = types.str; description = "The user the mcpo service will run as."; @@ -106,7 +100,7 @@ in after = [ "network.target" ]; wantedBy = [ "multi-user.target" ]; serviceConfig = { - ExecStart = "${getExe cfg.package} --port ${cfg.port} --config ${configFile}"; + ExecStart = "${getExe cfg.package} --config ${configFile}"; Restart = "on-failure"; User = cfg.user; Group = cfg.group; diff --git a/tests/run/librechat-oci.nix b/tests/run/librechat-oci.nix deleted file mode 100644 index 70aabed..0000000 --- a/tests/run/librechat-oci.nix +++ /dev/null @@ -1,38 +0,0 @@ -let - port = 3080; -in -{ - name = "librechat-oci-test"; - - nodes.machine = - { ... }: - { - imports = [ - ../../modules/nixos/librechat-oci - ]; - - config = { - virtualisation.diskSize = 32768; - virtualisation.memorySize = 8192; - - services.librechat-oci = { - enable = true; - inherit port; - }; - - networking.firewall.enable = false; - }; - }; - - testScript = '' - start_all() - - machine.wait_for_unit("default.target") - - machine.wait_for_unit("podman-librechat-mongodb.service") - machine.wait_for_unit("podman-librechat.service") - machine.wait_for_open_port(${toString port}) - - machine.succeed("curl --fail --retry 10 --retry-delay 5 --retry-connrefused http://localhost:${toString port}/") - ''; -}