From 77486e37565e576eb4588da9377733235ff654bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joosep=20J=C3=A4=C3=A4ger?= Date: Mon, 4 Dec 2023 22:22:32 +0200 Subject: [PATCH] Added nix flake package --- default.nix | 19 +++++++++++++++++++ flake.nix | 47 +++++++++++++++++++++++++++++++++-------------- 2 files changed, 52 insertions(+), 14 deletions(-) create mode 100644 default.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..0a31ea6 --- /dev/null +++ b/default.nix @@ -0,0 +1,19 @@ +{ mkDerivation, base, containers, exceptions, lens, lib, libGL +, libX11, libXcursor, libXext, libXi, libXinerama, libXrandr, raylib, ... +}: +mkDerivation { + pname = "h-raylib"; + version = "5.0.0.1"; + src = ./.; + isLibrary = true; + isExecutable = true; + configureFlags = [ + "-fplatform-nixos" + ]; + libraryHaskellDepends = [ base containers exceptions lens ]; + librarySystemDepends = [ + libGL libX11 libXcursor libXext libXi libXinerama libXrandr raylib + ]; + description = "Raylib bindings for Haskell"; + license = lib.licenses.asl20; +} diff --git a/flake.nix b/flake.nix index 305eb08..1f90bce 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,7 @@ { - inputs.nixpkgs.url = "nixpkgs"; + inputs = { + nixpkgs.url = "nixpkgs"; + }; outputs = { self, nixpkgs, ... }@inputs: let @@ -9,7 +11,25 @@ pkgsForSystem = system: - import nixpkgs { inherit system; overlays = [ ]; }; + import nixpkgs { + inherit system; + overlays = [ + (self: super: { + raylib = super.raylib.overrideAttrs (old: { + patches = []; + src = self.fetchFromGitHub { + owner = "raysan5"; + repo = "raylib"; + rev = "e33e9da277865207123158430ebf42cc5626e5b7"; + sha256 = "sha256-tLvaO8zWHx8+NTV17X49JveWdVPG5AKuTzFsyDDaTss="; + }; + postFixup = '' + cp ../src/*.h $out/include/ + ''; + }); + }) + ]; + }; in { devShells = forAllSystems (system: @@ -24,23 +44,22 @@ stdenv.cc ghc - ((raylib.override { includeEverything = true; }).overrideAttrs (old: { - patches = []; - src = fetchFromGitHub { - owner = "raysan5"; - repo = "raylib"; - rev = "b8cd10264b6d34ff4b09ccdd0b0f7b254cf3b122"; - sha256 = "sha256-VRNQZ0Pp1uczhLSF4Hz2QWiEini2jFtEGJDZMcLE+0w="; - }; - postFixup = '' - cp ../src/*.h $out/include/ - ''; - })) glfw cabal-install + xorg.libXinerama + xorg.libXcursor + xorg.libXrandr + xorg.libXi + xorg.libXext + raylib ]; }; } ); + packages = forAllSystems (system: let + pkgs = pkgsForSystem system; + in { + default = import ./default.nix (pkgs // pkgs.xorg // pkgs.haskellPackages); + }); }; }