From adc35e1558cc96478c03dfae1751d0a0e6993f68 Mon Sep 17 00:00:00 2001 From: rm-dr <96270320+rm-dr@users.noreply.github.com> Date: Wed, 11 Mar 2026 10:39:00 -0700 Subject: [PATCH] Add nix files --- default.nix | 47 +++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+) create mode 100644 default.nix create mode 100644 flake.nix diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..538066f --- /dev/null +++ b/default.nix @@ -0,0 +1,47 @@ +let + rustOverlay = import ( + builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz" + ); + pkgsDefault = import { overlays = [ rustOverlay ]; }; + rustToolchain = pkgsDefault.rust-bin.stable."1.94.0".default; + rustPlatformDefault = pkgsDefault.makeRustPlatform { + cargo = rustToolchain; + rustc = rustToolchain; + }; +in +{ + pkgs ? pkgsDefault, + rustPlatform ? rustPlatformDefault, +}: + +rustPlatform.buildRustPackage { + pname = "pile"; + version = "0.0.1"; + src = ./.; + + cargoLock.lockFile = ./Cargo.lock; + + buildInputs = [ + pkgs.pdfium-binaries + pkgs.openssl + ] + ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ + pkgs.darwin.apple_sdk.frameworks.Security + pkgs.darwin.apple_sdk.frameworks.SystemConfiguration + ]; + + nativeBuildInputs = [ + pkgs.pkg-config + pkgs.makeWrapper + ]; + + postInstall = '' + wrapProgram $out/bin/pile \ + --prefix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath [ pkgs.pdfium-binaries ]} + ''; + + meta = { + description = "pile - flexible file indexing"; + mainProgram = "pile"; + }; +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..0f43458 --- /dev/null +++ b/flake.nix @@ -0,0 +1,40 @@ +{ + description = "pile - personal data indexer"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + rust-overlay = { + url = "github:oxalica/rust-overlay"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, rust-overlay, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { inherit system overlays; }; + + rustToolchain = pkgs.rust-bin.stable."1.94.0".default; + + rustPlatform = pkgs.makeRustPlatform { + cargo = rustToolchain; + rustc = rustToolchain; + }; + + in { + packages.default = import ./default.nix { inherit pkgs rustPlatform; }; + + devShells.default = pkgs.mkShell { + buildInputs = [ + rustToolchain + pkgs.pdfium-binaries + pkgs.openssl + pkgs.pkg-config + ]; + + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath [ pkgs.pdfium-binaries ]; + }; + }); +}