No description
  • Svelte 48.5%
  • Rust 22.2%
  • TypeScript 15.2%
  • Nix 10%
  • JavaScript 2.6%
  • Other 1.5%
Find a file
Christian Lengert 4a96adefe0 clean
2026-06-07 22:35:43 +02:00
backend clean 2026-06-07 22:35:43 +02:00
frontend pw 2026-05-25 11:04:22 +02:00
nix clean 2026-06-07 22:18:43 +02:00
.gitignore done 2026-05-23 22:57:23 +02:00
CLAUDE.md done 2026-05-23 22:57:23 +02:00
flake.lock done 2026-05-23 22:57:23 +02:00
flake.nix fix: set correct npmDepsHash for Nix build 2026-05-23 23:19:09 +02:00
instructions done 2026-05-23 22:57:23 +02:00
README.md done 2026-05-23 23:07:44 +02:00

GIS Service

A GIS web application with an OpenLayers map frontend (SvelteKit PWA) and a Rust/Rocket backend.

Requirements

  • Nix with flakes enabled

Development

1. Enter the dev shell

nix develop

This gives you cargo, node, npm, and cargo-watch.

2. Build the frontend

cd frontend
npm install        # first time only
npm run build
cd ..

3. Run the backend

cargo run --manifest-path backend/Cargo.toml

The server starts on http://0.0.0.0:9021. Open it in your browser.

To auto-restart on code changes:

cargo watch -x run --manifest-path backend/Cargo.toml

Note: After any change to the frontend, re-run npm run build in the frontend/ directory and restart the backend (the frontend assets are embedded in the binary at compile time).

NixOS deployment

The flake exports a NixOS module that registers a systemd service and opens the firewall port automatically.

1. Add the input to your system flake

In your NixOS system's flake.nix, add gis-service as an input and pass it through to your modules:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

    gis-service = {
      url = "git+https://your-host/path/to/gis-service";
      # Keep nixpkgs in sync so you don't pull in a second copy
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { nixpkgs, gis-service, ... }: {
    nixosConfigurations.myhost = nixpkgs.lib.nixosSystem {
      system = "x86_64-linux";
      modules = [
        ./configuration.nix
        gis-service.nixosModules.gis-service  # <-- import the module
      ];
    };
  };
}

2. Enable the service in your configuration

In configuration.nix (or any module in your system):

{
  services.gis-service = {
    enable = true;
    port    = 9021;        # optional — default: 9021
    address = "0.0.0.0";  # optional — default: 0.0.0.0
  };
}

Then deploy:

nixos-rebuild switch --flake .#myhost

The service will be running at http://<host>:9021 and managed by systemd:

systemctl status gis-service
journalctl -u gis-service -f

Module options

Option Type Default Description
services.gis-service.enable bool false Enable the service
services.gis-service.port port 9021 Port to listen on
services.gis-service.address string "0.0.0.0" Address to bind to
services.gis-service.package package built from flake Override the package

The module automatically opens the configured port in networking.firewall.

Project structure

.
├── flake.nix          # Nix dev shell, package build, NixOS module
├── nix/
│   └── module.nix     # NixOS module definition
├── frontend/          # SvelteKit + OpenLayers PWA
│   ├── src/routes/
│   │   └── +page.svelte   # Map page
│   └── build/         # Generated by `npm run build` (not committed)
└── backend/           # Rust / Rocket HTTP server
    └── src/main.rs    # Embeds frontend/build via rust-embed