Compare commits

..

No commits in common. "85dc1735b85f3a5fd1a4ba2401eeac70df94be27" and "c39357a93be51d16e47e15e63b240fe31fc2f496" have entirely different histories.

7 changed files with 72 additions and 47 deletions

3
.envrc
View file

@ -1,3 +0,0 @@
#!/usr/bin/env bash
use flake

5
.gitignore vendored
View file

@ -26,6 +26,5 @@ cabal.project.local~
# ignore vscodium's local config # ignore vscodium's local config
.vscode/ .vscode/
# ignore nix build system # ignore nix result symlinks
result* result*
.direnv

View file

@ -44,15 +44,15 @@ processEvent = event noEvent $ \case
EventMotion {} -> noEvent EventMotion {} -> noEvent
EventResize size -> Event $ Resize size EventResize size -> Event $ Resize size
run :: DisplayableSpace f => (Int, Int) -> f Bool -> SF InputEvent Picture run :: forall f. DisplayableSpace f => f Bool -> SF InputEvent Picture
run size st = run st =
let initSpace = gol' standardRule st let initSpace = gol' standardRule st
in proc inp -> do in proc inp -> do
let cmdev = processEvent inp let cmdev = processEvent inp
playing <- accumHoldBy (const . not) True -< filterE isPlayPause cmdev playing <- accumHoldBy (const . not) True -< filterE isPlayPause cmdev
time <- accum 0.2 -< mapFilterE getChangeSpeed cmdev time <- accum 0.2 -< mapFilterE getChangeSpeed cmdev
windowSize <- hold size -< mapFilterE getResize cmdev windowSize <- hold (100, 100) -< mapFilterE getResize cmdev
tick <- tickSignal -< time tick <- tickSignal -< time
space <- engine initSpace -< gate tick playing space <- engine initSpace -< gate tick playing

View file

@ -6,7 +6,6 @@ import Graphics.Engine (initialSpace, run)
import Graphics.Gloss import Graphics.Gloss
import Graphics.GlossUtils (playYampa) import Graphics.GlossUtils (playYampa)
-- random space just to test things
space :: ToroidalSpace Bool space :: ToroidalSpace Bool
space = tabulate (\(x, y) -> (x + y `mod` 5) * 10 + x - y > 30) space = tabulate (\(x, y) -> (x + y `mod` 5) * 10 + x - y > 30)
@ -16,4 +15,4 @@ main =
(InWindow "Conway's Game of Life" (200, 200) (10, 10)) (InWindow "Conway's Game of Life" (200, 200) (10, 10))
black black
30 30
(run (200, 200) space) (run space)

View file

@ -1,5 +1,21 @@
{ {
"nodes": { "nodes": {
"flake-compat": {
"flake": false,
"locked": {
"lastModified": 1627913399,
"narHash": "sha256-hY8g6H2KFL8ownSiFeMOjwPC8P0ueXpCVEbxgda3pko=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "12c64ca55c1014cdc1b16ed5a804aa8576601ff2",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-utils": { "flake-utils": {
"locked": { "locked": {
"lastModified": 1638122382, "lastModified": 1638122382,
@ -32,6 +48,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"flake-compat": "flake-compat",
"flake-utils": "flake-utils", "flake-utils": "flake-utils",
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
} }

View file

@ -1,54 +1,59 @@
# SPDX-FileCopyrightText: 2021 Serokell <https://serokell.io/>
#
# SPDX-License-Identifier: CC0-1.0
{ {
description = "Conway's Game of Life in Haskell"; description = "My haskell application";
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs"; nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils"; flake-utils.url = "github:numtide/flake-utils";
flake-compat.url = "github:edolstra/flake-compat";
flake-compat.flake = false;
}; };
outputs = { self, nixpkgs, flake-utils, ... }: outputs = { self, nixpkgs, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system: flake-utils.lib.eachDefaultSystem (system:
let let
overlays = [ ];
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
haskellPackages = pkgs.haskellPackages;
jailbreakUnbreak = pkg:
pkgs.haskell.lib.doJailbreak (pkg.overrideAttrs (_: { meta = { }; }));
packageName = "conways-game-of-life";
execName = "gol"; execName = "gol";
hp = pkgs.haskellPackages; # pkgs.haskell.packages.ghc921; in {
project = returnShellEnv: packages.${packageName} =
hp.developPackage { haskellPackages.callCabal2nix packageName self rec {
inherit returnShellEnv; # Dependency overrides go here
name = "conways-game-of-life";
root = ./.;
withHoogle = false;
overrides = self: super: with pkgs.haskell.lib; {
# Use callCabal2nix to override Haskell dependencies here
# cf. https://tek.brick.do/K3VXJd8mEKO7
# Example:
# > NanoID = self.callCabal2nix "NanoID" inputs.NanoID { };
# Assumes that you have the 'NanoID' flake input defined.
};
modifier = drv:
pkgs.haskell.lib.addBuildTools drv (with hp; [
# Specify your build/dev dependencies here.
hlint
haskell-language-server
ormolu
pkgs.mesa
pkgs.mesa_glu
pkgs.freeglut
]);
}; };
in
{
# Used by `nix build` & `nix run` (prod exe)
defaultPackage = project false;
defaultApp = { defaultPackage = self.packages.${system}.${packageName};
apps.${execName} = {
type = "app"; type = "app";
program = "${self.defaultPackage.${system}}/bin/${execName}"; program = "${self.packages.${system}.${packageName}}/bin/${execName}";
}; };
# Used by `nix develop` (dev shell) defaultApp = self.apps.${system}.${execName};
devShell = project true;
devShell = pkgs.mkShell {
buildInputs = with haskellPackages; [
ghcid
cabal-install
hlint
pkgs.haskell-language-server
pkgs.ormolu
pkgs.mesa
pkgs.mesa_glu
pkgs.freeglut
];
inputsFrom = builtins.attrValues self.packages.${system};
};
}); });
} }

8
shell.nix Normal file
View file

@ -0,0 +1,8 @@
(import (
let lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
) { src = ./.; }).shellNix