mirror of
https://github.com/kavishdevar/librepods.git
synced 2026-03-11 00:33:02 +00:00
feat(nix): add comprehensive Nix flake for linux-rust
This commit is contained in:
180
flake.nix
180
flake.nix
@@ -1,67 +1,141 @@
|
||||
|
||||
{
|
||||
description = "A Nix-flake-based Rust development environment";
|
||||
description = "AirPods liberated from Apple's ecosystem";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
crane.url = "github:ipetkov/crane";
|
||||
flake-parts.url = "github:hercules-ci/flake-parts";
|
||||
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.tar.gz";
|
||||
systems.url = "github:nix-systems/default";
|
||||
treefmt-nix.url = "github:numtide/treefmt-nix";
|
||||
};
|
||||
|
||||
outputs =
|
||||
{ self, nixpkgs, ... }@inputs:
|
||||
|
||||
let
|
||||
supportedSystems = [
|
||||
"x86_64-linux"
|
||||
inputs@{
|
||||
self,
|
||||
crane,
|
||||
flake-parts,
|
||||
systems,
|
||||
...
|
||||
}:
|
||||
flake-parts.lib.mkFlake { inherit inputs; } {
|
||||
systems = import systems;
|
||||
imports = [
|
||||
inputs.treefmt-nix.flakeModule
|
||||
];
|
||||
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
||||
pkgsFor = system: import nixpkgs {
|
||||
inherit system;
|
||||
};
|
||||
in
|
||||
{
|
||||
packages = forAllSystems (system: let
|
||||
pkgs = pkgsFor system;
|
||||
in {
|
||||
default = pkgs.rustPlatform.buildRustPackage rec {
|
||||
name = "librepods";
|
||||
version = "0.1.0";
|
||||
|
||||
doCheck = false;
|
||||
perSystem =
|
||||
{
|
||||
self',
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
let
|
||||
buildInputs =
|
||||
with pkgs;
|
||||
[
|
||||
dbus
|
||||
libpulseaudio
|
||||
alsa-lib
|
||||
bluez
|
||||
# https://github.com/max-privatevoid/iced/blob/master/DEPENDENCIES.md
|
||||
expat
|
||||
fontconfig
|
||||
freetype
|
||||
freetype.dev
|
||||
libGL
|
||||
pkg-config
|
||||
xorg.libX11
|
||||
xorg.libXcursor
|
||||
xorg.libXi
|
||||
xorg.libXrandr
|
||||
wayland
|
||||
libxkbcommon
|
||||
vulkan-loader
|
||||
]
|
||||
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
|
||||
pkgs.libiconv
|
||||
];
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
pkg-config
|
||||
libpulseaudio
|
||||
autoPatchelfHook
|
||||
makeWrapper
|
||||
];
|
||||
nativeBuildInputs = with pkgs; [
|
||||
pkg-config
|
||||
makeWrapper
|
||||
];
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
dbus
|
||||
libpulseaudio
|
||||
wayland
|
||||
craneLib = crane.mkLib pkgs;
|
||||
unfilteredRoot = ./linux-rust/.;
|
||||
src = lib.fileset.toSource {
|
||||
root = unfilteredRoot;
|
||||
fileset = lib.fileset.unions [
|
||||
# Default files from crane (Rust and cargo files)
|
||||
(craneLib.fileset.commonCargoSources unfilteredRoot)
|
||||
(lib.fileset.maybeMissing ./linux-rust/assets/font)
|
||||
];
|
||||
};
|
||||
|
||||
# From https://github.com/max-privatevoid/iced/blob/master/DEPENDENCIES.md
|
||||
expat
|
||||
fontconfig
|
||||
freetype
|
||||
freetype.dev
|
||||
libGL
|
||||
pkg-config
|
||||
xorg.libX11
|
||||
xorg.libXcursor
|
||||
xorg.libXi
|
||||
xorg.libXrandr
|
||||
wayland
|
||||
libxkbcommon
|
||||
];
|
||||
commonArgs = {
|
||||
inherit buildInputs nativeBuildInputs src;
|
||||
strictDeps = true;
|
||||
|
||||
src = ./linux-rust;
|
||||
cargoHash = "sha256-Ebqx+UU2tdygvqvDGjBSxbkmPnkR47/yL3sCVWo54CU=";
|
||||
RUST_BACKTRACE = "1";
|
||||
};
|
||||
|
||||
postFixup = ''
|
||||
wrapProgram $out/bin/librepods --suffix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath buildInputs}
|
||||
'';
|
||||
};
|
||||
});
|
||||
};
|
||||
librepods = craneLib.buildPackage (
|
||||
commonArgs
|
||||
// {
|
||||
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
||||
|
||||
doCheck = false;
|
||||
|
||||
# Wrap the binary after build to set runtime library path
|
||||
postInstall = ''
|
||||
wrapProgram $out/bin/librepods \
|
||||
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs}
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "AirPods liberated from Apple's ecosystem";
|
||||
homepage = "https://github.com/kavishdevar/librepods";
|
||||
license = pkgs.lib.licenses.gpl3Only;
|
||||
maintainers = [ "kavishdevar" ];
|
||||
platforms = pkgs.lib.platforms.unix;
|
||||
mainProgram = "librepods";
|
||||
};
|
||||
}
|
||||
);
|
||||
in
|
||||
{
|
||||
# checks = {
|
||||
# inherit librepods;
|
||||
# };
|
||||
|
||||
packages.default = librepods;
|
||||
apps.default = {
|
||||
type = "app";
|
||||
program = lib.getExe librepods;
|
||||
};
|
||||
|
||||
devShells.default = craneLib.devShell {
|
||||
name = "librepods-dev";
|
||||
checks = self'.checks;
|
||||
|
||||
# NOTE: cargo and rustc are provided by default.
|
||||
buildInputs =
|
||||
with pkgs;
|
||||
[
|
||||
rust-analyzer
|
||||
]
|
||||
++ buildInputs;
|
||||
|
||||
# LD_LIBRARY_PATH = builtins.foldl' (a: b: "${a}:${b}/lib") "${pkgs.vulkan-loader}/lib" buildInputs;
|
||||
LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
|
||||
};
|
||||
|
||||
treefmt = {
|
||||
programs.nixfmt.enable = pkgs.lib.meta.availableOn pkgs.stdenv.buildPlatform pkgs.nixfmt-rfc-style.compiler;
|
||||
programs.nixfmt.package = pkgs.nixfmt-rfc-style;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user