home/scripts: move to pkgs
This commit is contained in:
parent
690c024995
commit
6057cf181d
11 changed files with 77 additions and 63 deletions
|
@ -2,6 +2,7 @@
|
||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
lib,
|
lib,
|
||||||
|
inputs,
|
||||||
...
|
...
|
||||||
}: {
|
}: {
|
||||||
imports = [
|
imports = [
|
||||||
|
@ -67,6 +68,7 @@
|
||||||
modifier = "Mod4";
|
modifier = "Mod4";
|
||||||
keybindings = let
|
keybindings = let
|
||||||
inherit (config.wayland.windowManager.sway.config) modifier;
|
inherit (config.wayland.windowManager.sway.config) modifier;
|
||||||
|
inherit (inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.scripts) screenshot;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
### Sway itself
|
### Sway itself
|
||||||
|
@ -100,9 +102,9 @@
|
||||||
"${modifier}+Shift+Semicolon" = ''exec rofi -modi "power-menu:rofi-power-menu --confirm=reboot/shutdown" -show power-menu'';
|
"${modifier}+Shift+Semicolon" = ''exec rofi -modi "power-menu:rofi-power-menu --confirm=reboot/shutdown" -show power-menu'';
|
||||||
|
|
||||||
# Screenshot
|
# Screenshot
|
||||||
"${modifier}+Shift+s" = "exec screenshot region";
|
"${modifier}+Shift+s" = "exec ${screenshot} region";
|
||||||
"Print" = "exec screenshot fullscreen";
|
"Print" = "exec ${screenshot} fullscreen";
|
||||||
"Print+Control" = "exec screenshot swappy";
|
"Print+Control" = "exec ${screenshot} swappy";
|
||||||
|
|
||||||
# Fn keys
|
# Fn keys
|
||||||
"XF86MonBrightnessUp" = "exec ${lib.getExe pkgs.brightnessctl} set 5%+";
|
"XF86MonBrightnessUp" = "exec ${lib.getExe pkgs.brightnessctl} set 5%+";
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
imports =
|
imports =
|
||||||
[
|
[
|
||||||
./fonts
|
./fonts
|
||||||
./scripts
|
|
||||||
./wallpapers
|
./wallpapers
|
||||||
|
|
||||||
./theme.nix
|
./theme.nix
|
||||||
|
|
|
@ -1,53 +0,0 @@
|
||||||
{pkgs, ...}:
|
|
||||||
with pkgs; let
|
|
||||||
# trimmed down version of writeShellApplication
|
|
||||||
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/trivial-builders/default.nix#L245
|
|
||||||
#
|
|
||||||
# it wont work if i change writeTextFile to writeScriptBin... unsure why
|
|
||||||
# error: A definition for option ... is not of type `package'. Definition values:
|
|
||||||
# - In `/nix/store/<hash>-source/nixos/profiles/common/graphical/home/scripts': <function>
|
|
||||||
makeScript = {
|
|
||||||
name,
|
|
||||||
file,
|
|
||||||
runtimeInputs ? [],
|
|
||||||
}:
|
|
||||||
writeTextFile {
|
|
||||||
inherit name;
|
|
||||||
executable = true;
|
|
||||||
destination = "/bin/${name}";
|
|
||||||
text = ''
|
|
||||||
#!${runtimeShell}
|
|
||||||
${lib.optionalString (runtimeInputs != []) ''export PATH="${lib.makeBinPath runtimeInputs}:$PATH"''}
|
|
||||||
${builtins.readFile file}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
in {
|
|
||||||
home.packages = [
|
|
||||||
(makeScript {
|
|
||||||
name = "lofi";
|
|
||||||
runtimeInputs = [coreutils mpv];
|
|
||||||
file = pkgs.fetchurl {
|
|
||||||
url = "https://raw.githubusercontent.com/lime-desu/bin/69422c37582c5914863997c75c268791a0de136e/lofi";
|
|
||||||
hash = "sha256-hT+S/rqOHUYnnFcSDFfQht4l1DGasz1L3wDHKUWLraA=";
|
|
||||||
};
|
|
||||||
})
|
|
||||||
|
|
||||||
(makeScript {
|
|
||||||
name = "screenshot";
|
|
||||||
runtimeInputs = [coreutils jq grim slurp swappy wl-clipboard libnotify];
|
|
||||||
file = pkgs.substitute {
|
|
||||||
src = pkgs.fetchurl {
|
|
||||||
url = "https://raw.githubusercontent.com/nwg-piotr/nwg-shell/c29e8eb4658a2613fb221ead0b101c75f457bcaf/scripts/screenshot";
|
|
||||||
hash = "sha256-Z/fWloz8pLHsvPTPOeBxnbMsGDRTY3G3l/uePQ3ZxjU=";
|
|
||||||
};
|
|
||||||
|
|
||||||
# i dont like using an environment variable
|
|
||||||
substitutions = [
|
|
||||||
"--replace-warn"
|
|
||||||
"DIR=\${SCREENSHOT_DIR:=$HOME/Screenshots}"
|
|
||||||
"DIR=$HOME/Pictures/Screenshots"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
})
|
|
||||||
];
|
|
||||||
}
|
|
|
@ -1,7 +1,14 @@
|
||||||
_pkgs: {
|
# NOTE: 301: All packages are migrated to `github:Guanran928/nur-packages`,
|
||||||
# fcitx5-tokyonight = pkgs.callPackage ./fcitx5-tokyonight {};
|
# only keeping some packages that only fits for personal use.
|
||||||
# metacubexd = pkgs.callPackage ./metacubexd {};
|
pkgs: {
|
||||||
# mpvScripts.modernx = pkgs.callPackage ./mpvScripts/modernx {};
|
scripts = rec {
|
||||||
# picom-ft-labs = pkgs.callPackage ./picom-ft-labs {};
|
# util
|
||||||
# v2ray-rules-dat = pkgs.callPackage ./v2ray-rules-dat {};
|
makeScript = pkgs.callPackage ./scripts/makeScript.nix {};
|
||||||
|
|
||||||
|
# scripts
|
||||||
|
# TODO: Do I really have to inherit `makeScript` for every script?
|
||||||
|
# NOTE: ./scripts/_bin/* is unused, I probably should to remove them.
|
||||||
|
lofi = pkgs.callPackage ./scripts/lofi.nix {inherit makeScript;};
|
||||||
|
screenshot = pkgs.callPackage ./scripts/screenshot.nix {inherit makeScript;};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
14
pkgs/scripts/lofi.nix
Normal file
14
pkgs/scripts/lofi.nix
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
makeScript,
|
||||||
|
coreutils,
|
||||||
|
mpv,
|
||||||
|
fetchurl,
|
||||||
|
}:
|
||||||
|
makeScript {
|
||||||
|
name = "lofi";
|
||||||
|
runtimeInputs = [coreutils mpv];
|
||||||
|
file = fetchurl {
|
||||||
|
url = "https://raw.githubusercontent.com/lime-desu/bin/69422c37582c5914863997c75c268791a0de136e/lofi";
|
||||||
|
hash = "sha256-hT+S/rqOHUYnnFcSDFfQht4l1DGasz1L3wDHKUWLraA=";
|
||||||
|
};
|
||||||
|
}
|
16
pkgs/scripts/makeScript.nix
Normal file
16
pkgs/scripts/makeScript.nix
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
# trimmed down version of writeShellApplication
|
||||||
|
# https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/trivial-builders/default.nix#L245
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
runtimeShell,
|
||||||
|
writeScriptBin,
|
||||||
|
}: {
|
||||||
|
name,
|
||||||
|
file,
|
||||||
|
runtimeInputs ? [],
|
||||||
|
}:
|
||||||
|
writeScriptBin name ''
|
||||||
|
#!${runtimeShell}
|
||||||
|
${lib.optionalString (runtimeInputs != []) ''export PATH="${lib.makeBinPath runtimeInputs}:$PATH"''}
|
||||||
|
${builtins.readFile file}
|
||||||
|
''
|
29
pkgs/scripts/screenshot.nix
Normal file
29
pkgs/scripts/screenshot.nix
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
makeScript,
|
||||||
|
coreutils,
|
||||||
|
jq,
|
||||||
|
grim,
|
||||||
|
slurp,
|
||||||
|
swappy,
|
||||||
|
wl-clipboard,
|
||||||
|
libnotify,
|
||||||
|
fetchurl,
|
||||||
|
substitute,
|
||||||
|
}:
|
||||||
|
makeScript {
|
||||||
|
name = "screenshot";
|
||||||
|
runtimeInputs = [coreutils jq grim slurp swappy wl-clipboard libnotify];
|
||||||
|
file = substitute {
|
||||||
|
src = fetchurl {
|
||||||
|
url = "https://raw.githubusercontent.com/nwg-piotr/nwg-shell/c29e8eb4658a2613fb221ead0b101c75f457bcaf/scripts/screenshot";
|
||||||
|
hash = "sha256-Z/fWloz8pLHsvPTPOeBxnbMsGDRTY3G3l/uePQ3ZxjU=";
|
||||||
|
};
|
||||||
|
|
||||||
|
# i dont like using an environment variable
|
||||||
|
substitutions = [
|
||||||
|
"--replace-warn"
|
||||||
|
"DIR=\${SCREENSHOT_DIR:=$HOME/Screenshots}"
|
||||||
|
"DIR=$HOME/Pictures/Screenshots"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue