Skip to content

Instantly share code, notes, and snippets.

View fzakaria's full-sized avatar

Farid Zakaria fzakaria

View GitHub Profile
@fzakaria
fzakaria / differences.txt
Created January 1, 2022 16:30
ldd vs. --list for resolving dependencies
$ ldd $(which bash)
linux-vdso.so.1 (0x00007ffd8e5e8000)
/lib/x86_64-linux-gnu/libnss_cache.so.2 (0x00007fb4d70fa000)
libdl.so.2 => /nix/store/vjq3q7dq8vmc13c3py97v27qwizvq7fd-glibc-2.33-59/lib/libdl.so.2 (0x00007fb4d70f5000)
libc.so.6 => /nix/store/vjq3q7dq8vmc13c3py97v27qwizvq7fd-glibc-2.33-59/lib/libc.so.6 (0x00007fb4d6f30000)
/nix/store/vjq3q7dq8vmc13c3py97v27qwizvq7fd-glibc-2.33-59/lib/ld-linux-x86-64.so.2 => /nix/store/vjq3q7dq8vmc13c3py97v27qwizvq7fd-glibc-2.33-59/lib64/ld-linux-x86-64.so.2 (0x00007fb4d7103000)
$ /nix/store/vjq3q7dq8vmc13c3py97v27qwizvq7fd-glibc-2.33-59/lib/ld-linux-x86-64.so.2 --list $(which bash)
linux-vdso.so.1 (0x00007ffec849c000)
/lib/x86_64-linux-gnu/libnss_cache.so.2 (0x00007f5003e00000)
@fzakaria
fzakaria / rpath_total_chromium.rb
Last active December 13, 2021 19:53
Finding all the total length of all rpath entries needed to search for Chromium
#!/usr/bin/env ruby
require 'find'
require 'elftools'
# ldd /nix/store/5v13hyafx34x5sksfr4ifwc6mbpvx3yy-chromium-unwrapped-92.0.4515.107/libexec/chromium/chromium | grep -oE "/nix/store/.* "
ENTRIES = "/nix/store/cvr0kjg2q7z2wwhjblx6c73rv422k8cm-glibc-2.33-47/lib/libdl.so.2
/nix/store/cvr0kjg2q7z2wwhjblx6c73rv422k8cm-glibc-2.33-47/lib/libpthread.so.0
/nix/store/4fzxscwhxb1q1jrxg0p3g5c9dgxvlp59-glib-2.68.3/lib/libgobject-2.0.so.0
/nix/store/4fzxscwhxb1q1jrxg0p3g5c9dgxvlp59-glib-2.68.3/lib/libglib-2.0.so.0
/nix/store/alrr12qahbxbksi9lhh300s7f83kb7hq-nss-3.68/lib64/libsmime3.so
@fzakaria
fzakaria / rpath.rb
Last active December 13, 2021 04:36
Find ELF file with largest RPATH entry
#!/usr/bin/env ruby
require 'find'
require 'elftools'
STORE = "/nix/store"
puts "Searching /nix/store for rpath entries."
seen = 0
current = ""
@fzakaria
fzakaria / nix_clang_asan_support.diff
Created November 23, 2021 03:31
Add support to Nix when building with Clang to use the Address Sanitizer (ASan)
diff --git a/Makefile b/Makefile
index 5040d2884..ac29e2526 100644
--- a/Makefile
+++ b/Makefile
@@ -27,11 +27,14 @@ makefiles = \
OPTIMIZE = 1
ifeq ($(OPTIMIZE), 1)
- GLOBAL_CXXFLAGS += -O3
+ GLOBAL_CXXFLAGS += -O1
@fzakaria
fzakaria / nix_clang_support.diff
Created November 23, 2021 03:21
Patch Nix to support building with Clang
diff --git a/flake.nix b/flake.nix
index fd5e18429..a9248ef90 100644
--- a/flake.nix
+++ b/flake.nix
@@ -1,5 +1,6 @@
{
description = "The purely functional package manager";
+ # make a change to ruin the binary cache
inputs.nixpkgs.url = "nixpkgs/nixos-21.05-small";
@fzakaria
fzakaria / sanitizer.diff
Created November 23, 2021 03:18
Patch Nix to support building with Clang
diff --git a/Makefile b/Makefile
index 5040d2884..ac29e2526 100644
--- a/Makefile
+++ b/Makefile
@@ -27,11 +27,14 @@ makefiles = \
OPTIMIZE = 1
ifeq ($(OPTIMIZE), 1)
- GLOBAL_CXXFLAGS += -O3
+ GLOBAL_CXXFLAGS += -O1
@fzakaria
fzakaria / minimal-shell.nix
Last active August 2, 2021 16:59
A super minimal nix-shell
let
nixpkgs = import (builtins.fetchTarball {
name = "nixos-unstable-2020-09-24";
url =
"https://github.com/nixos/nixpkgs/archive/8ecc61c91a596df7d3293603a9c2384190c1b89a.tar.gz";
sha256 = "0vhajylsmipjkm5v44n2h0pglcmpvk4mkyvxp7qfvkjdxw21dyml";
}) { };
stdenvMinimal = nixpkgs.stdenvNoCC.override {
cc = null;
preHook = "";
[nix-shell:~/code/nix/playground]$ echo $PATH | tr : '\n'
/nix/store/fgbzvd4c6nly9m4dpczrxybdpkm8mnk3-bash-interactive-4.4-p23/bin
/nix/store/hicfsj7pp72fc96vp1mqjb0qjzf8fiik-patchelf-0.12/bin
/nix/store/nvlnl2swxmk50x25mzn71rhc0gzpylfr-coreutils-8.32/bin
/nix/store/f67dl43kggvml0mnrdcasqh0fw2lx5xr-findutils-4.7.0/bin
/nix/store/mbahsiqqj61wjyh2yyzflxpf35hdpjbz-diffutils-3.7/bin
/nix/store/b3l5zq2nkhfpqrr0lil06dhqyjf5jz38-gnused-4.8/bin
/nix/store/7lkzid5yncibabddzaw4sj13n342jz1s-gnugrep-3.6/bin
/nix/store/b27wld0aqcdspznhxwgmr6cs67kg9lk3-gawk-5.1.0/bin
/nix/store/i92f6n6mb65fzpppl3h4vbm3a2rfyb5n-gnutar-1.34/bin
fixupOutputHooks+=(autoStripNonDeterminism)
autoStripNonDeterminism() {
find $output -type f \
-exec strip-nondeterminism {}
}
@fzakaria
fzakaria / jruby.nix
Created June 15, 2021 23:14
Build any JRuby commit easily
# This derivation is meant to be used in the overlay or can be built
# by itself to test which is why you see all the defaults being set.
# Please consult https://github.com/looker/helltool/blob/master/docs/jruby.md
# for additional information.
{ sources ? import ./sources.nix, pkgs ? import sources.nixpkgs { }
, lib ? pkgs.lib, stdenv ? pkgs.stdenv, callPackage ? pkgs.callPackage
, fetchFromGitHub ? pkgs.fetchFromGitHub, makeWrapper ? pkgs.makeWrapper
, jre ? pkgs.jre, maven ? pkgs.maven, ant ? pkgs.ant }: