aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
blob: b301e2d99a7dfddeb4afe95d3c081589d10ea8eb (plain) (blame)
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
87
88
89
90
91
92
93
94
95
96
97
{
  description = "A very simple static Gemini server, now with Titan support!";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs";
    systems.url = "github:nix-systems/default";

    flake-compat = {
      url = "github:edolstra/flake-compat";
      flake = false;
    };

    flake-utils = {
      url = "github:numtide/flake-utils";
      inputs.systems.follows = "systems";
    };
  };

  outputs =
    {
      nixpkgs,
      flake-utils,
      self,
      ...
    }:
    flake-utils.lib.eachDefaultSystem (
      system:
      let
        pkgs = import nixpkgs { inherit system; };

        meta = with pkgs.lib; {
          description = "A very simple static Gemini server, now with Titan support!";
          homepage = "https://github.com/gemrest/maple";
          license = licenses.gpl3Only;
          maintainers = [ maintainers.Fuwn ];
          mainPackage = "maple";
          platforms = platforms.unix;
        };

        maple =
          with pkgs;
          (
            if pkgs.stdenv.isDarwin then
              pkgs.clangStdenvNoLibs
            else
              pkgs.stdenvAdapters.useMoldLinker pkgs.clangStdenvNoLibs
          ).mkDerivation
            {
              inherit meta;

              name = "maple";
              version = "0.1.6";
              src = lib.cleanSource ./.;

              nativeBuildInputs = [
                ninja
                clang
              ];

              buildInputs = [
                libressl.dev
              ];

              buildPhase = ''
                mkdir -p $out/bin
                ninja
              '';

              installPhase = ''
                cp build/maple $out/bin/maple
              '';
            };
      in
      {
        packages = {
          inherit maple;

          default = maple;
        };

        apps = {
          maple = {
            inherit meta;

            type = "app";
            program = "${maple}/bin/maple";
          };

          default = self.apps.${system}.maple;
        };

        devShells.default = import ./shell.nix {
          inherit pkgs;
        };
      }
    );
}