Compare commits

..

2 commits

Author SHA1 Message Date
Vinzenz Schroeter 36ccd9db6e fix build 2025-01-26 13:36:33 +01:00
Vinzenz Schroeter c8b51a8ab4 fix build 2025-01-26 13:30:16 +01:00
6 changed files with 122 additions and 139 deletions

View file

@ -23,19 +23,7 @@ Without nix: check out this repository and use `cargo run --release`.
## Command line arguments ## Command line arguments
``` The application binds to `0.0.0.0:2342` by default (`./servicepoint-simulator --bind host:port` to change this).
Usage: servicepoint-simulator [OPTIONS]
Options:
--bind <BIND> address and port to bind to [default: 0.0.0.0:2342]
-f, --font <FONT> The name of the font family to use. This defaults to the system monospace font.
-s, --spacers add spacers between tile rows to simulate gaps in real display
-r, --red Use the red color channel
-g, --green Use the green color channel
-b, --blue Use the blue color channel
-v, --verbose Set default log level lower. You can also change this via the RUST_LOG environment variable.
-h, --help Print help
```
See [env_logger](https://docs.rs/env_logger/latest/env_logger/) to configure logging. See [env_logger](https://docs.rs/env_logger/latest/env_logger/) to configure logging.

View file

@ -37,11 +37,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1736200483, "lastModified": 1737672001,
"narHash": "sha256-JO+lFN2HsCwSLMUWXHeOad6QUxOuwe9UOAF/iSl1J4I=", "narHash": "sha256-YnHJJ19wqmibLQdUeq9xzE6CjrMA568KN/lFPuSVs4I=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "3f0a8ac25fb674611b98089ca3a5dd6480175751", "rev": "035f8c0853c2977b24ffc4d0a42c74f00b182cd8",
"type": "github" "type": "github"
}, },
"original": { "original": {

139
flake.nix
View file

@ -25,24 +25,99 @@
"aarch64-darwin" "aarch64-darwin"
"x86_64-darwin" "x86_64-darwin"
]; ];
forAllSystems = forAllSystems = lib.genAttrs supported-systems;
f: make-rust-toolchain-core =
lib.genAttrs supported-systems ( pkgs:
system: pkgs.symlinkJoin {
f rec { name = "rust-toolchain-core";
pkgs = nixpkgs.legacyPackages.${system}; paths = with pkgs; [
inherit system; rustc
} cargo
); rustPlatform.rustcSrc
];
};
in in
rec { rec {
packages = forAllSystems ( packages = forAllSystems (
{ pkgs, ... }: system:
rec { let
servicepoint-simulator = import ./servicepoint-simulator.nix { pkgs = nixpkgs.legacyPackages."${system}";
inherit nix-filter pkgs; rust-toolchain-core = make-rust-toolchain-core pkgs;
naersk' = pkgs.callPackage naersk { }; naersk' = pkgs.callPackage naersk {
cargo = rust-toolchain-core;
rustc = rust-toolchain-core;
}; };
in
rec {
servicepoint-simulator = naersk'.buildPackage rec {
src = nix-filter.lib.filter {
root = ./.;
include = [
./Cargo.toml
./Cargo.lock
./src
./Web437_IBM_BIOS.woff
./README.md
./LICENSE
];
};
nativeBuildInputs = with pkgs; [
pkg-config
makeWrapper
];
strictDeps = true;
buildInputs =
with pkgs;
[
xe
xz
roboto
]
++ lib.optionals pkgs.stdenv.isLinux (
with pkgs;
[
# gpu
libGL
vulkan-headers
vulkan-loader
vulkan-tools vulkan-tools-lunarg
vulkan-extension-layer
vulkan-validation-layers
# keyboard
libxkbcommon
# font loading
fontconfig
freetype
# WINIT_UNIX_BACKEND=wayland
wayland
# WINIT_UNIX_BACKEND=x11
xorg.libXcursor
xorg.libXrandr
xorg.libXi
xorg.libX11
xorg.libX11.dev
]
)
++ lib.optionals pkgs.stdenv.isDarwin (
with pkgs.darwin.apple_sdk.frameworks;
[
Carbon
QuartzCore
AppKit
]
);
postInstall = ''
wrapProgram $out/bin/servicepoint-simulator \
--suffix LD_LIBRARY_PATH : ${lib.makeLibraryPath buildInputs}
'';
};
default = servicepoint-simulator; default = servicepoint-simulator;
} }
); );
@ -50,35 +125,29 @@
legacyPackages = packages; legacyPackages = packages;
devShells = forAllSystems ( devShells = forAllSystems (
{ system:
pkgs, let
system, pkgs = nixpkgs.legacyPackages."${system}";
}: rust-toolchain = pkgs.symlinkJoin {
name = "rust-toolchain";
paths = with pkgs; [
(make-rust-toolchain-core pkgs)
rustfmt
clippy
cargo-expand
];
};
in
{ {
default = pkgs.mkShell rec { default = pkgs.mkShell rec {
inputsFrom = [ self.packages.${system}.default ]; inputsFrom = [ self.packages.${system}.default ];
packages = [ packages = [ rust-toolchain pkgs.gdb ];
pkgs.gdb
(pkgs.symlinkJoin {
name = "rust-toolchain";
paths = with pkgs; [
rustc
cargo
rustPlatform.rustcSrc
rustfmt
clippy
cargo-expand
];
})
];
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath (builtins.concatMap (d: d.buildInputs) inputsFrom)}"; LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath (builtins.concatMap (d: d.buildInputs) inputsFrom)}";
NIX_LD_LIBRARY_PATH = LD_LIBRARY_PATH;
NIX_LD = pkgs.stdenv.cc.bintools.dynamicLinker;
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
}; };
} }
); );
formatter = forAllSystems ({ pkgs, ... }: pkgs.nixfmt-rfc-style); formatter = forAllSystems (system: nixpkgs.legacyPackages."${system}".nixfmt-rfc-style);
}; };
} }

