feat: move self-defined packages to own files

This commit is contained in:
Swarsel 2024-07-29 09:10:04 +02:00
parent 2390199b8a
commit db231d4b83
Signed by: swarsel
GPG key ID: 26A54C31F2A4FD84
8 changed files with 191 additions and 106 deletions

8
pkgs/bak/default.nix Normal file
View file

@ -0,0 +1,8 @@
{ writeShellApplication }:
writeShellApplication {
name = "bak";
text = ''
cp "$1"{,.bak}
'';
}

9
pkgs/cdb/default.nix Normal file
View file

@ -0,0 +1,9 @@
{ writeShellApplication, fzf }:
writeShellApplication {
name = "cdb";
runtimeInputs = [ fzf ];
text = ''
git checkout "$(git branch --list | grep -v "^\*" | fzf | awk '{print $1}')"
'';
}

9
pkgs/cdw/default.nix Normal file
View file

@ -0,0 +1,9 @@
{ writeShellApplication, fzf }:
writeShellApplication {
name = "cdw";
runtimeInputs = [ fzf ];
text = ''
cd "$(git worktree list | fzf | awk '{print $1}')"
'';
}

28
pkgs/cura5/default.nix Normal file
View file

@ -0,0 +1,28 @@
{ appimageTools, fetchurl, writeScriptBin, pkgs }:
let
cura5 = appimageTools.wrapType2 rec {
name = "cura5";
version = "5.4.0";
src = fetchurl {
url = "https://github.com/Ultimaker/Cura/releases/download/${version}/UltiMaker-Cura-${version}-linux-modern.AppImage";
hash = "sha256-QVv7Wkfo082PH6n6rpsB79st2xK2+Np9ivBg/PYZd74=";
};
extraPkgs = pkgs: with pkgs; [ ];
};
in
writeScriptBin "cura" ''
#! ${pkgs.bash}/bin/bash
# AppImage version of Cura loses current working directory and treats all paths relative to $HOME.
# So we convert each of the files passed as argument to an absolute path.
# This fixes use cases like `cd /path/to/my/files; cura mymodel.stl anothermodel.stl`.
args=()
for a in "$@"; do
if [ -e "$a" ]; then
a="$(realpath "$a")"
fi
args+=("$a")
done
exec "${cura5}/bin/cura5" "''${args[@]}"
''

View file

@ -5,4 +5,9 @@ in
{
pass-fuzzel = callPackage ./pass-fuzzel { };
pass-fuzzel-otp = callPackage ./pass-fuzzel-otp { };
cura5 = callPackage ./cura5 { };
cdw = callPackage ./cdw { };
cdb = callPackage ./cdb { };
bak = callPackage ./bak { };
timer = callPackage ./timer { };
}

9
pkgs/timer/default.nix Normal file
View file

@ -0,0 +1,9 @@
{ writeShellApplication, speechd }:
writeShellApplication {
name = "timer";
runtimeInputs = [ speechd ];
text = ''
sleep "$1"; while true; do spd-say "$2"; sleep 0.5; done;
'';
}