Skip to content

Commit 372e1a2

Browse files
committed
Add initial implementation of Nix flake and package
Signed-off-by: ReStranger <[email protected]>
1 parent 36cdf4f commit 372e1a2

File tree

3 files changed

+120
-0
lines changed

3 files changed

+120
-0
lines changed

flake.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
description = "Simple flake for build Audio Source";
3+
4+
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
5+
6+
outputs = { self, nixpkgs }:
7+
let
8+
systems = [
9+
"x86_64-linux"
10+
"aarch64-linux"
11+
];
12+
forAllSystems = nixpkgs.lib.genAttrs systems;
13+
pkgsForSystem = system: import nixpkgs { inherit system; };
14+
in
15+
{
16+
formatter = forAllSystems (system: (pkgsForSystem system).nixfmt-tree);
17+
packages = forAllSystems (system: {
18+
audiosource = import ./nix/package.nix {
19+
inherit (pkgsForSystem system)
20+
stdenv
21+
lib
22+
pkgs
23+
fetchFromGitHub
24+
makeWrapper
25+
;
26+
};
27+
default = self.packages.${system}.audiosource;
28+
});
29+
devShell = forAllSystems (
30+
system: with (pkgsForSystem system); {
31+
default = mkShell {
32+
inputsFrom = [ self.packages.${system}.default ];
33+
packages = [
34+
nixd
35+
nixfmt-tree
36+
bash-language-server
37+
];
38+
};
39+
}
40+
);
41+
};
42+
}

nix/package.nix

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
stdenv,
3+
lib,
4+
pkgs,
5+
fetchFromGitHub,
6+
makeWrapper,
7+
}:
8+
let
9+
runtimeBins = with pkgs; [
10+
android-tools
11+
python312
12+
pulseaudio
13+
];
14+
runtimePath = builtins.concatStringsSep ":" (map (pkg: "${pkg}/bin") runtimeBins);
15+
16+
in
17+
stdenv.mkDerivation (finalAttrs: {
18+
pname = "audiosource";
19+
version = "1.4";
20+
outputs = [
21+
"out"
22+
];
23+
src = fetchFromGitHub {
24+
owner = "gdzx";
25+
repo = "audiosource";
26+
rev = "v${finalAttrs.version}";
27+
hash = "sha256-SlX8gjs7X5jfoeU6pyk4n8f6oMJgneGVt0pmFs48+mQ=";
28+
};
29+
nativeBuildInputs = [ makeWrapper ];
30+
installPhase = ''
31+
runHook preInstall
32+
mkdir -p $out/bin
33+
install -Dm755 audiosource $out/bin/audiosource
34+
runHook postInstall
35+
'';
36+
postInstall = ''
37+
wrapProgram $out/bin/audiosource \
38+
--prefix PATH : "${runtimePath}"
39+
'';
40+
meta = with lib; {
41+
description = "Use an Android device as a USB microphone";
42+
mainProgram = "audiosource";
43+
homepage = "https://github.com/gdzx/audiosource";
44+
license = licenses.mit;
45+
platforms = [
46+
"x86_64-linux"
47+
"aarch64-linux"
48+
];
49+
maintainers = [ "ReStranger" ];
50+
};
51+
})

0 commit comments

Comments
 (0)