Skip to content

Instantly share code, notes, and snippets.

View ConnorBaker's full-sized avatar

Connor Baker ConnorBaker

View GitHub Profile
@ConnorBaker
ConnorBaker / 2024-03-28-Explaining-Dependency-Offsets-And-Splicing.md
Created March 29, 2024 01:15
2024-03-28 Explaining Dependency Offsets And Splicing

2024-03-28 Explaining Dependency Offsets And Splicing

Most of this is summarized from https://github.com/NixOS/nixpkgs/blob/bc061915ac2cf395e4d1f021cb565f495edfa24a/doc/stdenv/cross-compilation.chapter.md.

Dependency Offsets

In Nixpkgs, dependency offsets are the relative positioning of dependencies in the build process with respect to the build, host, and target platforms. In the case we're not doing cross-compilation, the build, host, and target platforms are the same, and none of this really matters. (Although, with strictDeps = true it can be important as you're telling Nix to enforce separation between build-time and run-time dependencies.)

Some key points:

@ConnorBaker
ConnorBaker / filesize_stats.awk
Created March 28, 2024 05:44
find /nix/store/.links -type f -printf "%s\n" | awk --file=filesize_stats.awk
function human_readable(size) {
split("B KB MB GB TB PB", units); # Include PB in the units array to avoid separate handling
unit_idx = 1; # Start with bytes
while (size >= 1024 && unit_idx < length(units)) {
size /= 1024;
unit_idx++;
}
return sprintf("%.6f %s", size, units[unit_idx]);
@ConnorBaker
ConnorBaker / nixpkgs-review-markdown-template.md
Last active May 1, 2024 15:08
Markdown and bash command templates for Nixpkgs-review for CUDA.

Important

This review was run against commit ########.

Note

Template nixpkgs-review command:

PR="301416" \
@ConnorBaker
ConnorBaker / cudaPackages-build-helper.sh
Last active November 7, 2023 19:36
Helper to build cudaPackages package set
#!/usr/bin/env bash
set -euo pipefail
json_cuda_packages_categorized=$(nix eval --impure --json .#cudaPackages --apply '
attrs:
let
drvKind = drvName:
let
drv = attrs.${drvName};
@ConnorBaker
ConnorBaker / Dockerfile
Last active January 10, 2023 23:45
Dockerfile for building Mimalloc, Mold, CPython, Magma, PyTorch, Torchvision, and Triton from source
# Clone repositories
FROM docker.io/bitnami/git:2.39.0@sha256:8802a1053f0a75c948da43c0d04e591b500381447745f0b5f75d3cf85509626c as git_base
# Basic git configuration
RUN git config --global advice.detachedHead false \
&& git config --global init.defaultBranch main
# Install xz-utils for decompressing tarballs
RUN --mount=type=cache,target=/var/cache/apt \
export DEBIAN_FRONTEND=noninteractive \
{-# LANGUAGE TemplateHaskell #-}
module Tasty.Runners.Buildkite.History where
import Tasty.Runners.Buildkite.Span ( Span )
import Data.Aeson (defaultOptions, camelTo2)
import Data.Aeson.TH (deriveJSON, Options (fieldLabelModifier))
data History = History {
@ConnorBaker
ConnorBaker / output.log
Created April 21, 2022 16:32
M1 build log to test cc-wrapper: Fortran: disable stackprotector hardening on darwin aarch64 #151983 Raw
This file has been truncated, but you can view the full file.
connorbaker@Connors-MacBook-Pro nixpkgs % nix run nixpkgs#nixpkgs-review rev HEAD
$ git -c fetch.prune=false fetch --no-tags --force https://github.com/NixOS/nixpkgs master:refs/nixpkgs-review/0
From https://github.com/NixOS/nixpkgs
1730f14d79a..1a763b8465a master -> refs/nixpkgs-review/0
$ git worktree add /Users/connorbaker/.cache/nixpkgs-review/rev-2cc754a7baa72659430ec961608f0fc1dbe128df/nixpkgs 1a763b8465ad9aca80869792d8a5abac2c4f6373
Preparing worktree (detached HEAD 1a763b8465a)
Updating files: 100% (30225/30225), done.
HEAD is now at 1a763b8465a Merge pull request #168049 from NixOS/haskell-updates
$ nix-env --option system aarch64-darwin -f /Users/connorbaker/.cache/nixpkgs-review/rev-2cc754a7baa72659430ec961608f0fc1dbe128df/nixpkgs -qaP --xml --out-path --show-trace
$ git merge --no-commit --no-ff 2cc754a7baa72659430ec961608f0fc1dbe128df
@ConnorBaker
ConnorBaker / output.log
Created April 13, 2022 11:05
M1 build log to test cc-wrapper: Fortran: disable stackprotector hardening on darwin aarch64 #151983
these 150 paths will be fetched (104.70 MiB download, 655.11 MiB unpacked):
/nix/store/0ak4ybyr97gda5idyfgx4aj9anpja3hr-aws-c-auth-0.6.8
/nix/store/0f7kd5smkxkq0b36qgwiqsng795353fi-perl5.34.0-Test-Needs-0.002006
/nix/store/0hl87pfmhp0q1jbk0dmf8kasvi3ya8ps-apple-framework-QuartzCore-11.0.0
/nix/store/0mr7pcp32apiipy2chwbm40xiyr4rwk2-bash-interactive-5.1-p12-man
/nix/store/0sk7avb5ssjkgmlxy5f3nblh4q482b9v-perl5.34.0-HTML-Tagset-3.20
/nix/store/0yg297zlk50wjr65dqkw74ym1h69cjgb-apple-framework-NetFS-11.0.0
/nix/store/10nzv9njvi32rai2mw5wp15dva05f5q6-perl5.34.0-CGI-4.51
/nix/store/1661xd8g1bc9sw5cvy7da4fp6b51qkpn-nix-2.5.1-man
/nix/store/1nj00g8034rp8h58as2bb0jqlxf6vp44-gettext-0.21
@ConnorBaker
ConnorBaker / run.sh
Created March 16, 2022 15:30
Command to find which nixpkg derivation support `withPackages` or `withPlugins`
rg "(withPackages *=)|(withPlugins *=)" --ignore-case --glob '*.nix'
fst = (a) -> (b) -> a
snd = (a) -> (b) -> b
_Pair2 = (a) -> (b) -> (p2) -> p2(a)(b)
show_pair = (p2) -> p2((a) -> (b) -> "(${a}, ${b})")
test_p2 = _Pair2('A')('B')
// (A, B)
println(show_pair(test_p2))
// A
println(test_p2(fst))