Run a script automatically on sunrise and sunset
Find a file
2024-08-16 14:38:11 -07:00
app refactor: complete modularization 2024-08-01 20:15:32 -07:00
.envrc chore: add .envrc for automatic dev env loading 2024-08-16 14:37:56 -07:00
.gitignore chore: add .envrc for automatic dev env loading 2024-08-16 14:37:56 -07:00
CHANGELOG.md initial commit 2024-07-13 19:50:43 -07:00
flake.lock deps(dev): switch to nix 2024-08-16 06:28:52 -07:00
flake.nix deps: add all required dependencies to flake 2024-08-16 14:38:11 -07:00
LICENSE initial commit 2024-07-13 19:50:43 -07:00
README.md docs: add development instructions 2024-08-16 06:51:01 -07:00
suntheme.cabal deps(dev): switch to nix 2024-08-16 06:28:52 -07:00

Suntheme

runs a script on sunrise and sunset, written in pure haskell.

You may be wondering how a program written in Haskell, the purely functional programming language, could possibly act on the real world by running a so-called "script".

It's simple. We take in the entire World as an input to a pure function, the IO Monad. It then maps the original World to the changed World, with our desired IO actions carefully applied.

From the second perspective, an IO action transforms the whole world. IO actions are actually pure, because they receive a unique world as an argument and then return the changed world.

See this for more information.

Hacking on suntheme

It's trivially easy to get started with suntheme development thanks to Nix, the purely functional package manager. Naturally, we leverage it as our primary package manager, for both Hackage packages and development tools like language servers and the like.

First, install Nix through your preferred avenue. If unsure, we recommend the Determinate Nix Installer. Make sure flakes and nix-command are enabled (the Determinate Installer will enable them by default).

Once you have nix, simply type

nix develop

Say yes to any prompts asking you to allow substituters or trust public keys. Nix will fetch all of the required packages, such as GHC and Hackage dependencies. Additionally, you will have access to hlint and the haskell-language-server.

To create a build, type

nix build

A binary will be produced in result/bin/suntheme.

To make suntheme available in the shell without outputting to result, use

nix shell

This will build a binary just like nix build but add it temporarily to the PATH, so you can just type suntheme.

To build and run suntheme immediately without adding it to the PATH, use

nix run

This will build a binary just like nix shell but immediately execute it.