Every page's footer names the commit the binary is built from, with a link to it on the forge, and /version answers with the full hash, open without a login like /healthz, so a script can tell which release is live. build.rs writes COMMIT: from VISA_COMMIT, which the flake sets to its source's revision (a Nix build has no .git), else from git in a checkout, else empty. The flake sets it on the package alone, not on the dependencies' build, which so stays cached from commit to commit.
80 lines
2.4 KiB
Nix
80 lines
2.4 KiB
Nix
{
|
|
description = "visa.buildfor.life: immigration records, deadlines and extension packs for foreigners in Thailand";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
crane.url = "github:ipetkov/crane";
|
|
};
|
|
|
|
outputs =
|
|
{
|
|
self,
|
|
nixpkgs,
|
|
crane,
|
|
}:
|
|
let
|
|
systems = [
|
|
"x86_64-linux"
|
|
"aarch64-linux"
|
|
];
|
|
forAll = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
|
|
|
|
# The server: one binary with its templates, static files, migrations
|
|
# and blank forms compiled in (build.rs, sqlx::migrate!, include_bytes!). The tests need
|
|
# PostgreSQL, so the package build runs none; CI and the fleet's VM
|
|
# test (checks.visa in cnx-network-clan) cover them.
|
|
package =
|
|
pkgs:
|
|
let
|
|
craneLib = crane.mkLib pkgs;
|
|
inherit (pkgs) lib;
|
|
src = lib.fileset.toSource {
|
|
root = ./.;
|
|
fileset = lib.fileset.unions [
|
|
./Cargo.toml
|
|
./Cargo.lock
|
|
./build.rs
|
|
./src
|
|
./templates
|
|
./static
|
|
./migrations
|
|
# the blank forms and their font, compiled in (src/papers)
|
|
./forms
|
|
# Cargo.toml names tests/main.rs as a target
|
|
./tests
|
|
];
|
|
};
|
|
common = {
|
|
inherit src;
|
|
pname = "visa";
|
|
version = "0.1.0";
|
|
strictDeps = true;
|
|
doCheck = false;
|
|
};
|
|
cargoArtifacts = craneLib.buildDepsOnly common;
|
|
in
|
|
craneLib.buildPackage (
|
|
common
|
|
// {
|
|
inherit cargoArtifacts;
|
|
cargoExtraArgs = "--locked --bin visa";
|
|
# The commit for the footer and /version (build.rs). Set here only,
|
|
# not in `common`, so the dependencies' build stays the same from
|
|
# commit to commit.
|
|
VISA_COMMIT = self.rev or self.dirtyRev or "";
|
|
meta = {
|
|
description = "Immigration records, deadlines and extension packs for foreigners in Thailand";
|
|
homepage = "https://git.b4l.co.th/B4L/visa";
|
|
mainProgram = "visa";
|
|
};
|
|
}
|
|
);
|
|
in
|
|
{
|
|
packages = forAll (pkgs: rec {
|
|
visa = package pkgs;
|
|
default = visa;
|
|
});
|
|
};
|
|
}
|