Skip to content

Commit

Permalink
feat: create nix flake for lib and abrasive
Browse files Browse the repository at this point in the history
  • Loading branch information
SolarLiner committed Jan 20, 2024
1 parent 4b999d4 commit cc332d6
Show file tree
Hide file tree
Showing 2 changed files with 189 additions and 0 deletions.
111 changes: 111 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 78 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
naersk.url = "github:nix-community/naersk";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixpkgs-mozilla = {
url = "github:mozilla/nixpkgs-mozilla";
flake = false;
};
};

outputs = { self, flake-utils, naersk, nixpkgs, nixpkgs-mozilla }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = (import nixpkgs) {
inherit system;
overlays = [ (import nixpkgs-mozilla) ];
};

toolchain = (pkgs.rustChannelOf {
toolchain = ./rust-toolchain;
sha256 = "sha256-NNO9WVU8KfipdeTGgFnQ6Zlw3wImnN5RKAQPdAHG0d0=";
}).rust;
naersk' = pkgs.callPackage naersk {
cargo = toolchain;
rustc = toolchain;
};

package' = { pname, display-name, gui ? false }:
naersk'.buildPackage {
name = pname;
nativeBuildInputs = with pkgs; [ pkg-config python3 ];
buildInputs = if gui then
with pkgs;
with pkgs.xorg; [
alsa-lib
jack2
libGL
libX11
libxcb
libXcursor
xcbutilwm
]
else
[ ];
src = ./.;
cargoBuildOptions = opts: [ "-p ${pname}" ] ++ opts;
postInstall = ''
OUT_DIR=''${PWD}/target/release
LIBNAME=''${OUT_DIR}/lib${pname}.so
EXENAME=''${OUT_DIR}/${pname}
pwd
ls -alh
ls -alh $PWD/target
ls -alh $OUT_DIR
ls $LIBNAME $EXENAME
if [[ -f $LIBNAME ]]; then
mkdir -p $out/lib/{vst3,clap}
cp ''${LIBNAME} $out/lib/vst3/${display-name}.vst3
cp ''${LIBNAME} $out/lib/clap/${display-name}.clap
fi
'';
};
in rec {
packages.workspace = naersk'.buildPackage {
src = ./.;
doDoc = true;
};
packages.abrasive = package' {
pname = "abrasive";
display-name = "Abrasive";
gui = true;
};
defaultPackage = packages.workspace;
});
}

0 comments on commit cc332d6

Please sign in to comment.