View file

@ -1,74 +0,0 @@
{
naersk',
pkgs,
nix-filter,
}:
naersk'.buildPackage rec {
src = nix-filter.lib.filter {
root = ./.;
include = [
./Cargo.toml
./Cargo.lock
./src
./Web437_IBM_BIOS.woff
./README.md
./LICENSE
];
};
nativeBuildInputs = with pkgs; [
pkg-config
makeWrapper
];
strictDeps = true;
buildInputs =
with pkgs;
[
xe
xz
roboto
]
++ lib.optionals pkgs.stdenv.isLinux (
with pkgs;
[
# gpu
libGL
vulkan-headers
vulkan-loader
vulkan-tools
vulkan-tools-lunarg
vulkan-extension-layer
vulkan-validation-layers
# keyboard
libxkbcommon
# font loading
fontconfig
freetype
# WINIT_UNIX_BACKEND=wayland
wayland
# WINIT_UNIX_BACKEND=x11
xorg.libXcursor
xorg.libXrandr
xorg.libXi
xorg.libX11
xorg.libX11.dev
]
)
++ lib.optionals pkgs.stdenv.isDarwin (
with pkgs.darwin.apple_sdk.frameworks;
[
Carbon
QuartzCore
AppKit
]
);
postInstall = ''
wrapProgram $out/bin/servicepoint-simulator \
--suffix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath buildInputs}
'';
}

View file

@ -8,6 +8,12 @@ pub struct Cli {
help = "address and port to bind to" help = "address and port to bind to"
)] )]
pub bind: String, pub bind: String,
#[arg(
short,
long,
help = "Set default log level lower. You can also change this via the RUST_LOG environment variable."
)]
pub debug: bool,
#[arg( #[arg(
short, short,
long, long,
@ -16,23 +22,10 @@ pub struct Cli {
pub font: Option<String>, pub font: Option<String>,
#[clap(flatten)] #[clap(flatten)]
pub gui: GuiOptions, pub gui: GuiOptions,
#[arg(
short,
long,
help = "Set default log level lower. You can also change this via the RUST_LOG environment variable."
)]
pub verbose: bool,
} }
#[derive(Parser, Debug)] #[derive(Parser, Debug)]
pub struct GuiOptions { pub struct GuiOptions {
#[arg(
short,
long,
default_value_t = false,
help = "add spacers between tile rows to simulate gaps in real display"
)]
pub spacers: bool,
#[arg( #[arg(
short, short,
long, long,
@ -54,4 +47,11 @@ pub struct GuiOptions {
help = "Use the blue color channel" help = "Use the blue color channel"
)] )]
pub blue: bool, pub blue: bool,
#[arg(
short,
long,
default_value_t = false,
help = "add spacers between tile rows to simulate gaps in real display"
)]
pub spacers: bool,
} }

View file

@ -29,7 +29,7 @@ fn main() {
cli.gui.green = true; cli.gui.green = true;
} }
init_logging(cli.verbose); init_logging(cli.debug);
info!("starting with args: {:?}", &cli); info!("starting with args: {:?}", &cli);
let socket = UdpSocket::bind(&cli.bind).expect("could not bind socket"); let socket = UdpSocket::bind(&cli.bind).expect("could not bind socket");