build.rs builds the string (git, or SLINUXM_* env for builds without .git) and the lib exposes it as VERSION. --version, /healthz, /api/v1/ping, MCP server info and OTel service.version use it; OpenAPI info.version stays on the semver so docs/openapi.json does not change per commit. The flake passes the commit date and short rev to the package.
69 lines
2.5 KiB
Nix
69 lines
2.5 KiB
Nix
{
|
|
description = "skyg-linux-tracker: read-only systemd, journal and Docker monitor";
|
|
|
|
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
|
|
outputs = { self, nixpkgs }:
|
|
let
|
|
system = "x86_64-linux";
|
|
systems = [ "x86_64-linux" "aarch64-linux" ];
|
|
forAll = f: nixpkgs.lib.genAttrs systems (s: f nixpkgs.legacyPackages.${s});
|
|
|
|
# Stamp for `slinuxm --version`: the commit date and short sha, so the
|
|
# build is reproducible. A flake does not know its branch; package.nix
|
|
# defaults it to "nix".
|
|
lastModified = self.lastModifiedDate or "19700101000000";
|
|
stamp = {
|
|
buildDate = "${builtins.substring 0 4 lastModified}.${builtins.substring 4 2 lastModified}.${builtins.substring 6 2 lastModified}";
|
|
gitSha =
|
|
if self ? shortRev
|
|
then builtins.substring 0 7 self.shortRev
|
|
else self.dirtyShortRev or "unknown";
|
|
};
|
|
in
|
|
{
|
|
packages = forAll (pkgs: rec {
|
|
skyg-linux-tracker = pkgs.callPackage ./nix/package.nix stamp;
|
|
default = skyg-linux-tracker;
|
|
});
|
|
|
|
nixosModules.default = { pkgs, lib, ... }: {
|
|
imports = [ ./nix/module.nix ];
|
|
services.skyg-linux-tracker.package =
|
|
lib.mkDefault self.packages.${pkgs.stdenv.hostPlatform.system}.default;
|
|
};
|
|
|
|
checks.${system} =
|
|
let
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
in
|
|
import ./nix/checks.nix {
|
|
inherit pkgs;
|
|
package = self.packages.${system}.default;
|
|
} // {
|
|
package = self.packages.${system}.default;
|
|
vm = import ./nix/tests/vm.nix {
|
|
inherit pkgs;
|
|
module = self.nixosModules.default;
|
|
};
|
|
vm-peers = import ./nix/tests/peers.nix {
|
|
inherit pkgs;
|
|
module = self.nixosModules.default;
|
|
};
|
|
# Evaluation-only: every case renders the module's config and unit,
|
|
# so forcing the list either lists the passed checks or throws. The
|
|
# output file is only there to give `nix flake check` a derivation.
|
|
module-peers = pkgs.runCommand "skyg-linux-tracker-module-peers-eval" { } ''
|
|
printf '%s\n' ${
|
|
nixpkgs.lib.escapeShellArg (
|
|
builtins.concatStringsSep "\n" (import ./nix/tests/module-peers.nix {
|
|
inherit pkgs;
|
|
module = self.nixosModules.default;
|
|
})
|
|
)
|
|
} > $out
|
|
'';
|
|
};
|
|
};
|
|
}
|