Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nix support #6

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 18 additions & 27 deletions .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,33 @@ jobs:
doc:
name: Documentation
runs-on: ubuntu-22.04
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}/valib
permissions:
id-token: write
pages: write
steps:
- name: Install dependencies
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install -y libasound2-dev libgl-dev libjack-dev libx11-xcb-dev libxcb1-dev libxcb-dri2-0-dev libxcb-icccm4-dev libxcursor-dev libxkbcommon-dev libxcb-shape0-dev libxcb-xfixes0-dev
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ matrix.name }}-${{ matrix.cross-target }}
- name: Install Nix
uses: cachix/install-nix-action@v25
- name: Cache Nix derivations
uses: DeterminateSystems/magic-nix-cache-action@v2
- uses: actions/checkout@v2
- name: Fetch all git history
run: git fetch --force --prune --tags --unshallow
- name: Set up Rust toolchain
uses: actions-rs/toolchain@v1
- name: Build documentation
run: cargo doc --all-features --no-deps
run: nix build .#workspace.doc
- name: Fix permissions
run: |
chmod -c -R +rX "target/doc" | while read line; do
chmod -c -R +rX "_site/" | while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: target/doc
uses: actions/upload-pages-artifact@v2
doc-deploy:
needs: doc
permissions:
pages: write # to deploy to Pages
id-token: write # to verify the deployment originates from an appropriate source
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action
uses: actions/deploy-pages@v4 # or specific "vX.X.X" version tag for this action
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.

89 changes: 89 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
{
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) ];
};
inherit (pkgs) lib stdenv;

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

package' = { pname, display-name, gui ? false, vst3 ? false, clap ? false }:
naersk'.buildPackage {
name = pname;
nativeBuildInputs = with pkgs; [ pkg-config python3 ];
buildInputs = if gui then
with pkgs;
with pkgs.xorg; [
jack2
libGL
] ++ lib.optionals (!stdenv.isDarwin) [
alsa-lib
libX11
libxcb
libXcursor
xcbutilwm
]
else
[ ];
src = ./.;
cargoBuildOptions = opts: [ "-p ${pname}" ] ++ opts;
CREATE_VST3 = vst3;
CREATE_CLAP = clap;
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}
if (( ''${CREATE_VST3} )); then
cp ''${LIBNAME} $out/lib/vst3/${display-name}.vst3
fi
if (( ''${CREATE_CLAP} )); then
cp ''${LIBNAME} $out/lib/clap/${display-name}.clap
fi
fi
'';
};
in rec {
packages.valib = naersk'.buildPackage {
src = ./.;
doDoc = true;
};
packages.abrasive = package' {
pname = "abrasive";
display-name = "Abrasive";
gui = true;
vst3 = true;
clap = true;
};
defaultPackage = packages.valib;
apps.abrasive = flake-utils.lib.mkApp { drv = packages.abrasive; };
});
}
Loading
Loading