Skip to content

Instantly share code, notes, and snippets.

@andrew-d
Created February 10, 2020 06:41
Show Gist options
  • Save andrew-d/41f2942a32b02249fac2dadf934cecec to your computer and use it in GitHub Desktop.
Save andrew-d/41f2942a32b02249fac2dadf934cecec to your computer and use it in GitHub Desktop.
Completely untested Nix builder for icon theme with only "image-missing.png"
{ stdenv
, pkgs
, gnome3
, hicolor-icon-theme
}:
stdenv.mkDerivation {
pname = "only-missing";
version = "0.0.1";
propagatedBuildInputs = [ hicolor-icon-theme ];
buildInputs = [ gnome3.adwaita-icon-theme ];
builder = pkgs.writeScript "only-missing-builder.sh" ''
. ${stdenv}/setup
mkdir -p $out/share/icons/only-missing/
declare -a directories
for f in "${gnome3.adwaita-icon-theme}/share/icons/Adwaita"/*; do
if [[ ! -d "$f" ]]; then
continue
fi
size="''${f##*/}"
if [[ -f "$f/legacy/image-missing.png" ]]; then
mkdir -p $out/share/icons/only-missing/$size/legacy
cp -v "$f/legacy/image-missing.png" $out/share/icons/only-missing/$size/legacy/
directories+=("$size/legacy")
fi
if [[ -f "$f/status/image-missing.png" ]]; then
mkdir -p $out/share/icons/only-missing/$size/status
cp -v "$f/status/image-missing.png" $out/share/icons/only-missing/$size/status/
directories+=("$size/status")
fi
done
theme=$out/share/icons/only-missing/index.theme
cat <<EOF > $theme
[Icon Theme]
Name=only-missing
Comment=Fallback icon theme with image-missing
Hidden=true
EOF
( export IFS="," ; echo "Directories=''${directories[*]}" ) >> $theme
for dir in "''${directories[@]}"; do
size="''${dir%%x*}"
name="''${dir##*/}"
cat <<EOF >> $theme
[$dir]
Size=$size
Context=''${name^}
Type=Fixed
EOF
done
'';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment