Files
puppy-tracker/flake.nix
T
Alexander Heldt 93d6ea27a7 Disable the sleep boundary that repeats the last one
While asleep, tapping "Sleep start" again can only produce a zero-length
sleep window, and likewise "Sleep end" while awake — so renderActionHints
now disables that button outright instead of merely dimming it, with a
title explaining why ("Already asleep" / "Already awake"). Every other
action stays clickable, and a genuinely missed boundary is still fixable
from the event log, which accepts any time. With no sleep history yet,
either boundary remains a valid first event.

Also adds nodejs to the dev shell for `node --check` on src/*.js.
2026-08-18 18:35:14 +00:00

88 lines
3.0 KiB
Nix

{
description = "Puppy Tracker — offline-first puppy tracking app with server-side sync.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
let
mkStatic = pkgs:
pkgs.stdenvNoCC.mkDerivation {
pname = "puppy-tracker-static";
version = "0.2.0";
src = ./src;
dontConfigure = true;
dontBuild = true;
installPhase = ''
mkdir -p $out/share/puppy-tracker
cp -r ./* $out/share/puppy-tracker/
'';
};
mkServer = pkgs:
pkgs.buildGoModule {
pname = "puppy-tracker-server";
version = "0.2.0";
src = ./server;
vendorHash = "sha256-J1lYhwbaRh2PeAh3SzyB9WgUZa1gCNXBWdaJ5isUedA=";
# Pure-Go build for a tiny static binary.
env.CGO_ENABLED = "0";
ldflags = [ "-s" "-w" ];
# The binary built from `module puppy-tracker` is `puppy-tracker`,
# rename so the executable name reflects its role.
postInstall = ''
mv $out/bin/puppy-tracker $out/bin/puppy-tracker-server
'';
meta.mainProgram = "puppy-tracker-server";
};
in
{
nixosModules.default = import ./module.nix self;
nixosModules.puppy-tracker = self.nixosModules.default;
}
//
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
static = mkStatic pkgs;
server = mkServer pkgs;
in
{
packages.static = static;
packages.server = server;
# `default` bundles both so `nix build` produces a runnable directory.
packages.default = pkgs.symlinkJoin {
name = "puppy-tracker";
paths = [ server static ];
};
devShells.default = pkgs.mkShell {
# nodejs is here for `node --check` on src/*.js — the frontend has no
# build step, so this is a syntax-check tool, not a dependency.
packages = [ pkgs.go pkgs.python3 pkgs.nodejs ];
shellHook = ''
echo "puppy-tracker dev shell"
echo " cd server && go run . -static ../src -data /tmp/puppy-events.json"
'';
};
# `nix run` → start the server, serving the bundled static files,
# storing data in $XDG_DATA_HOME/puppy-tracker/events.json.
apps.default = {
type = "app";
program = toString (pkgs.writeShellScript "puppy-tracker-run" ''
data_dir="''${XDG_DATA_HOME:-$HOME/.local/share}/puppy-tracker"
mkdir -p "$data_dir"
exec ${server}/bin/puppy-tracker-server \
-addr "''${PUPPY_ADDR:-:8080}" \
-static ${static}/share/puppy-tracker \
-data "$data_dir/puppy.db"
'');
meta.description = "Run puppy-tracker locally (data in $XDG_DATA_HOME/puppy-tracker)";
};
}
);
}