Zine example dev flake for Helix

I tried to updated my website to the latest Zine but realized that I need to build three different apps from source since not all of them are built on CI.

Here’s my flake.nix Making sure you're not a bot!

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";
    zig = {
      url = "github:mitchellh/zig-overlay";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs =
    {
      self,
      nixpkgs,
      zig,
    }:
    let
      # Systems supported
      allSystems = [
        "x86_64-linux"
        "aarch64-linux"
        "x86_64-darwin"
        "aarch64-darwin"
      ];

      forAllSystems =
        f:
        nixpkgs.lib.genAttrs allSystems (
          system:
          f {
            pkgs = import nixpkgs {
              inherit system;
              overlays = [
                zig.overlays.default
                (
                  final: prev:
                  let
                    zigMaster = final.zigpkgs.master-2025-07-12 // {
                      meta = prev.zig.meta;
                    };
                  in
                  {
                    zig = zigMaster // {
                      hook = prev.zig.hook.override {
                        zig = zigMaster;
                      };
                    };

                    superhtml = final.callPackage ./nix/superhtml/package.nix { };
                    supermd = final.callPackage ./nix/supermd/package.nix { };
                    ziggy = final.callPackage ./nix/ziggy/package.nix { };
                  }
                )
              ];
            };
          }
        );
    in
    {
      devShells = forAllSystems (
        { pkgs }:
        {
          default = pkgs.mkShellNoCC {
            packages = [
              pkgs.zig
              pkgs.zon2nix
              pkgs.superhtml
              pkgs.supermd
              pkgs.ziggy
            ];

            env = {
              HELIX_RUNTIME = "./.helix/runtime";
            };

            shellHook = ''
              mkdir -p $HELIX_RUNTIME/queries
              mkdir -p ./nix/src/

              # unlink ./nix/src/superhtml
              # unlink ./nix/src/ziggy
              # unlink ./nix/src/supermd
              ln -n -s ${pkgs.superhtml.src} ./nix/src/superhtml
              ln -n -s ${pkgs.ziggy.src} ./nix/src/ziggy
              ln -n -s ${pkgs.supermd.src} ./nix/src/supermd

              # unlink $HELIX_RUNTIME/queries/ziggy
              # unlink $HELIX_RUNTIME/queries/ziggy_schema
              # unlink $HELIX_RUNTIME/queries/supermd
              # unlink $HELIX_RUNTIME/queries/supermd_inline
              # unlink $HELIX_RUNTIME/queries/superhtml

              ln -n -s $PWD/nix/src/ziggy/tree-sitter-ziggy/queries $HELIX_RUNTIME/queries/ziggy
              ln -n -s $PWD/nix/src/ziggy/tree-sitter-ziggy-schema/queries $HELIX_RUNTIME/queries/ziggy_schema
              ln -n -s $PWD/nix/src/supermd/editors/helix/queries/supermd $HELIX_RUNTIME/queries/supermd
              ln -n -s $PWD/nix/src/supermd/editors/helix/queries/supermd_inline $HELIX_RUNTIME/queries/supermd_inline
              ln -n -s $PWD/nix/src/superhtml/tree-sitter-superhtml/queries $HELIX_RUNTIME/queries/superhtml  
            '';
          };
        }
      );
    };
}

Now editing my website is only one nix develop away after updates :slight_smile:

Unfortunately nix flakes in the zine ecosystem are not actively maintained, so it was easier to just package them myself (but I should probably make PR to update upstream too).

2 Likes

yes sorry I don’t use nix and I haven’t figured out what’s the best approach yet

1 Like