aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
blob: cdd302704862db200f9fda32468d162085a66d27 (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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
{
  description = "Simple & Efficient Gemini-to-HTTP Proxy";

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

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

    rust-overlay = {
      url = "github:oxalica/rust-overlay";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

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

          overlays = [ (import rust-overlay) ];
        };

        craneLib = crane.mkLib pkgs;

        meta = with pkgs.lib; {
          homepage = "https://github.com/gemrest/september";
          description = "Simple & Efficient Gemini-to-HTTP Proxy";
          license = licenses.gpl3Only;
          maintainers = [ maintainers.Fuwn ];
          mainPackage = "september";
          platforms = platforms.linux;
        };

        september = craneLib.buildPackage {
          inherit meta;

          strictDeps = true;

          src = pkgs.lib.cleanSourceWith {
            src = ./.;

            filter =
              path: type:
              builtins.match ".*css$" path != null
              || builtins.match ".*\\.git.*" path != null
              || (craneLib.filterCargoSources path type);
          };
        };
      in
      {
        packages = {
          inherit september;

          default = self.packages.${system}.september;
        };

        apps = {
          september = {
            inherit meta;

            type = "app";
            program = "${self.packages.${system}.september}/bin/september";
          };

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

        devShells.default =
          with pkgs;
          mkShell.override
            {
              stdenv = stdenvAdapters.useMoldLinker clangStdenv;
            }
            {
              RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";

              buildInputs = [
                cargo-make
                openssl
                pkg-config
                cargo-watch

                (lib.hiPrio (
                  rust-bin.stable.latest.minimal.override {
                    extensions = [ "rust-docs" ];
                  }
                ))

                (rust-bin.selectLatestNightlyWith (
                  toolchain:
                  toolchain.minimal.override {
                    extensions = [ "rustfmt" ];
                  }
                ))
              ];
            };
      }
    );
}