Skip to content

Commit 402019c

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

File tree

3 files changed

+121
-0
lines changed

3 files changed

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

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)