Skip to content

Instantly share code, notes, and snippets.

@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 October 13, 2024 16:25
Rosetta AOT Caching on Linux for Virtualization.Framework
@arianvp
arianvp / .envrc
Last active November 14, 2024 02:16
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"
@arianvp
arianvp / dira-.envrc
Last active December 10, 2023 14:31
multiple shells (Note gists don't support subdirectories so read - as / lol)
use flake .#dira
[root@nixos:~]# poweroff
[root@nixos:~]# Stopping Session 1 of User root...
Stopping Session 2 of User root...
[ OK ] Removed slice Slice /system/modprobe.
[ OK ] Stopped target Multi-User System.
[ OK ] Stopped target Login Prompts.
[ OK ] Stopped target Containers.
[ OK ] Stopped target Network is Online.
@arianvp
arianvp / README.md
Last active June 4, 2024 01:48
An error occurred (AccessDenied) when calling the StartInstanceRefresh operation: You are not authorized to use launch template:

An error occurred (AccessDenied) when calling the StartInstanceRefresh operation: You are not authorized to use launch template:

You came here because you Googled the above error and got zero hits. You will now get a hit!

Problem

You have an error like:

An error occurred (AccessDenied) when calling the StartInstanceRefresh operation: You are not authorized to use launch template:
@arianvp
arianvp / thesis.nix
Created March 8, 2023 12:24
thesis.nix
{ pkgs ? import <nixpkgs> {} }:
let
fontsConf = pkgs.makeFontsConf {
fontDirectories = [ ./fonts ];
};
texlive = pkgs.texlive.combine {
inherit (pkgs.texlive)
appendix
tikzmark