Skip to content
Draft
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,5 @@ ui.zip
# local embedded frontend output for fast E2E runs
internal/http/dist/*
!internal/http/dist/.gitkeep

result
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ If you've looked at Wiki.js or Outline and thought "this is too much to operate
→ If it fits, [a star](https://github.com/perber/leafwiki) helps others find it.

```bash
# Docker
docker run -p 8080:8080 -v ~/leafwiki-data:/app/data \
ghcr.io/perber/leafwiki:latest \
--jwt-secret=yoursecret --admin-password=yourpassword --allow-insecure=true

# Nix
nix run github:perber/leafwiki -- --help
```

→ [All install options](#install) (Docker Compose, Linux installer, binary)
Expand Down
61 changes: 61 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

88 changes: 88 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
{
description = "LeafWiki - a fast wiki for people who think in folders, not feeds";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};

version = "0.0.0";

# Build the Vite/React frontend
ui = pkgs.buildNpmPackage {
pname = "leafwiki-ui";
inherit version;
src = ./ui/leafwiki-ui;

npmDepsHash = "sha256-gYL+VczQNEISjvNEtsfjFMFJ0tvfYgqeERlUcHdzAsY=";

env.VITE_API_URL = "/";

installPhase = ''
runHook preInstall
cp -r dist $out
runHook postInstall
'';
Comment thread
outofrange marked this conversation as resolved.
Outdated
};

# Build the Go backend, embedding the compiled frontend
leafwiki = pkgs.buildGoModule {
pname = "leafwiki";
inherit version;
src = ./.;

vendorHash = "sha256-/5K4BfYCFeNCJ/Sfd1eV7GO3LMx7pEe5yst7el+TfaY=";

# Copy frontend dist into the expected location before the Go build
preBuild = ''
mkdir -p internal/http/dist
cp -r ${ui}/. internal/http/dist/
'';

ldflags = [
"-s"
"-w"
"-X github.com/perber/wiki/internal/http.EmbedFrontend=true"
"-X github.com/perber/wiki/internal/http.Environment=production"
];

# Only build the main binary; e2e-proxy is a separate Go module
subPackages = [ "cmd/leafwiki" ];

# modernc.org/sqlite is pure Go – no C compiler needed
env.CGO_ENABLED = "0";
};
in
{
packages = {
default = leafwiki;
inherit leafwiki ui;
};

apps = {
default = flake-utils.lib.mkApp { drv = leafwiki; };
leafwiki = flake-utils.lib.mkApp { drv = leafwiki; };
};

devShells.default = pkgs.mkShell {
packages = with pkgs; [
# Go toolchain
go
gopls
gotools
golangci-lint
# Node / frontend
nodejs
typescript-language-server
# Utilities
git
gnumake
];
};
});
}