treesummaryrefslogcommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorPatrick Schönberger2026-04-24 16:33:42 +0200
committerPatrick Schönberger2026-04-24 16:33:42 +0200
commit5b193f70d4cd96672394f08ed0936b1ccd09eece (patch)
treefdf60c53707c94e081ba96b605fe23ab2d6634f1 /flake.nix
parentbfea8ab1db8866157b39a05e18de179eef544a96 (diff)
downloadzhttpws-5b193f70d4cd96672394f08ed0936b1ccd09eece.tar.gz
zhttpws-5b193f70d4cd96672394f08ed0936b1ccd09eece.zip
update flake
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix98
1 files changed, 27 insertions, 71 deletions
diff --git a/flake.nix b/flake.nix
index 3908ef8..8662667 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,78 +1,34 @@
{
- description = "Zig project flake";
-
inputs = {
- zig2nix.url = "github:Cloudef/zig2nix";
+ nixpkgs.url = "nixpkgs";
+ zig.url = "github:silversquirl/zig-flake";
+ zig.inputs.nixpkgs.follows = "nixpkgs";
};
- 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} {};
- 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 {
- 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";
+ outputs = {
+ nixpkgs,
+ zig,
+ ...
+ }: let
+ forAllSystems = f:
+ builtins.mapAttrs
+ (system: pkgs: f pkgs zig.packages.${system}.nightly)
+ nixpkgs.legacyPackages;
+ in {
+ devShells = forAllSystems (pkgs: zig: {
+ default = pkgs.mkShellNoCC {
+ packages = [pkgs.bash zig zig.zls];
};
-
- # nix run .
- apps.default = env.app [] "zig build run -- \"$@\"";
-
- # nix run .#build
- apps.build = env.app [] "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;
+ });
+
+ packages = forAllSystems (pkgs: zig: {
+ default = zig.makePackage {
+ pname = "zig-flake-template";
+ version = "0.0.0";
+ src = ./.;
+ zigReleaseMode = "fast";
+ depsHash = "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=";
};
- }));
+ });
+ };
}