this repo has no description
1{
2 description = "Flake for building my website";
3
4 inputs = {
5 nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6 zig2nix.url = "github:Cloudef/zig2nix";
7 };
8
9 outputs = {
10 nixpkgs,
11 zig2nix,
12 ...
13 }: let
14 flake-utils = zig2nix.inputs.flake-utils;
15 in (flake-utils.lib.eachDefaultSystem (system: let
16 # Zig flake helper
17 # Check the flake.nix in zig2nix project for more options:
18 # <https://github.com/Cloudef/zig2nix/blob/master/flake.nix>
19 env = zig2nix.outputs.zig-env.${system} {zig = zig2nix.outputs.packages.${system}.zig-latest;};
20 pkgs = nixpkgs.legacyPackages.${system};
21 in
22 with builtins;
23 with env.pkgs.lib; rec {
24 # Produces clean binaries meant to be ship'd outside of nix
25 # nix build .#foreign
26 packages.foreign = env.package {
27 src = cleanSource ./.;
28
29 # Packages required for compiling
30 nativeBuildInputs = with pkgs; [dart-sass];
31
32 # Packages required for linking
33 buildInputs = with env.pkgs; [];
34
35 # Smaller binaries and avoids shipping glibc.
36 zigPreferMusl = true;
37 };
38
39 # nix build .
40 packages.default = packages.foreign.override (attrs: {
41 # Prefer nix friendly settings.
42 zigPreferMusl = false;
43
44 # Executables required for runtime
45 # These packages will be added to the PATH
46 zigWrapperBins = with env.pkgs; [];
47
48 # Libraries required for runtime
49 # These packages will be added to the LD_LIBRARY_PATH
50 zigWrapperLibs = attrs.buildInputs or [];
51 });
52
53 # For bundling with nix bundle for running outside of nix
54 # example: https://github.com/ralismark/nix-appimage
55 apps.bundle = {
56 type = "app";
57 program = "${packages.foreign}/bin/master";
58 };
59
60 # nix run .
61 apps.default = env.app [] "zig build serve -- \"$@\"";
62
63 # nix run .#build
64 apps.build = env.app [] "zig build \"$@\"";
65
66 # nix run .#stylesheet
67 apps.stylesheet = env.app [] "zig build stylesheet -- \"$@\"";
68
69 # nix run .#zig2nix
70 apps.zig2nix = env.app [] "zig2nix \"$@\"";
71
72 # nix develop
73 devShells.default = env.mkShell {
74 # Packages required for compiling, linking and running
75 # Libraries added here will be automatically added to the LD_LIBRARY_PATH and PKG_CONFIG_PATH
76 nativeBuildInputs =
77 []
78 ++ packages.default.nativeBuildInputs
79 ++ packages.default.buildInputs
80 ++ packages.default.zigWrapperBins
81 ++ packages.default.zigWrapperLibs;
82 };
83 }));
84}