Skip to content

Instantly share code, notes, and snippets.

@arianvp
arianvp / test.sh
Last active February 26, 2025 12:15
Nix signing experiments
#!/bin/sh
set -e
rm -rf unsigned
unsigned="file:///$PWD/unsigned"
# show that content addressed store paths verify without signatures
ca=$(nix store add-path ./file --store "$unsigned")
@arianvp
arianvp / README.md
Last active February 13, 2025 22:15

Asynchronous post-build-hook

this hook queues up store paths on a unix domain socket and then spawns a service to actually push the store path to the cache through socket activation

works on MacOS and Linux

@arianvp
arianvp / fetch.sh
Created December 27, 2024 13:41
fethc.sh
#!/bin/sh
cat "$(nix-build ci -A eval.full --max-jobs 4 --cores 2 --arg chunkSize 10000)"/outpaths.json | jq -r '.[]|values[]|values' | sort | uniq | cut -c 12-43 | xargs -P128 -I {} curl --head https://nixos.tvix.store/{}.narinfo
@arianvp
arianvp / example.nix
Created November 14, 2024 09:48
Block IMDS globally, but allow per service.
let imds = ["169.254.169.254" "fd00:ec2::254"]; in
{
systemd.slices."-".sliceConfig.IPAddressDeny = imds;
systemd.services.my-service-that-needs-aws.serviceConfig.IPAddressAllow = imds;
}
resource "aws_s3_bucket_item" "this" {
bucket = "images"
key = var.image_name
source = var.image_path
}
resource "aws_ebs_snapshort_import" "this" {
disk_container {
type = "VHD"
user_bucket = aws_s3_bucket_item.this.bucket
@arianvp
arianvp / MyLib.hs
Last active October 29, 2024 20:04
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE OverloadedStrings #-}
module MyLib (someFunc) where
import Conduit (ConduitT, Flush (Chunk, Flush), Source, yield, (.|))
import Control.Concurrent (threadDelay)
import Control.Monad (forM_)
import Control.Monad.IO.Class
import Control.Monad.Trans.Class (lift)
longComputation = do
threaDelay 5000
pure ["a", "b" ,"c"]
longComputation2 = do
threadDelay 3000
pure "lol"
website = do
h1 "Hello, World!"
@arianvp
arianvp / README.md
Last active March 4, 2025 18:41
Rosetta AOT Caching on Linux for Virtualization.Framework
@arianvp
arianvp / .envrc
Last active December 6, 2024 14:25
Use nix flakes with private github deps
#!/bin/sh
#If already set (e.g. in github actions); use that instead
if [ -z "$GITHUB_TOKEN" ]; then
nix run nixpkgs#gh auth status || nix run nixpkgs#gh auth login
GITHUB_TOKEN="$(nix run nixpkgs#gh auth token)"
export GITHUB_TOKEN
fi
NIX_CONFIG="access-tokens = github.com=$GITHUB_TOKEN"