### Nix Copy Command Example Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2024-07-05-learn-nix-the-fun-way.md An example of copying a Nix-built derivation to a remote machine using 'nix copy'. This illustrates binary deployment and portability across systems. ```bash nix copy --to ssh://nixie.tail9f4b5.ts.net \ $(nix-build what-is-my-ip.nix) --no-check-sigs ``` -------------------------------- ### Lametun Usage Examples Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2020-09-20-vpns-from-first-principles.md Command-line examples demonstrating how to run the lametun application as either a server (listen mode) or a client, specifying the server IP address. ```bash # the server runs it in listen mode > ./lametun -listen # the client needs to provide the server's IP > ./lametun -server 54.219.126.112 ``` -------------------------------- ### Docker Run Example Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2024-07-05-learn-nix-the-fun-way.md Demonstrates loading and running the Nix-built Docker image. The output confirms the 'what-is-my-ip' tool functions correctly within the container. ```bash docker load < $(nix-build what-is-my-ip-docker.nix) docker run -it what-is-my-ip-docker:c9g6x30invdq1bjfah3w1aw5w52vkdfn ``` -------------------------------- ### Nix Hash Command Example Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2025-03-28-what-s-in-a-nix-store-path.md An example of attempting to hash a Nix store derivation file directly using `nix-hash`. This is shown as an incorrect approach for understanding the full store path derivation. ```console ❌ $ nix-hash /nix/store/w4mcfbibhjgri1nm627gb9whxxd65gmi-simple.drv ``` -------------------------------- ### Nix Store Query Example Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2024-07-05-learn-nix-the-fun-way.md Demonstrates querying the Nix store for the dependency graph of a built derivation. This helps visualize the build dependencies of the 'what-is-my-ip' tool. ```bash nix-store --query --graph $(nix-build what-is-my-ip.nix) | \ dot -Tpng -o what-is-my-ip-deps.png ``` -------------------------------- ### Serve Blog Locally with Jekyll Source: https://github.com/fzakaria/fzakaria.com/blob/master/README.md Starts the Jekyll development server, enabling live preview and testing of the blog content locally. ```sh jekyll serve ``` -------------------------------- ### Generated gemset.nix Example Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2020-07-18-what-is-bundlerenv-doing.md An example of the gemset.nix file generated by bundix. It details the version, source, and checksum for a specific gem, formatted for Nix consumption. ```nix { hello-world = { groups = ["default"]; platforms = []; source = { remotes = ["https://rubygems.org"]; sha256 = "141r6pafbwjf8aczsilxxhdrdbbmdhimgbsq8m9qsvjm522ln15p"; type = "gem"; }; version = "1.2.0"; }; } ``` -------------------------------- ### Nix Shell Setup Coupling with stdenv Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2021-08-05-the-search-for-a-minimal-nix-shell-continued-mkshellminimal.md Illustrates a C++ code snippet from Nix's internal implementation, showing the tight coupling of the nix-shell setup with `$stdenv/setup`. This highlights a technical challenge encountered when aiming for minimal environments. ```c++ std::string rc = fmt( R"(_nix_shell_clean_tmpdir() { rm -rf %1%; }; )"s + (keepTmp ? "trap _nix_shell_clean_tmpdir EXIT; " "exitHooks+=(_nix_shell_clean_tmpdir); " "failureHooks+=(_nix_shell_clean_tmpdir); ": "_nix_shell_clean_tmpdir; ") + (pure ? "" : "[ -n \"$PS1\" ] && [ -e ~/.bashrc ] && source ~/.bashrc;") + "%2%" "dontAddDisableDepTrack=1;\n" + structuredAttrsRC + "\n[ -e $stdenv/setup ] && source $stdenv/setup; " "%3%" "PATH=%4%: \"$PATH\"; " "SHELL=%5%; ``` -------------------------------- ### Makefile Dependency Example Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2025-03-11-nix-dynamic-derivations-a-practical-application.md An example of a dependency file generated by GCC's `-MM` flag, showing the source file and header dependencies for compiling an object file. ```makefile main.o: src/main.c src/hello.h src/world.h ``` -------------------------------- ### package.json Example Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2025-03-12-nix-dynamic-derivations-a-lang2nix-practicum.md A sample package.json file for a Node.js project, defining its name, version, and dependencies. This serves as the input for generating the package-lock.json. ```JSON { "name": "npmnix-demo", "version": "1.0.0", "dependencies": { "is-number": "^7.0.0", "is-odd": "3.0.1", "left-pad": "1.3.0" } } ``` -------------------------------- ### Start Elasticsearch Service Source: https://github.com/fzakaria/fzakaria.com/blob/master/_old_blog/2014-04-16-how-to-install-elasticsearch-on-ec2-with-amazon-linux.html Starts the Elasticsearch service on an Amazon Linux instance using the init script provided by the RPM package. This command assumes Elasticsearch has been installed and configured. ```bash sudo service elasticsearch start ``` -------------------------------- ### Guice Module Composition and Deduplication Example Source: https://github.com/fzakaria/fzakaria.com/blob/master/_old_blog/2016-12-11-large-scale-guice-projects-module-deduplication.html Demonstrates Guice module composition using AbstractModule and the install method. It illustrates the common Multiple Binding Exception that occurs when modules are installed multiple times and hints at the solution using a deduplication library. ```java public class Example { public static class JsonSerializer { //Implementation not important } public static class JsonModule extends AbstractModule { @Override protected void configure() { bind(JsonSerializer.class); } } public static class ModuleA extends AbstractModule { @Override protected void configure() { install(new JsonModule()); } } public static class ModuleB extends AbstractModule { @Override protected void configure() { install(new JsonModule()); } } } ``` -------------------------------- ### Create Dummy Nix Store Dockerfile Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2021-09-10-using-an-overlay-filesystem-to-improve-nix-ci-builds.md This Dockerfile sets up a basic Ubuntu environment with a dummy Nix store directory and a placeholder file. It serves as a minimal base for demonstrating overlay filesystem concepts. ```dockerfile FROM ubuntu # Let's make a dummy nix-store RUN mkdir -p /nix/store # let's put a dummy derivation RUN echo "hello" > /nix/store/hello # a dummy command CMD ["/bin/bash"] ``` -------------------------------- ### Run Bazel with systemd-run (Initial Attempt) Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2025-05-08-bazel-cgroup-memory-investigation.md Example of running a Bazel build command (`//:eat_memory`) using `systemd-run` with memory constraints. This demonstrates an initial setup that might lead to SIGKILL if memory limits are exceeded. ```console > systemd-run --user --scope -p MemoryMax=10M \ -p MemorySwapMax=0M -- bazel run //:eat_memory Running as unit: run-r351ccd338626452181cbe63b78287bbe.scope; invocation ID: 16c6551b89924a7c8182bf2d217253c0 INFO: Analyzed target //:eat_memory (0 packages loaded, 0 targets configured). INFO: Found 1 target... Target //:eat_memory up-to-date: bazel-bin/eat_memory INFO: Elapsed time: 0.058s, Critical Path: 0.00s INFO: 1 process: 1 internal. INFO: Build completed successfully, 1 total action INFO: Running command line: bazel-bin/eat_memory Attempting to allocate 1024 MB of memory gradually. Allocated: 1 MB / 1024 MB Allocated: 2 MB / 1024 MB Allocated: 3 MB / 1024 MB Allocated: 4 MB / 1024 MB Allocated: 5 MB / 1024 MB fish: Job 1, 'systemd-run --user --scope -p M…' terminated by signal SIGKILL (Forced quit) ``` -------------------------------- ### Example of Bazel Runfile Symlinks Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2024-02-27-hermetic-but-at-what-cost.md Illustrates the structure of symlinks created by Bazel for a Python installation within a test's runfiles directory. This output shows how Bazel organizes external dependencies and highlights the presence of numerous symbolic links pointing to cached files. ```console ❯ ls -l bazel-out/k8-fastbuild/mytest.test.runfiles/rules_python\~0.30.0\~python\~python_3_10_x86_64-unknown-linux-gnu/bin 2to3 -> /home/fmzakari/.cache/bazel/_bazel_fmzakari/17bce12c4b47a4a2fc75249afee05177/external/rules_python~0.30.0~python~python_3_10_x86_64-unknown-linux-gnu/bin/2to3 2to3-3.10 -> /home/fmzakari/.cache/bazel/_bazel_fmzakari/17bce12c4b47a4a2fc75249afee05177/external/rules_python~0.30.0~python~python_3_10_x86_64-unknown-linux-gnu/bin/2to3-3.10 idle3 -> /home/fmzakari/.cache/bazel/_bazel_fmzakari/17bce12c4b47a4a2fc75249afee05177/external/rules_python~0.30.0~python~python_3_10_x86_64-unknown-linux-gnu/bin/idle3 ``` -------------------------------- ### Install Elasticsearch AWS Plugin Source: https://github.com/fzakaria/fzakaria.com/blob/master/_old_blog/2014-04-16-how-to-install-elasticsearch-on-ec2-with-amazon-linux.html Installs the Elasticsearch AWS cloud plugin using the plugin manager. This command should be run from the Elasticsearch installation directory and requires Elasticsearch to be installed prior to execution. ```bash bin/plugin -install elasticsearch/elasticsearch-cloud-aws/2.1.0 ``` -------------------------------- ### NixOS VM Execution Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2024-07-05-learn-nix-the-fun-way.md Shows how to build and run the NixOS VM, log in, and verify that the 'what-is-my-ip' tool is available and functional within the virtualized environment. ```console ❯ nix-build what-is-my-ip-vm.nix ❯ QEMU_KERNEL_PARAMS=console=ttyS0 ./result/bin/run-nixos-vm -nographic; reset <<< Welcome to NixOS 24.05pre-git (x86_64) - ttyS0 >>> Run 'nixos-help' for the NixOS manual. nixos login: alice Password: [alice@nixos:~]$ which what-is-my-ip /etc/profiles/per-user/alice/bin/what-is-my-ip [alice@nixos:~]$ readlink $(which what-is-my-ip) /nix/store/lr6wlz2652r35rwzc79samg77l6iqmii-what-is-my-ip/bin/what-is-my-ip [alice@nixos:~]$ what-is-my-ip 24.5.113.148 ``` -------------------------------- ### Passing Data via CustomEvent Detail Source: https://github.com/fzakaria/fzakaria.com/blob/master/_old_blog/2012-01-13-chrome-extension-getting-those-ajax-queries.html This example shows how to pass data through a custom event by serializing and parsing the object using JSON.stringify and JSON.parse. This method is used to circumvent issues with passing complex or 'weird' objects, like those with __proto__ properties, directly through events. ```javascript document.dispatchEvent(new CustomEvent('eventId', {'detail': JSON.parse(JSON.stringify(data))})); ``` -------------------------------- ### Nix Commands: Running and Inspecting Derivations Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2025-03-11-nix-dynamic-derivations-a-practical-application.md Illustrates basic Nix command-line operations for building derivations, executing results, and inspecting derivation inputs using `jq` for structured output. These commands are essential for managing and understanding Nix build processes. ```console > nix run nixpkgs#fish --store /tmp/dyn-drvs > nix build -f default.nix --store /tmp/dyn-drvs --print-out-paths -L /nix/store/v4hkwn8y4m083gsap6523c0m5r985ygr-result > ./result Hello, World! > nix derivation show /nix/store/v4hkwn8y4m083gsap6523c0m5r985ygr-result --store /tmp/dyn-drvs/ | jq -r '.[].inputDrvs | keys' [ "/nix/store/2hm681pgbj7wwg0x0a6wyw0m98rvg0q4-gcc-wrapper-13.3.0.drv", "/nix/store/6inhnnprqd57qw5dv5sqxmc9ywiwi5yf-world.o.drv", "/nix/store/7k0msqyp2dm021sdj0qjgpkzff8xhqzr-bash-5.2p37.drv", "/nix/store/fwvwwnpi04yzpcjcnl6yn3mg82vvp45k-hello.o.drv", "/nix/store/ki70bzsbzapc9wihavq67irlr5zxp90q-main.o.drv", "/nix/store/ycj0m56p8b0rv9v78mggfa6xhm31rww3-stdenv-linux.drv" ] ``` -------------------------------- ### HiveQL for CloudTrail Log Analysis Source: https://github.com/fzakaria/fzakaria.com/blob/master/_old_blog/2014-10-13-analyzing-cloudtrail-logs-using-hivehadoop.html This entry covers the setup and querying of AWS CloudTrail logs using Hive. It includes adding necessary JARs, creating an external table with a custom CloudTrail deserializer, and various example queries to analyze security events. The queries demonstrate filtering by user ID, time ranges, event sources, and aggregating data by user agent. ```APIDOC HiveQL Commands for CloudTrail Log Analysis This section details how to use HiveQL to query AWS CloudTrail logs, which are typically stored in S3. It requires specific JAR files provided by AWS EMR for deserializing the CloudTrail JSON format. Setup: ADD JAR /usr/share/aws/emr/goodies/lib/EmrHadoopGoodies-1.0.0.jar; ADD JAR /usr/share/aws/emr/goodies/lib/EmrHiveGoodies-1.0.0.jar; -- Create an external Hive table for CloudTrail logs. -- This table uses a custom SerDe (CloudTrailLogDeserializer) and InputFormat -- designed to parse the nested JSON structure of CloudTrail logs. CREATE EXTERNAL TABLE IF NOT EXISTS CloudTrailTable ROW FORMAT SERDE 'com.amazon.emr.hive.serde.CloudTrailLogDeserializer' STORED AS INPUTFORMAT 'com.amazon.emr.cloudtrail.CloudTrailInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat' LOCATION 's3://us-east-1.elasticmapreduce.samples/cloudtrail-logs/data/AWSLogs/176430881729/CloudTrail/us-east-1/2014/07/01/'; Queries: -- Show all distinct API calls made by a specific user. -- Filters logs based on the principalId. SELECT DISTINCT(eventName) FROM CloudTrailTable WHERE userIdentity.principalId = "63f29b7986e7c43cb8cd4"; -- Show all distinct API calls made by a specific user within a given time period. -- Converts eventTime to Unix timestamp for comparison. SELECT DISTINCT(eventName) FROM CloudTrailTable WHERE userIdentity.principalId = "40c71535f6ba" AND TO_UNIX_TIMESTAMP(eventTime,"yyyy-MM-dd'T'HH:mm:ss'Z'") BETWEEN TO_UNIX_TIMESTAMP("2014-07-01T10:00:53Z","yyyy-MM-dd'T'HH:mm:ss'Z'") AND TO_UNIX_TIMESTAMP("2014-07-01T20:00:53Z","yyyy-MM-dd'T'HH:mm:ss'Z'"); -- Show API calls originating from the EMR service and the associated caller. -- Filters logs based on the eventSource. SELECT eventName, userIdentity.principalId FROM CloudTrailTable WHERE eventSource = "elasticmapreduce.amazonaws.com"; -- Show the count of different clients (user agents) used, ordered by count descending. -- Groups results by userAgent and counts the number of requests. SELECT userAgent , count(requestId) AS cnt FROM CloudTrailTable GROUP BY userAgent ORDER BY cnt DESC; Optional Configuration for Small Files: -- These settings can be used when dealing with many small log files to improve -- performance by merging them. They are typically set before table creation or data loading. -- SET mapred.input.dir.recursive=true; -- SET hive.mapred.supports.subdirectories=true; -- SET hive.merge.mapredfiles=true; -- SET hive.merge.mapfiles=true; -- Alternative table creation for small files (commented out): -- CREATE EXTERNAL TABLE IF NOT EXISTS CloudTrailTempTable -- ROW FORMAT SERDE 'com.amazon.emr.hive.serde.CloudTrailLogDeserializer' ``` -------------------------------- ### Install Docker CE on Debian Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2020-05-31-containers-from-first-principles.md Installs Docker Community Edition on a Debian system. This includes adding the Docker repository, GPG key, and installing the necessary packages. ```bash sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian buster stable" sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io sudo groupadd docker sudo usermod -aG docker $USER ``` -------------------------------- ### Accessing Bazel Build Outputs with --output_groups Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2025-06-10-bazel-knowledge-diagnostic-messages-only-on-failure.md This example shows how to use the `--output_groups` flag with Bazel to retrieve specific outputs from a successful build. By specifying `output`, it ensures that artifacts like `.out.log` are generated and accessible, facilitating easier inspection of build results. This is a convenient way to get build artifacts without manually configuring output locations. ```bash > bazel build //:hello_world --output_groups=output INFO: Invocation ID: f2341485-42f3-4117-aced-bfdd87ef60ca INFO: Analyzed target //:hello_world (0 packages loaded, 0 targets configured). INFO: Found 1 target... Target //:hello_world up-to-date: bazel-bin/hello_world.err.log bazel-bin/hello_world.out.log INFO: Elapsed time: 0.369s, Critical Path: 0.08s INFO: 3 processes: 1 disk cache hit, 1 internal, 1 darwin-sandbox. INFO: Build completed successfully, 3 total actions ``` -------------------------------- ### C Project Structure and Build Output Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2025-03-11-nix-dynamic-derivations-a-practical-application.md Displays the file structure of a C project and the output of compiling and running a simple 'Hello, World!' program. ```console > tree ├── Makefile └── src ├── hello.c ├── hello.h ├── main.c ├── world.c └── world.h > make all > ./main Hello, World! ``` -------------------------------- ### Bazel Build and Output Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2025-07-08-bazel-knowledge-transition-with-style.md Illustrates building a Bazel target named '//:thesis' and then displaying the content of the generated artifact 'bazel-bin/thesis.txt'. This example highlights Bazel's build process and output. ```bash > bazel build //:thesis INFO: Invocation ID: 5e897401-b516-48fe-bb1b-225ab326fb35 INFO: Analyzed target //:thesis (0 packages loaded, 8 targets configured). INFO: Found 1 target... Target //:thesis up-to-date: bazel-bin/thesis.txt INFO: Elapsed time: 0.134s, Critical Path: 0.00s INFO: 2 processes: 2 internal. INFO: Build completed successfully, 2 total actions > cat bazel-bin/thesis.txt This is my thesis. WELCOME TO CHAPTER 1. WELCOME TO CHAPTER 1 PART 1. Welcome to chapter 1 part 1. Welcome to chapter 2. ``` -------------------------------- ### Console: Install Python Package from GitHub Releases Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2024-01-15-abusing-github-as-a-pypi-server.md Demonstrates how to use pip to install a Python package directly from a GitHub releases page. The -f flag is used with the URL pointing to the expanded assets view, enabling installation without a traditional package index. ```console pip install mlir-python-bindings \ -f https://github.com/makslevental/mlir-wheels/releases/expanded_assets/latest ``` -------------------------------- ### Nix Installation with Trusted User Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2025-07-02-nix-s3-multi-user-woes.md This bash command illustrates how to install Nix in multi-user mode using the Determinate Systems installer. It includes the `--extra-conf "trusted-users = $(whoami)"` flag to add the current user to the list of trusted users, simplifying Nix operations. ```bash curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | \ sh -s -- install linux --no-confirm --init systemd \ --extra-conf "trusted-users = $(whoami)" ``` -------------------------------- ### Build and Sign Nix Store Path Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2020-07-15-setting-up-a-nix-s3-binary-cache.md Builds the Nix derivation locally to ensure the store path exists, then signs the resulting path using the generated private key. This prepares the artifact for upload to the binary cache. ```bash # build it locally so it's present in /nix/store nix-build --no-out-link lolhello.nix # sign the /nix/store path nix sign-paths --key-file cache-priv-key.pem \ $(nix-build --no-out-link lolhello.nix) ``` -------------------------------- ### Building a .drv Output Derivation Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2025-03-10-an-early-look-at-nix-dynamic-derivations.md Demonstrates how to build the Nix derivation that outputs a '.drv' file. This shows the instantiation process and how to retrieve the path to the generated '.drv' file. ```console > nix-instantiate end-drv.nix /nix/store/hm1d9ihxsws8pcdlqyn32qkfaxcjmblr-world.drv.drv > nix build -f end-drv.nix --print-out-paths -L /nix/store/2r65y379iga77g8z42gfibn0bn0w7kgd-world.drv ``` -------------------------------- ### Install HTTPie Source: https://github.com/fzakaria/fzakaria.com/blob/master/_old_blog/2016-01-11-photoreflect-unwatermarked-image.html Command to install HTTPie, a user-friendly command-line HTTP client. This was mentioned as a tool to potentially help with HTTP requests during the investigation. ```shell brew install httpie ``` -------------------------------- ### Run Blog Locally with Nix Source: https://github.com/fzakaria/fzakaria.com/blob/master/README.md This command uses Nix to fetch and run the personal blog project from its GitHub repository, allowing for local execution without manual setup. ```sh nix run github:fzakaria/fzakaria.com ``` -------------------------------- ### HypeMachine Set-Cookie Header Example Source: https://github.com/fzakaria/fzakaria.com/blob/master/_old_blog/2011-03-30-hypemachine-cocoa-win.html An example of a 'Set-Cookie' header received from HypeMachine, illustrating the format and content of authentication cookies used for session management. ```HTTP Set-Cookie: "AUTH=03%3A430aaa119c1852924ef832bbaf5fa989%3A1301502627%3A2170648814%3AON-CA; expires=Fri, 26-Mar-2027 16:30:27 GMT; path=/; domain=hypem.com" ``` -------------------------------- ### Inspect Dynamic Linker Paths and Dependencies Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2022-03-14-shrinkwrap-taming-dynamic-shared-objects.md Demonstrates how to use `patchelf` to inspect the number of directories in a binary's RUNPATH and `ldd` to count its direct shared object dependencies. This illustrates the potential overhead faced by the dynamic linker at process startup. ```console $ patchelf --print-rpath /nix/store/vvxcs4f8x14gyahw50ssff3sk2dij2b3-emacs-27.2/bin/.emacs-27.2-wrapped \ | tr ':' '\n' | wc -l 36 $ ldd /nix/store/vvxcs4f8x14gyahw50ssff3sk2dij2b3-emacs-27.2/bin/.emacs-27.2-wrapped | wc -l 103 ``` -------------------------------- ### Building a Nix Derivation with nix-store --realize Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2025-03-23-nix-derivations-by-hand.md Demonstrates the command used to build a Nix derivation from its .drv file. This process executes the builder script defined in the derivation. ```console > nix-store --realize /nix/store/vh5zww1mqbcshfcblrw3y92v7kkzamfx-simple.drv this derivation will be built: /nix/store/vh5zww1mqbcshfcblrw3y92v7kkzamfx-simple.drv building '/nix/store/vh5zww1mqbcshfcblrw3y92v7kkzamfx-simple.drv'... ``` -------------------------------- ### Nix-Shell Example Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2020-08-11-caching-your-nix-shell.md A simple Nix expression defining a development shell that includes the Chromium browser. This example is used to illustrate the difference in the number of store paths when caching. ```nix let nixpkgs = import {}; in with nixpkgs; with stdenv; with stdenv.lib; mkShell { name = "example-shell"; buildInputs = [chromium]; } ``` -------------------------------- ### NixOS Module Configuration Example Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2024-07-28-nixos-option-inspection.md A basic NixOS module written in Nix language, demonstrating how to set a configuration option. This serves as a simple example for module definition. ```nix {lib, ...}: { config = { a.value = false; }; } ``` -------------------------------- ### Incremental Build Demonstration After Patch Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2025-03-11-nix-dynamic-derivations-a-practical-application.md Shows the output of `nix build` after applying the source code patch. It highlights that only `hello.o` is rebuilt, demonstrating the efficiency of Nix's incremental build capabilities with dynamic derivations. The final output reflects the change made in `src/hello.c`. ```console > nix build -f default.nix --store /tmp/dyn-drvs -print-out-paths -L result.drv> Running phase: unpackPhase result.drv> source root is source result.drv> Running phase: patchPhase result.drv> Running phase: configurePhase result.drv> no configure script, doing nothing result.drv> Running phase: buildPhase result.drv> gcc -MM src/hello.c > src/hello.d result.drv> gcc -MM src/main.c > src/main.d result.drv> gcc -MM src/world.c > src/world.d result.drv> Dependencies generated hello.o> Running phase: unpackPhase hello.o> source root is source hello.o> Running phase: patchPhase hello.o> Running phase: configurePhase hello.o> no configure script, doing nothing hello.o> Running phase: buildPhase hello.o> Running phase: installPhase hello.o> Running phase: fixupPhase /nix/store/flqzpyhf6by2rjizr3px3nmbgqvpj0vv-result > ./result Goodbye, World! ``` -------------------------------- ### Apply Shrinkwrap and Verify Dependency Stamping Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2022-03-14-shrinkwrap-taming-dynamic-shared-objects.md Shows the process of using `patchelf --print-needed` to list dependencies, applying the `shrinkwrap` tool to a binary, and then using `patchelf --print-needed` again on the modified binary to show how dependencies are now stamped with absolute paths, simplifying resolution. ```bash $ patchelf --print-needed /nix/store/zb2h75vbhg7w42b3f42bl0y2d4m0a4n3-emacs-27.1/bin/.emacs-27.1-wrapped libtiff.so.5 libjpeg.so.62 libpng16.so.16 libz.so.1 libungif.so.4 libXpm.so.4 libgtk-3.so.0 libgdk-3.so.0 $ shrinkwrap /nix/store/zb2h75vbhg7w42b3f42bl0y2d4m0a4n3-emacs-27.1/bin/.emacs-27.1-wrapped -o emacs_stamped $ patchelf --print-needed emacs_stamped /nix/store/2nkjrh3za68vrw6kf8lxn6nq1dval05v-gcc-10.3.0-lib/lib/libstdc++.so.6 /nix/store/jvbyjnjh4w8qg7izfq4x5d2wy9lv9461-icu4c-70.1/lib/libicudata.so.70 /nix/store/2kzsm8hhc4lzji6g1ksav9bdjbbiyxln-libgpg-error-1.42/lib/libgpg-error.so.0 /nix/store/mpwncqr8fbqflmglkrxj7a288xdbymk3-util-linux-2.37.2-lib/lib/libblkid.so.1 /nix/store/8n6mjngkw6909rx631rzwby2rsdk0blf-libglvnd-1.3.4/lib/libGLX.so.0 /nix/store/8n6mjngkw6909rx631rzwby2rsdk0blf-libglvnd-1.3.4/lib/libGLdispatch.so.0 /nix/store/xlvnyyviqcjys8if5hgkyykgv7d10hb8-libdatrie-2019-12-20-lib/lib/libdatrie.so.1 /nix/store/2zl3dw54ysdf55hngapkkfhiw0w8c9gp-json-glib-1.6.6/lib/libjson-glib-1.0.so.0 /nix/store/30q5xa4pfbvic54nh68qn86w6kjki66i-sqlite-3.36.0/lib/libsqlite3.so.0 /nix/store/jvbyjnjh4w8qg7izfq4x5d2wy9lv9461-icu4c-70.1/lib/libicui18n.so.70 /nix/store/jvbyjnjh4w8qg7izfq4x5d2wy9lv9461-icu4c-70.1/lib/libicuuc.so.70 ``` -------------------------------- ### Install HTTP Client Tool Source: https://github.com/fzakaria/fzakaria.com/blob/master/_old_blog/2016-01-11-photoreflect-unwatermarked-image.html Installs the `httpie` command-line tool, a user-friendly alternative to cURL, which is used for making HTTP requests. This is a prerequisite for the subsequent download command. ```shell brew install http ``` -------------------------------- ### Bazel Build Output Example Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2025-07-08-bazel-knowledge-transition-with-style.md Illustrates the content of a generated text file after a Bazel build command that applies an 'upper' style. The output shows the thesis text converted to uppercase. ```bash cat bazel-bin/thesis.txt # Expected Output: # THIS IS MY THESIS. # WELCOME TO CHAPTER 1. # WELCOME TO CHAPTER 1 PART 1. # WELCOME TO CHAPTER 2. ``` -------------------------------- ### HypeMachine Downloader Usage Guide Source: https://github.com/fzakaria/fzakaria.com/blob/master/_old_blog/2011-05-19-java-hypemachine-batch-downloader.html Provides instructions for using the HypeMachine Batch Downloader Application. It details how to change download sources, select save locations, scrape additional songs, refresh listings, and initiate downloads. ```text ~Welcome to my slapped together HypeMachine Batch Downloader Application~ 1. Choosing the location to download from: You can change the URL in the top right text field. Simply change ‘popular’ to things such as ‘latest’ or even any username! 2. Choosing where to save the MP3 files. The button to the top right lets you chose the save location. By default it’s where the application has launched from. 3. The 'More' button scrapes additional songs! (Thinking of just having it notice when you scroll to the end instead) 4. The 'Refresh' button restarts the page number 1 and refreshes the song listing. 5. The 'Download' button downloads. Simple! ``` -------------------------------- ### Bazel Build Output Example Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2024-10-23-bazel-knowledge-mind-your-path.md An example of output from a Bazel build command. It shows the invocation ID, build warnings, analysis progress, and detailed compilation steps with caching information and sandbox details. ```bash > bazel build INFO: Invocation ID: f16c3f83-0150-494e-bd34-1a9cfb6a2e67 WARNING: Build option --incompatible_strict_action_env has changed, discarding analysis cache (this can be expensive, see https://bazel.build/advanced/performance/iteration-speed). INFO: Analyzed target @@com_google_protobuf//:protoc (113 packages loaded, 1377 targets configured). [483 / 845] 13 actions, 12 running Compiling src/google/protobuf/compiler/importer.cc; 3s disk-cache, darwin-sandbox Compiling src/google/protobuf/compiler/java/names.cc; 1s disk-cache, darwin-sandbox Compiling src/google/protobuf/compiler/java/name_resolver.cc; 1s disk-cache, darwin-sandbox Compiling src/google/protobuf/compiler/java/helpers.cc; 1s disk-cache, darwin-sandbox Compiling src/google/protobuf/compiler/objectivec/enum.cc; 1s disk-cache, darwin-sandbox Compiling absl/strings/cord.cc; 1s disk-cache, darwin-sandbox Compiling src/google/protobuf/compiler/objectivec/names.cc; 0s disk-cache, darwin-sandbox Compiling absl/time/internal/cctz/src/time_zone_lookup.cc; 0s disk-cache, darwin-sandbox ... ``` -------------------------------- ### sqlelf Tool Output Example Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2023-09-11-quick-insights-using-sqlelf.md This console output shows the results of running the sqlelf tool with a specific SQL query against the /usr/bin/ruby binary. It lists symbols that are shadowed, indicating the symbol name, version, count of libraries exporting it, and the paths to those libraries. ```Console ❯ sqlelf /usr/bin/ruby --recursive --sql " SELECT name, version, count(*) as symbol_count, GROUP_CONCAT(path, ':') as libraries FROM elf_symbols WHERE exported = TRUE GROUP BY name, version HAVING count(*) >= 2" ┌────────────┬─────────────┬──────────────┬─────────────────────────────────────────────────────────────────────────┐ │ name │ version │ symbol_count │ libraries │ │ __finite │ GLIBC_2.2.5 │ 2 │ /usr/lib/x86_64-linux-gnu/libm.so.6:/usr/lib/x86_64-linux-gnu/libc.so.6 │ │ __finitef │ GLIBC_2.2.5 │ 2 │ /usr/lib/x86_64-linux-gnu/libm.so.6:/usr/lib/x86_64-linux-gnu/libc.so.6 │ │ __finitel │ GLIBC_2.2.5 │ 2 │ /usr/lib/x86_64-linux-gnu/libm.so.6:/usr/lib/x86_64-linux-gnu/libc.so.6 │ │ __signbit │ GLIBC_2.2.5 │ 2 │ /usr/lib/x86_64-linux-gnu/libm.so.6:/usr/lib/x86_64-linux-gnu/libc.so.6 │ │ __signbitf │ GLIBC_2.2.5 │ 2 │ /usr/lib/x86_64-linux-gnu/libm.so.6:/usr/lib/x86_64-linux-gnu/libc.so.6 │ │ __signbitl │ GLIBC_2.2.5 │ 2 │ /usr/lib/x86_64-linux-gnu/libm.so.6:/usr/lib/x86_64-linux-gnu/libc.so.6 │ │ copysign │ GLIBC_2.2.5 │ 2 │ /usr/lib/x86_64-linux-gnu/libm.so.6:/usr/lib/x86_64-linux-gnu/libc.so.6 │ │ copysignf │ GLIBC_2.2.5 │ 2 │ /usr/lib/x86_64-linux-gnu/libm.so.6:/usr/lib/x86_64-linux-gnu/libc.so.6 │ │ copysignl │ GLIBC_2.2.5 │ 2 │ /usr/lib/x86_64-linux-gnu/libm.so.6:/usr/lib/x86_64-linux-gnu/libc.so.6 │ │ finite │ GLIBC_2.2.5 │ 2 │ /usr/lib/x86_64-linux-gnu/libm.so.6:/usr/lib/x86_64-linux-gnu/libc.so.6 │ │ finitef │ GLIBC_2.2.5 │ 2 │ /usr/lib/x86_64-linux-gnu/libm.so.6:/usr/lib/x86_64-linux-gnu/libc.so.6 │ │ finitel │ GLIBC_2.2.5 │ 2 │ /usr/lib/x86_64-linux-gnu/libm.so.6:/usr/lib/x86_64-linux-gnu/libc.so.6 │ │ frexp │ GLIBC_2.2.5 │ 2 │ /usr/lib/x86_64-linux-gnu/libm.so.6:/usr/lib/x86_64-linux-gnu/libc.so.6 │ │ frexpf │ GLIBC_2.2.5 │ 2 │ /usr/lib/x86_64-linux-gnu/libm.so.6:/usr/lib/x86_64-linux-gnu/libc.so.6 │ │ frexpl │ GLIBC_2.2.5 │ 2 │ /usr/lib/x86_64-linux-gnu/libm.so.6:/usr/lib/x86_64-linux-gnu/libc.so.6 │ │ ldexp │ GLIBC_2.2.5 │ 2 │ /usr/lib/x86_64-linux-gnu/libm.so.6:/usr/lib/x86_64-linux-gnu/libc.so.6 │ │ ldexpf │ GLIBC_2.2.5 │ 2 │ /usr/lib/x86_64-linux-gnu/libm.so.6:/usr/lib/x86_64-linux-gnu/libc.so.6 │ │ ldexpl │ GLIBC_2.2.5 │ 2 │ /usr/lib/x86_64-linux-gnu/libm.so.6:/usr/lib/x86_64-linux-gnu/libc.so.6 │ │ modf │ GLIBC_2.2.5 │ 2 │ /usr/lib/x86_64-linux-gnu/libm.so.6:/usr/lib/x86_64-linux-gnu/libc.so.6 │ │ modff │ GLIBC_2.2.5 │ 2 │ /usr/lib/x86_64-linux-gnu/libm.so.6:/usr/lib/x86_64-linux-gnu/libc.so.6 │ │ modfl │ GLIBC_2.2.5 │ 2 │ /usr/lib/x86_64-linux-gnu/libm.so.6:/usr/lib/x86_64-linux-gnu/libc.so.6 │ │ scalbn │ GLIBC_2.2.5 │ 2 │ /usr/lib/x86_64-linux-gnu/libm.so.6:/usr/lib/x86_64-linux-gnu/libc.so.6 │ │ scalbnf │ GLIBC_2.2.5 │ 2 │ /usr/lib/x86_64-linux-gnu/libm.so.6:/usr/lib/x86_64-linux-gnu/libc.so.6 │ │ scalbnl │ GLIBC_2.2.5 │ 2 │ /usr/lib/x86_64-linux-gnu/libm.so.6:/usr/lib/x86_64-linux-gnu/libc.so.6 │ └────────────┴─────────────┴──────────────┴─────────────────────────────────────────────────────────────────────────┘ ``` -------------------------------- ### Generated MANIFEST.MF Example Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2020-07-20-packaging-a-maven-application-with-nix.md An example of the META-INF/MANIFEST.MF file generated by the Maven Jar Plugin. It includes the main class and the constructed classpath pointing to dependencies within the 'lib/' directory, following a repository layout. ```MANIFEST Manifest-Version: 1.0 Created-By: Maven Jar Plugin 3.2.0 Build-Jdk-Spec: 11 Class-Path: . lib/org/slf4j/slf4j-api/1.7.30/slf4j-api-1.7.30.jar lib/or g/slf4j/slf4j-simple/1.7.30/slf4j-simple-1.7.30.jar lib/com/google/guav a/guava/29.0-jre/guava-29.0-jre.jar lib/com/google/guava/failureaccess/ 1.0.1/failureaccess-1.0.1.jar lib/com/google/guava/listenablefuture/999 9.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to -avoid-conflict-with-guava.jar lib/com/google/code/findbugs/jsr305/3.0. 2/jsr305-3.0.2.jar lib/org/checkerframework/checker-qual/2.11.1/checker -qual-2.11.1.jar lib/com/google/errorprone/error_prone_annotations/2.3. 4/error_prone_annotations-2.3.4.jar lib/com/google/j2objc/j2objc-annota tions/1.3/j2objc-annotations-1.3.jar Main-Class: com.example.Main ``` -------------------------------- ### Prepare Host Directory for Overlayfs Source: https://github.com/fzakaria/fzakaria.com/blob/master/_posts/2021-09-10-using-an-overlay-filesystem-to-improve-nix-ci-builds.md These bash commands create directories on the host system that will be used as the upper and work directories for the overlay filesystem. A dummy file is placed in the upper directory to simulate pre-existing data. ```bash mkdir -p /tmp/fake-nix/{upper,workdir} echo "ping" > /tmp/fake-nix/upper/pong ```