Skip to content

Instantly share code, notes, and snippets.

@ingenieroariel
Last active December 1, 2024 23:08
Show Gist options
  • Save ingenieroariel/e835dce9328e992ea777948b477afe3b to your computer and use it in GitHub Desktop.
Save ingenieroariel/e835dce9328e992ea777948b477afe3b to your computer and use it in GitHub Desktop.
Arcan on stage 1
{
# nix flake update; nix build .#payload
# python proxyclient/tools/run_guest.py -r ../not-os/result/m1n1-linux.bin
inputs = {
nixpkgs.url = "path:./nixpkgs";
firmware = {
url = "path:./firmware";
flake = false;
};
cosmocurl = {
url = "https://cosmo.zip/pub/cosmos/bin/curl";
flake = false;
};
cosmobash = {
url = "https://cosmo.zip/pub/cosmos/bin/bash";
flake = false;
};
};
outputs = { self, nixpkgs, firmware, cosmocurl, cosmobash }: let
system = "aarch64-linux";
asahiKernel = pkgs.callPackage ./linux-asahi/default.nix {
_kernelPatches = [{
name = "asahi-gpu-config";
patch = null;
extraConfig = kernelConfig;
}];
withRust = true;
};
asahiKernelPackages = pkgs.linuxPackagesFor asahiKernel.kernel;
kernelModules = [
# List of initrd modules
"nvme_apple"
"pinctrl-apple-gpio"
"macsmc"
"macsmc-rtkit"
"i2c-pasemi-platform"
"tps6598x"
"apple-admac"
"apple-dart"
"apple-drm"
"asahi"
"dwc3"
"dwc3-of-simple"
"xhci-pci"
"pcie-apple"
"gpio_macsmc"
"phy-apple-atc"
"nvmem_apple_efuses"
"spi-apple"
"spi-hid-apple"
"spi-hid-apple-of"
"rtc-macsmc"
"simple-mfd-spmi"
"spmi-apple-controller"
"nvmem_spmi_mfd"
"apple-dockchannel"
"dockchannel-hid"
"apple-rtkit-helper"
# Additional modules
"usb-storage"
"xhci-plat-hcd"
"usbhid"
"hid_generic"
"r8152"
"cdc_acm"
"uinput"
"snd_seq"
"sunrpc"
"brcmfmac"
"brcmfmac_wcc"
"brcmutil"
"cfg80211"
"bluetooth"
"apple_mfi_fastcharge"
"ofpart"
"apple_dcp"
"sdhci_pci"
"snd_soc_macaudio"
"snd_soc_tas2764"
"snd_soc_cs42l84"
"rfkill"
"spi_nor"
"drm_dma_helper"
"snd_soc_apple_mca"
"mux_core"
"cqhci"
"sdhci"
"snd_soc_core"
"mtd"
"macsec"
"atlantic"
"apple_soc_cpufreq"
"macsmc_hid"
"apple_sio"
"i2c_pasemi_core"
"apple_wdt"
"ulpi"
"udc_core"
"typec"
"clk_apple_nco"
"apple_sart"
"nvme_core"
"nvme_auth"
"scsi_dh_rdac"
"scsi_dh_emc"
"scsi_dh_alua"
];
kernelConfig = ''
CONFIG_EARLY_PRINTK y
CONFIG_SERIAL_EARLYCON y
DRM y
DRM_KMS_HELPER y
DRM_APPLE y
GPU_SCHED y
DRM_GEM_SHMEM_HELPER y
DRM_SIMPLEDRM n
DRM_PANEL y
DRM_BRIDGE y
DRM_PANEL_BRIDGE y
DRM_TTM y
DRM_SHMEM y
DRM_DEBUG_MM y
DRM_DEBUG_KMS y
FRAMEBUFFER_CONSOLE y
FRAMEBUFFER y
FB_SIMPLE y
FONT_8x16 y
FONT_TER16x32 y
INPUT_KEYBOARD y
INPUT_MOUSE y
HID_GENERIC y
USB_HID y
KEYBOARD_ATKBD y
VT y
VT_CONSOLE y
VT_HW_CONSOLE_BINDING y
SND y
SND_USB y
SND_USB_AUDIO y
VFAT_FS y
FAT_FS y
FUSE_FS y
INPUT y
INPUT_FF_MEMLESS y
HID y
HID_PLAYSTATION y
MACSEC y
BT y
BT_RFCOMM y
BT_BNEP y
CRYPTO_CRCT10DIF_ARM64_CE y
CRYPTO_SHA3_ARM64 y
CRYPTO_SHA512_ARM64 y
BINFMT_MISC y
I2C_CHARDEV y
SHMEM y
TMPFS y
DEVTMPFS y
DEVPTS_MULTIPLE_INSTANCES y
'';
pkgs = import nixpkgs {
inherit system;
config = { allowUnfree = true; };
overlays = [
(final: prev: {
cosmoUtils = prev.runCommand "cosmoutils" {} ''
mkdir -p $out/bin
cp ${cosmocurl} $out/bin/curl
cp ${cosmobash} $out/bin/bash
chmod +x $out/bin/*
'';
openssh = prev.openssh.override { withFIDO = false; withKerberos = false; };
util-linux = prev.util-linux.override {
pamSupport = false;
capabilitiesSupport = false;
ncursesSupport = false;
systemdSupport = false;
nlsSupport = false;
translateManpages = false;
};
utillinuxCurses = prev.util-linux;
utillinuxMinimal = prev.util-linux;
m1n1 = prev.callPackage ./m1n1/default.nix {};
asahi-fwextract = prev.callPackage ./asahi-fwextract/default.nix {};
coreutils = prev.coreutils.overrideAttrs (_: { doCheck = false; });
diffutils = prev.diffutils.overrideAttrs (_: { doCheck = false; });
findutils = prev.findutils.overrideAttrs (_: { doCheck = false; });
gnugrep = prev.gnugrep.overrideAttrs (_: { doCheck = false; });
e2fsprogs = prev.e2fsprogs.overrideAttrs (_: { doCheck = false; });
})
];
};
# Define base modules directly
baseModules = [
({ lib, pkgs, config, ... }:
let
modules = pkgs.makeModulesClosure {
rootModules = config.boot.initrd.availableKernelModules ++ config.boot.initrd.kernelModules;
allowMissing = true;
kernel = asahiKernel.kernel;
firmware = config.hardware.firmware;
};
dhcpcd = pkgs.dhcpcd.override { udev = null; };
extraUtils = pkgs.runCommandCC "extra-utils"
{
nativeBuildInputs = [ pkgs.nukeReferences ];
allowedReferences = [ "out" pkgs.glibc.out ];
} ''
set +o pipefail
mkdir -p $out/bin $out/lib
mkdir -p $out/share/arcan/appl/pipeworld
mkdir -p $out/share/arcan/appl/durden
mkdir -p $out/share/arcan/appl/cat9
mkdir -p $out/share/arcan/appl/console
mkdir -p $out/share/arcan/appl/welcome
mkdir -p $out/share/arcan/scripts
mkdir -p $out/share/arcan/resources
mkdir -p $out/share/man/man1
ln -s $out/bin $out/sbin
copy_bin_and_libs() {
[ -f "$out/bin/$(basename $1)" ] && rm "$out/bin/$(basename $1)"
cp -rpd $1 $out/bin
}
cp -r ${pkgs.arcan}/share $out/
cp -r ${pkgs.cat9}/share $out/
cp -r ${pkgs.durden}/share $out/
cp -r ${pkgs.pipeworld}/share $out/
mkdir $out/tests
cp -r ${pkgs.arcan.src}/tests $out/tests
cp -r ${pkgs.xkeyboard_config}/share/X11/xkb $out/xkb
# Copy Busybox
for BIN in ${pkgs.busybox}/{s,}bin/*; do
copy_bin_and_libs $BIN
done
for BIN in ${pkgs.arcan}/{s,}bin/*; do
copy_bin_and_libs $BIN
done
for BIN in ${pkgs.sqlite}/{s,}bin/*; do
copy_bin_and_libs $BIN
done
for BIN in ${pkgs.cosmoUtils}/{s,}bin/*; do
copy_bin_and_libs $BIN
done
for BIN in ${pkgs.dhcpcd}/{s,}bin/*; do
copy_bin_and_libs $BIN
done
for BIN in ${pkgs.vulkan-tools}/{s,}bin/*; do
copy_bin_and_libs $BIN
done
for BIN in ${pkgs.kmscube}/{s,}bin/*; do
copy_bin_and_libs $BIN
done
for BIN in ${pkgs.evtest}/{s,}bin/*; do
copy_bin_and_libs $BIN
done
for BIN in ${pkgs.autoconf}/bin/*; do
copy_bin_and_libs $BIN
done
for BIN in ${pkgs.automake}/bin/*; do
copy_bin_and_libs $BIN
done
for BIN in ${pkgs.texinfo}/bin/*; do
copy_bin_and_libs $BIN
done
for BIN in ${pkgs.openssl}/bin/*; do
copy_bin_and_libs $BIN
done
for BIN in ${pkgs.bison}/bin/*; do
copy_bin_and_libs $BIN
done
for BIN in ${pkgs.m4}/bin/*; do
copy_bin_and_libs $BIN
done
for BIN in ${pkgs.ninja}/bin/*; do
copy_bin_and_libs $BIN
done
for BIN in ${pkgs.cmake}/bin/*; do
copy_bin_and_libs $BIN
done
for BIN in ${pkgs.pkg-config}/bin/*; do
copy_bin_and_libs $BIN
done
for BIN in ${pkgs.strace}/bin/*; do
copy_bin_and_libs $BIN
done
# Copy ld manually since it isn't detected correctly
cp -pv ${pkgs.glibc.out}/lib/ld*.so.? $out/lib
cp -pv ${pkgs.zlib}/lib/libz.so.? $out/lib
# Copy all of the needed libraries
find $out/bin $out/lib $out/sbin -type f | while read BIN; do
echo "Copying libs for executable $BIN"
LDD="$(ldd $BIN)" || continue
LIBS="$(echo "$LDD" | awk '{print $3}' | sed '/^$/d')"
for LIB in $LIBS; do
TGT="$out/lib/$(basename $LIB)"
if [ ! -f "$TGT" ]; then
SRC="$(readlink -e $LIB)"
cp -pdv "$SRC" "$TGT"
fi
done
done
# Strip binaries further than normal.
chmod -R u+w $out
# Run patchelf to make the programs refer to the copied libraries.
find $out/bin $out/lib $out/sbin -type f | while read i; do
if ! test -L $i; then
nuke-refs -e $out $i
fi
done
find $out/bin -type f | while read i; do
if ! test -L $i; then
echo "patching $i..."
patchelf --set-interpreter $out/lib/ld*.so.? --set-rpath $out/lib $i || true
fi
done
# Make sure that the patchelf'ed binaries still work.
echo "testing patched programs..."
$out/bin/ash -c 'echo hello world' | grep "hello world"
export LD_LIBRARY_PATH=$out/lib
$out/bin/mount --help 2>&1 | grep -q "BusyBox"
'';
shell = "${extraUtils}/bin/ash";
enablePlymouth = false;
dhcpHook = pkgs.writeScript "dhcpHook" ''
#!${shell}
'';
bootStage1 = pkgs.writeScript "stage1" ''
#!${shell}
echo "running /initrd"
export PATH=/bin/:${extraUtils}/sbin:/libexec/git-core
export LD_LIBRARY_PATH=${extraUtils}/lib:/lib
ln -s ${extraUtils}/bin /bin
mkdir -p /proc /sys /dev /etc/udev /tmp /run/ /lib/ /mnt/ /var/log /var/db /var/run /opt
mount -t devtmpfs devtmpfs /dev/
mount -t proc proc /proc
mount -t sysfs sysfs /sys
mkdir -p /dev/shm
mkdir -p /dev/pts
mount -t tmpfs tmpfs /dev/shm -o mode=1777,nosuid,nodev
mount -t devpts devpts /dev/pts -o mode=620,gid=5
chmod 1777 /dev/shm
ln -s ${modules}/lib/modules /lib/modules
echo "loading asahi GPU driver"
modprobe asahi
modprobe apple-dart
${extraUtils}/bin/echo 'nameserver 1.1.1.1' > /etc/resolv.conf
mkdir -p /etc
cat > /etc/drirc <<EOF
<driconf>
<device>
<application name="Default">
<option name="allow_rgb10_configs" value="true" />
<option name="mesa_glthread" value="true" />
</application>
</device>
</driconf>
EOF
#export ARCAN_VIDEO_DECODE=1
#export ARCAN_VIDEO_DEBUG=1
#export LIBGL_DEBUG=verbose
#export MESA_DEBUG=1
#export MESA_LOADER_DRIVER_OVERRIDE=asahi
#export DRI_PRIME=1
#export DRM_DEBUG=15
#export AGX_DEBUG=all
export SHELL=${extraUtils}/bin/bash
export XKB_CONFIG_ROOT=${extraUtils}/xkb
export LASH_BASE=${extraUtils}/share/arcan/appl/cat9/
export LASH_SHELL=cat9
export ARCAN_VIDEO_DEVICE=/dev/dri/card0
export ARCAN_VIDEO_DRAW_DEVICE=/dev/dri/renderD128
export ARCAN_RENDER_NODE=/dev/dri/renderD128
export ARCAN_RESOURCEPATH=${extraUtils}/share/arcan/resources
export ARCAN_FONTPATH=${extraUtils}/share/arcan/resources/fonts
export ARCAN_LOGPATH=/tmp/log
export ARCAN_APPLBASEPATH=${extraUtils}/share/arcan/appl
export ARCAN_SCRIPTPATH=${extraUtils}/share/arcan/scripts
export ARCAN_STATEPATH=/tmp/state
export ARCAN_STATEBASEPATH=/tmp/statebase
export ARCAN_APPLTEMPPATH=/tmp/appltemp
export ARCAN_APPLSTOREPATH=/tmp/applstore
export ARCAN_BINPATH=${extraUtils}/bin/arcan_frameserver
export ARCAN_DB=/.arcan/arcan.sqlite
export ARCAN_DB_SQL_INIT=/.arcan/arcan.sql
mkdir -p /tmp/log /tmp/state /tmp/statebase /tmp/appltemp /tmp/applstore /.arcan
cat > $ARCAN_DB_SQL_INIT <<EOF
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE appl_arcan (key TEXT UNIQUE, val TEXT NOT NULL);
INSERT INTO appl_arcan VALUES('dbversion','4');
CREATE TABLE appl_arcan_lwa (key TEXT UNIQUE, val TEXT NOT NULL);
INSERT INTO appl_arcan_lwa VALUES('dbversion','4');
CREATE TABLE target (tgtid INTEGER PRIMARY KEY,tag STRING NOT NULL,name STRING UNIQUE NOT NULL,executable TEXT NOT NULL,user_id STRING DEFAULT NULL,user_group STRING DEFAULT NULL,bfmt INTEGER NOT NULL);
CREATE TABLE config (cfgid INTEGER PRIMARY KEY,name STRING NOT NULL,passed_counter INTEGER,failed_counter INTEGER,target INTEGER NOT NULL,UNIQUE (name, target),FOREIGN KEY (target) REFERENCES target(tgtid) ON DELETE CASCADE );
CREATE TABLE target_argv (argnum INTEGER PRIMARY KEY,arg STRING NOT NULL,target INTEGER NOT NULL,FOREIGN KEY (target) REFERENCES target(tgtid) ON DELETE CASCADE );
CREATE TABLE config_argv (argnum INTEGER PRIMARY KEY,arg STRING NOT NULL,config INTEGER NOT NULL,FOREIGN KEY (config) REFERENCES config(cfgid) ON DELETE CASCADE );
CREATE TABLE target_kv (key STRING NOT NULL,val STRING NOT NULL,target INT NOT NULL,UNIQUE (key, target), FOREIGN KEY (target) REFERENCES target(tgtid) ON DELETE CASCADE );
CREATE TABLE config_kv (key STRING NOT NULL,val STRING NOT NULL,config INT NOT NULL,UNIQUE (key, config), FOREIGN KEY (config) REFERENCES config(cfgid) ON DELETE CASCADE );
CREATE TABLE target_env (key STRING NOT NULL,val STRING NOT NULL,target INT NOT NULL,UNIQUE (key, target), FOREIGN KEY (target) REFERENCES target(tgtid) ON DELETE CASCADE );
CREATE TABLE config_env (key STRING NOT NULL,val STRING NOT NULL,config INT NOT NULL,UNIQUE (key, config),FOREIGN KEY (config) REFERENCES target(tgtid) ON DELETE CASCADE );
CREATE TABLE target_libs (libnum INTEGER PRIMARY KEY,libname STRING NOT NULL,libnote STRING NOT NULL,target INT NOT NULL,UNIQUE (libname, target),FOREIGN KEY (target) REFERENCES target(tgtid) ON DELETE CASCADE );
CREATE TABLE appl_durden (key TEXT UNIQUE, val TEXT NOT NULL);
INSERT INTO appl_durden VALUES('tbar_btn_float_2','left:icon_maximize:/target/window/move_resize/maximize');
INSERT INTO appl_durden VALUES('tbar_btn_all_1','left:icon_destroy:/target/window/destroy');
INSERT INTO appl_durden VALUES('tbar_btn_float_1','left:icon_minimize:/target/window/minimize');
INSERT INTO appl_durden VALUES('sbar_btn_2','left:icon_cli:/global/open/terminal');
INSERT INTO appl_durden VALUES('sbar_btn_1','left:Go:/global');
INSERT INTO appl_durden VALUES('sbar_btn_alt_1','/global/tools/popup/menu=/menus/cli_icon');
INSERT INTO appl_durden VALUES('sysk_meta_1','LMETA');
INSERT INTO appl_durden VALUES('sysk_meta_2','RMETA');
INSERT INTO appl_durden VALUES('autostart_ok','1');
INSERT INTO appl_durden VALUES('wsk_default_1_insert','h');
INSERT INTO appl_durden VALUES('wsk_default_1_mode','tile');
INSERT INTO appl_durden VALUES('tiler_default_sel','1');
INSERT INTO appl_durden VALUES('disp_64656661756c745f_primary','0');
INSERT INTO appl_durden VALUES('disp_64656661756c745f_ppcm','56.559219290494');
INSERT INTO appl_durden VALUES('disp_64656661756c745f_map','0');
INSERT INTO appl_durden VALUES('disp_64656661756c745f_shader','DEFAULT');
INSERT INTO appl_durden VALUES('disp_64656661756c745f_backlight','1');
INSERT INTO appl_durden VALUES('disp_64656661756c745f_w','1920');
INSERT INTO appl_durden VALUES('disp_64656661756c745f_h','1080');
INSERT INTO appl_durden VALUES('disp_64656661756c745f_refresh','240');
INSERT INTO appl_durden VALUES('htab_rpad','0');
INSERT INTO appl_durden VALUES('enc_vpreset','8');
INSERT INTO appl_durden VALUES('enc_presilence','0');
INSERT INTO appl_durden VALUES('control_path','control');
INSERT INTO appl_durden VALUES('term_bitmap','false');
INSERT INTO appl_durden VALUES('gpu_auth','none');
INSERT INTO appl_durden VALUES('clipboard_access','none');
INSERT INTO appl_durden VALUES('xarcan_clipboard_autopaste','false');
INSERT INTO appl_durden VALUES('subwnd_limit','10');
INSERT INTO appl_durden VALUES('display_shader','basic');
INSERT INTO appl_durden VALUES('display_vrr','false');
INSERT INTO appl_durden VALUES('display_direct','false');
INSERT INTO appl_durden VALUES('display_color','30:30:30');
INSERT INTO appl_durden VALUES('display_fs_rtrate','2');
INSERT INTO appl_durden VALUES('transition','10');
INSERT INTO appl_durden VALUES('animation','10');
INSERT INTO appl_durden VALUES('wnd_animation','10');
INSERT INTO appl_durden VALUES('popup_animation','5');
INSERT INTO appl_durden VALUES('ws_transition_in','fade');
INSERT INTO appl_durden VALUES('ws_transition_out','fade');
INSERT INTO appl_durden VALUES('ws_autodestroy','true');
INSERT INTO appl_durden VALUES('ws_autoadopt','true');
INSERT INTO appl_durden VALUES('ws_default','tile');
INSERT INTO appl_durden VALUES('ws_altmenu','wsmenu');
INSERT INTO appl_durden VALUES('ws_child_default','parent');
INSERT INTO appl_durden VALUES('child_ws_control','true');
INSERT INTO appl_durden VALUES('ws_popup','wsbtn');
INSERT INTO appl_durden VALUES('hide_titlebar','false');
INSERT INTO appl_durden VALUES('titlebar_ptn','%p %t - %i');
INSERT INTO appl_durden VALUES('titlebar_statusbar','false');
INSERT INTO appl_durden VALUES('mouse_focus_event','click');
INSERT INTO appl_durden VALUES('mouse_remember_position','true');
INSERT INTO appl_durden VALUES('mouse_dblclick','12');
INSERT INTO appl_durden VALUES('mouse_m2_cursortag','true');
INSERT INTO appl_durden VALUES('mouse_stickydnd','true');
INSERT INTO appl_durden VALUES('mouse_coalesce','true');
INSERT INTO appl_durden VALUES('mouse_debounce_1','0');
INSERT INTO appl_durden VALUES('mouse_debounce_2','0');
INSERT INTO appl_durden VALUES('mouse_debounce_3','0');
INSERT INTO appl_durden VALUES('mouse_debounce_4','0');
INSERT INTO appl_durden VALUES('mouse_debounce_5','0');
INSERT INTO appl_durden VALUES('mouse_debounce_6','0');
INSERT INTO appl_durden VALUES('mouse_debounce_7','0');
INSERT INTO appl_durden VALUES('mouse_debounce_8','0');
INSERT INTO appl_durden VALUES('float_tile_sz','16:16');
INSERT INTO appl_durden VALUES('float_tbar_override','false');
INSERT INTO appl_durden VALUES('float_bg_rclick','/global/tools/popup/menu=/menus/floatbg');
INSERT INTO appl_durden VALUES('tile_gap_w','0');
INSERT INTO appl_durden VALUES('tile_gap_h','0');
INSERT INTO appl_durden VALUES('tile_insert_child','child');
INSERT INTO appl_durden VALUES('tile_breadth_cap','0');
INSERT INTO appl_durden VALUES('mouse_scalef','1');
INSERT INTO appl_durden VALUES('mt_classifier','relmouse');
INSERT INTO appl_durden VALUES('idle_threshold','2500');
INSERT INTO appl_durden VALUES('gain_fade','10');
INSERT INTO appl_durden VALUES('global_mute','false');
INSERT INTO appl_durden VALUES('kbd_period','2');
INSERT INTO appl_durden VALUES('kbd_delay','300');
INSERT INTO appl_durden VALUES('advfloat_spawn','auto');
INSERT INTO appl_durden VALUES('meta_lock','none');
INSERT INTO appl_durden VALUES('meta_stick_time','0');
INSERT INTO appl_durden VALUES('meta_dbltime','10');
INSERT INTO appl_durden VALUES('meta_hold_suggest','120');
INSERT INTO appl_durden VALUES('device_notification','500');
INSERT INTO appl_durden VALUES('term_autosz','true');
INSERT INTO appl_durden VALUES('term_cellw','12');
INSERT INTO appl_durden VALUES('term_cellh','12');
INSERT INTO appl_durden VALUES('term_font_sz','12');
INSERT INTO appl_durden VALUES('term_font_hint','2');
INSERT INTO appl_durden VALUES('enc_fps','30');
INSERT INTO appl_durden VALUES('enc_vbr','0');
INSERT INTO appl_durden VALUES('term_popup_height','0.3');
INSERT INTO appl_durden VALUES('enc_vqual','7');
INSERT INTO appl_durden VALUES('enc_container','mkv');
INSERT INTO appl_durden VALUES('enc_srate','-1');
INSERT INTO appl_durden VALUES('a12net_on_initial','button_left');
INSERT INTO appl_durden VALUES('advfloat_actionreg','false');
INSERT INTO appl_durden VALUES('shadow_style','none');
INSERT INTO appl_durden VALUES('shadow_t','6');
INSERT INTO appl_durden VALUES('shadow_l','6');
INSERT INTO appl_durden VALUES('shadow_d','6');
INSERT INTO appl_durden VALUES('shadow_r','6');
INSERT INTO appl_durden VALUES('shadow_color','0:0:0');
INSERT INTO appl_durden VALUES('advfloat_hide','statusbar-left');
INSERT INTO appl_durden VALUES('overview_tilebg_opa','0.8');
INSERT INTO appl_durden VALUES('overview_tilebg_shader','default');
INSERT INTO appl_durden VALUES('bind_waittime','30');
INSERT INTO appl_durden VALUES('lbar_dim','0.8');
INSERT INTO appl_durden VALUES('lbar_spacing','10');
INSERT INTO appl_durden VALUES('lbar_bg','51:51:51');
INSERT INTO appl_durden VALUES('lbar_helperbg','36:36:36');
INSERT INTO appl_durden VALUES('lbar_textstr','\#cccccc ');
INSERT INTO appl_durden VALUES('lbar_alertstr','\#ff0000 ');
INSERT INTO appl_durden VALUES('lbar_labelstr','\#00ff00 ');
INSERT INTO appl_durden VALUES('lbar_menulblstr','\#ffff00 ');
INSERT INTO appl_durden VALUES('lbar_menulblselstr','\#ffff00 ');
INSERT INTO appl_durden VALUES('lbar_helperstr','\#aaaaaa ');
INSERT INTO appl_durden VALUES('mouse_factor','1');
INSERT INTO appl_durden VALUES('mouse_hovertime','40');
INSERT INTO appl_durden VALUES('mouse_dragdelta','4');
INSERT INTO appl_durden VALUES('mouse_hidetime','420');
INSERT INTO appl_durden VALUES('lbar_caret_col','0:255:0');
INSERT INTO appl_durden VALUES('lbar_seltextstr','\#ffffff ');
INSERT INTO appl_durden VALUES('lbar_seltextbg','68:102:136');
INSERT INTO appl_durden VALUES('lbar_itemspace','10');
INSERT INTO appl_durden VALUES('lbar_fltfun','prefix');
INSERT INTO appl_durden VALUES('lbar_nextsym','➡');
INSERT INTO appl_durden VALUES('sbar_min_sz','0');
INSERT INTO appl_durden VALUES('bind_repeat','5');
INSERT INTO appl_durden VALUES('sbar_alpha','0.3');
INSERT INTO appl_durden VALUES('msg_timeout','100');
INSERT INTO appl_durden VALUES('sbar_tspace','0');
INSERT INTO appl_durden VALUES('sbar_lspace','0');
INSERT INTO appl_durden VALUES('sbar_dspace','0');
INSERT INTO appl_durden VALUES('sbar_rspace','0');
INSERT INTO appl_durden VALUES('sbar_tshadow','8');
INSERT INTO appl_durden VALUES('sbar_lshadow','5');
INSERT INTO appl_durden VALUES('borderw','1');
INSERT INTO appl_durden VALUES('sbar_rshadow','5');
INSERT INTO appl_durden VALUES('bordert_float','1');
INSERT INTO appl_durden VALUES('borderw_float','4');
INSERT INTO appl_durden VALUES('border_color','60:104:135');
INSERT INTO appl_durden VALUES('tbar_color','60:104:135');
INSERT INTO appl_durden VALUES('sbar_position','top');
INSERT INTO appl_durden VALUES('shadow_defocus','1');
INSERT INTO appl_durden VALUES('sbar_visible','desktop');
INSERT INTO appl_durden VALUES('sbar_wsbuttons','true');
INSERT INTO appl_durden VALUES('browser_position','20');
INSERT INTO appl_durden VALUES('browser_trigger','selection');
INSERT INTO appl_durden VALUES('sbar_dispbuttons','true');
INSERT INTO appl_durden VALUES('passmask','false');
INSERT INTO appl_durden VALUES('float_defw','0.3');
INSERT INTO appl_durden VALUES('float_defh','0.2');
INSERT INTO appl_durden VALUES('sbar_lockbutton_visible','locked');
INSERT INTO appl_durden VALUES('sbar_lockbutton_symbol','Lock');
INSERT INTO appl_durden VALUES('htab_tpad','0');
INSERT INTO appl_durden VALUES('sbar_lockbutton_dir','left');
INSERT INTO appl_durden VALUES('sbar_lblcolor','dynamic');
INSERT INTO appl_durden VALUES('sbar_prefixcolor','dynamic');
INSERT INTO appl_durden VALUES('sbar_compact','false');
INSERT INTO appl_durden VALUES('sbar_sidepad','0');
INSERT INTO appl_durden VALUES('tbar_text','left');
INSERT INTO appl_durden VALUES('tbar_textstr','\#ffffff ');
INSERT INTO appl_durden VALUES('tbar_rclick','/global/tools/popup/menu=/target');
INSERT INTO appl_durden VALUES('gamma_access','none');
INSERT INTO appl_durden VALUES('tbar_position','top');
INSERT INTO appl_durden VALUES('tbar_compact','false');
INSERT INTO appl_durden VALUES('tbar_sidepad','0');
INSERT INTO appl_durden VALUES('mouse_hardlock','false');
INSERT INTO appl_durden VALUES('xarcan_autows_nodecor','true');
INSERT INTO appl_durden VALUES('xarcan_autows_tagname','true');
INSERT INTO appl_durden VALUES('xarcan_metawm','false');
INSERT INTO appl_durden VALUES('xarcan_seamless','false');
INSERT INTO appl_durden VALUES('icon_set','default');
INSERT INTO appl_durden VALUES('notifications_enable','true');
INSERT INTO appl_durden VALUES('lwa_autores','true');
INSERT INTO appl_durden VALUES('mouse_reveal','true');
INSERT INTO appl_durden VALUES('cloth_mass','1');
INSERT INTO appl_durden VALUES('cloth_damp_s','0.99');
INSERT INTO appl_durden VALUES('cloth_damp_t','0.99');
INSERT INTO appl_durden VALUES('sbar_sz','34');
INSERT INTO appl_durden VALUES('sbar_tpad','1');
INSERT INTO appl_durden VALUES('sbar_bpad','1');
INSERT INTO appl_durden VALUES('tbar_sz','38');
INSERT INTO appl_durden VALUES('tbar_tpad','4');
INSERT INTO appl_durden VALUES('tbar_bpad','2');
INSERT INTO appl_durden VALUES('lbar_sz','36');
INSERT INTO appl_durden VALUES('lbar_caret_h','32');
INSERT INTO appl_durden VALUES('hc_palette_1','\#efd469');
INSERT INTO appl_durden VALUES('hc_palette_2','\#43abc9');
INSERT INTO appl_durden VALUES('hc_palette_3','\#cd594a');
INSERT INTO appl_durden VALUES('hc_palette_4','\#b5c689');
INSERT INTO appl_durden VALUES('hc_palette_5','\#f58b4c');
INSERT INTO appl_durden VALUES('hc_palette_6','\#ed6785');
INSERT INTO appl_durden VALUES('hc_palette_7','\#d0d0d0');
INSERT INTO appl_durden VALUES('a12net_on_update','alert');
INSERT INTO appl_durden VALUES('flair_speed','50');
INSERT INTO appl_durden VALUES('gesture_flash','true');
INSERT INTO appl_durden VALUES('gesture_cooldown','20');
INSERT INTO appl_durden VALUES('gesture_timeout','10');
INSERT INTO appl_durden VALUES('gesture_delta','5');
INSERT INTO appl_durden VALUES('gesture_threshold','1');
INSERT INTO appl_durden VALUES('gesture_samples','60');
INSERT INTO appl_durden VALUES('gesture_color','\#00aa00');
INSERT INTO appl_durden VALUES('menu_helper','true');
INSERT INTO appl_durden VALUES('a12net_on_discover','button_left');
INSERT INTO appl_durden VALUES('meta_guard','false');
INSERT INTO appl_durden VALUES('term_bgcol','0:0:0');
INSERT INTO appl_durden VALUES('term_fgcol','255:255:255');
INSERT INTO appl_durden VALUES('term_cursor','block');
INSERT INTO appl_durden VALUES('term_blink','0');
INSERT INTO appl_durden VALUES('term_interp','tsm');
INSERT INTO appl_durden VALUES('term_opa','1');
INSERT INTO appl_durden VALUES('flair_hud','darken');
INSERT INTO appl_durden VALUES('sbar_color','127:127:127');
INSERT INTO appl_durden VALUES('flair_create','disabled');
INSERT INTO appl_durden VALUES('cloth_spacing','0.15');
INSERT INTO appl_durden VALUES('cloth_passes','2');
INSERT INTO appl_durden VALUES('autolay_sidetbar','true');
INSERT INTO appl_durden VALUES('browser_preview','full');
INSERT INTO appl_durden VALUES('autolay_selswap','true');
INSERT INTO appl_durden VALUES('lbar_caret_w','2');
INSERT INTO appl_durden VALUES('autolay_sideshdr','noalpha');
INSERT INTO appl_durden VALUES('lbar_errstr','\#ff4444 ');
INSERT INTO appl_durden VALUES('overlay_size','0.1');
INSERT INTO appl_durden VALUES('autolay_shader','false');
INSERT INTO appl_durden VALUES('overlay_corner','left');
INSERT INTO appl_durden VALUES('overlay_opacity','1');
INSERT INTO appl_durden VALUES('autolay_sideopa','0.5');
INSERT INTO appl_durden VALUES('flair_drag','disabled');
INSERT INTO appl_durden VALUES('flair_drag_opacity','1');
INSERT INTO appl_durden VALUES('overlay_shader','noalpha');
INSERT INTO appl_durden VALUES('flair_destroy','disabled');
INSERT INTO appl_durden VALUES('tbar_timeout','200');
INSERT INTO appl_durden VALUES('font_def','default.ttf');
INSERT INTO appl_durden VALUES('flair_hide','disabled');
INSERT INTO appl_durden VALUES('font_sz','18');
INSERT INTO appl_durden VALUES('font_hint','2');
INSERT INTO appl_durden VALUES('font_fb','emoji.ttf');
INSERT INTO appl_durden VALUES('lbar_tpad','4');
INSERT INTO appl_durden VALUES('dt_shadow_opa','0.3');
INSERT INTO appl_durden VALUES('lbar_bpad','0');
INSERT INTO appl_durden VALUES('extcon_path','durden');
INSERT INTO appl_durden VALUES('sbar_dshadow','8');
INSERT INTO appl_durden VALUES('text_color','\#aaaaaa');
INSERT INTO appl_durden VALUES('global_gain','1');
INSERT INTO appl_durden VALUES('bordert','1');
INSERT INTO appl_durden VALUES('sbar_popup_pad','4');
INSERT INTO appl_durden VALUES('sbar_shadow','soft');
INSERT INTO appl_durden VALUES('shadow_focus','0.5');
INSERT INTO appl_durden VALUES('sbar_dispbutton_dir','right');
INSERT INTO appl_durden VALUES('sbar_numberprefix','true');
INSERT INTO appl_durden VALUES('sbar_wsmeta','true');
INSERT INTO appl_durden VALUES('mouse_block','false');
INSERT INTO appl_durden VALUES('first_run','false');
INSERT INTO appl_durden VALUES('htab_barw','0.1');
INSERT INTO appl_durden VALUES('htab_lpad','0');
INSERT INTO appl_durden VALUES('dt_shadow_ofs_y','0');
INSERT INTO appl_durden VALUES('dt_shadow_ofs_x','0');
INSERT INTO appl_durden VALUES('dt_shadow','0');
INSERT INTO appl_durden VALUES('dt_opa','0.8');
INSERT INTO appl_durden VALUES('dt_height','0.4');
INSERT INTO appl_durden VALUES('dt_width','0.5');
INSERT INTO appl_durden VALUES('cloth_level','20');
INSERT INTO appl_durden VALUES('cloth_gravity','0.015');
INSERT INTO appl_durden VALUES('autolay_centerw','0.8');
INSERT INTO appl_durden VALUES('xarcan_autows','float');
INSERT INTO appl_durden VALUES('extcon_startdelay','100');
INSERT INTO appl_durden VALUES('mouse_cursorset','default');
INSERT INTO appl_durden VALUES('extcon_rlimit','25');
INSERT INTO appl_durden VALUES('mouse_autohide','true');
INSERT INTO appl_durden VALUES('flair_select','disabled');
INSERT INTO appl_durden VALUES('extcon_wndlimit','0');
INSERT INTO appl_durden VALUES('browser_timer','5');
INSERT INTO appl_durden VALUES('term_font','hack.ttf');
INSERT INTO appl_durden VALUES('typer_model','instant');
INSERT INTO appl_durden VALUES('typer_oracle','spell');
INSERT INTO appl_durden VALUES('tui_colorscheme','dracula');
INSERT INTO appl_durden VALUES('typer_language','en_GB');
INSERT INTO appl_durden VALUES('enc_vcodec','H264');
INSERT INTO appl_durden VALUES('sbar_textstr','\#00ff00 ');
INSERT INTO appl_durden VALUES('sbar_shadow_color','0:0:0');
INSERT INTO appl_durden VALUES('sbar_dispbutton_prefix','D');
INSERT INTO appl_durden VALUES('meta_latch','LCTRL_m');
COMMIT;
EOF
sqlite3 $ARCAN_DB < $ARCAN_DB_SQL_INIT
count=0
while [ $count -lt 30 ]; do
if [ -e /dev/dri/renderD128 ]; then
exec arcan -d $ARCAN_DB durden &
break
fi
count=$((count + 1))
sleep 0.2
done
for x in nvme_apple pinctrl-apple-gpio macsmc macsmc-rtkit i2c-pasemi-platform tps6598x apple-admac apple-dart apple-drm asahi dwc3 dwc3-of-simple xhci-pci pcie-apple gpio_macsmc phy-apple-atc nvmem_apple_efuses spi-apple spi-hid-apple spi-hid-apple-of rtc-macsmc simple-mfd-spmi spmi-apple-controller nvmem_spmi_mfd apple-dockchannel dockchannel-hid apple-rtkit-helper usb-storage xhci-plat-hcd usbhid hid_generic r8152 cdc_acm uinput snd_seq sunrpc brcmfmac brcmfmac_wcc brcmutil cfg80211 bluetooth apple_mfi_fastcharge ofpart apple_dcp sdhci_pci snd_soc_macaudio snd_soc_tas2764 snd_soc_cs42l84 rfkill spi_nor drm_dma_helper snd_soc_apple_mca mux_core cqhci sdhci snd_soc_core mtd macsec atlantic apple_soc_cpufreq macsmc_hid apple_sio i2c_pasemi_core apple_wdt ulpi udc_core typec clk_apple_nco apple_sart nvme_core nvme_auth scsi_dh_rdac scsi_dh_emc scsi_dh_alua; do
modprobe $x
done
exec sh
'';
initialRamdisk = pkgs.makeInitrd {
contents = [ { object = bootStage1; symlink = "/init"; } ];
};
in
{
options = {
not-os.preMount = lib.mkOption {
type = lib.types.lines;
default = "";
};
systemd.services = lib.mkOption {};
systemd.user.paths = lib.mkOption {};
systemd.user.services = lib.mkOption {};
systemd.user.slices = lib.mkOption {};
systemd.user.sockets = lib.mkOption {};
systemd.user.targets = lib.mkOption {};
systemd.user.timers = lib.mkOption {};
systemd.user.tmpfiles.rules = lib.mkOption {};
systemd.user.tmpfiles.users = lib.mkOption {};
systemd.user.units = lib.mkOption {};
systemd.tmpfiles.packages = lib.mkOption {};
systemd.tmpfiles.rules = lib.mkOption {};
systemd.tmpfiles.settings = lib.mkOption {};
};
config = {
system.build.bootStage1 = bootStage1;
system.build.initialRamdisk = lib.mkForce initialRamdisk;
system.build.extraUtils = extraUtils;
};
})
# Import NixOS modules from nixpkgs
"${nixpkgs}/nixos/modules/system/etc/etc.nix"
"${nixpkgs}/nixos/modules/system/activation/activation-script.nix"
"${nixpkgs}/nixos/modules/misc/nixpkgs.nix"
"${nixpkgs}/nixos/modules/misc/assertions.nix"
"${nixpkgs}/nixos/modules/system/boot/kernel.nix"
"${nixpkgs}/nixos/modules/misc/lib.nix"
"${nixpkgs}/nixos/modules/config/sysctl.nix"
];
# Define your NixOS configuration
nixosConfiguration = {
imports = baseModules;
# System configuration
nixpkgs.system = system;
boot = {
kernelPackages = asahiKernelPackages;
initrd = {
enable = true;
includeDefaultModules = false;
availableKernelModules = [];
kernelModules = kernelModules;
};
kernelParams = [];
};
system.build.payload = let
firm = firmware;
rInitRd = nixosSystem.config.system.build.initialRamdisk;
kernel = asahiKernel.kernel;
in pkgs.runCommand "payload" {} ''
mkdir -p $out/nix-support
cd $out
# Copy m1n1.bin
cp ${pkgs.m1n1}/build/m1n1.bin m1n1.bin
# Copy kernel image and compress
cp ${kernel}/Image kernel.img.uncompressed
gzip -1 < kernel.img.uncompressed > kernel.img.gz
# Copy device tree blobs
cp -r ${firm}/dtb .
# Extract firmware
mkdir firmware
${pkgs.asahi-fwextract}/bin/asahi-fwextract ${firm} firmware
zcat ${rInitRd}/initrd | \
cat - firmware/firmware.cpio | \
gzip -1 > combined.initrd.gz
# Combine all components into m1n1-linux.bin
cat m1n1.bin \
<(echo 'chosen.bootargs=debug rw mem=64G fbcon=rotate:0 console=ttySAC0,5000000n8 boot.shell_on_fail ignore_loglevel drm.edid_firmware=edid/1920x1080.bin log_buf_len=4M firmware_class.allow_unsigned=1 brcmfmac.ignore_country_ie=1 cfg80211.ieee80211_regdom=00 earlycon') \
dtb/apple/*.dtb \
kernel.img.gz \
combined.initrd.gz \
> m1n1-linux.bin
# Record the build output
echo "file binary-dist $out/m1n1-linux.bin" >> $out/nix-support/hydra-build-products
# List the contents for verification (optional)
ls -ltrhL
'';
environment.systemPackages = [ ];
};
# Build the NixOS system
nixosSystem = nixpkgs.lib.nixosSystem {
inherit system;
modules = [ nixosConfiguration ];
pkgs = pkgs;
};
in {
packages.${system}.payload = nixosSystem.config.system.build.payload;
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment