Some checks failed
CI / check (push) Has been cancelled
CI / ida (push) Has been cancelled
CI / cpt (push) Has been cancelled
CI / build-nixos (ena) (push) Has been cancelled
CI / build-nixos (hako) (push) Has been cancelled
CI / build-nixos (kazusa) (push) Has been cancelled
CI / build-nixos (mizuki) (push) Has been cancelled
34 lines
1.2 KiB
Nix
34 lines
1.2 KiB
Nix
{
|
|
pkgs,
|
|
inputs,
|
|
...
|
|
}:
|
|
let
|
|
avatar = pkgs.runCommand "kanade-avatar.jpg" { nativeBuildInputs = [ pkgs.imagemagick ]; } ''
|
|
magick "${inputs.self}/assets/avatar.webp" -quality 92 "$out"
|
|
'';
|
|
in
|
|
{
|
|
system.activationScripts.postActivation.text = ''
|
|
avatarPath="/Library/User Pictures/imnyang.jpg"
|
|
importFile="$(/usr/bin/mktemp /tmp/imnyang-avatar.XXXXXX)"
|
|
|
|
/usr/bin/install -d -m 0755 "/Library/User Pictures"
|
|
/usr/bin/install -m 0644 "${avatar}" "$avatarPath"
|
|
|
|
# Replace both account-picture representations. JPEGPhoto is embedded in
|
|
# the directory record and is used by the login screen and System Settings.
|
|
/usr/bin/dscl . -delete /Users/imnyang JPEGPhoto >/dev/null 2>&1 || true
|
|
/usr/bin/dscl . -delete /Users/imnyang Picture >/dev/null 2>&1 || true
|
|
/usr/bin/dscl . -create /Users/imnyang Picture "$avatarPath"
|
|
|
|
/usr/bin/printf '%s\n%s:%s' \
|
|
'0x0A 0x5C 0x3A 0x2C dsRecTypeStandard:Users 2 dsAttrTypeStandard:RecordName externalbinary:dsAttrTypeStandard:JPEGPhoto' \
|
|
'imnyang' \
|
|
"$avatarPath" > "$importFile"
|
|
/usr/bin/dsimport "$importFile" /Local/Default M
|
|
/bin/rm -f "$importFile"
|
|
|
|
/usr/bin/dscacheutil -flushcache
|
|
'';
|
|
}
|