From c096923f3928da5e5cd5b9808dc1cb6234e52bd9 Mon Sep 17 00:00:00 2001 From: kiana-S Date: Wed, 29 Dec 2021 22:54:49 -0500 Subject: [PATCH 01/10] Fix window size bug --- Graphics/Engine.hs | 6 +++--- Main.hs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Graphics/Engine.hs b/Graphics/Engine.hs index 5416a90..3ddab38 100644 --- a/Graphics/Engine.hs +++ b/Graphics/Engine.hs @@ -44,15 +44,15 @@ processEvent = event noEvent $ \case EventMotion {} -> noEvent EventResize size -> Event $ Resize size -run :: forall f. DisplayableSpace f => f Bool -> SF InputEvent Picture -run st = +run :: DisplayableSpace f => (Int, Int) -> f Bool -> SF InputEvent Picture +run size st = let initSpace = gol' standardRule st in proc inp -> do let cmdev = processEvent inp playing <- accumHoldBy (const . not) True -< filterE isPlayPause cmdev time <- accum 0.2 -< mapFilterE getChangeSpeed cmdev - windowSize <- hold (100, 100) -< mapFilterE getResize cmdev + windowSize <- hold size -< mapFilterE getResize cmdev tick <- tickSignal -< time space <- engine initSpace -< gate tick playing diff --git a/Main.hs b/Main.hs index b13cd4c..3888bfc 100644 --- a/Main.hs +++ b/Main.hs @@ -15,4 +15,4 @@ main = (InWindow "Conway's Game of Life" (200, 200) (10, 10)) black 30 - (run space) \ No newline at end of file + (run (200, 200) space) \ No newline at end of file From 3b56e44971257a9923baca18ef1ea043a54baeb9 Mon Sep 17 00:00:00 2001 From: kiana-S Date: Tue, 11 Jan 2022 23:28:57 -0500 Subject: [PATCH 02/10] Start using direnv --- .direnv/flake-profile | 1 + .direnv/flake-profile-1-link | 1 + .envrc | 3 +++ shell.nix | 8 -------- 4 files changed, 5 insertions(+), 8 deletions(-) create mode 120000 .direnv/flake-profile create mode 120000 .direnv/flake-profile-1-link create mode 100644 .envrc delete mode 100644 shell.nix diff --git a/.direnv/flake-profile b/.direnv/flake-profile new file mode 120000 index 0000000..0c05709 --- /dev/null +++ b/.direnv/flake-profile @@ -0,0 +1 @@ +flake-profile-1-link \ No newline at end of file diff --git a/.direnv/flake-profile-1-link b/.direnv/flake-profile-1-link new file mode 120000 index 0000000..5e2e9a0 --- /dev/null +++ b/.direnv/flake-profile-1-link @@ -0,0 +1 @@ +/nix/store/y7cn6n6zvp9z6vz8k22mfqqh7vkshc5j-nix-shell-env \ No newline at end of file diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..21282b0 --- /dev/null +++ b/.envrc @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +use flake \ No newline at end of file diff --git a/shell.nix b/shell.nix deleted file mode 100644 index 81e3286..0000000 --- a/shell.nix +++ /dev/null @@ -1,8 +0,0 @@ -(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 \ No newline at end of file From f20b5a972b75ef7630588bc7534667ff302642cc Mon Sep 17 00:00:00 2001 From: kiana-S Date: Tue, 11 Jan 2022 23:41:18 -0500 Subject: [PATCH 03/10] Remove ghcid from devshell --- .direnv/flake-profile | 2 +- .direnv/flake-profile-2-link | 1 + flake.nix | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 120000 .direnv/flake-profile-2-link diff --git a/.direnv/flake-profile b/.direnv/flake-profile index 0c05709..c7ae5b7 120000 --- a/.direnv/flake-profile +++ b/.direnv/flake-profile @@ -1 +1 @@ -flake-profile-1-link \ No newline at end of file +flake-profile-2-link \ No newline at end of file diff --git a/.direnv/flake-profile-2-link b/.direnv/flake-profile-2-link new file mode 120000 index 0000000..681f136 --- /dev/null +++ b/.direnv/flake-profile-2-link @@ -0,0 +1 @@ +/nix/store/4101gk8ld9z4n2yrcpb07y3p9dsf6za4-nix-shell-env \ No newline at end of file diff --git a/flake.nix b/flake.nix index 9b0d69c..e93ac51 100644 --- a/flake.nix +++ b/flake.nix @@ -43,7 +43,7 @@ devShell = pkgs.mkShell { buildInputs = with haskellPackages; [ - ghcid + ghc cabal-install hlint pkgs.haskell-language-server From 07d8764c633ebbfb6fe3838db7406f17801bacf2 Mon Sep 17 00:00:00 2001 From: kiana-S Date: Tue, 11 Jan 2022 23:54:53 -0500 Subject: [PATCH 04/10] Update direnv --- .direnv/flake-profile | 1 - .direnv/flake-profile-1-link | 1 - .direnv/flake-profile-2-link | 1 - .gitignore | 5 +++-- 4 files changed, 3 insertions(+), 5 deletions(-) delete mode 120000 .direnv/flake-profile delete mode 120000 .direnv/flake-profile-1-link delete mode 120000 .direnv/flake-profile-2-link diff --git a/.direnv/flake-profile b/.direnv/flake-profile deleted file mode 120000 index c7ae5b7..0000000 --- a/.direnv/flake-profile +++ /dev/null @@ -1 +0,0 @@ -flake-profile-2-link \ No newline at end of file diff --git a/.direnv/flake-profile-1-link b/.direnv/flake-profile-1-link deleted file mode 120000 index 5e2e9a0..0000000 --- a/.direnv/flake-profile-1-link +++ /dev/null @@ -1 +0,0 @@ -/nix/store/y7cn6n6zvp9z6vz8k22mfqqh7vkshc5j-nix-shell-env \ No newline at end of file diff --git a/.direnv/flake-profile-2-link b/.direnv/flake-profile-2-link deleted file mode 120000 index 681f136..0000000 --- a/.direnv/flake-profile-2-link +++ /dev/null @@ -1 +0,0 @@ -/nix/store/4101gk8ld9z4n2yrcpb07y3p9dsf6za4-nix-shell-env \ No newline at end of file diff --git a/.gitignore b/.gitignore index cce9137..73b0670 100644 --- a/.gitignore +++ b/.gitignore @@ -26,5 +26,6 @@ cabal.project.local~ # ignore vscodium's local config .vscode/ -# ignore nix result symlinks -result* \ No newline at end of file +# ignore nix build system +result* +.direnv \ No newline at end of file From c42111017279b2bc09ab0ef40b331b80929a1ec3 Mon Sep 17 00:00:00 2001 From: kiana-S Date: Wed, 9 Mar 2022 13:49:35 -0500 Subject: [PATCH 05/10] Remove unnecessary flake-compat input --- flake.lock | 17 ----------------- flake.nix | 5 +---- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/flake.lock b/flake.lock index e15f5a8..b1039cb 100644 --- a/flake.lock +++ b/flake.lock @@ -1,21 +1,5 @@ { "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": { "locked": { "lastModified": 1638122382, @@ -48,7 +32,6 @@ }, "root": { "inputs": { - "flake-compat": "flake-compat", "flake-utils": "flake-utils", "nixpkgs": "nixpkgs" } diff --git a/flake.nix b/flake.nix index e93ac51..4972117 100644 --- a/flake.nix +++ b/flake.nix @@ -8,9 +8,6 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs"; flake-utils.url = "github:numtide/flake-utils"; - - flake-compat.url = "github:edolstra/flake-compat"; - flake-compat.flake = false; }; outputs = { self, nixpkgs, flake-utils, ... }: @@ -56,4 +53,4 @@ inputsFrom = builtins.attrValues self.packages.${system}; }; }); -} \ No newline at end of file +} From 6c3742e14831d1bb14decd0a8d12580e723b4399 Mon Sep 17 00:00:00 2001 From: kiana-S Date: Thu, 10 Mar 2022 10:10:10 -0500 Subject: [PATCH 06/10] Name --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 4972117..d915b78 100644 --- a/flake.nix +++ b/flake.nix @@ -3,7 +3,7 @@ # SPDX-License-Identifier: CC0-1.0 { - description = "My haskell application"; + description = "Conway's Game of Life in Haskell"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs"; From adb081fd22e7e25c6c22063d3e2ac0b8a0b02840 Mon Sep 17 00:00:00 2001 From: kiana-S Date: Fri, 11 Mar 2022 23:01:32 -0500 Subject: [PATCH 07/10] Switch flake.nix architecture --- flake.nix | 74 +++++++++++++++++++++++++++---------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/flake.nix b/flake.nix index d915b78..38dc9f6 100644 --- a/flake.nix +++ b/flake.nix @@ -1,7 +1,3 @@ -# SPDX-FileCopyrightText: 2021 Serokell -# -# SPDX-License-Identifier: CC0-1.0 - { description = "Conway's Game of Life in Haskell"; @@ -13,44 +9,48 @@ outputs = { self, nixpkgs, flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system: let - pkgs = nixpkgs.legacyPackages.${system}; - - haskellPackages = pkgs.haskellPackages; - - jailbreakUnbreak = pkg: - pkgs.haskell.lib.doJailbreak (pkg.overrideAttrs (_: { meta = { }; })); - - packageName = "conways-game-of-life"; - + overlays = [ ]; + pkgs = import nixpkgs { inherit system overlays; config.allowBroken = true; }; execName = "gol"; - in { - packages.${packageName} = - haskellPackages.callCabal2nix packageName self rec { - # Dependency overrides go here + hp = pkgs.haskellPackages; # pkgs.haskell.packages.ghc921; + project = returnShellEnv: + hp.developPackage { + inherit returnShellEnv; + 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. + ghc + cabal-install + hlint + haskell-language-server + ormolu + + pkgs.mesa + pkgs.mesa_glu + pkgs.freeglut + ]); }; + in + { + # Used by `nix build` & `nix run` (prod exe) + defaultPackage = project false; - defaultPackage = self.packages.${system}.${packageName}; - - apps.${execName} = { + defaultApp = { type = "app"; - program = "${self.packages.${system}.${packageName}}/bin/${execName}"; + program = "${self.defaultPackage.${system}}/bin/${execName}"; }; - defaultApp = self.apps.${system}.${execName}; - - devShell = pkgs.mkShell { - buildInputs = with haskellPackages; [ - ghc - cabal-install - hlint - pkgs.haskell-language-server - pkgs.ormolu - - pkgs.mesa - pkgs.mesa_glu - pkgs.freeglut - ]; - inputsFrom = builtins.attrValues self.packages.${system}; - }; + # Used by `nix develop` (dev shell) + devShell = project true; }); } From a3e2ea6e8662888b46b9caa3f88ff29f6cfb7798 Mon Sep 17 00:00:00 2001 From: Kiana Sheibani <54818348+kiana-S@users.noreply.github.com> Date: Fri, 8 Apr 2022 00:54:06 -0400 Subject: [PATCH 08/10] Add slightly more informative comment --- Main.hs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Main.hs b/Main.hs index 3888bfc..5c166dc 100644 --- a/Main.hs +++ b/Main.hs @@ -6,6 +6,7 @@ import Graphics.Engine (initialSpace, run) import Graphics.Gloss import Graphics.GlossUtils (playYampa) +-- random space just to test things space :: ToroidalSpace Bool space = tabulate (\(x, y) -> (x + y `mod` 5) * 10 + x - y > 30) @@ -15,4 +16,4 @@ main = (InWindow "Conway's Game of Life" (200, 200) (10, 10)) black 30 - (run (200, 200) space) \ No newline at end of file + (run (200, 200) space) From edb65814cd65fa1333055dd1e0afa171b9d7f69f Mon Sep 17 00:00:00 2001 From: kiana-S Date: Mon, 14 Mar 2022 08:26:54 -0400 Subject: [PATCH 09/10] Disallow broken packages --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 38dc9f6..01a4c63 100644 --- a/flake.nix +++ b/flake.nix @@ -10,7 +10,7 @@ flake-utils.lib.eachDefaultSystem (system: let overlays = [ ]; - pkgs = import nixpkgs { inherit system overlays; config.allowBroken = true; }; + pkgs = nixpkgs.legacyPackages.${system}; execName = "gol"; hp = pkgs.haskellPackages; # pkgs.haskell.packages.ghc921; project = returnShellEnv: From 85dc1735b85f3a5fd1a4ba2401eeac70df94be27 Mon Sep 17 00:00:00 2001 From: kiana-S Date: Mon, 14 Mar 2022 08:28:31 -0400 Subject: [PATCH 10/10] Remove unnecessary dependencies --- flake.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/flake.nix b/flake.nix index 01a4c63..d57e1bb 100644 --- a/flake.nix +++ b/flake.nix @@ -29,8 +29,6 @@ modifier = drv: pkgs.haskell.lib.addBuildTools drv (with hp; [ # Specify your build/dev dependencies here. - ghc - cabal-install hlint haskell-language-server ormolu