nix-git/modules/gnome-profile-image.nix

38 lines
1.5 KiB
Nix
Raw Normal View History

2025-01-19 13:00:38 +01:00
{ config, pkgs, ... }:
let
2025-01-21 21:10:25 +01:00
iconsDir = "/var/lib/AccountsService/icons";
usersDir = "/var/lib/AccountsService/users";
2025-01-19 13:00:38 +01:00
user = "yoda";
in
{
# https://discourse.nixos.org/t/setting-the-user-profile-image-under-gnome/36233/4
# Important: File permissions and file format
# https://discourse.nixos.org/t/setting-the-user-profile-image-under-gnome/36233/7
# https://github.com/tolgaerok/nixos-kde/blob/3c4b55f2b0345facc5bc5157750dfaecef9d4d6c/machines/LAPTOPS/HP-i5-ProBook-6460b/user/user-profile-pic/default.nix
# https://github.com/tolgaerok/nixos-kde/blob/3c4b55f2b0345facc5bc5157750dfaecef9d4d6c/user/user-home-settings/create-user-profile-pics.nix
# After changing my profile image in KDE Plasma 6, this file was created:
2025-01-21 21:10:25 +01:00
# /var/lib/AccountsService/users/yoda
2025-01-19 13:00:38 +01:00
# With content:
# [User]
# Icon=/var/lib/AccountsService/icons/yoda
# SystemAccount=false
# Permissions: root:root 0600
2025-01-21 21:10:25 +01:00
# This file is required, thus we create it manually in this nix config.
2025-01-19 13:00:38 +01:00
# `system.activationScripts`:
# - Since these are executed every time you boot the system or run `nixos-rebuild`, its important that they are idempotent and fast.
system.activationScripts.setGnomeProfilePicture = ''
2025-01-21 21:10:25 +01:00
mkdir -p ${iconsDir}
cp ${(pkgs.callPackage ./profile-image.nix { })}/img.png ${iconsDir}/${user}
mkdir -p ${usersDir}
rm -f ${usersDir}/${user}
echo "[User]" >> ${usersDir}/${user}
echo "Icon=${iconsDir}/${user}" >> ${usersDir}/${user}
echo "SystemAccount=false" >> ${usersDir}/${user}
2025-01-19 13:00:38 +01:00
'';
}