From e2d17b8bae0c823107f7d2a2032cf55750d72699 Mon Sep 17 00:00:00 2001 From: Sophia Date: Thu, 11 Dec 2025 20:07:58 +0100 Subject: [PATCH] linux-rust: add nix flake (#371) * build: :construction_worker: add nix flake * chore: :see_no_evil: add nix's result to gitignore --- .gitignore | 3 +++ flake.lock | 27 ++++++++++++++++++++++ flake.nix | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index ed06b89..c18fa33 100644 --- a/.gitignore +++ b/.gitignore @@ -659,3 +659,6 @@ 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 +result diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..c630f97 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1764517877, + "narHash": "sha256-pp3uT4hHijIC8JUK5MEqeAWmParJrgBVzHLNfJDZxg4=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "2d293cbfa5a793b4c50d17c05ef9e385b90edf6c", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..2caf7a5 --- /dev/null +++ b/flake.nix @@ -0,0 +1,67 @@ + +{ + description = "A Nix-flake-based Rust development environment"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + }; + + outputs = + { self, nixpkgs, ... }@inputs: + + let + supportedSystems = [ + "x86_64-linux" + ]; + 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} + ''; + }; + }); + }; +}