Skip to content

Instantly share code, notes, and snippets.

View bew's full-sized avatar
😎
https://nohello.net

Benoit de Chezelles bew

😎
https://nohello.net
View GitHub Profile
@hellwolf
hellwolf / trace-symlink
Created March 27, 2023 11:58
Nix Helpers: trace-symlink & trace-which
@roberth
roberth / minimod.nix
Last active June 26, 2024 08:27
Simple and quick module system alternative + thoughts and tasks
/*
minimod: A stripped down module system
TODO Comparison:
- [ ] Come up with a benchmark "logic" using plain old functions and let bindings
- [ ] Write the benchmark for the module system
- [ ] Write the benchmark for POP?
- [ ] Qualitative comparison of extensibility in the context of composable
Nixpkgs packaging logic
TODO Fine-tuning:
@bew
bew / WSL2 - Python and pip managed by Nix.md
Last active November 8, 2020 20:35
WSL2 - Basic but working python (with pip) managed by Nix

WSL2 - Basic but working python (with pip) managed by the best Nix package manager

Setup WSL2 using Debian to be able to install Nix

  • On WSL2, install the Debian distribution from the microsoft store, then open wsl.exe in a terminal. I recommand using the Microsoft Terminal (this feels weird to say, since I'm more a linux user than a windows user, but when you NEED to use windows....)

    It should open the Debian distrib, with a small bootstrapping script to create a user.

  • Now update the apt package repositories with sudo apt update

@manveru
manveru / crystal2nix.nix
Created December 16, 2019 23:24
static compilation with crystal
{ lib, crystal, nix-prefetch-git, makeStaticLibraries, stdenv, glibc, pcre
, libyaml, boehmgc, libevent }:
let
staticStdenv = makeStaticLibraries stdenv;
staticGlibc = glibc.static;
staticPcre = pcre.override { stdenv = staticStdenv; };
staticLibyaml = libyaml.override { stdenv = staticStdenv; };
staticBoehmgc =
boehmgc.override { stdenv = staticStdenv // { isLinux = false; }; };
#!/usr/bin/env bash
# Installs NixOS on an OVH server, wiping the server.
#
# This is for a specific server configuration; adjust where needed.
# Originally written for an OVH STOR-1 server.
#
# Prerequisites:
# * Create a LUKS key file at /root/benacofs-luks-key
# e.g. by copying it up.
@bendavis78
bendavis78 / capslock_super_esc.md
Last active August 7, 2024 10:44
Mapping Caps Lock to simultaneous Esc and Super (Mod4)

Mapping Caps Lock to simultaneous Esc and Super (Mod4)

The CAPS key can be mapped to an escape key when pressed once, and a super (mod4) key when used in combination with other keys.

Create the file /usr/share/X11/xkb/symbols/custom_opts with the following:

// Make Caps an additional Escape
hidden partial modifier_keys
xkb_symbols "super_esc" {

key { [ Escape ] };

@ddevault
ddevault / Makefile
Last active February 20, 2024 14:17
Tiny Wayland compositor
WAYLAND_PROTOCOLS=/usr/share/wayland-protocols
# wayland-scanner is a tool which generates C headers and rigging for Wayland
# protocols, which are specified in XML. wlroots requires you to rig these up
# to your build system yourself and provide them in the include path.
xdg-shell-protocol.h:
wayland-scanner server-header \
$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
xdg-shell-protocol.c: xdg-shell-protocol.h
@Papierkorb
Papierkorb / 000_HOWTO.md
Last active May 25, 2024 08:25
Dynamic library in Crystal

Writing a dynamic library in Crystal, and calling it from C

  • Download all files.
  • Build the Crystal part:
crystal build --release --cross-compile --prelude ./no_main library.cr
              ^ You can leave this out
                        ^ We want to link ourselves!
 ^ Use our custom prelude!
@bcardiff
bcardiff / list-deps.cr
Last active May 29, 2024 17:37
List binary dependencies to build a minimal docker image from scratch
unless ARGV.size > 0
puts " Missing executable file argument"
puts " Usage (in a Dockerfile)"
puts " RUN crystal run ./path/to/list-deps.cr -- ./bin/executable"
exit 1
end
executable = File.expand_path(ARGV[0])
unless File.exists?(executable)
require "../crystal/**"
require "../onyx/**"
macro dump_prop(name)
io << "\n" << " " * (depth+1) << {{name.stringify}}[1..-1].cyan << ": "
case (v = {{name}})
when Nil then io << "nil"
else v.dump_inspect(io, terse_output, depth + 1)