Skip to content

Commit

Permalink
test: app flake
Browse files Browse the repository at this point in the history
  • Loading branch information
aidanaden committed Sep 23, 2024
1 parent 9f365ed commit 42248d0
Showing 1 changed file with 32 additions and 21 deletions.
53 changes: 32 additions & 21 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,38 @@
zig2nix.url = "github:Cloudef/zig2nix";
};

outputs = { zig2nix, ... }: let
outputs = {zig2nix, ...}: let
flake-utils = zig2nix.inputs.flake-utils;
in (flake-utils.lib.eachDefaultSystem (system: let
# Zig flake helper
# Check the flake.nix in zig2nix project for more options:
# <https://github.com/Cloudef/zig2nix/blob/master/flake.nix>
env = zig2nix.outputs.zig-env.${system} {};
system-triple = env.lib.zigTripleFromString system;
in with builtins; with env.lib; with env.pkgs.lib; rec {
# Zig flake helper
# Check the flake.nix in zig2nix project for more options:
# <https://github.com/Cloudef/zig2nix/blob/master/flake.nix>
env = zig2nix.outputs.zig-env.${system} {};
system-triple = env.lib.zigTripleFromString system;
in
with builtins;
with env.lib;
with env.pkgs.lib; rec {
# nix build .#target.{zig-target}
# e.g. nix build .#target.x86_64-linux-gnu
packages.target = genAttrs allTargetTriples (target: env.packageForTarget target ({
src = cleanSource ./.;
packages.target = genAttrs allTargetTriples (target:
env.packageForTarget target ({
src = cleanSource ./.;

nativeBuildInputs = with env.pkgs; [];
buildInputs = with env.pkgsForTarget target; [];
nativeBuildInputs = with env.pkgs; [];
buildInputs = with env.pkgsForTarget target; [];

# Smaller binaries and avoids shipping glibc.
zigPreferMusl = true;
# Smaller binaries and avoids shipping glibc.
zigPreferMusl = true;

# This disables LD_LIBRARY_PATH mangling, binary patching etc...
# The package won't be usable inside nix.
zigDisableWrap = true;
} // optionalAttrs (!pathExists ./build.zig.zon) {
pname = "schnorr";
version = "0.0.0";
}));
# This disables LD_LIBRARY_PATH mangling, binary patching etc...
# The package won't be usable inside nix.
zigDisableWrap = true;
}
// optionalAttrs (!pathExists ./build.zig.zon) {
pname = "schnorr";
version = "0.0.0";
}));

# nix build .
packages.default = packages.target.${system-triple}.override {
Expand All @@ -53,7 +58,13 @@
apps.bundle.default = apps.bundle.target.${system-triple};

# nix run .
apps.default = env.app [] "zig build run -- \"$@\"";
# apps.default = env.app [] "zig build run -- \"$@\"";
apps.default = let
pkg = packages.target.${system-triple};
in {
type = "app";
program = "${pkg}/bin/schnorr";
};

# nix run .#build
apps.build = env.app [] "zig build \"$@\"";
Expand Down

0 comments on commit 42248d0

Please sign in to comment.