summaryrefslogtreecommitdiff
path: root/flake.nix
blob: a31598177308a2df1991c645f41179481fcfe52a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
{
  inputs = {
    nixpkgs.url = "nixpkgs/nixpkgs-unstable";
    hs-bindgen.url = "github:well-typed/hs-bindgen";
    self.submodules = true;
  };
  outputs = {
    nixpkgs,
    hs-bindgen,
    self,
    ...
  }: let
    version = "0.1.0";
    package = {
      # nix stuff
      mkDerivation,
      lib,
      # haskell deps
      base,
      c-expr-runtime,
      hs-bindgen-runtime,
      # pkgconfig deps
      libGL,
      libX11,
      libXcursor,
      libXi,
      xrandr,
      # shell deps
      clang,
      hs-bindgen-cli,
      tree,
    }:
      mkDerivation {
        pname = "hs-rgfw";
        inherit version;
        src = ./.;
        libraryHaskellDepends = [
          base
          c-expr-runtime
          hs-bindgen-runtime
        ];
        libraryPkgconfigDepends = [
          libGL
          libX11
          libXcursor
          libXi
          xrandr
        ];
        preConfigure = ''
          set -x
          export PATH=${clang}/bin:${hs-bindgen-cli}/bin:${tree}/bin:$PATH
          ./generate.sh
          set +x
        '';
        homepage = "https://git.mtgmonkey.net/Andromeda/hs-rgfw";
        license = lib.licenses.gpl3Only;
        platforms = ["x86_64-linux"];
      };
    system = "x86_64-linux";
    pkgs = import nixpkgs {
      inherit system;
      overlays = [
        hs-bindgen.overlays.libclangBindings
        hs-bindgen.overlays.hsBindgen
      ];
    };
  in {
    devShells.${system} = {
      default = pkgs.mkShell {
        stdenv = pkgs.clangStdenv;
        packages = [
          pkgs.clang
          pkgs.cabal-install
          pkgs.hs-bindgen-cli
          pkgs.hsBindgenHook
        ];
        inputsFrom = [
          self.packages.${system}.default
        ];
      };
    };
    packages.${system} = {
      default = pkgs.haskellPackages.callPackage package {};
    };
  };
}