flake/nixos/profiles/common/graphical/home/scripts/default.nix

48 lines
1.7 KiB
Nix
Raw Normal View History

2024-02-04 06:08:38 +00:00
{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}";
2024-02-06 09:20:38 +00:00
text = ''
#!${runtimeShell}
${lib.optionalString (runtimeInputs != []) ''export PATH="${lib.makeBinPath runtimeInputs}:$PATH"''}
${builtins.readFile file}
'';
2023-12-02 09:22:38 +00:00
};
2024-02-04 06:08:38 +00:00
in {
home.packages = [
(makeScript {
name = "lofi";
2024-02-06 09:20:38 +00:00
runtimeInputs = [coreutils mpv];
2024-02-04 06:08:38 +00:00
file = pkgs.fetchurl {
url = "https://raw.githubusercontent.com/lime-desu/bin/69422c37582c5914863997c75c268791a0de136e/lofi";
hash = "sha256-hT+S/rqOHUYnnFcSDFfQht4l1DGasz1L3wDHKUWLraA=";
};
})
2023-12-15 10:38:26 +00:00
2024-02-04 06:08:38 +00:00
(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=";
};
replacements = ["--replace-warn" "DIR=\${SCREENSHOT_DIR:=$HOME/Screenshots}" "DIR=$HOME/Pictures/Screenshots"]; # i dont like using an environment variable
};
2024-02-04 06:08:38 +00:00
})
];
2023-11-25 09:02:50 +00:00
}