diff --git a/flake.nix b/flake.nix index e7ba46d..8019bda 100644 --- a/flake.nix +++ b/flake.nix @@ -1,5 +1,5 @@ { - description = "A C library with a clean API"; + description = "Image Processor C API"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; @@ -9,37 +9,34 @@ self, nixpkgs, }: let - # Support for multiple systems (Linux and macOS) supportedSystems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"]; forAllSystems = nixpkgs.lib.genAttrs supportedSystems; - pkgsFor = system: import nixpkgs {inherit system;}; in { - # This is the actual library package packages = forAllSystems (system: let - pkgs = pkgsFor system; + pkgs = import nixpkgs {inherit system;}; in { default = pkgs.stdenv.mkDerivation { - pname = "my-c-api"; + pname = "image-processor"; version = "0.1.0"; - src = ./.; + src = ./.; # Since the flake is in the repo, we use local source - # Add dependencies here + # nativeBuildInputs are tools needed at build time (like CMake) + nativeBuildInputs = [pkgs.cmake pkgs.pkg-config]; + + # buildInputs are libraries your API depends on (e.g., libpng, opencv) buildInputs = []; - nativeBuildInputs = [pkgs.pkg-config]; - # Nix expects a standard 'make install' by default. - # Ensure your Makefile handles $(DESTDIR)$(PREFIX) correctly. - installFlags = ["PREFIX=$(out)"]; + # Nix automatically runs: cmakeConfigurePhase, buildPhase, installPhase + # You just need to ensure your CMakeLists.txt has 'install()' targets. }; }); - # This provides 'nix develop' for you to work on the API itself devShells = forAllSystems (system: let - pkgs = pkgsFor system; + pkgs = import nixpkgs {inherit system;}; in { default = pkgs.mkShell { inputsFrom = [self.packages.${system}.default]; - packages = with pkgs; [gdb valgrind clang-tools]; + packages = [pkgs.gdb]; }; }); };