Skip to content

Instantly share code, notes, and snippets.

@ninioArtillero
Created April 15, 2024 22:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ninioArtillero/ac5aa10125135e10809098ba0b079dc4 to your computer and use it in GitHub Desktop.
Save ninioArtillero/ac5aa10125135e10809098ba0b079dc4 to your computer and use it in GitHub Desktop.
A simple reproducible script for launching a ghci session with Euterpea and HSoM libraries loaded using Nix
#! /usr/bin/env nix-shell
#! nix-shell --pure -i ghci
#! nix-shell -p "haskellPackages.ghcWithPackages (pkgs: [ pkgs.Euterpea pkgs.HSoM ])"
#! nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/380be19fbd2d9079f677978361792cb25e8a3635.tar.gz
{-
This script loads an interactive environment for music eDSL Euterpea,
with all modules from the Haskell Scholl of Music (HSoM) library exposed.
IMPORTANT: Only first call will take a long time to load
as long as the nix store is not garbage collected, as when using
`nix-collect-garbage` or `nix-store --gc`.
### References ###
Reproducible scripts:
https://nix.dev/tutorials/first-steps/reproducible-scripts.html
nixpkgs pin:
https://releases.nixos.org/nixos/22.05/nixos-22.05.4694.380be19fbd2d
nixos-22.05 release nixos-22.05.4694.380be19fbd2d
Released on 2023-08-01 15:05:53
from Git commit 380be19fbd2d9079f677978361792cb25e8a3635 via Hydra evaluation 1798090.
-}
import Euterpea
import HSoM
help :: IO ()
help = putStrLn $ unlines [
"\nEuterpea and its book companion library, HSoM, are loaded in this ghci session inside a custom nix-shell.",
"Note that HSoM funcions are called using their full qualified name, as in",
"\n> play $ HSoM.Examples.Interlude.childSong6\n",
"IMPORTANT: Only first call will take a long time to load",
"as long as the nix store is not garbage collected, like when using",
"`nix-collect-garbage` or `nix-store --gc`.",
"\nTo exit, quit ghci as usual using\n",
"> :q"
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment