Skip to content

Commit

Permalink
feat: add nix flake
Browse files Browse the repository at this point in the history
  • Loading branch information
flexiondotorg committed Jul 22, 2024
1 parent 2244197 commit 53575da
Show file tree
Hide file tree
Showing 6 changed files with 142 additions and 0 deletions.
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.direnv/
stream-sprout.yaml
15 changes: 15 additions & 0 deletions devshell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{ lib,
mkShell,
pkgs,
stdenv,
}:
mkShell {
packages = with pkgs; ([
ffmpeg-headless
procps
yq-go
]);

shellHook = ''
'';
}
40 changes: 40 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
description = "Stream Sprout flake";
inputs = {
flake-schemas.url = "https://flakehub.com/f/DeterminateSystems/flake-schemas/*.tar.gz";
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/*.tar.gz";
};

outputs = {
self,
flake-schemas,
nixpkgs,
}: let
# Define supported systems and a helper function for generating system-specific outputs
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" "aarch64-linux" ];

forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
system = system;
pkgs = import nixpkgs { inherit system; };
});
in {
# Define schemas for the flake's outputs
schemas = flake-schemas.schemas;

# Define overlays for each supported system
overlays = forEachSupportedSystem ({pkgs, system, ...}: {
default = final: prev: {
stream-sprout = final.callPackage ./package.nix { };
};
});

# Define packages for each supported system
packages = forEachSupportedSystem ({pkgs, system, ...}: rec {
stream-sprout = pkgs.callPackage ./package.nix { };
default = stream-sprout;
});

# Define devShells for each supported system
devShells = forEachSupportedSystem ({pkgs, system, ...}: {
default = pkgs.callPackage ./devshell.nix { };
});
};
}
42 changes: 42 additions & 0 deletions package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{ lib
, installShellFiles
, makeWrapper
, stdenv
, ffmpeg-headless
, procps
, yq-go
}:
let
runtimePaths = [
ffmpeg-headless
procps
yq
];
versionMatches =
builtins.match ''
.*
readonly[[:blank:]]VERSION="([[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+)"
.*
'' (builtins.readFile ./stream-sprout);
in
stdenv.mkDerivation rec {
pname = "stream-sprout";
version = builtins.concatStringsSep "" versionMatches;
src = lib.cleanSource ./.;

nativeBuildInputs = [ makeWrapper installShellFiles ];

installPhase = ''
runHook preInstall
install -Dm755 -t "$out/bin" stream-sprout
runHook postInstall
'';

meta = {
description = "Re-stream a video source to multiple destinations such as Twitch, YouTube, and Owncast.";
homepage = "https://github.com/wimpys-world/stream-sprout";
mainProgram = "stream-sprout";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ flexiondotorg ];
};
}

0 comments on commit 53575da

Please sign in to comment.