diff --git a/flake.lock b/flake.lock index 2041716..3992719 100644 --- a/flake.lock +++ b/flake.lock @@ -44,25 +44,6 @@ "type": "github" } }, - "calorie-tracker": { - "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" - }, - "locked": { - "lastModified": 1771341818, - "narHash": "sha256-rR3AWsRiBBXWm4ZabCaAjqwAGPrXEzPzRnbHnoIAdQw=", - "owner": "thegeneralist01", - "repo": "calorie-tracker", - "rev": "5ef47d51c66a9156ff30cc59472e2d5cd6c87c4b", - "type": "github" - }, - "original": { - "owner": "thegeneralist01", - "repo": "calorie-tracker", - "type": "github" - } - }, "fenix": { "inputs": { "nixpkgs": [ @@ -170,28 +151,10 @@ "type": "github" } }, - "flake-utils_4": { - "inputs": { - "systems": "systems_5" - }, - "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" - } - }, "ghostty": { "inputs": { "flake-compat": "flake-compat", - "flake-utils": "flake-utils_2", + "flake-utils": "flake-utils", "nixpkgs-stable": "nixpkgs-stable", "nixpkgs-unstable": "nixpkgs-unstable", "zig": "zig", @@ -214,7 +177,7 @@ "helium": { "inputs": { "flake-compat": "flake-compat_2", - "flake-utils": "flake-utils_3", + "flake-utils": "flake-utils_2", "nixpkgs": [ "nixpkgs" ] @@ -326,11 +289,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1771008912, - "narHash": "sha256-gf2AmWVTs8lEq7z/3ZAsgnZDhWIckkb+ZnAo5RzSxJg=", + "lastModified": 1755186698, + "narHash": "sha256-wNO3+Ks2jZJ4nTHMuks+cxAiVBGNuEBXsT29Bz6HASo=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "a82ccc39b39b621151d6732718e3e250109076fa", + "rev": "fbcf476f790d8a217c3eab4e12033dc4a0f6d23c", "type": "github" }, "original": { @@ -373,22 +336,6 @@ } }, "nixpkgs_2": { - "locked": { - "lastModified": 1755186698, - "narHash": "sha256-wNO3+Ks2jZJ4nTHMuks+cxAiVBGNuEBXsT29Bz6HASo=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "fbcf476f790d8a217c3eab4e12033dc4a0f6d23c", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_3": { "locked": { "lastModified": 1769789167, "narHash": "sha256-kKB3bqYJU5nzYeIROI82Ef9VtTbu4uA3YydSk/Bioa8=", @@ -406,8 +353,8 @@ }, "readlater-bot": { "inputs": { - "flake-utils": "flake-utils_4", - "nixpkgs": "nixpkgs_3" + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_2" }, "locked": { "lastModified": 1772524468, @@ -426,7 +373,6 @@ "root": { "inputs": { "agenix": "agenix", - "calorie-tracker": "calorie-tracker", "fenix": "fenix", "ghostty": "ghostty", "helium": "helium", @@ -435,7 +381,7 @@ "homebrew-core": "homebrew-core", "nix-darwin": "nix-darwin", "nix-homebrew": "nix-homebrew", - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs", "readlater-bot": "readlater-bot" } }, @@ -516,21 +462,6 @@ "type": "github" } }, - "systems_5": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, "zig": { "inputs": { "flake-compat": [ diff --git a/flake.nix b/flake.nix index a30bc26..4a23c87 100644 --- a/flake.nix +++ b/flake.nix @@ -51,10 +51,6 @@ readlater-bot = { url = "github:thegeneralist01/bookkeeper"; }; - - calorie-tracker = { - url = "github:thegeneralist01/calorie-tracker"; - }; }; outputs = diff --git a/hosts/thegeneralist-central/calorie-tracker/default.nix b/hosts/thegeneralist-central/calorie-tracker/default.nix deleted file mode 100644 index 9864eb2..0000000 --- a/hosts/thegeneralist-central/calorie-tracker/default.nix +++ /dev/null @@ -1,99 +0,0 @@ -{ pkgs, inputs, ... }: -let - sourceDir = "${inputs.calorie-tracker}"; - appDir = "/var/lib/calorie-tracker/app"; - dataDir = "/var/lib/calorie-tracker"; - port = 4322; - - acmeDomain = "thegeneralist01.com"; - domain = "calorie.${acmeDomain}"; - - ssl = { - forceSSL = true; - quic = true; - useACMEHost = acmeDomain; - }; -in -{ - systemd.services.calorie-tracker = { - description = "Calorie Tracker"; - wantedBy = [ "multi-user.target" ]; - wants = [ "network-online.target" ]; - after = [ "network-online.target" ]; - - environment = { - NODE_ENV = "production"; - HOST = "127.0.0.1"; - PORT = toString port; - DATABASE_URL = "file:${dataDir}/dev.db"; - PRISMA_ENGINES_CHECKSUM_IGNORE_MISSING = "1"; - - PRISMA_FMT_BINARY = "${pkgs.prisma-engines}/bin/prisma-fmt"; - PRISMA_SCHEMA_ENGINE_BINARY = "${pkgs.prisma-engines}/bin/schema-engine"; - PRISMA_QUERY_ENGINE_BINARY = "${pkgs.prisma-engines}/bin/query-engine"; - PRISMA_QUERY_ENGINE_LIBRARY = "${pkgs.prisma-engines}/lib/libquery_engine.node"; - }; - - path = with pkgs; [ - bash - coreutils - gnused - nodejs_22 - prisma - prisma-engines - rsync - sqlite - ]; - - preStart = '' - mkdir -p ${appDir} - rsync -a --delete --exclude ".git" --exclude "node_modules" --exclude "dist" --exclude ".astro" ${sourceDir}/ ${appDir}/ - chmod -R u+rwX ${appDir} - - cd ${appDir} - - if [ ! -f .env ]; then - cp .env.example .env - fi - - sed -i 's#^DATABASE_URL=.*#DATABASE_URL="file:${dataDir}/dev.db"#' .env - - if [ ! -d node_modules ] || [ ! -d node_modules/@astrojs/node ] || [ ! -d node_modules/server-destroy ] || [ ! -d node_modules/@vite-pwa/astro ] || [ ! -d node_modules/@astrojs/check ]; then - npm ci --include=dev --no-fund --no-audit - fi - - sqlite3 "${dataDir}/dev.db" < ${./schema.sql} - - npm run prisma:generate - rm -rf dist - npm run build - ''; - - serviceConfig = { - Type = "simple"; - User = "thegeneralist"; - Group = "users"; - StateDirectory = "calorie-tracker"; - StateDirectoryMode = "0750"; - # Keep working dir on the guaranteed StateDirectory path so preStart can - # create ${appDir} on first boot/deploy before ExecStart runs. - WorkingDirectory = dataDir; - ExecStart = "${pkgs.nodejs_22}/bin/node ${appDir}/dist/server/entry.mjs"; - KillMode = "mixed"; - Restart = "always"; - RestartSec = 5; - }; - }; - - # services.nginx.virtualHosts.${domain} = ssl // { - # locations."/" = { - # proxyPass = "http://127.0.0.1:${toString port}"; - # proxyWebsockets = true; - # recommendedProxySettings = true; - # extraConfig = '' - # proxy_read_timeout 300s; - # proxy_send_timeout 300s; - # ''; - # }; - # }; -} diff --git a/hosts/thegeneralist-central/calorie-tracker/schema.sql b/hosts/thegeneralist-central/calorie-tracker/schema.sql deleted file mode 100644 index 7c2c1a8..0000000 --- a/hosts/thegeneralist-central/calorie-tracker/schema.sql +++ /dev/null @@ -1,180 +0,0 @@ -PRAGMA foreign_keys = ON; - -CREATE TABLE IF NOT EXISTS "User" ( - "id" TEXT NOT NULL PRIMARY KEY, - "username" TEXT NOT NULL UNIQUE, - "email" TEXT NOT NULL UNIQUE, - "passwordHash" TEXT NOT NULL, - "isAdmin" INTEGER NOT NULL DEFAULT 0, - "emailVerifiedAt" DATETIME, - "locale" TEXT NOT NULL DEFAULT 'en', - "dayCutoffMinutes" INTEGER NOT NULL DEFAULT 0, - "weekStartsOn" INTEGER NOT NULL DEFAULT 1, - "scheduledDeletionAt" DATETIME, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP -); - -CREATE TABLE IF NOT EXISTS "Session" ( - "id" TEXT NOT NULL PRIMARY KEY, - "tokenHash" TEXT NOT NULL UNIQUE, - "rememberDevice" INTEGER NOT NULL DEFAULT 1, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "lastActiveAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "expiresAt" DATETIME NOT NULL, - "recentAuthAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "userId" TEXT NOT NULL, - FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE -); -CREATE INDEX IF NOT EXISTS "Session_userId_idx" ON "Session"("userId"); - -CREATE TABLE IF NOT EXISTS "Goal" ( - "id" TEXT NOT NULL PRIMARY KEY, - "userId" TEXT NOT NULL UNIQUE, - "type" TEXT NOT NULL DEFAULT 'MAINTAIN_WEIGHT', - "calorieFormula" TEXT NOT NULL DEFAULT 'MIFFLIN_ST_JEOR', - "dailyCalorieTarget" INTEGER, - "proteinGramsTarget" INTEGER, - "carbsGramsTarget" INTEGER, - "fatGramsTarget" INTEGER, - "adaptiveSuggestions" INTEGER NOT NULL DEFAULT 1, - "requiresApproval" INTEGER NOT NULL DEFAULT 1, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE -); - -CREATE TABLE IF NOT EXISTS "UserSettings" ( - "id" TEXT NOT NULL PRIMARY KEY, - "userId" TEXT NOT NULL UNIQUE, - "waterGoalLiters" REAL NOT NULL DEFAULT 2, - "useMetricDistance" INTEGER NOT NULL DEFAULT 1, - "precisionMode" TEXT NOT NULL DEFAULT 'BASIC', - "weekStartConfigurable" INTEGER NOT NULL DEFAULT 1, - "remindersEnabled" INTEGER NOT NULL DEFAULT 1, - "reminderQuietHoursStart" TEXT DEFAULT '22:00', - "reminderQuietHoursEnd" TEXT DEFAULT '07:00', - "pwaInstallPromptDismissed" INTEGER NOT NULL DEFAULT 0, - "pwaUpdateToastEnabled" INTEGER NOT NULL DEFAULT 1, - "aiPhotoEstimationEnabled" INTEGER NOT NULL DEFAULT 0, - "aiPhotoConsentAt" DATETIME, - "aiPhotoConsentPolicy" TEXT, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE -); - -CREATE TABLE IF NOT EXISTS "Product" ( - "id" TEXT NOT NULL PRIMARY KEY, - "ownerUserId" TEXT, - "name" TEXT NOT NULL, - "brand" TEXT, - "barcode" TEXT, - "qrCode" TEXT, - "region" TEXT, - "packageSizeLabel" TEXT, - "servingSizeLabel" TEXT, - "calories" REAL, - "protein" REAL, - "carbs" REAL, - "fat" REAL, - "source" TEXT NOT NULL DEFAULT 'MANUAL', - "isAiEstimated" INTEGER NOT NULL DEFAULT 0, - "isGlobal" INTEGER NOT NULL DEFAULT 0, - "publicationStatus" TEXT NOT NULL DEFAULT 'LOCAL_ONLY', - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "publishedAt" DATETIME, - FOREIGN KEY ("ownerUserId") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE -); -CREATE INDEX IF NOT EXISTS "Product_ownerUserId_idx" ON "Product"("ownerUserId"); -CREATE INDEX IF NOT EXISTS "Product_isGlobal_publicationStatus_idx" ON "Product"("isGlobal", "publicationStatus"); -CREATE INDEX IF NOT EXISTS "Product_barcode_brand_region_idx" ON "Product"("barcode", "brand", "region"); - -CREATE TABLE IF NOT EXISTS "ProductSubmission" ( - "id" TEXT NOT NULL PRIMARY KEY, - "productId" TEXT NOT NULL, - "submittedById" TEXT NOT NULL, - "reviewedById" TEXT, - "labelPhotoUrl" TEXT, - "status" TEXT NOT NULL DEFAULT 'PENDING', - "reason" TEXT, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "reviewedAt" DATETIME, - FOREIGN KEY ("productId") REFERENCES "Product"("id") ON DELETE CASCADE ON UPDATE CASCADE, - FOREIGN KEY ("submittedById") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE, - FOREIGN KEY ("reviewedById") REFERENCES "User"("id") ON DELETE SET NULL ON UPDATE CASCADE -); -CREATE INDEX IF NOT EXISTS "ProductSubmission_productId_status_idx" ON "ProductSubmission"("productId", "status"); - -CREATE TABLE IF NOT EXISTS "ProductContribution" ( - "id" TEXT NOT NULL PRIMARY KEY, - "productId" TEXT NOT NULL, - "contributorId" TEXT NOT NULL, - "payloadJson" TEXT NOT NULL, - "status" TEXT NOT NULL DEFAULT 'PENDING', - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - "reviewedAt" DATETIME, - "reviewedById" TEXT, - FOREIGN KEY ("productId") REFERENCES "Product"("id") ON DELETE CASCADE ON UPDATE CASCADE, - FOREIGN KEY ("contributorId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE -); -CREATE INDEX IF NOT EXISTS "ProductContribution_productId_status_idx" ON "ProductContribution"("productId", "status"); - -CREATE TABLE IF NOT EXISTS "ModerationAuditLog" ( - "id" TEXT NOT NULL PRIMARY KEY, - "actorUserId" TEXT NOT NULL, - "targetType" TEXT NOT NULL, - "targetId" TEXT NOT NULL, - "action" TEXT NOT NULL, - "reason" TEXT, - "beforeJson" TEXT, - "afterJson" TEXT, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - FOREIGN KEY ("actorUserId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE -); -CREATE INDEX IF NOT EXISTS "ModerationAuditLog_targetType_targetId_idx" ON "ModerationAuditLog"("targetType", "targetId"); - -CREATE TABLE IF NOT EXISTS "MealEntry" ( - "id" TEXT NOT NULL PRIMARY KEY, - "userId" TEXT NOT NULL, - "productId" TEXT, - "mealType" TEXT NOT NULL, - "consumedAt" DATETIME NOT NULL, - "quantityValue" REAL NOT NULL, - "quantityUnit" TEXT NOT NULL, - "calories" REAL NOT NULL, - "protein" REAL NOT NULL, - "carbs" REAL NOT NULL, - "fat" REAL NOT NULL, - "snapshotJson" TEXT NOT NULL, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE, - FOREIGN KEY ("productId") REFERENCES "Product"("id") ON DELETE SET NULL ON UPDATE CASCADE -); -CREATE INDEX IF NOT EXISTS "MealEntry_userId_consumedAt_idx" ON "MealEntry"("userId", "consumedAt"); - -CREATE TABLE IF NOT EXISTS "WaterEntry" ( - "id" TEXT NOT NULL PRIMARY KEY, - "userId" TEXT NOT NULL, - "amountMl" INTEGER NOT NULL, - "consumedAt" DATETIME NOT NULL, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE -); -CREATE INDEX IF NOT EXISTS "WaterEntry_userId_consumedAt_idx" ON "WaterEntry"("userId", "consumedAt"); - -CREATE TABLE IF NOT EXISTS "ActivityEntry" ( - "id" TEXT NOT NULL PRIMARY KEY, - "userId" TEXT NOT NULL, - "name" TEXT NOT NULL, - "method" TEXT NOT NULL, - "durationMinutes" INTEGER, - "distanceKm" REAL, - "intensity" REAL, - "caloriesBurned" REAL NOT NULL, - "startedAt" DATETIME NOT NULL, - "createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, - FOREIGN KEY ("userId") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE -); -CREATE INDEX IF NOT EXISTS "ActivityEntry_userId_startedAt_idx" ON "ActivityEntry"("userId", "startedAt"); diff --git a/hosts/thegeneralist-central/configuration.nix b/hosts/thegeneralist-central/configuration.nix index 789e56e..72512f8 100644 --- a/hosts/thegeneralist-central/configuration.nix +++ b/hosts/thegeneralist-central/configuration.nix @@ -17,7 +17,6 @@ ./cache ./archive ./forgejo - ./calorie-tracker ]; age.secrets.password.file = ./password.age; diff --git a/hosts/thegeneralist-central/hardware-configuration.nix b/hosts/thegeneralist-central/hardware-configuration.nix index 59d3951..070666c 100644 --- a/hosts/thegeneralist-central/hardware-configuration.nix +++ b/hosts/thegeneralist-central/hardware-configuration.nix @@ -35,14 +35,14 @@ } ]; - fileSystems."/mnt/usb" = { - device = "/dev/disk/by-label/TURTLEBAT"; - options = [ - "rw" - "noatime" - ]; - }; - + # fileSystems."/mnt/usb" = { + # device = "/dev/disk/by-label/TURTLEBAT"; + # options = [ + # "rw" + # "noatime" + # ]; + # }; + # boot.extraModprobeConfig = '' options usbcore autosuspend=-1 ''; diff --git a/hosts/thegeneralist-central/plex/default.nix b/hosts/thegeneralist-central/plex/default.nix index 883034e..a9fca15 100644 --- a/hosts/thegeneralist-central/plex/default.nix +++ b/hosts/thegeneralist-central/plex/default.nix @@ -8,14 +8,38 @@ let quic = true; useACMEHost = domain; }; + + plexDebUrl = "http://thegeneralist01.com/plexmediaserver_1.43.0.10492-121068a07_arm64.deb"; + plexDebSha256 = "1fkh09b46q70kicjprxf0v507idhg2jh3pk97nhbxj1jagkhgck2"; + plex = pkgs.stdenv.mkDerivation { + pname = "plexmediaserver"; + version = "1.43.0.10492-121068a07"; + + src = pkgs.fetchurl { + url = plexDebUrl; + sha256 = plexDebSha256; + }; + + nativeBuildInputs = [ pkgs.dpkg ]; + + unpackPhase = '' + runHook preUnpack + dpkg-deb -x $src . + runHook postUnpack + ''; + + installPhase = '' + runHook preInstall + mkdir -p $out + cp -r usr/* $out/ + runHook postInstall + ''; + }; in { - environment.systemPackages = with pkgs; [ - plex - ]; - services.plex = { enable = true; + package = plex; # openFirewall = true; }; diff --git a/hosts/thegeneralist-central/site.nix b/hosts/thegeneralist-central/site.nix index 83f9a6d..4e68e63 100644 --- a/hosts/thegeneralist-central/site.nix +++ b/hosts/thegeneralist-central/site.nix @@ -102,7 +102,6 @@ in "thegeneralist01.com" = "http://localhost:80"; "www.thegeneralist01.com" = "http://localhost:80"; "cache.thegeneralist01.com" = "http://localhost:80"; - "calorie.thegeneralist01.com" = "http://localhost:4322"; "git.thegeneralist01.com" = "http://localhost:3000"; }; default = "http_status:404"; diff --git a/modules/linux/helium.nix b/modules/linux/helium.nix deleted file mode 100644 index 388987b..0000000 --- a/modules/linux/helium.nix +++ /dev/null @@ -1,6 +0,0 @@ -{ inputs, pkgs, ... }: { - environment.systemPackages = [ - # inputs.helium.defaultPackage.${pkgs.system} - inputs.helium.packages.${pkgs.system}.default - ]; -} diff --git a/modules/linux/packages.nix b/modules/linux/packages.nix index 0b1f9b9..47b1be7 100644 --- a/modules/linux/packages.nix +++ b/modules/linux/packages.nix @@ -1,4 +1,4 @@ -{ pkgs, lib, config, ...}: let +{ inputs, pkgs, lib, config, ...}: let inherit (lib) attrValues; in { environment.systemPackages = attrValues { @@ -7,13 +7,15 @@ in { pwvucontrol wireplumber playerctl - ntfs3g - - obsidian - tor-browser; + ntfs3g; } ++ (if (!config.isServer) then (attrValues { inherit (pkgs) protonup-qt xsane - simple-scan; - }) else []); + simple-scan + + obsidian + tor-browser; + }) else []) ++ (if (!config.isServer) then [ + inputs.helium.packages.${pkgs.system}.default + ] else []); }