From c6a35484eae7b4464dee6d548bdd21016ceb9fa5 Mon Sep 17 00:00:00 2001 From: blissful Date: Sun, 12 May 2024 13:58:09 -0400 Subject: [PATCH] add ffmpeg zig dependency --- Makefile | 2 +- flake.lock | 45 +++++++++++++++++++++++++++++++++++++- flake.nix | 17 +++++++++------ rose-zig/build.zig | 5 +++++ rose-zig/build.zig.zon | 4 ++++ rose-zig/deps.nix | 49 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 114 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 2f17f51..f593c0c 100644 --- a/Makefile +++ b/Makefile @@ -35,4 +35,4 @@ clean: nixify-zig-deps: cd rose-zig && zon2nix > deps.nix -.PHONY: build-zig check test typecheck lintcheck lint clean nixify-zig-deps +.PHONY: help check build-zig test-py test-zig test typecheck lintcheck lint clean nixify-zig-deps diff --git a/flake.lock b/flake.lock index 488bea8..d3848f9 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,26 @@ { "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "zon2nix-src", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1698882062, + "narHash": "sha256-HkhafUayIqxXyHH1X8d9RDl1M2CkFgZLjKD3MzabiEo=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "8c9fa2545007b49a5db5f650ae91f227672c3877", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, "flake-utils": { "inputs": { "systems": "systems" @@ -37,7 +58,8 @@ "root": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "zon2nix-src": "zon2nix-src" } }, "systems": { @@ -54,6 +76,27 @@ "repo": "default", "type": "github" } + }, + "zon2nix-src": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1715536407, + "narHash": "sha256-ow/4w6dV2fpi/dY2SHksDg2pZZwam3dH29bCyR92pmI=", + "owner": "azuline", + "repo": "zon2nix", + "rev": "88a009e478480c313ed9c013d3efac411557c9ae", + "type": "github" + }, + "original": { + "owner": "azuline", + "repo": "zon2nix", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 2fd5f7b..44004e7 100644 --- a/flake.nix +++ b/flake.nix @@ -4,12 +4,16 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; + # Bug in upstream: https://github.com/nix-community/zon2nix/pull/8. + zon2nix-src.url = "github:azuline/zon2nix"; + zon2nix-src.inputs.nixpkgs.follows = "nixpkgs"; }; outputs = { self , nixpkgs , flake-utils + , zon2nix-src }: flake-utils.lib.eachDefaultSystem (system: let @@ -52,6 +56,7 @@ python-with-deps = python-pin.withPackages (_: pkgs.lib.attrsets.mapAttrsToList (a: b: b) py-deps ); + zon2nix = zon2nix-src.packages.${system}.default; in { devShells.default = pkgs.mkShell { @@ -73,13 +78,13 @@ buildInputs = [ (pkgs.buildEnv { name = "rose-devshell"; - paths = with pkgs; [ + paths = [ + pkgs.ruff + pkgs.nodePackages.pyright + pkgs.nodePackages.prettier + pkgs.zig + pkgs.zls python-with-deps - ruff - nodePackages.pyright - nodePackages.prettier - zig - zls zon2nix ]; }) diff --git a/rose-zig/build.zig b/rose-zig/build.zig index 614c298..8306375 100644 --- a/rose-zig/build.zig +++ b/rose-zig/build.zig @@ -9,6 +9,10 @@ pub fn build(b: *std.Build) void { .target = target, .optimize = optimize, }); + const ffmpeg = b.dependency("ffmpeg", .{ + .target = target, + .optimize = optimize, + }); // Specify the core library module. const rose = b.addModule("rose", .{ @@ -16,6 +20,7 @@ pub fn build(b: *std.Build) void { .target = target, .optimize = optimize, .imports = &[_]std.Build.Module.Import{ + .{ .name = "av", .module = ffmpeg.module("av") }, .{ .name = "sqlite", .module = sqlite.module("sqlite") }, }, }); diff --git a/rose-zig/build.zig.zon b/rose-zig/build.zig.zon index 04a6fe7..e739b2b 100644 --- a/rose-zig/build.zig.zon +++ b/rose-zig/build.zig.zon @@ -6,6 +6,10 @@ .url = "https://github.com/vrischmann/zig-sqlite/archive/dc339b7cf3bca82a12c2169231dd247587766781.tar.gz", .hash = "1220e0961c135c5aa3af77a043dbc5890a18235a157238df0e2882fe84a8c8439c7a", }, + .ffmpeg = .{ + .url = "https://github.com/andrewrk/ffmpeg/archive/1704e8898ea6217df91e6afc2a2de3f2b82a98d9.tar.gz", + .hash = "1220dd6f0bbf4614f338d632473e4b0a879ec26eca445ed305dcdbc6b5cb6405e3cd", + }, }, .paths = .{""}, } diff --git a/rose-zig/deps.nix b/rose-zig/deps.nix index a6d7ce3..5ebb052 100644 --- a/rose-zig/deps.nix +++ b/rose-zig/deps.nix @@ -3,6 +3,55 @@ { linkFarm, fetchzip }: linkFarm "zig-packages" [ + { + name = "122004fa7e2ff0b3d472049743358f8fdf065cdf63bc0e5e3d54c6bb8d81d93e40da"; + path = fetchzip { + url = "https://github.com/andrewrk/nasm/archive/b5f62392d56baf6aa02567f28e0da70664609262.tar.gz"; + hash = "sha256-tPBQixxG+phvEfRHeOLHMjY1Ynp7r9zNSgRy4R/ILQM="; + }; + } + { + name = "1220138f4aba0c01e66b68ed9e1e1e74614c06e4743d88bc58af4f1c3dd0aae5fea7"; + path = fetchzip { + url = "https://github.com/allyourcodebase/zlib/archive/refs/tags/1.3.1-3.tar.gz"; + hash = "sha256-R1tB+ORO3qeV/cNxsp5GqsiOyKUXjaj4Pd1v5AfWYz4="; + }; + } + { + name = "122074e0bf09c3622780e697c11c6744e763dd63777e480baf2b583ee3ab6a02ff14"; + path = fetchzip { + url = "https://github.com/andrewrk/libvorbis/archive/refs/tags/1.3.8-3.tar.gz"; + hash = "sha256-KHKYT3tmab9qYu8N2iJwm1rS+mU7Cwnn8Jp0cfOdnIg="; + }; + } + { + name = "12207d353609d95cee9da7891919e6d9582e97b7aa2831bd50f33bf523a582a08547"; + path = fetchzip { + url = "https://github.com/madler/zlib/archive/refs/tags/v1.3.tar.gz"; + hash = "sha256-eUuXV5zfy+fmiMNdWw5QCqDloBkaxy1tgi7by9nYHNA="; + }; + } + { + name = "1220b3e1fb33317c92f9ead09630f6b4be59e80d0a8780754f8aa4ee7da61cb7b47a"; + path = fetchzip { + url = "https://github.com/andrewrk/libogg/archive/refs/tags/1.3.6-2.tar.gz"; + hash = "sha256-3dFDBo4Af58bW8Gf+sHLigwo8CO2siwzWWtAoYe5opI="; + }; + } + { + name = "1220bee0fcf98bf6ad75b7bb09ff1f873ca38547a15b1e7a4532d20d94107d8d330a"; + path = fetchzip { + url = "https://github.com/andrewrk/libmp3lame/archive/refs/tags/3.100.1-3.tar.gz"; + hash = "sha256-kMI7JACnIVAdUHp5DUKx2XfKgIb1ftr6x/oYJdsTKyI="; + }; + } + { + name = "1220dd6f0bbf4614f338d632473e4b0a879ec26eca445ed305dcdbc6b5cb6405e3cd"; + path = fetchzip { + url = "https://github.com/andrewrk/ffmpeg/archive/1704e8898ea6217df91e6afc2a2de3f2b82a98d9.tar.gz"; + hash = "sha256-6EYu1QT76cJQMW9F41DvXsVLulH1YwGrkhwSV6IsBes="; + }; + } { name = "1220e0961c135c5aa3af77a043dbc5890a18235a157238df0e2882fe84a8c8439c7a"; path = fetchzip {