Add Nix flake 7096e28f parent 74d532d9

authored by ~talya

flake.lock 27 +++++++++++++++++++++++++
flake.nix 81 +++++++++++++++++++++++++
2 files changed, 108 insertions(+), 0 deletions(-)
flake.lock (new file)
@@ -0,0 +1,27 @@
1 + {
2 + "nodes": {
3 + "nixpkgs": {
4 + "locked": {
5 + "lastModified": 1768323494,
6 + "narHash": "sha256-yBXJLE6WCtrGo7LKiB6NOt6nisBEEkguC/lq/rP3zRQ=",
7 + "owner": "NixOS",
8 + "repo": "nixpkgs",
9 + "rev": "2c3e5ec5df46d3aeee2a1da0bfedd74e21f4bf3a",
10 + "type": "github"
11 + },
12 + "original": {
13 + "owner": "NixOS",
14 + "ref": "nixos-25.11",
15 + "repo": "nixpkgs",
16 + "type": "github"
17 + }
18 + },
19 + "root": {
20 + "inputs": {
21 + "nixpkgs": "nixpkgs"
22 + }
23 + }
24 + },
25 + "root": "root",
26 + "version": 7
27 + }
flake.nix (new file)
@@ -0,0 +1,81 @@
1 + {
2 + description = "blissify-rs";
3 +
4 + inputs = {
5 + nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
6 + };
7 +
8 + outputs =
9 + {
10 + nixpkgs,
11 + ...
12 + }:
13 + let
14 + systems = [
15 + "aarch64-darwin"
16 + "aarch64-linux"
17 + "x86_64-darwin"
18 + "x86_64-linux"
19 + ];
20 + eachSystem = nixpkgs.lib.genAttrs systems;
21 + in
22 + {
23 +
24 + packages = eachSystem (
25 + system:
26 + let
27 + pkgs = nixpkgs.legacyPackages.${system};
28 + cargoToml = pkgs.lib.importTOML ./Cargo.toml;
29 +
30 + mkBlissifyRs =
31 + pkgs:
32 + pkgs.rustPlatform.buildRustPackage {
33 + pname = "blissify-rs";
34 + inherit (cargoToml.package) version;
35 +
36 + nativeBuildInputs = with pkgs; [
37 + pkg-config
38 + llvmPackages.libclang
39 + llvmPackages.libcxxClang
40 + clang
41 + ];
42 +
43 + buildInputs = with pkgs; [
44 + ffmpeg
45 + sqlite
46 + ];
47 +
48 + LIBCLANG_PATH = with pkgs; "${llvmPackages.libclang.lib}/lib";
49 +
50 + # This step per https://hoverbear.org/blog/rust-bindgen-in-nix/.
51 + # I haven't tried reducing it to see what's strictly necessary.
52 + preBuild =
53 + let
54 + inherit (pkgs) stdenv lib;
55 + in
56 + ''
57 + export BINDGEN_EXTRA_CLANG_ARGS="$(< ${stdenv.cc}/nix-support/libc-crt1-cflags) \
58 + $(< ${stdenv.cc}/nix-support/libc-cflags) \
59 + $(< ${stdenv.cc}/nix-support/cc-cflags) \
60 + $(< ${stdenv.cc}/nix-support/libcxx-cxxflags) \
61 + ${lib.optionalString stdenv.cc.isClang "-idirafter ${stdenv.cc.cc}/lib/clang/${lib.getVersion stdenv.cc.cc}/include"} \
62 + ${lib.optionalString stdenv.cc.isGNU "-isystem ${stdenv.cc.cc}/include/c++/${lib.getVersion stdenv.cc.cc} -isystem ${stdenv.cc.cc}/include/c++/${lib.getVersion stdenv.cc.cc}/${stdenv.hostPlatform.config} -idirafter ${stdenv.cc.cc}/lib/gcc/${stdenv.hostPlatform.config}/${lib.getVersion stdenv.cc.cc}/include"} \
63 + "
64 + '';
65 +
66 + src = ./.;
67 + cargoLock.lockFile = ./Cargo.lock;
68 +
69 + doCheck = false;
70 + };
71 + in
72 + rec {
73 + default = blissify-rs;
74 +
75 + blissify-rs = mkBlissifyRs pkgs;
76 + }
77 + );
78 +
79 + formatter = eachSystem (system: nixpkgs.legacyPackages.${system}.nixfmt);
80 + };
81 + }