From: patrick-scho Date: Fri, 11 Apr 2025 12:06:55 +0000 (+0200) Subject: update flake.nix and add dependencies as submodules X-Git-Url: https://gitweb.ps.run/chirp/commitdiff_plain/4dd72bd444298a01fea2e17d5ba9915489c6f6ad?ds=sidebyside update flake.nix and add dependencies as submodules --- diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..124ee89 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "ext/zighttp"] + path = ext/zighttp + url = git@psch.dev:zighttp +[submodule "ext/ziglmdb"] + path = ext/ziglmdb + url = git@psch.dev:ziglmdb diff --git a/ext/zighttp b/ext/zighttp new file mode 160000 index 0000000..274c46e --- /dev/null +++ b/ext/zighttp @@ -0,0 +1 @@ +Subproject commit 274c46eb3f7e9987cc9260bb70c43b4f5d8555ac diff --git a/ext/ziglmdb b/ext/ziglmdb new file mode 160000 index 0000000..88cb74a --- /dev/null +++ b/ext/ziglmdb @@ -0,0 +1 @@ +Subproject commit 88cb74a430fa9629c8127c3a866c40e79a8e4612 diff --git a/flake.nix b/flake.nix index 60987e7..5022167 100644 --- a/flake.nix +++ b/flake.nix @@ -12,84 +12,15 @@ # Check the flake.nix in zig2nix project for more options: # env = zig2nix.outputs.zig-env.${system} {}; - zighttp = env.pkgs.fetchFromGitHub { - owner = "patrick-scho"; - repo = "zighttp"; - rev = "274c46eb3f7e9987cc9260bb70c43b4f5d8555ac"; - sha256 = "sha256-SUFHiA0r46QfzhlO6Ie1CByzC/+qPR2kyAbeDEdKOJ0="; - }; - ziglmdb = env.pkgs.fetchFromGitHub { - owner = "patrick-scho"; - repo = "ziglmdb"; - rev = "88cb74a430fa9629c8127c3a866c40e79a8e4612"; - sha256 = "sha256-SUFHiA0r46QfzhlO6Ie1CByzC/+qPR2kyAbeDEdKOJ0="; - }; in with builtins; with env.pkgs.lib; rec { - # Produces clean binaries meant to be ship'd outside of nix - # nix build .#foreign - packages.foreign = env.package { + apps.default = env.app [] "zig build run -- \"$@\""; + packages.default = env.package { src = cleanSource ./.; - # Packages required for compiling nativeBuildInputs = with env.pkgs; []; - - # Packages required for linking buildInputs = with env.pkgs; []; - # Smaller binaries and avoids shipping glibc. - zigPreferMusl = true; - }; - - # nix build . - packages.default = packages.foreign.override (attrs: { - # Prefer nix friendly settings. zigPreferMusl = false; - - # Executables required for runtime - # These packages will be added to the PATH - zigWrapperBins = with env.pkgs; []; - - # Libraries required for runtime - # These packages will be added to the LD_LIBRARY_PATH - zigWrapperLibs = attrs.buildInputs or []; - }); - - # For bundling with nix bundle for running outside of nix - # example: https://github.com/ralismark/nix-appimage - apps.bundle = { - type = "app"; - program = "${packages.foreign}/bin/default"; - }; - - # nix run . - apps.default = env.app [] "zig build run -- \"$@\""; - - # nix run .#build - apps.build = env.app [] '' - mkdir -p ext - ln -s ${zighttp} ext/zighttp - ln -s ${ziglmdb} ext/ziglmdb - zig build "$@" - ''; - - # nix run .#test - apps.test = env.app [] "zig build test -- \"$@\""; - - # nix run .#docs - apps.docs = env.app [] "zig build docs -- \"$@\""; - - # nix run .#zig2nix - apps.zig2nix = env.app [] "zig2nix \"$@\""; - - # nix develop - devShells.default = env.mkShell { - # Packages required for compiling, linking and running - # Libraries added here will be automatically added to the LD_LIBRARY_PATH and PKG_CONFIG_PATH - nativeBuildInputs = [] - ++ packages.default.nativeBuildInputs - ++ packages.default.buildInputs - ++ packages.default.zigWrapperBins - ++ packages.default.zigWrapperLibs; }; })); }