nixfiles/home/environments/darwin/konawall.nix
2023-11-29 07:59:39 -08:00

57 lines
1.8 KiB
Nix
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{
config,
inputs,
pkgs,
...
}: let
konawallConfig = {
interval = 3000;
rotate = true;
source = "konachan";
tags = [
"rating:s"
"nobody"
"score:>=50"
"width:>=1500"
];
logging = {
file = "INFO";
console = "DEBUG";
};
};
in {
home.file."Library/Application Support/konawall/config.toml".source = (pkgs.formats.toml {}).generate "konawall-config" konawallConfig;
launchd.agents.konawall = {
enable = true;
config = let
konawallInitialize = pkgs.writeScriptBin "konawall-initialize" ''
#!/usr/bin/env bash
set -xeuo pipefail
# get a temporary directory
tmpDir=$(mktemp -d)
# copy the repository to the temporary directory recursively without keeping the permissions from the nix store
${pkgs.coreutils}/bin/cp -r --no-preserve=mode,ownership "${inputs.konawall-py.outPath}" "$tmpDir/konawall"
# change directory to the copy
cd $tmpDir/konawall
# install the dependencies
${pkgs.poetry}/bin/poetry install
# run the package
${pkgs.poetry}/bin/poetry run gui
'';
in {
# yeah if https://github.com/NixOS/nixpkgs/issues/233265 and https://github.com/NixOS/nixpkgs/issues/101360
# and https://github.com/NixOS/nixpkgs/issues/105156 were ok we might be able to do this
#Program = "${inputs.konawall-py.packages.${pkgs.system}.konawall-py}/bin/konawall";
#ProgramArguments = ["${inputs.konawall-py.packages.${pkgs.system}.konawall-py}/bin/konawall"];
# it's unfortunate that this has to be done this way, for the most part.
ProgramArguments = [
"/usr/bin/env"
"bash"
"${konawallInitialize}/bin/konawall-initialize"
];
RunAtLoad = true;
KeepAlive = true;
};
};
}