Skip to content

Instantly share code, notes, and snippets.

@mausch
Created August 5, 2026 20:52
Show Gist options
  • Select an option

  • Save mausch/3ee9a4921b905bc56384f63f2a3e3e04 to your computer and use it in GitHub Desktop.

Select an option

Save mausch/3ee9a4921b905bc56384f63f2a3e3e04 to your computer and use it in GitHub Desktop.
yin-yang
{
description = "Yin-Yang automatic light and dark theme switcher";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/148bab9c1c3c53136ecb44a6ea356a0ed5b39b06";
outputs = { self, nixpkgs }:
let
systems = [ "x86_64-linux" "aarch64-linux" ];
forAllSystems = nixpkgs.lib.genAttrs systems;
in
{
packages = forAllSystems (system:
let
pkgs = import nixpkgs { inherit system; };
python = pkgs.python3;
pythonPackages = python.pkgs;
suntime = pythonPackages.buildPythonPackage rec {
pname = "suntime";
version = "1.3.2";
pyproject = true;
src = pkgs.fetchPypi {
inherit pname version;
hash = "sha256-SDT3kHrRPbs2mQTLX0N27cCwbG6KHPwKrBJo9k0Ozc8=";
};
build-system = [ pythonPackages.setuptools ];
dependencies = [ pythonPackages.python-dateutil ];
};
in
{
yin-yang = pythonPackages.buildPythonApplication rec {
pname = "yin-yang";
version = "4.0.0";
pyproject = true;
src = pkgs.fetchFromGitHub {
owner = "oskarsh";
repo = "Yin-Yang";
rev = "8569de0abf7c45caaadc8ce88c1bbbce769638f5";
hash = "sha256-8prFy6i0LP7fqAHPwG77TiPxNL9byF/+wbgSUuXwIOg=";
};
build-system = [ pythonPackages.poetry-core ];
# nixpkgs supplies a newer, API-compatible requests release.
dontCheckRuntimeDeps = true;
postPatch = ''
substituteInPlace yin_yang/position.py \
--replace-fail \
' self._positionSource.positionUpdated.connect(self.handlePosition)' \
$' if self._positionSource is not None:\n self._positionSource.positionUpdated.connect(self.handlePosition)' \
--replace-fail \
' self._positionSource.startUpdates()' \
$' if self._positionSource is not None:\n self._positionSource.startUpdates()' \
--replace-fail \
' self._lastPosition = self._positionSource.lastKnownPosition()' \
' self._lastPosition = self._positionSource.lastKnownPosition() if self._positionSource else QGeoPositionInfo()'
'';
dependencies = with pythonPackages; [
psutil
requests
python-dateutil
systemd-python
pyside6
shiboken6
suntime
];
nativeBuildInputs = [ pkgs.makeWrapper ];
postInstall = ''
install -Dm644 resources/icon.svg \
$out/share/icons/hicolor/scalable/apps/sh.oskar.yin_yang.svg
install -Dm644 resources/sh.oskar.yin_yang.metainfo.xml \
$out/share/metainfo/sh.oskar.yin_yang.metainfo.xml
install -Dm644 resources/yin_yang.timer \
$out/share/yin-yang/resources/yin_yang.timer
substitute resources/yin_yang.service \
$out/share/yin-yang/resources/yin_yang.service \
--replace-fail /usr/bin/yin_yang $out/bin/yin_yang
install -Dm644 /dev/stdin \
$out/share/applications/sh.oskar.yin_yang.desktop <<EOF
[Desktop Entry]
Type=Application
Name=Yin & Yang
Comment=Automatically switch between light and dark themes
Exec=$out/bin/yin_yang
Icon=sh.oskar.yin_yang
Categories=Utility;System;Settings;
EOF
wrapProgram $out/bin/yin_yang \
--run "cd $out/share/yin-yang" \
--prefix PATH : ${pkgs.lib.makeBinPath [ pkgs.systemd pkgs.libnotify ]}
'';
meta = {
description = "Automatic light and dark theme switcher for Linux desktops";
homepage = "https://github.com/oskarsh/Yin-Yang";
license = pkgs.lib.licenses.mit;
mainProgram = "yin_yang";
platforms = pkgs.lib.platforms.linux;
};
};
default = self.packages.${system}.yin-yang;
});
};
}
@mausch

mausch commented Aug 5, 2026

Copy link
Copy Markdown
Author

https://github.com/oskarsh/Yin-Yang

nix run --refresh --no-write-lock-file git+https://gist.github.com/mausch/3ee9a4921b905bc56384f63f2a3e3e04.git

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment