diff --git a/Main.hs b/Main.hs index 1549755..f3b76c0 100644 --- a/Main.hs +++ b/Main.hs @@ -113,7 +113,7 @@ ballRadius = 20 -- | Draw the ball in gloss ballPic :: Ball -> Picture -ballPic Ball { ballPos = (x, y) } = translate x y $ color white $ thickCircle (ballRadius / 2) ballRadius +ballPic Ball { ballPos = (x, y) } = translate x y $ color red $ thickCircle (ballRadius / 2) ballRadius -- | The type of internal state of the 'ballSim' data Ball = Ball diff --git a/README.md b/README.md index 231dbe2..d4bb8fb 100644 --- a/README.md +++ b/README.md @@ -25,14 +25,14 @@ There are also useful utilities for debugging and quickchecking. git clone https://github.com/turion/essence-of-live-coding-tutorial cd essence-of-live-coding-tutorial ``` -2. Either install [`nix`](https://nixos.org/download.html) and launch a `nix-shell`, +2. Either install [`nix`](https://nixos.org/download.html) and launch `nix develop`, or install the [external dependencies listed below](#external-dependencies) 3. `cabal update` (A new version of the library was released recently) 4. Sanity check: Launch `cabal repl` and close it again. This should succeed without errors. 5. Open `Main.hs` in an editor. -6. Run `ghcid` from the console. +6. Run `ghcid` from the console (the same where you did `nix develop` before). You should now be seeing a window containing a solid circle (a ball). If you click anywhere in the window, the ball will start to move in that direction. @@ -45,23 +45,23 @@ it will automatically reload. (See [below](#non-linux-systems).) * A standard Haskell development environment, including `cabal` and `ghci`. (`stack` is not needed.) - Supported GHC versions are 8.6 and 8.8. * [`ghcid`](https://github.com/ndmitchell/ghcid). * OpenGL development libraries and PulseAudio development libraries. (For other sound setups, see [below](#sound-support).) In Debian-based systems, this amounts to installing these packages: `libgl1-mesa-dev` `libglu1-mesa-dev` `freeglut3-dev` `libpulse-dev` `libblas-dev` `liblapack-dev` +If you use `nix` on Linux, all of these will be easily available with `nix develop`. + ### Nix cache & nixpkgs versions -* The `nix-shell` is pinned to an up-to-date version of `nixos-unstable`. +* The `nix develop` is pinned to an up-to-date version of `nixos-unstable`. This may cause a long build. You can alleviate that by using `cachix`, or using a different `nixpkgs` version. * If you use [`cachix`](https://cachix.org/), you can speed up your build by using `cachix use manuelbaerenz`. I'm uploading build artifacts there. -* To use a different `nixpkgs`, edit the first lines of `mypkgs.nix`, and re-run `nix-shell`. ### Non-Linux systems diff --git a/default.nix b/default.nix deleted file mode 100644 index d2eaa63..0000000 --- a/default.nix +++ /dev/null @@ -1,3 +0,0 @@ -let mypkgs = import ./mypkgs.nix {}; -in -mypkgs.essence-of-live-coding-tutorial diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..597f6c5 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "locked": { + "lastModified": 1644229661, + "narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "haskell-flake-utils": { + "inputs": { + "flake-utils": "flake-utils" + }, + "locked": { + "lastModified": 1672412555, + "narHash": "sha256-Kaa8F7nQFR3KuS6Y9WRUxeJeZlp6CCubyrRfmiEsW4k=", + "owner": "ivanovs-4", + "repo": "haskell-flake-utils", + "rev": "896219e5bde6efac72198550454e9dd9b5ed9ac9", + "type": "github" + }, + "original": { + "owner": "ivanovs-4", + "repo": "haskell-flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1681285065, + "narHash": "sha256-8gtobiSz/tgK89AAyD5TnaSzX8rp4QRibXnH8Fl3BdM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c707583645406a98df72440f5bd28f6c707db894", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable-small", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "haskell-flake-utils": "haskell-flake-utils", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..ae088bf --- /dev/null +++ b/flake.nix @@ -0,0 +1,22 @@ +{ + description = "Tutorial application for essence-of-live-coding"; + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small"; + haskell-flake-utils.url = "github:ivanovs-4/haskell-flake-utils"; + }; + + outputs = { self, nixpkgs, haskell-flake-utils, ... }@inputs: + haskell-flake-utils.lib.simpleCabal2flake { + inherit self nixpkgs; + systems = [ "x86_64-linux" ]; + + name = "essence-of-live-coding-tutorial"; + + hpPreOverrides = { pkgs }: self: super: + with pkgs.haskell.lib; + with haskell-flake-utils.lib; + tunePackages pkgs super { + essence-of-live-coding = [ (jailbreakUnbreak pkgs) ]; + }; + }; +} diff --git a/mypkgs.nix b/mypkgs.nix deleted file mode 100644 index e3f8cc9..0000000 --- a/mypkgs.nix +++ /dev/null @@ -1,54 +0,0 @@ -{ compiler ? "ghc884" -# Leave the next line to use a fairly recent nixos-unstable. -, nixpkgs ? import (builtins.fetchTarball "https://github.com/NixOS/nixpkgs-channels/archive/16fc531784ac226fb268cc59ad573d2746c109c1.tar.gz") {} -# Comment the above and uncomment the following for bleeding-edge nixos-unstable. You might want to `cachix use manuelbaerenz` or wait a long time for builds. -# , nixpkgs ? import (builtins.fetchTarball "https://github.com/NixOS/nixpkgs-channels/archive/c59ea8b8a0e7f927e7291c14ea6cd1bd3a16ff38.tar.gz") {} -# If you have a nix-channel installed locally which you want to use, uncomment and possibly edit the following line, and comment the lines above. -# , nixpkgs ? import {} -}: - -let - inherit (nixpkgs) pkgs; - - essence-of-live-coding = haskellPackages.callHackageDirect { - pkg = "essence-of-live-coding"; - ver = "0.2.4"; - sha256 = "08pjcsjwsb13ld4f1r1kkzmssx6rfv3qsgnwn17i1ag6dqjq5hrd"; - } {}; - essence-of-live-coding-gloss = haskellPackages.callHackageDirect { - pkg = "essence-of-live-coding-gloss"; - ver = "0.2.4"; - sha256 = "03rwwn8a3sjl97mznbymm512j1jak647rawf7pr6cvaz5ljg6kw3"; - } {}; - essence-of-live-coding-pulse = haskellPackages.callHackageDirect { - pkg = "essence-of-live-coding-pulse"; - ver = "0.2.4"; - sha256 = "10w6pzi7bazk4h8ci67pwg2fl71kwxhf2vbpdalds37dxiq3a6p0"; - } {}; - essence-of-live-coding-warp = haskellPackages.callHackageDirect { - pkg = "essence-of-live-coding-warp"; - ver = "0.2.4"; - sha256 = "01am1azb62qsq49cky6accpbxmr7c81ci1jkrb3gjp9c3jcs9kkv"; - } {}; - - haskellPackages = pkgs.haskell.packages.${compiler}.override { - overrides = self: super: { - inherit - essence-of-live-coding - essence-of-live-coding-gloss - essence-of-live-coding-pulse - essence-of-live-coding-warp - ; - http-client = super.http-client_0_7_1; - }; - }; - - myPkgs = haskellPackages.extend (pkgs.haskell.lib.packageSourceOverrides { - essence-of-live-coding-tutorial = ./.; - # Uncomment the following lines if you have forked essence-of-live-coding and insert the appropriate path - # essence-of-live-coding = ../essence-of-live-coding/essence-of-live-coding; - # essence-of-live-coding-gloss = ../essence-of-live-coding/essence-of-live-coding-gloss; - # essence-of-live-coding-warp = ../essence-of-live-coding/essence-of-live-coding-warp; - }); -in -myPkgs diff --git a/shell.nix b/shell.nix deleted file mode 100644 index b0e60c2..0000000 --- a/shell.nix +++ /dev/null @@ -1,13 +0,0 @@ -let myPkgs = import ./mypkgs.nix {}; -in myPkgs.shellFor { - packages = p: with p; [ - essence-of-live-coding-tutorial - ]; - buildInputs = with myPkgs; [ - cabal-install - ghcid - ghcide - hlint - # Add further build tools as you like - ]; -}