Skip to content

Commit 3b7aafc

Browse files
committed
Update README with new instructions.
1 parent 837bd49 commit 3b7aafc

File tree

1 file changed

+27
-94
lines changed

1 file changed

+27
-94
lines changed

README.md

+27-94
Original file line numberDiff line numberDiff line change
@@ -8,117 +8,47 @@ A simple, maybe not so simple clock replacement for the office of ACM@UIC.
88
* CTA Bus and Train Arrival Times
99
* Weather from DarkSky
1010

11-
## Using with docker
11+
# Building and deployment
1212

13-
1. `docker` and `docker-compose` should be installed.
14-
2. Download just the `docker-compose.yaml` file or clone the repository.
15-
3. Create a `.env` file based on `.env.example`.
16-
4. Run `docker-compose up -d` (Use `docker-compose up -d --build` instead to include local changes).
13+
This project is built and deployed with the Nix package manager. The NPM
14+
application can be built as follows:
1715

18-
To use `docker` without `docker compose`, run:
16+
```sh
17+
nix build .#
1918
```
20-
docker run -d -p 8080:8080 -e HTTPS="false" -e KEY="/root/ssl/ssl.key" -e CERT="/root/ssl/ssl.crt" -e PORT="8080" -e CTA_TRAIN_API_KEY="" -e CTA_BUS_API_KEY="" -e METRA_TRAIN_ID="" -e METRA_TRAIN_SECRET="" -e DARK_SKY_API_KEY="" -e COLORS="303030 01579B 006064 304FFE 004D40" -e BUS_STOPS="6700 6627 307 332 4640 14487 6347 206" -e TRAIN_STATIONS="40350" -e WEATHER_LAT_LONG="37.8267,-122.4233" -e UNITS="both" bmiddha/simple-js-clock
21-
```
2219

23-
## Installation
20+
This will produce a symlink called "result" in your local directory. The program
21+
can be run as follows:
2422

25-
These steps seem to require python2, which does not ship with most linux distributions and is sunset. Therefore, it is recommended to run this app through docker instead (though of course, vulnerability will still exist - they will just be constrained to the container).
26-
1. Clone the repository.
27-
2. Navigate to the repository directory.
28-
3. Create a `.env` file based on `.env.example`.
29-
4. Run `npm install` to install dependencies.
30-
31-
## How to use
32-
33-
1. Run `npm run start` to start the npm server or `npm run watch` to watch for changes.
34-
2. Navigate the browser to `locahost:8080` or the port specified in the `.env` config.
35-
36-
## Offline Mode
37-
38-
Offline mode will disable api requests to the server leaving only the clock running. It can be activated by going to `/offline` path.
39-
40-
## Demo Mode
41-
Demo mode works like offline mode but displays demo information instead of real data from apis. It can be activated by going to `/demo` path.
42-
43-
## Configuration
44-
To override the default config, you can use the URL GET parameters or by pressing `c` to open the config options.
45-
46-
# Deployment on a Raspberry PI
47-
48-
## Step 0: Install Packages
49-
```
50-
sudo apt update && sudo apt upgrade -y
51-
sudo apt install --no-install-recommends -y chromium-browser xserver-xorg x11-xserver-utils xinit
23+
```sh
24+
./result/bin/simple-ts-clock
5225
```
5326

54-
## Step 1: Enable auto-login
55-
Use the `raspi-config` tool to enable auto-login to the console.
56-
`sudo raspi-config` => Boot Options => Desktop / CLI => Console Autologin
27+
## Deployment
5728

58-
## Step 2: Set console orientation
59-
Edit the file `/boot/config.txt`
60-
Add the following option:
61-
```
62-
display_rotate=3
63-
```
29+
To deploy to ACM's clock machine, simply run
6430

65-
```
66-
display_rotate=0 Normal
67-
display_rotate=1 90 degrees
68-
display_rotate=2 180 degrees
69-
display_rotate=3 270 degrees
31+
```sh
32+
./deploy
7033
```
7134

72-
## Step 4: `.xinitrc` file
35+
This repo is set to poll and auto upgrade the ACM clock machine every day
36+
automatically from the contents of this repo.
7337

74-
`/home/pi/.xinitrc`
75-
```
76-
#!/bin/sh
77-
xset -dpms
78-
xset s off
79-
xset s noblank
80-
81-
xrandr --output default --rotate left
38+
To deploy outside ACM, first use [agenix](https://github.com/ryantm/agenix) to
39+
encrypt an env file containing the secrets (based on .env.example) replace the
40+
current `enc.env` file. You can encrypt your file to the SSH host key of the
41+
target machine. The `enc.env` file in the repo will decrypt on ACM's clock
42+
machine.
8243

83-
setxkbmap -option "terminate:ctrl_alt_bksp"
44+
Then, edit the system configuration at `nix/system.nix` to your liking and
45+
deploy:
8446

85-
unclutter &
86-
chromium-browser http://server:8080 --window-size=1080,1920 --start-fullscreen --kiosk --incognito --noerrdialogs --disable-translate --no-first-run --fast --fast-start --disable-infobars --disable-features=TranslateUI --disk-cache-dir=/dev/null
8747
```
88-
Replace `http://server:8080` with nodejs server.
89-
90-
## Reboot
91-
92-
# Deployment on NixOS
93-
94-
## Step 0: Provision machine
95-
96-
This project follows a standard NixOS deployment process. Utilize the [`nixos/configuration.nix`](./nixos/configuration.nix) file to deploy a standard NixOS installation on a given machine. This sets up [cage](https://github.com/Hjdskes/cage) which is a Wayland kiosk application. The configuration is setup to launch Google Chrome and visit a local dockerized instance of the project.
97-
98-
## Step 1: Build the application
99-
100-
Build the application locally.
101-
102-
```bash
103-
docker build -t acm-uic/simple-ts-clock:latest .
104-
```
105-
106-
## Step 2: Setup environment secrets
107-
108-
Make a copy of the example `.env` file and populate the variables with the ones used for your setup.
109-
110-
```bash
111-
cp .env.example .env
112-
nvim .env
48+
nixos-rebuild switch --flake .#acmclock --build-host root@yourmachine --target-host root@yourmachine
11349
```
50+
Make sure to change `system.autoUpgrade` to point to your repo, or disable it.
11451

115-
## Step 3: Run Docker-compose
116-
117-
Run the application using docker-compose.
118-
119-
```bash
120-
docker-compose up -d
121-
```
12252

12353
# Authors
12454

@@ -127,3 +57,6 @@ This project was originally a rewrite of [sudoclock](https://github.com/acm-uic/
12757
The project has since been rewritten mostly in the [simple-js-clock](https://github.com/bmiddha/simple-js-clock) repo by [bmiddha](https://github.com/bmiddha) and other contributors.
12858

12959
In January 2023, the simple-js-clock repo was forked to continue development here.
60+
61+
In February 2025, @SohamG and @clee231 updated the app to Node 20 and added the
62+
Nix-based build and deployment.

0 commit comments

Comments
 (0)