summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormtgmonkey <mtgmonkey@nixos>2025-12-13 19:22:42 +0100
committermtgmonkey <mtgmonkey@nixos>2025-12-13 19:22:42 +0100
commite9b4e2d34af8f0ea4a54d8d093108cdfdc68757c (patch)
tree125b11cc5e5d28c12298d1a1e95bdad706e67c5d
parent73985e298a407ecc161d65b6bf92d3fc535aa73a (diff)
Cabal; non-Nix support
-rw-r--r--.gitignore2
-rw-r--r--CHANGELOG.md21
-rw-r--r--README.md41
-rw-r--r--flake.nix113
-rw-r--r--hs-game.cabal38
-rw-r--r--package.nix39
-rw-r--r--src/Game/Internal.hs2
-rw-r--r--src/Main.hs (renamed from src/Game.hs)2
8 files changed, 141 insertions, 117 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..bd4112d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+dist-newstyle
+result
diff --git a/CHANGELOG.md b/CHANGELOG.md
index afb9ca7..5db8649 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -20,6 +20,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- use `Double` rather than `FLoat` for internal calculations
- `cursorPos`, `dt` natively `Double` already
+## [0.3.0] - 2025-12-08
+
+### Added
+
+- Cabal build system
+- `.gitignore` against build artifacts
+
+### Changed
+
+- versioning using the [PVP standard](https://pvp.haskell.org/), though it will remain SemVer compliant
+ - SemVer version A.B.C will become PVP version A.B.C.0
+- `README.md` overhauled to reflect new build system
+
+### Fixed
+
+- a couple non-impactful typos
+
+### Removed
+
+- `Game` module -> moved to `Main`
+
## [0.2.1] - 2025-12-08
### Changed
diff --git a/README.md b/README.md
index 9c5c051..c3065c4 100644
--- a/README.md
+++ b/README.md
@@ -1,21 +1,30 @@
-to run:
+see CHANGELOG.md
-```bash
-git clone https://git.mtgmonkey.net/Andromeda/hs-game
-cd hs-game
-nix run
-```
+to run without nix:
+- get build tools:
+ - with apt: `apt install cabal-install ghc git`
+- get source code: `git clone https://git.mtgmonkey.net/Andromeda/hs-game --depth 1; cd hs-game`
+- get dependencies
+ - with apt on x86-64: `apt install g++-x86-64_linux-gnu libgl-dev libx11-dev libxi-dev libxrandr-dev libxxf86vm-dev libxcursor-dev libxinerama-dev libglu1-mesa-dev`
+- run with `cabal run` or build with `cabal build`
-to release:
-
-```bash
-nix build .#release
-```
+to run with nix:
+`nix run git+https://git.mtgmonkey.net/Andromeda/hs-game`
-to debug build:
+to enter nix development shell:
+`nix develop git+https://git.mtgmonkey.net/Andromeda/hs-game`
-```bash
-nix build .#debug
-```
+build tested on
+- nix
+- Kubuntu 25.10
-todo moved to CHANGELOG.md
+to release:
+- update CHANGELOG.md with new version
+- update version in hs-game.cabal
+- update version in flake.nix
+- check that it builds
+- `git add -A`
+- `git status` make sure there aren't random files
+- `git status -v` make sure all additions are in CHANGELOG.md
+- double check that flake, .cabal, and CHANGELOG.md all have the same version
+- release
diff --git a/flake.nix b/flake.nix
index 6468b28..90a80c5 100644
--- a/flake.nix
+++ b/flake.nix
@@ -2,70 +2,63 @@
inputs = {
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
};
- outputs = {nixpkgs, ...}: let
+ outputs = {
+ nixpkgs,
+ self,
+ ...
+ }: let
+ versionString = "0.3.0";
+ package = {
+ mkDerivation,
+ base,
+ bytestring,
+ GLFW-b,
+ lens,
+ lib,
+ linear,
+ OpenGL,
+ }:
+ mkDerivation {
+ pname = "hs-game";
+ version = versionString;
+ src = ./.;
+ isLibrary = false;
+ isExecutable = true;
+ executableHaskellDepends = [
+ base
+ bytestring
+ GLFW-b
+ lens
+ linear
+ OpenGL
+ ];
+ homepage = "https://git.mtgmonkey.net/Andromeda/hs-game";
+ license = lib.licenses.bsd3;
+ mainProgram = "hs-game";
+ };
system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
- debugGhcOptions = pkgs.lib.concatStringsSep " " (debugGhcFlags ++ commonGhcFlags);
- debugGhcFlags = [
- "-O0"
- "-Wall"
- "-Widentities"
- "-Wincomplete-record-updates"
- "-Wincomplete-uni-patterns"
- # "-Wmissing-export-lists"
- "-Wmissing-home-modules"
- "-Wpartial-fields"
- "-Wredundant-constraints"
- "-threaded"
- "-rtsopts"
- "-with-rtsopts=-N"
- "-main-is Game"
- ];
- haddockOptions = pkgs.lib.concatStringsSep " " haddockFlags;
- haddockFlags = [
- "--html"
- "--odir docs"
- "--optghc=-i./src"
- "src/Game.hs"
- ];
- releaseGhcOptions = pkgs.lib.concatStringsSep " " (releaseGhcFlags ++ commonGhcFlags);
- releaseGhcFlags = [
- "-O2"
- "-threaded"
- "-rtsopts"
- "-with-rtsopts=-N"
- "-main-is Game"
- ];
- noHaddockOptions = "";
- commonGhcFlags = [
- "-i./src"
- ];
- ghcPackages = p: [
- p.GLFW-b
- p.linear
- p.OpenGL
- ];
in {
packages.${system} = {
- debug = pkgs.callPackage ./package.nix {
- ghcOptions = debugGhcOptions;
- haddockOptions = noHaddockOptions;
- inherit ghcPackages;
- };
- release = pkgs.callPackage ./package.nix {
- ghcOptions = releaseGhcOptions;
- haddockOptions = noHaddockOptions;
- inherit ghcPackages;
- };
- docs = pkgs.callPackage ./package.nix {
- ghcOptions = "--version";
- inherit haddockOptions;
- inherit ghcPackages;
- };
- default = pkgs.callPackage ./package.nix {
- ghcOptions = releaseGhcOptions;
- inherit haddockOptions;
- inherit ghcPackages;
+ default =
+ pkgs.haskellPackages.callPackage package {};
+ };
+ devShells.${system} = {
+ default = pkgs.mkShell {
+ packages = [
+ pkgs.cabal-install
+ pkgs.libGL
+ pkgs.xorg.libX11
+ pkgs.xorg.libXi
+ pkgs.xorg.libXrandr
+ pkgs.xorg.libXxf86vm
+ pkgs.xorg.libXcursor
+ pkgs.xorg.libXinerama
+ pkgs.libGLU
+ ];
+ inputsFrom = [
+ self.packages.${system}.default
+ ];
};
};
};
diff --git a/hs-game.cabal b/hs-game.cabal
new file mode 100644
index 0000000..c38218a
--- /dev/null
+++ b/hs-game.cabal
@@ -0,0 +1,38 @@
+cabal-version: 3.0
+name: hs-game
+version: 0.3.0
+-- synopsis:
+-- description:
+homepage: https://git.mtgmonkey.net/Andromeda/hs-game
+license: BSD-3-Clause
+license-file: LICENSE
+author: andromeda
+maintainer: @andromeda:tchncs.de
+-- copyright:
+category: Game
+build-type: Simple
+extra-doc-files: CHANGELOG.md
+-- extra-source-files:
+
+common warnings
+ ghc-options: -Wall
+
+common optimizations
+ ghc-options: -O2
+
+executable hs-game
+ import: optimizations
+ main-is: Main.hs
+ other-modules:
+ Game.Internal,
+ Game.Internal.LoadShaders,
+ Game.Internal.Types
+ -- other-extensions:
+ build-depends:
+ base >= 4.18,
+ bytestring >= 0.12,
+ GLFW-b >= 3.3,
+ lens >= 5.3,
+ linear >= 1.23,
+ OpenGL >= 3.0,
+ hs-source-dirs: src
diff --git a/package.nix b/package.nix
deleted file mode 100644
index 1b6f738..0000000
--- a/package.nix
+++ /dev/null
@@ -1,39 +0,0 @@
-{
- haskellPackages,
- lib,
- stdenv,
- ghcOptions,
- haddockOptions,
- ghcPackages,
- ...
-}:
-stdenv.mkDerivation {
- pname = "hs-game";
- version = "0.1.0";
- src = ./.;
- nativeBuildInputs = [
- (haskellPackages.ghcWithPackages ghcPackages)
- ];
- buildInputs = [
- ];
- configurePhase = ''
- '';
- buildPhase = ''
- touch Main
- ghc ${ghcOptions} ./src/Game.hs -o ./Main
- mkdir ./docs
- haddock ${haddockOptions}
- '';
- installPhase = ''
- mkdir -p $out/bin
- cp ./Main $out/bin/hs-game
- cp ./docs $out/docs -r
- '';
-
- meta = {
- homepage = "https://mtgmonkey.net";
- license = lib.licenses.bsd3;
- mainProgram = "hs-game";
- platforms = ["x86_64-linux"];
- };
-}
diff --git a/src/Game/Internal.hs b/src/Game/Internal.hs
index 61832a9..3461d27 100644
--- a/src/Game/Internal.hs
+++ b/src/Game/Internal.hs
@@ -208,7 +208,7 @@ applyToTuples f (x, y) (a, b) = (f x a, f y b)
updateCursorPos :: Double -> Double -> Model -> Model
updateCursorPos x y model =
let
- pyth = (((fst model.cursorPos) - x) ** 2 + ((snd model.cursorPos - y)) ** 2) ** 0.5
+ pyth = (((fst model.cursorPos) - x) ** 2 + ((snd model.cursorPos) - y) ** 2) ** 0.5
in
if pyth < 16 then
model
diff --git a/src/Game.hs b/src/Main.hs
index f120a6f..2a96e89 100644
--- a/src/Game.hs
+++ b/src/Main.hs
@@ -7,7 +7,7 @@
- Maintainer : Matrix @Andromeda:tchncs.de
- Stability : Experimental
-}
-module Game (main) where
+module Main (main) where
import Game.Internal.Types
import Game.Internal