Skip to content

Instantly share code, notes, and snippets.

View inclyc's full-sized avatar

Yingchi Long inclyc

  • Institute of Computing Technology, CAS
  • Beijing
  • 15:11 (UTC +08:00)
View GitHub Profile
@inclyc
inclyc / namd2-bin.nix
Created April 26, 2024 02:39
NAMD2 patchelf from binary
{ stdenv
, fetchurl
, autoPatchelfHook
, zlib
}:
let
version = "2.14";
in
stdenv.mkDerivation {
inherit version;
@inclyc
inclyc / lldb-mi.nix
Created October 19, 2023 11:13
lldb-mi nix package
{ lib
, stdenv
, fetchFromGitHub
, cmake
, llvmPackages
}:
stdenv.mkDerivation rec {
pname = "lldb-mi";
version = "0.0.1";
@inclyc
inclyc / llvm-build.sh
Created October 4, 2023 11:35
LLVM compiling commands for developers, with some tweaks for debugging & ccache
#!/usr/bin/env bash
LLVM="$1"
# LLVMBaseDirectory="$LLVM"
# BuildMode="Release"
# BuildDirectory="build-release"
# BuildBase="${LLVMBaseDirectory}/${BuildDirectory}"
# LLVMEnableProjects="clang;mlir"
#!/usr/bin/env bash
# add-vfio.sh: detect iommu groups and override the driver of these devices to vfio-pci
IsolatingDevice="$1"
IOMMUGroup=$(ls "/sys/bus/pci/devices/$IsolatingDevice/iommu_group/devices")
for Device in ${IOMMUGroup}; do
DeviceDir="/sys/bus/pci/devices/$Device"
@inclyc
inclyc / grammar.txt
Created September 16, 2023 03:21
The grammar of Nix language, official implementation
start: expr;
expr: expr_function;
expr_function
: identifier ':' expr_function
| '{' formals '}' ':' expr_function
| '{' formals '}' '@' identifier ':' expr_function
| ASSERT expr ';' expr_function
@inclyc
inclyc / TPM.sh
Created September 9, 2023 10:20
TPM for QEMU, command line
# TPM
TPMSTATE=${TPMSTATE:-"$XDG_RUNTIME_DIR/tpm0"}
mkdir -p $TPMSTATE
TPMCMD=(
swtpm
socket
-d
--tpmstate dir=$TPMSTATE,mode=0600
--tpm2
--ctrl type=unixio,path=${TPMSTATE}/swtpm-sock
@inclyc
inclyc / launch-vm.sh
Last active September 20, 2023 11:21
#!/usr/bin/env bash
# shellcheck disable=SC2054
# Tweakable options, comment to unset.
# Passthrough the GPU (hardware) via PCI Passthrough (OVMF)
EnableGPUPassthrough=
# Whether or not add a sound device, connect to the system
# EnableSystemSound=
@inclyc
inclyc / start-win10.sh
Created May 5, 2023 08:51
QEMU - Windows 10 startup script
#!/usr/bin/env bash
MACHINE_NAME=win10
MACHINE_PATH=$PWD
SPICE_LINK=/tmp/vm-spice-$MACHINE_NAME.socket
# shellcheck disable=SC2054
qemu_cmd=(
#!/usr/bin/env python3
import subprocess
def main():
storePaths = [
'5jrqcja5680bgm7ycdw6lpnvm65hga5y-qemu-8.0.0',
'1nyg1fvhpz8bx3vn3r9f18zhra2rpbx9-glibc-2.37-8',
'28wb2asziwwv2wxynqi9nxiigycsjjmg-zlib-1.2.13',
'hp8yk1q64r8qmxp1k6bava09asgx805z-pcre2-10.42',
@inclyc
inclyc / patchelf-string-literal.sh
Created April 20, 2023 03:08
Patch hardcoded string literals in ELF
#!/usr/bin/env bash
# https://everydaywithlinux.blogspot.com/2012/11/patch-strings-in-binary-files-with-sed.html
function patch_strings_in_file() {
local FILE="$1"
local PATTERN="$2"
local REPLACEMENT="$3"
# Find all unique strings in FILE that contain the pattern