3 Commits

Author SHA1 Message Date
DIvan2000
bee679d3e1 Merge pull request #2 from DIvan2K/nix-flake
Add Nix flake for reproducible build and NixOS support
2026-04-25 22:07:33 +04:00
DIvan2000
0660130653 Merge pull request #1 from DIvan2K/runtime-config
Add runtime CLI configuration (replace compile-time constants)
2026-04-25 21:53:34 +04:00
659ec6af18 nix: add flake + devShell, ignore result 2026-04-24 19:35:15 +04:00
3 changed files with 147 additions and 0 deletions

4
.gitignore vendored
View File

@@ -5,3 +5,7 @@ nimcache/
demo.png/
diag.png/
diag.tape
# Nix
result
result-*

27
flake.lock generated Normal file
View File

@@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1776548001,
"narHash": "sha256-ZSK0NL4a1BwVbbTBoSnWgbJy9HeZFXLYQizjb2DPF24=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "b12141ef619e0a9c1c84dc8c684040326f27cdcc",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

116
flake.nix Normal file
View File

@@ -0,0 +1,116 @@
{
description = "Terminal oscilloscope with CRT phosphor rendering";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs =
{ self, nixpkgs }:
let
lib = nixpkgs.lib;
systems = [
"x86_64-linux"
"aarch64-linux"
];
forAllSystems = lib.genAttrs systems;
mkPkgs = system:
import nixpkgs { inherit system; };
in
{
packages = forAllSystems (system:
let
pkgs = mkPkgs system;
ffmpegForOsc = pkgs.ffmpeg-full;
runtimeLibraryPath = lib.makeLibraryPath [ ffmpegForOsc ];
in
{
default = pkgs.stdenv.mkDerivation {
pname = "terminal-oscilloscope";
version = "0.1.0";
src = ./.;
nativeBuildInputs = [
pkgs.nim
pkgs.makeWrapper
];
buildInputs = [
ffmpegForOsc
];
buildPhase = ''
runHook preBuild
nim c -d:release --threads:on --nimcache:$TMPDIR/nimcache-osc_braille -o:osc_braille src/osc_braille.nim
nim c -d:release --threads:on --nimcache:$TMPDIR/nimcache-osc_braille -o:osc src/osc.nim
runHook postBuild
'';
installPhase = ''
runHook preInstall
install -Dm755 osc $out/bin/osc-unwrapped
install -Dm755 osc_braille $out/bin/osc_braille-unwrapped
makeWrapper $out/bin/osc-unwrapped $out/bin/osc \
--prefix LD_LIBRARY_PATH : ${runtimeLibraryPath}
makeWrapper $out/bin/osc_braille-unwrapped $out/bin/osc_braille \
--prefix LD_LIBRARY_PATH : ${runtimeLibraryPath}
runHook postInstall
'';
meta = {
description = "Terminal oscilloscope with CRT phosphor rendering";
mainProgram = "osc";
platforms = lib.platforms.linux;
};
};
});
apps = forAllSystems (system: {
default = {
type = "app";
program = "${self.packages.${system}.default}/bin/osc";
};
osc = {
type = "app";
program = "${self.packages.${system}.default}/bin/osc";
};
osc_braille = {
type = "app";
program = "${self.packages.${system}.default}/bin/osc_braille";
};
});
devShells = forAllSystems (system:
let
pkgs = mkPkgs system;
ffmpegForOsc = pkgs.ffmpeg-full;
runtimeLibraryPath = lib.makeLibraryPath [ ffmpegForOsc ];
in
{
default = pkgs.mkShell {
packages = [
pkgs.nim
pkgs.nimble
pkgs.pkg-config
ffmpegForOsc
];
shellHook = ''
export LD_LIBRARY_PATH=${runtimeLibraryPath}:''${LD_LIBRARY_PATH:-}
'';
};
});
};
}