Something went wrong. Try again.
Open SIMH's computer history simulators, built with the Zig build system
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129# SPDX-FileCopyrightText: 2026 Jeffrey C. Ollie <jeff@ocjtech.us>## SPDX-License-Identifier: MIT
{ description = "Open SIMH, the computer history simulators, built with the Zig build system";
inputs = { nixpkgs = { url = "https://channels.nixos.org/nixos-unstable/nixexprs.tar.xz"; }; zon2nix = { url = "github:jcollie/zon2nix"; inputs = { nixpkgs.follows = "nixpkgs"; }; }; };
outputs = { nixpkgs, zon2nix, ... }: let inherit (nixpkgs) lib; makePackages = system: import nixpkgs { inherit system; }; forAllSystems = lib.genAttrs lib.systems.flakeExposed;
# The libraries simh can use. Each one is optional in build.zig; with # them all present every feature is built in. libpcap is not among them: # simh loads it with dlopen at run time, and its headers come from the # libpcap source named in build.zig.zon. libraries = pkgs: [ pkgs.SDL2 pkgs.libpng pkgs.zlib pkgs.pcre2 pkgs.libedit ] ++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [ pkgs.vde2 ]; in { devShells = forAllSystems ( system: let pkgs = makePackages system; in { default = pkgs.mkShell { name = "simh"; nativeBuildInputs = [ pkgs.zig_0_17 pkgs.pkg-config pkgs.python3 pkgs.reuse # zon2nix shells out to `zig env`, so make sure the Zig it finds # is this one rather than whatever happens to be on PATH. (pkgs.symlinkJoin { name = "zon2nix"; paths = [ zon2nix.packages.${system}.zon2nix ]; nativeBuildInputs = [ pkgs.makeWrapper ]; postBuild = '' wrapProgram $out/bin/zon2nix \ --prefix PATH : ${lib.makeBinPath [ pkgs.zig_0_17 ]} ''; }) ]; buildInputs = libraries pkgs; }; } ); packages = forAllSystems ( system: let pkgs = makePackages system; in rec { simh = pkgs.stdenvNoCC.mkDerivation (finalAttrs: { pname = "simh"; version = "4.1.0-unstable-2026-09-22"; nativeBuildInputs = [ pkgs.zig_0_17 pkgs.pkg-config ]; buildInputs = libraries pkgs; src = lib.fileset.toSource { root = ./.; fileset = lib.fileset.unions [ ./build.zig ./build.zig.zon ./simulators.zon ./tools/copy_tree.zig ]; }; deps = pkgs.callPackage ./build.zig.zon.nix { name = "${finalAttrs.pname}-${finalAttrs.version}-deps"; }; zigBuildFlags = [ "--system" "${finalAttrs.deps}" ]; # zig build test: upstream's test script for each simulator. doCheck = true; # simh asks `hostname` for the name it reports in SHOW VERSION. nativeCheckInputs = [ pkgs.hostname ]; zigCheckFlags = finalAttrs.zigBuildFlags; meta = { description = "Open SIMH, the computer history simulators"; homepage = "https://opensimh.org/"; license = lib.licenses.mit; }; }); default = simh; zig-deps = pkgs.callPackage ./build.zig.zon.nix { }; } ); };}