Add flake and some utils

This commit is contained in:
Sam W 2022-07-01 19:38:37 +01:00
commit f99b7ba23d
7 changed files with 189 additions and 0 deletions

1
.envrc Normal file
View File

@ -0,0 +1 @@
use flake

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.direnv

1
README.md Normal file
View File

@ -0,0 +1 @@
This is discosip, PRJ16, an attempt to enable use of discord from a SIP phone.

92
flake.lock Normal file
View File

@ -0,0 +1,92 @@
{
"nodes": {
"devshell": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1655976588,
"narHash": "sha256-VreHyH6ITkf/1EX/8h15UqhddJnUleb0HgbC3gMkAEQ=",
"owner": "numtide",
"repo": "devshell",
"rev": "899ca4629020592a13a46783587f6e674179d1db",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "devshell",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1642700792,
"narHash": "sha256-XqHrk7hFb+zBvRg6Ghl+AZDq03ov6OshJLiSWOoX5es=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "846b2ae0fc4cc943637d3d1def4454213e203cba",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1643381941,
"narHash": "sha256-pHTwvnN4tTsEKkWlXQ8JMY423epos8wUOhthpwJjtpc=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5efc8ca954272c4376ac929f4c5ffefcc20551d5",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1656490020,
"narHash": "sha256-xonV1ITvAtwtoM58Iaz77mrkkj3NQKvP2QOPYZNiNvs=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "23488b5815ef60b3084a874f71fdae2dff52e1f7",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"devshell": "devshell",
"nixpkgs": "nixpkgs_2",
"utils": "utils"
}
},
"utils": {
"locked": {
"lastModified": 1656065134,
"narHash": "sha256-oc6E6ByIw3oJaIyc67maaFcnjYOz1mMcOtHxbEf9NwQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "bee6a7250dd1b01844a2de7e02e4df7d8a0a206c",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

28
flake.nix Normal file
View File

@ -0,0 +1,28 @@
{
description = "A basic flake from samw";
inputs = {
utils.url = "github:numtide/flake-utils";
devshell.url = "github:numtide/devshell";
};
outputs = {
self,
nixpkgs,
utils,
devshell,
}:
utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [devshell.overlay];
};
in {
devShells.default = pkgs.devshell.mkShell {
packages = with pkgs; [
ffmpeg
(callPackage ./pjsip {inherit (darwin.apple_sdk.frameworks) AppKit;})
];
};
formatter = pkgs.alejandra;
});
}

53
pjsip/default.nix Normal file
View File

@ -0,0 +1,53 @@
{
lib,
stdenv,
fetchFromGitHub,
openssl,
libsamplerate,
alsa-lib,
AppKit,
fetchpatch,
}:
stdenv.mkDerivation rec {
pname = "pjsip";
version = "2.12.1";
src = fetchFromGitHub {
owner = pname;
repo = "pjproject";
rev = version;
sha256 = "sha256-HIDL4xzzTu3irzrIOf8qSNCAvHGOMpi8EDeqZb8mMnc=";
};
patches = [
./fix-aarch64.patch
];
buildInputs =
[openssl libsamplerate]
++ lib.optional stdenv.isLinux alsa-lib
++ lib.optional stdenv.isDarwin AppKit;
preConfigure = ''
export LD=$CC
'';
postInstall = ''
mkdir -p $out/bin
cp pjsip-apps/bin/pjsua-* $out/bin/pjsua
mkdir -p $out/share/${pname}-${version}/samples
cp pjsip-apps/bin/samples/*/* $out/share/${pname}-${version}/samples
'';
# We need the libgcc_s.so.1 loadable (for pthread_cancel to work)
dontPatchELF = true;
meta = with lib; {
description = "A multimedia communication library written in C, implementing standard based protocols such as SIP, SDP, RTP, STUN, TURN, and ICE";
homepage = "https://pjsip.org/";
license = licenses.gpl2Plus;
maintainers = with maintainers; [olynch];
mainProgram = "pjsua";
platforms = platforms.linux ++ platforms.darwin;
};
}

13
pjsip/fix-aarch64.patch Normal file
View File

@ -0,0 +1,13 @@
--- a/aconfigure
+++ b/aconfigure
@@ -9174,6 +9174,10 @@
ac_webrtc_instset=neon
ac_webrtc_cflags="-DWEBRTC_ARCH_ARM64"
;;
+ arm64*|aarch64*)
+ ac_webrtc_instset=neon
+ ac_webrtc_cflags="-DWEBRTC_ARCH_ARM64"
+ ;;
*)
ac_webrtc_instset=sse2
;;