Skip to content

Instantly share code, notes, and snippets.

@aksiksi
Last active March 17, 2022 18:30
Show Gist options
  • Save aksiksi/2da715a4fbac705517c69f926661b190 to your computer and use it in GitHub Desktop.
Save aksiksi/2da715a4fbac705517c69f926661b190 to your computer and use it in GitHub Desktop.
Build gbc using Nix
  1. Install Nix: sh <(curl -L https://nixos.org/nix/install) --no-daemon
  2. nix-build default.nix
# Pin nixpkgs to a specific hash
{ pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/64fc73bd74f04d3e10cb4e70e1c65b92337e76db.tar.gz") {
}
}:
let
pname = "gbc";
# We need to tell SDL2 to build a static lib because the crate needs it.
SDL2WithStatic = pkgs.SDL2.overrideAttrs (oldAttrs: rec {
dontDisableStatic = true;
});
in pkgs.rustPlatform.buildRustPackage {
pname = pname;
version = "0.1.0";
# Add the SDL2 library path to rustc linker flags
RUSTFLAGS = "-L ${SDL2WithStatic}/lib -l SDL2";
buildInputs = with pkgs; [
SDL2WithStatic
] ++ lib.optionals stdenv.isDarwin [
AudioToolbox
Cocoa
CoreAudio
OpenGL
];
src = pkgs.fetchFromGitHub {
owner = "aksiksi";
repo = pname;
rev = "f493dd1f6168cfadd8451a1af9f8b0a4a241987f";
sha256 = "sha256-hplk6DVJ2BdmhH86p8DlJm1nk5xrXbFx/mLeJicyke8=";
};
cargoPatches = [ ./disable-bundled-sdl2.patch ];
cargoSha256 = "sha256-j0woe7tNdy6BaLhCIm48FuA8oHUKxaTrT29zam6Mwzw=";
}
diff --git a/Cargo.lock b/Cargo.lock
index e35df67..cea3591 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1,10 +1,6 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
-[[package]]
-name = "adler"
-version = "0.2.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e"
+version = 3
[[package]]
name = "aho-corasick"
@@ -60,12 +56,6 @@ version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ae44d1a3d5a19df61dd0c8beb138458ac2a53a7ac09eba97d55592540004306b"
-[[package]]
-name = "cc"
-version = "1.0.66"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4c0496836a84f8d0495758516b8621a622beb77c0fed418570e50764093ced48"
-
[[package]]
name = "cfg-if"
version = "0.1.10"
@@ -105,33 +95,6 @@ dependencies = [
"unicode-width",
]
-[[package]]
-name = "cmake"
-version = "0.1.45"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "eb6210b637171dfba4cda12e579ac6dc73f5165ad56133e5d72ef3131f320855"
-dependencies = [
- "cc",
-]
-
-[[package]]
-name = "crc32fast"
-version = "1.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a"
-dependencies = [
- "cfg-if 1.0.0",
-]
-
-[[package]]
-name = "encoding_rs"
-version = "0.8.26"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "801bbab217d7f79c0062f4f7205b5d4427c6d1a7bd7aafdd1475f7c59d62b283"
-dependencies = [
- "cfg-if 1.0.0",
-]
-
[[package]]
name = "env_logger"
version = "0.8.2"
@@ -145,30 +108,6 @@ dependencies = [
"termcolor",
]
-[[package]]
-name = "filetime"
-version = "0.2.13"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0c122a393ea57648015bf06fbd3d372378992e86b9ff5a7a497b076a28c79efe"
-dependencies = [
- "cfg-if 1.0.0",
- "libc",
- "redox_syscall",
- "winapi",
-]
-
-[[package]]
-name = "flate2"
-version = "1.0.19"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "7411863d55df97a419aa64cb4d2f167103ea9d767e2c54a1868b7ac3f6b47129"
-dependencies = [
- "cfg-if 1.0.0",
- "crc32fast",
- "libc",
- "miniz_oxide",
-]
-
[[package]]
name = "gbc"
version = "0.1.0"
@@ -251,16 +190,6 @@ version = "2.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525"
-[[package]]
-name = "miniz_oxide"
-version = "0.4.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d"
-dependencies = [
- "adler",
- "autocfg",
-]
-
[[package]]
name = "num-integer"
version = "0.1.44"
@@ -328,12 +257,6 @@ dependencies = [
"proc-macro2",
]
-[[package]]
-name = "redox_syscall"
-version = "0.1.57"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce"
-
[[package]]
name = "regex"
version = "1.4.2"
@@ -371,11 +294,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28d81feded049b9c14eceb4a4f6d596a98cebbd59abdba949c5552a015466d33"
dependencies = [
"cfg-if 0.1.10",
- "cmake",
- "flate2",
"libc",
- "tar",
- "unidiff",
"version-compare",
]
@@ -444,18 +363,6 @@ dependencies = [
"unicode-xid",
]
-[[package]]
-name = "tar"
-version = "0.4.30"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "489997b7557e9a43e192c527face4feacc78bfbe6eed67fd55c4c9e381cba290"
-dependencies = [
- "filetime",
- "libc",
- "redox_syscall",
- "xattr",
-]
-
[[package]]
name = "termcolor"
version = "1.1.2"
@@ -512,17 +419,6 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
-[[package]]
-name = "unidiff"
-version = "0.3.3"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d8a62719acf1933bfdbeb73a657ecd9ecece70b405125267dd549e2e2edc232c"
-dependencies = [
- "encoding_rs",
- "lazy_static",
- "regex",
-]
-
[[package]]
name = "version-compare"
version = "0.0.10"
@@ -625,12 +521,3 @@ name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
-
-[[package]]
-name = "xattr"
-version = "0.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "244c3741f4240ef46274860397c7c74e50eb23624996930e484c16679633a54c"
-dependencies = [
- "libc",
-]
diff --git a/emu/Cargo.toml b/emu/Cargo.toml
index 243dc0a..ca7280c 100644
--- a/emu/Cargo.toml
+++ b/emu/Cargo.toml
@@ -9,7 +9,7 @@ debug = ["gbc/debug"]
[dependencies]
gbc = { path = "../lib" }
-sdl2 = { version = "0.34.3", features = [ "bundled", "static-link" ] }
+sdl2 = { version = "0.34.3", features = [ "static-link" ] }
structopt = { version = "0.3", default-features = false }
log = "0.4"
env_logger = "0.8"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment