Cabal; non-Nix support
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
dist-newstyle
|
||||
result
|
||||
21
CHANGELOG.md
21
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
|
||||
|
||||
45
README.md
45
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 run with nix:
|
||||
`nix run git+https://git.mtgmonkey.net/Andromeda/hs-game`
|
||||
|
||||
to enter nix development shell:
|
||||
`nix develop git+https://git.mtgmonkey.net/Andromeda/hs-game`
|
||||
|
||||
build tested on
|
||||
- nix
|
||||
- Kubuntu 25.10
|
||||
|
||||
to release:
|
||||
|
||||
```bash
|
||||
nix build .#release
|
||||
```
|
||||
|
||||
to debug build:
|
||||
|
||||
```bash
|
||||
nix build .#debug
|
||||
```
|
||||
|
||||
todo moved to CHANGELOG.md
|
||||
- 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
|
||||
|
||||
113
flake.nix
113
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
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
38
hs-game.cabal
Normal file
38
hs-game.cabal
Normal file
@@ -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
|
||||
39
package.nix
39
package.nix
@@ -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"];
|
||||
};
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user