updated flake.nix to cache

This commit is contained in:
Andrew Haynes
2026-03-26 10:11:12 -04:00
parent 5fb7893518
commit b725a006bf
+32 -14
View File
@@ -3,39 +3,57 @@
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
# Ghostty uses 'systems' to be cleaner, we can do similar or stick to a list
};
# This mirrors the Ghostty 'nixConfig' to ensure settings stay local to the project
nixConfig = {
extra-substituters = ["https://cache.nixos.org"];
extra-trusted-public-keys = ["cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="];
}; };
outputs = { outputs = {
self, self,
nixpkgs, nixpkgs,
}: let }: let
supportedSystems = ["aarch64-darwin" "x86_64-darwin" "x86_64-linux"]; supportedSystems = ["aarch64-darwin" "x86_64-darwin" "aarch64-linux" "x86_64-linux"];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems; # A helper to generate outputs for all systems
pkgsFor = system: import nixpkgs {inherit system;}; forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f (import nixpkgs {inherit system;}));
in { in {
# This allows other flakes to "consume" this library # 1. THE PACKAGE (What you 'pull' into other projects)
packages = forAllSystems (system: let packages = forAllSystems (pkgs: {
pkgs = pkgsFor system;
in {
default = pkgs.stdenv.mkDerivation { default = pkgs.stdenv.mkDerivation {
pname = "image_processor"; pname = "image_processor";
version = "0.1.0"; version = "0.1.0";
src = ./.; src = ./.;
nativeBuildInputs = [pkgs.cmake pkgs.pkg-config]; nativeBuildInputs = [pkgs.cmake pkgs.pkg-config];
buildInputs = [pkgs.libjpeg_turbo]; buildInputs = [pkgs.libjpeg_turbo];
# Ensure headers are found in the dev environment
propagatedBuildInputs = [pkgs.libjpeg_turbo];
}; };
}); });
# This provides the dev environment for the API itself # 2. THE DEV SHELL (What 'direnv' uses)
devShells = forAllSystems (system: let devShells = forAllSystems (pkgs: {
pkgs = pkgsFor system;
in {
default = pkgs.mkShell { default = pkgs.mkShell {
nativeBuildInputs = [pkgs.cmake pkgs.pkg-config]; # Use 'inputsFrom' so the shell always matches the package
buildInputs = [pkgs.libjpeg_turbo]; inputsFrom = [self.packages.${pkgs.system}.default];
# Add extra dev tools you only want when coding, not building
nativeBuildInputs = with pkgs; [
gdb
pkg-config
];
shellHook = '' shellHook = ''
# These exports make sure your C compiler finds the Nix-provided libs
export CPATH="${pkgs.libjpeg_turbo.dev}/include:$CPATH" export CPATH="${pkgs.libjpeg_turbo.dev}/include:$CPATH"
echo "⚙️ Image Processor API Dev Shell" export LIBRARY_PATH="${pkgs.libjpeg_turbo.out}/lib:$LIBRARY_PATH"
export PKG_CONFIG_PATH="${pkgs.libjpeg_turbo.dev}/lib/pkgconfig:$PKG_CONFIG_PATH"
echo "⚙️ Image Processor API Dev Shell Loaded"
''; '';
}; };
}); });