Skip to content

Instantly share code, notes, and snippets.

View mcdonc's full-sized avatar

Chris McDonough mcdonc

View GitHub Profile
### Keybase proof
I hereby claim:
* I am mcdonc on github.
* I am mcdonc (https://keybase.io/mcdonc) on keybase.
* I have a public key ASB_WBs_JoroZ76SlZJvQGbzm5lCeNzVubCGoYEj9Pu3sAo
To claim this, I am signing this object:
from pyramid.config import Configurator
from pyramid.view import view_config
from waitress import serve
import colander
from pyramid_deform import SessionFileUploadTempStore, CSRFSchema
import deform
from deform import widget
@colander.deferred
# validationtest.py single-file app
from pyramid.config import Configurator
from pyramid.view import view_config
from waitress import serve
import colander
from pyramid_deform import SessionFileUploadTempStore, CSRFSchema
import deform
from deform import widget
@mcdonc
mcdonc / Setup.local
Last active June 20, 2022 22:04
Modules/Setup.local file for building Python on NixOS
zlib zlibmodule.c -lz
readline readline.c -lreadline
_lzma _lzmamodule.c -llzma
_sqlite3 _sqlite/cache.c _sqlite/connection.c _sqlite/cursor.c _sqlite/microprotocols.c _sqlite/module.c _sqlite/prepare_protocol.c _sqlite/row.c _sqlite/statement.c _sqlite/util.c -lsqlite3 -IModules/_sqlite
_curses _cursesmodule.c -lncurses
_bz2 _bz2module.c -lbz2
_lzma _lzmamodule.c -llzma
_ctypes _ctypes/callbacks.c _ctypes/cfield.c _ctypes/_ctypes_test.c _ctypes/malloc_closure.c _ctypes/callproc.c _ctypes/_ctypes.c _ctypes/stgdict.c -I_ctypes/ctypes_dlfcn.h -I_ctypes/ctypes.h -I_ctypes/_ctypes_test.h -lffi
_hashlib _hashopenssl.c -lssl -lcrypto
_ssl _ssl.c -lssl -lcrypto
@mcdonc
mcdonc / x
Created June 20, 2022 22:06
nix-shell command for compiling Python
nix-shell -p gcc libunistring libidn2 bash tzdata zlib zlib.dev readline readline.dev bzip2 bzip2.dev ncurses ncurses.dev \
sqlite sqlite.dev openssl openssl.dev libuuid libuuid.dev gdbm lzlib tk tk.dev libffi libffi.dev expat expat.dev mailcap xz \
xz.dev
@mcdonc
mcdonc / gist:872a16354d1cd8219a188bc443e0a997
Created December 9, 2023 04:31
python3.11-vncdo build failure
❯ nix log /nix/store/8kivy1daix570b3g6yky3zf9cvsdmxa6-python3.11-vncdo-1.1.0.drv
warning: The interpretation of store paths arguments ending in `.drv` recently changed. If this command is now failing try again with '/nix/store/8kivy1daix570b3g6yky3zf9cvsdmxa6-python3.11-vncdo-1.1.0.drv^*'
Sourcing python-remove-tests-dir-hook
Sourcing python-catch-conflicts-hook.sh
Sourcing python-remove-bin-bytecode-hook.sh
Sourcing setuptools-build-hook
Using setuptoolsBuildPhase
Using setuptoolsShellHook
Sourcing pypa-install-hook
Using pypaInstallPhase

writeTextFile, writeText, writeTextDir, writeScript, writeScriptBin {#trivial-builder-writeText}

These functions write text to a file within the Nix store. This is useful for creating files from Nix expressions, which may be scripts or just non-executable text files, depending on the function used and its arguments.

writeTextFile takes an attribute set and expects two arguments, name and text. name corresponds to the name used in the Nix store path. text will be the contents of the file. You can also set executable to true to make this file have the executable bit set.

Many more commands wrap writeTextFile including writeText, writeTextDir, writeScript, and writeScriptBin. These are convenience functions over writeTextFile.

Here are a few examples:

- github secrets
- github integration (devcontainer)
- VS code integration
- analyze data sources
- mongo
#!/usr/bin/env python3
import os
import re
import sys
envvar_pattern = r'\$\{([^\}]+)\}'
def replace_envvars(text, file_path):
def replace(match):
env_var = match.group(1)
@mcdonc
mcdonc / skopeo-copy-nix-to-docker-daemon.md
Created January 27, 2024 23:17
skopeo-copy-nix-to-docker-daemon.md

I am using a project that uses skopeo under the hood. It generates a image json file that represents some Nix software that should be copied into a container image.

I noticed a problem when I attempted to generate a particular container image. I debugged it to the point that I was able to know what command was "failing", and this turned out to be a skopeo copy command. When I run that skopeo copy command, it actually appears to succeed fine, but nothing winds up in the target container registry (the local :docker-daemon).

I know skopeo is working in general on this system to generate images from Nix because I am totally able to generate a different container image within a different configuration, it works fine.