From a72d3b02198412dd514dd81f703ff618c980eb52 Mon Sep 17 00:00:00 2001 From: mtgmonkey Date: Thu, 4 Dec 2025 16:31:03 +0100 Subject: [PATCH] init --- flake.lock | 26 +++++++++++++++++++ flake.nix | 13 ++++++++++ package.nix | 65 ++++++++++++++++++++++++++++++++++++++++++++++++ src/Game/Main.hs | 6 +++++ 4 files changed, 110 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 package.nix create mode 100644 src/Game/Main.hs diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..9386f3f --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1764611609, + "narHash": "sha256-yU9BNcP0oadUKupw0UKmO9BKDOVIg9NStdJosEbXf8U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "8c29968b3a942f2903f90797f9623737c215737c", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixpkgs-unstable", + "type": "indirect" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..6e93c4c --- /dev/null +++ b/flake.nix @@ -0,0 +1,13 @@ +{ + inputs = { + nixpkgs.url = "nixpkgs/nixpkgs-unstable"; + }; + outputs = {nixpkgs, ...}: let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + in { + packages.${system} = { + default = pkgs.callPackage ./package.nix {}; + }; + }; +} diff --git a/package.nix b/package.nix new file mode 100644 index 0000000..f9513ce --- /dev/null +++ b/package.nix @@ -0,0 +1,65 @@ +{ + haskellPackages, + lib, + stdenv, + ... +}: let + ghcExeOptions = lib.concatStringsSep " " ghcFlags; + ghcFlags = [ + "-O" + "-Wall" + "-Widentities" + "-Wincomplete-record-updates" + "-Wincomplete-uni-patterns" + # "-Wmissing-export-lists" + "-Wmissing-home-modules" + "-Wpartial-fields" + "-Wredundant-constraints" + "-threaded" + "-rtsopts" + "-with-rtsopts=-N" + # src + "-i./src" + "-main-is Game" + ]; + haddockOptions = lib.concatStringsSep " " haddockFlags; + haddockFlags = [ + "--html" + "--odir docs" + "--optghc=-i./src" + "src/Game/Main.hs" + ]; + ghcPackages = p: [ + p.GLFW-b + p.linear + p.OpenGL + ]; +in + stdenv.mkDerivation { + pname = "haskengl"; + version = "0.1.0"; + src = ./.; + nativeBuildInputs = [ + (haskellPackages.ghcWithPackages ghcPackages) + ]; + buildInputs = [ + ]; + configurePhase = '' + ''; + buildPhase = '' + ghc ${ghcExeOptions} ./src/Game/Main.hs -o ./Main + 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.wtfpl; + mainProgram = "hs-game"; + platforms = ["x86_64-linux"]; + }; + } diff --git a/src/Game/Main.hs b/src/Game/Main.hs new file mode 100644 index 0000000..839ea70 --- /dev/null +++ b/src/Game/Main.hs @@ -0,0 +1,6 @@ +module Game (main) where + +main :: IO () +main = do + putStrLn "Hallo Welt" + return ()