Cabal; non-Nix support

This commit is contained in:
mtgmonkey
2025-12-13 19:22:42 +01:00
parent 73985e298a
commit e9b4e2d34a
8 changed files with 143 additions and 119 deletions

113
flake.nix
View File

@@ -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
];
};
};
};