parent
14081936af
commit
fe7b03dd4a
19 changed files with 39 additions and 37 deletions
pkgs
1
pkgs/coloryou/LICENSE
Normal file
1
pkgs/coloryou/LICENSE
Normal file
File diff suppressed because one or more lines are too long
45
pkgs/coloryou/coloryou.py
Executable file
45
pkgs/coloryou/coloryou.py
Executable file
|
@ -0,0 +1,45 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
The original script:
|
||||
https://github.com/dharmx/vile/blob/7d486c128c7e553912673755f97b118aaab0193d/src/shell/playerctl.py#L2
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import json
|
||||
from material_color_utilities_python import themeFromImage, hexFromArgb, Image
|
||||
|
||||
def range_type(value_string):
|
||||
value = int(value_string)
|
||||
if value not in range(0, 101):
|
||||
raise argparse.ArgumentTypeError("%s is out of range, choose in [0-100]" % value)
|
||||
return value
|
||||
|
||||
parser = argparse.ArgumentParser(
|
||||
prog='coloryou',
|
||||
description='This program extract Material You colors from an image. It returns them as a JSON object for scripting.')
|
||||
|
||||
parser.add_argument("image_path", help="A full path to your image", type=str)
|
||||
parser.add_argument('-i', '--image', dest='image', default=40, type=range_type, metavar='i', choices=range(0,101), help="Value should be within [0, 100] (default: %(default)s). Set the tone for the main image accent.")
|
||||
|
||||
parser.add_argument('-b', '--button', dest='button', default=90, type=range_type, metavar='i', choices=range(0,101), help="Value should be within [0, 100] (default: %(default)s). Set the tone for the button accent.")
|
||||
|
||||
parser.add_argument('-t', '--text', dest='text', default=10, type=range_type, metavar='i', choices=range(0,101), help="Value should be within [0, 100] (default: %(default)s). Set the tone for the button text accent.")
|
||||
|
||||
parser.add_argument('-o', '--hover', dest='hover', default=80, type=range_type, metavar='i', choices=range(0,101), help="Value should be within [0, 100] (default: %(default)s). Set the tone for the hovering effect accent.")
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
img = Image.open(args.image_path)
|
||||
basewidth = 64
|
||||
wpercent = (basewidth/float(img.size[0]))
|
||||
hsize = int((float(img.size[1])*float(wpercent)))
|
||||
img = img.resize((basewidth,hsize),Image.Resampling.LANCZOS)
|
||||
|
||||
theme = themeFromImage(img).get("palettes").get("primary")
|
||||
parsed_colors = {"imageAccent": hexFromArgb(theme.tone(args.image)),
|
||||
"buttonAccent": hexFromArgb(theme.tone(args.button)),
|
||||
"buttonText": hexFromArgb(theme.tone(args.text)),
|
||||
"hoverAccent": hexFromArgb(theme.tone(args.hover))}
|
||||
|
||||
print(json.dumps(parsed_colors))
|
19
pkgs/coloryou/default.nix
Normal file
19
pkgs/coloryou/default.nix
Normal file
|
@ -0,0 +1,19 @@
|
|||
{python3Packages, ...}:
|
||||
python3Packages.buildPythonPackage {
|
||||
pname = "coloryou";
|
||||
version = "0.0.1";
|
||||
|
||||
src = ./.;
|
||||
|
||||
propagatedBuildInputs = with python3Packages; [utils material-color-utilities];
|
||||
|
||||
postInstall = ''
|
||||
mv -v $out/bin/coloryou.py $out/bin/coloryou
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = ''
|
||||
Get Material You colors from an image.
|
||||
'';
|
||||
};
|
||||
}
|
2
pkgs/coloryou/requirements.txt
Normal file
2
pkgs/coloryou/requirements.txt
Normal file
|
@ -0,0 +1,2 @@
|
|||
material-color-utilities
|
||||
utils
|
7
pkgs/coloryou/setup.py
Normal file
7
pkgs/coloryou/setup.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
from distutils.core import setup
|
||||
|
||||
setup(
|
||||
name='coloryou',
|
||||
version='0.0.1',
|
||||
scripts=['coloryou.py',],
|
||||
)
|
7
pkgs/coloryou/shell.nix
Normal file
7
pkgs/coloryou/shell.nix
Normal file
|
@ -0,0 +1,7 @@
|
|||
with import <nixpkgs> {};
|
||||
with pkgs.python311Packages;
|
||||
buildPythonPackage {
|
||||
name = "coloryou";
|
||||
src = ./.;
|
||||
propagatedBuildInputs = [material-color-utilities utils];
|
||||
}
|
13
pkgs/curseforge-server-downloader/default.nix
Normal file
13
pkgs/curseforge-server-downloader/default.nix
Normal file
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
buildGoModule,
|
||||
curseforge-server-downloader-src,
|
||||
...
|
||||
}:
|
||||
buildGoModule {
|
||||
pname = "curseforge-server-downloader";
|
||||
version = "unstable";
|
||||
|
||||
src = curseforge-server-downloader-src;
|
||||
doCheck = false;
|
||||
vendorHash = null;
|
||||
}
|
23
pkgs/default.nix
Normal file
23
pkgs/default.nix
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
pkgs,
|
||||
curseforge-server-downloader-src,
|
||||
pam-fprint-grosshack-src,
|
||||
pokemon-colorscripts-src,
|
||||
...
|
||||
}: {
|
||||
coloryou = pkgs.callPackage ./coloryou {};
|
||||
|
||||
curseforge-server-downloader = pkgs.callPackage ./curseforge-server-downloader {
|
||||
inherit curseforge-server-downloader-src;
|
||||
};
|
||||
|
||||
pam-fprint-grosshack = pkgs.callPackage ./pam-fprint-grosshack {
|
||||
inherit pam-fprint-grosshack-src;
|
||||
};
|
||||
|
||||
pokemon-colorscripts = pkgs.callPackage ./pokemon-colorscripts {
|
||||
inherit pokemon-colorscripts-src;
|
||||
};
|
||||
|
||||
repl = pkgs.callPackage ./repl {};
|
||||
}
|
41
pkgs/pam-fprint-grosshack/default.nix
Normal file
41
pkgs/pam-fprint-grosshack/default.nix
Normal file
|
@ -0,0 +1,41 @@
|
|||
{
|
||||
stdenv,
|
||||
meson,
|
||||
ninja,
|
||||
pkg-config,
|
||||
glib,
|
||||
libfprint,
|
||||
polkit,
|
||||
dbus,
|
||||
systemd,
|
||||
pam,
|
||||
libpam-wrapper,
|
||||
pam-fprint-grosshack-src,
|
||||
...
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
name = "pam-fprint-grosshack";
|
||||
version = pam-fprint-grosshack-src.shortRev;
|
||||
|
||||
src = pam-fprint-grosshack-src;
|
||||
|
||||
nativeBuildInputs = [
|
||||
meson
|
||||
ninja
|
||||
pkg-config
|
||||
glib
|
||||
libfprint
|
||||
polkit
|
||||
dbus
|
||||
systemd
|
||||
pam
|
||||
libpam-wrapper
|
||||
];
|
||||
|
||||
mesonFlags = [
|
||||
"-Dpam_modules_dir=${placeholder "out"}/lib/security"
|
||||
"-Dsysconfdir=${placeholder "out"}/etc"
|
||||
"-Ddbus_service_dir=${placeholder "out"}/share/dbus-1/system-services"
|
||||
"-Dsystemd_system_unit_dir=${placeholder "out"}/lib/systemd/system"
|
||||
];
|
||||
}
|
27
pkgs/pokemon-colorscripts/default.nix
Normal file
27
pkgs/pokemon-colorscripts/default.nix
Normal file
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
stdenv,
|
||||
python3Packages,
|
||||
pokemon-colorscripts-src,
|
||||
...
|
||||
}:
|
||||
stdenv.mkDerivation {
|
||||
name = "pokemon-colorscripts";
|
||||
version = pokemon-colorscripts-src.shortRev;
|
||||
|
||||
src = pokemon-colorscripts-src;
|
||||
|
||||
propagatedBuildInputs = with python3Packages; [
|
||||
python
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/pokemon-colorscripts $out/bin
|
||||
|
||||
cp -rf colorscripts $out/pokemon-colorscripts
|
||||
cp pokemon.json $out/pokemon-colorscripts
|
||||
|
||||
cp pokemon-colorscripts.py $out/pokemon-colorscripts
|
||||
|
||||
ln -s $out/pokemon-colorscripts/pokemon-colorscripts.py $out/bin/pokemon-colorscripts
|
||||
'';
|
||||
}
|
26
pkgs/repl/default.nix
Normal file
26
pkgs/repl/default.nix
Normal file
|
@ -0,0 +1,26 @@
|
|||
# modified from https://github.com/gytis-ivaskevicius/flake-utils/plus
|
||||
{
|
||||
coreutils,
|
||||
gnused,
|
||||
writeShellScriptBin,
|
||||
...
|
||||
}: let
|
||||
repl = ./repl.nix;
|
||||
example = command: desc: ''\n\u001b[33m ${command}\u001b[0m - ${desc}'';
|
||||
in
|
||||
writeShellScriptBin "repl" ''
|
||||
case "$1" in
|
||||
"-h"|"--help"|"help")
|
||||
printf "%b\n\e[4mUsage\e[0m: \
|
||||
${example "repl" "Loads system flake if available."} \
|
||||
${example "repl /path/to/flake.nix" "Loads specified flake."}\n"
|
||||
;;
|
||||
*)
|
||||
if [ -z "$1" ]; then
|
||||
nix repl --arg flakePath $(${coreutils}/bin/readlink -f "$FLAKE") --file ${repl}
|
||||
else
|
||||
nix repl --arg flakePath $(${coreutils}/bin/readlink -f $1 | ${gnused}/bin/sed 's|/flake.nix||') --file ${repl}
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
''
|
49
pkgs/repl/repl.nix
Normal file
49
pkgs/repl/repl.nix
Normal file
|
@ -0,0 +1,49 @@
|
|||
{
|
||||
flakePath ? null,
|
||||
hostnamePath ? "/etc/hostname",
|
||||
registryPath ? /etc/nix/registry.json,
|
||||
}: let
|
||||
inherit (builtins) getFlake head match currentSystem readFile pathExists filter fromJSON;
|
||||
|
||||
selfFlake =
|
||||
if pathExists registryPath
|
||||
then filter (it: it.from.id == "self") (fromJSON (readFile registryPath)).flakes
|
||||
else [];
|
||||
|
||||
flakePath' =
|
||||
toString
|
||||
(
|
||||
if flakePath != null
|
||||
then flakePath
|
||||
else if selfFlake != []
|
||||
then (head selfFlake).to.path
|
||||
else "/etc/nixos"
|
||||
);
|
||||
|
||||
flake =
|
||||
if pathExists flakePath'
|
||||
then getFlake flakePath'
|
||||
else {};
|
||||
hostname =
|
||||
if pathExists hostnamePath
|
||||
then head (match "([a-zA-Z0-9\\-]+)\n" (readFile hostnamePath))
|
||||
else "";
|
||||
|
||||
nixpkgsFromInputsPath = flake.inputs.nixpkgs.outPath or "";
|
||||
nixpkgs =
|
||||
flake.pkgs.${currentSystem}.nixpkgs
|
||||
or (
|
||||
if nixpkgsFromInputsPath != ""
|
||||
then import nixpkgsFromInputsPath {}
|
||||
else {}
|
||||
);
|
||||
|
||||
nixpkgsOutput = removeAttrs (nixpkgs // nixpkgs.lib or {}) ["options" "config"];
|
||||
in
|
||||
{inherit flake;}
|
||||
// flake
|
||||
// builtins
|
||||
// (flake.nixosConfigurations or {})
|
||||
// flake.nixosConfigurations.${hostname} or {}
|
||||
// nixpkgsOutput
|
||||
// {getFlake = path: getFlake (toString path);}
|
Loading…
Add table
Add a link
Reference in a new issue