Skip to content
Merged
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
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -660,5 +660,9 @@ obj/
# End of https://www.toptal.com/developers/gitignore/api/qt,c++,clion,kotlin,python,android,pycharm,androidstudio,visualstudiocode,linux
linux/.qmlls.ini

# Nix build symlink
# Nix
result
result-*

# direnv
.direnv
12 changes: 12 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(import (
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
nodeName = lock.nodes.root.inputs.flake-compat;
in
fetchTarball {
url =
lock.nodes.${nodeName}.locked.url
or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.${nodeName}.locked.rev}.tar.gz";
sha256 = lock.nodes.${nodeName}.locked.narHash;
}
) { src = ./.; }).defaultNix
126 changes: 121 additions & 5 deletions flake.lock

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

192 changes: 133 additions & 59 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -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;

nativeBuildInputs = with pkgs; [
pkg-config
libpulseaudio
autoPatchelfHook
makeWrapper
];

buildInputs = with pkgs; [
dbus
libpulseaudio
wayland

# 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
];

src = ./linux-rust;
cargoHash = "sha256-Ebqx+UU2tdygvqvDGjBSxbkmPnkR47/yL3sCVWo54CU=";

postFixup = ''
wrapProgram $out/bin/librepods --suffix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath buildInputs}
'';
};
});
};

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
makeWrapper
];

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)
];
};

commonArgs = {
inherit buildInputs nativeBuildInputs src;
strictDeps = true;

# RUST_BACKTRACE = "1";
};

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 = 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;
};
};
};
}
Loading