aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
blob: ba3000c92fed5175a8c0c5579a1d015523761308 (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
{
  description = "EZLive: Self-hosted Serverless Livestream";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let
        pkgs = nixpkgs.legacyPackages.${system};
      in
      {
        packages.default = pkgs.stdenv.mkDerivation {
          pname = "ezlive";
          version = "0.1.0";

          src = ./.;

          nativeBuildInputs = with pkgs; [
            pkg-config
          ];

          buildInputs = with pkgs; [
            ffmpeg
            aws-sdk-cpp
          ];

          makeFlags = [
            "CC=${pkgs.stdenv.cc}/bin/cc"
            "CXX=${pkgs.stdenv.cc}/bin/c++"
          ];

          installPhase = ''
            runHook preInstall
            mkdir -p $out/bin
            cp ezlive $out/bin/
            runHook postInstall
          '';

          meta = with pkgs.lib; {
            description = "Self-hosted Serverless Livestream built on top of S3-compatible object storage";
            homepage = "https://github.com/mistivia/ezlive";
            license = licenses.agpl3Only;
            maintainers = [ ];
            platforms = platforms.linux;
          };
        };

        devShells.default = pkgs.mkShell {
          buildInputs = with pkgs; [
            gcc
            gnumake
            pkg-config
            ffmpeg
            aws-sdk-cpp
          ];

          shellHook = ''
            echo "EZLive development environment"
            echo "Run 'make' to build the project"
          '';
        };

        packages.docker = pkgs.dockerTools.buildLayeredImage {
          name = "ezlive";
          tag = "latest";
          
          contents = [ self.packages.${system}.default ];
          
          config = {
            Cmd = [ "${self.packages.${system}.default}/bin/ezlive" ];
            WorkingDir = "/app";
          };
        };
      }
    );
}