diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..9226210 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1759632233, + "narHash": "sha256-krgZxGAIIIKFJS+UB0l8do3sYUDWJc75M72tepmVMzE=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d7f52a7a640bc54c7bb414cca603835bf8dd4b10", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..f66c507 --- /dev/null +++ b/flake.nix @@ -0,0 +1,42 @@ +{ + description = "Simple flake for build Audio Source"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + + outputs = { self, nixpkgs }: + let + systems = [ + "x86_64-linux" + "aarch64-linux" + ]; + forAllSystems = nixpkgs.lib.genAttrs systems; + pkgsForSystem = system: import nixpkgs { inherit system; }; + in + { + formatter = forAllSystems (system: (pkgsForSystem system).nixfmt-tree); + packages = forAllSystems (system: { + audiosource = import ./nix/package.nix { + inherit (pkgsForSystem system) + stdenv + lib + pkgs + fetchFromGitHub + makeWrapper + ; + }; + default = self.packages.${system}.audiosource; + }); + devShell = forAllSystems ( + system: with (pkgsForSystem system); { + default = mkShell { + inputsFrom = [ self.packages.${system}.default ]; + packages = [ + nixd + nixfmt-tree + bash-language-server + ]; + }; + } + ); + }; +} diff --git a/nix/package.nix b/nix/package.nix new file mode 100644 index 0000000..09936f4 --- /dev/null +++ b/nix/package.nix @@ -0,0 +1,51 @@ +{ + stdenv, + lib, + pkgs, + fetchFromGitHub, + makeWrapper, +}: +let + runtimeBins = with pkgs; [ + android-tools + python312 + pulseaudio + ]; + runtimePath = builtins.concatStringsSep ":" (map (pkg: "${pkg}/bin") runtimeBins); + +in +stdenv.mkDerivation (finalAttrs: { + pname = "audiosource"; + version = "1.4"; + outputs = [ + "out" + ]; + src = fetchFromGitHub { + owner = "gdzx"; + repo = "audiosource"; + rev = "v${finalAttrs.version}"; + hash = "sha256-SlX8gjs7X5jfoeU6pyk4n8f6oMJgneGVt0pmFs48+mQ="; + }; + nativeBuildInputs = [ makeWrapper ]; + installPhase = '' + runHook preInstall + mkdir -p $out/bin + install -Dm755 audiosource $out/bin/audiosource + runHook postInstall + ''; + postInstall = '' + wrapProgram $out/bin/audiosource \ + --prefix PATH : "${runtimePath}" + ''; + meta = with lib; { + description = "Use an Android device as a USB microphone"; + mainProgram = "audiosource"; + homepage = "https://github.com/gdzx/audiosource"; + license = licenses.mit; + platforms = [ + "x86_64-linux" + "aarch64-linux" + ]; + maintainers = [ "ReStranger" ]; + }; +})