feat: big refactor
This commit is contained in:
parent
2c09c21833
commit
ebedec9768
159 changed files with 1927 additions and 2222 deletions
8
modules/home-manager/scripts/default.nix
Normal file
8
modules/home-manager/scripts/default.nix
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
{ pkgs, nixosConfig, ... }:
|
||||
{
|
||||
imports = [ ./pomodoro.nix ];
|
||||
home.packages = [
|
||||
(import ./git-clone-list.nix { inherit pkgs; })
|
||||
(import ./nix-update.nix { inherit pkgs nixosConfig; })
|
||||
];
|
||||
}
|
||||
63
modules/home-manager/scripts/git-clone-list.nix
Normal file
63
modules/home-manager/scripts/git-clone-list.nix
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
{ pkgs }:
|
||||
pkgs.writeShellScriptBin "git-clone-list" ''
|
||||
reset="\e[0m"
|
||||
bold="\e[1m"
|
||||
underline="\e[4m"
|
||||
red="\e[31m"
|
||||
green="\e[32m"
|
||||
|
||||
XPATH='//*[@id="user-list-repositories"]//a[not(@class)]/@href'
|
||||
|
||||
function help_screen {
|
||||
echo
|
||||
echo -e "''${bold}''${underline}Usage:''${reset} ''${bold}$0''${reset} <USER> <LIST>"
|
||||
echo
|
||||
echo -e "''${bold}''${underline}Arguments''${reset}:"
|
||||
echo -e " ''${bold}USER''${reset} Github username of target user"
|
||||
echo -e " ''${bold}LIST''${reset} List name of target list"
|
||||
echo
|
||||
}
|
||||
|
||||
function error {
|
||||
echo
|
||||
echo -e "''${red}>>> ''${bold}Error''${reset}''${red}: $1''${reset}"
|
||||
if [ "$2" == "help" ]; then
|
||||
help_screen
|
||||
fi
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ $# -ne 2 ]; then
|
||||
error "Expected 2 arguments, got $#" help
|
||||
fi
|
||||
|
||||
USER=$1
|
||||
LIST=$2
|
||||
|
||||
NOT_VISITED=("/stars/$USER/lists/$LIST?page=1")
|
||||
VISITED=()
|
||||
REPOS=()
|
||||
|
||||
while [[ "''${#NOT_VISITED[@]}" != 0 ]]; do
|
||||
echo -e "''${green}>>> Fetching https://github.com''${NOT_VISITED[0]} ...''${reset}"
|
||||
while IFS= read -r line; do
|
||||
VISITED+=("''${NOT_VISITED[0]}")
|
||||
unset NOT_VISITED[0]
|
||||
if [[ "$line" == "/stars/$USER/lists/$LIST"* ]]; then
|
||||
if [[ ! "''${VISITED[@]}" =~ "''${line}" ]]; then
|
||||
NOT_VISITED+=("$line")
|
||||
fi
|
||||
else
|
||||
REPOS+=("$line")
|
||||
fi
|
||||
done < <(${pkgs.xidel}/bin/xidel "https://github.com''${NOT_VISITED[0]}" --xpath $XPATH)
|
||||
done
|
||||
|
||||
IT=1
|
||||
|
||||
for repo in "''${REPOS[@]}"; do
|
||||
echo -e "''${green}>>> [$IT/''${#REPOS[@]}] Cloning https://github.com$repo.git ...''${reset}"
|
||||
${pkgs.git}/bin/git clone "https://github.com$repo.git" "''${repo:1}"
|
||||
IT=$((IT + 1))
|
||||
done
|
||||
''
|
||||
37
modules/home-manager/scripts/nix-update.nix
Normal file
37
modules/home-manager/scripts/nix-update.nix
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
{ pkgs, nixosConfig }:
|
||||
pkgs.writeShellScriptBin "nuf" ''
|
||||
reset="\e[0m"
|
||||
red="\e[31m"
|
||||
green="\e[32m"
|
||||
yellow="\e[33m"
|
||||
white_bold="\e[1;37m"
|
||||
tmp=$(mktemp -d)
|
||||
|
||||
function error {
|
||||
rm -rf tmp
|
||||
echo ""
|
||||
echo -e "''${red}>>> ''${bold}Error''${reset}''${red}: $1''${reset}"
|
||||
exit 1
|
||||
}
|
||||
|
||||
FLAKE=$(readlink -f /etc/nixos)
|
||||
|
||||
echo -e "''${green}>>> Updating flake $FLAKE ...''${reset}"
|
||||
${nixosConfig.nix.package}/bin/nix flake update --flake "$FLAKE" || error "Updating failed"
|
||||
|
||||
cd $tmp
|
||||
echo ""
|
||||
echo -e "''${green}>>> Building configuration ...''${reset}"
|
||||
nixos-rebuild build --flake "$FLAKE" || error "Building failed"
|
||||
|
||||
echo ""
|
||||
echo -e "''${green}>>> Running diff ...''${reset}";
|
||||
${pkgs.nvd}/bin/nvd diff /run/current-system result || error "Diff failed"
|
||||
|
||||
cd - > /dev/null
|
||||
rm -rf $tmp
|
||||
|
||||
echo ""
|
||||
echo -e "''${yellow}>>> The new configuration has not been activated.''${reset}"
|
||||
echo -e "''${yellow}>>> Use ''${white_bold}nixos-rebuild switch''${reset}''${yellow} to activate.''${reset}"
|
||||
''
|
||||
19
modules/home-manager/scripts/pomodoro.nix
Normal file
19
modules/home-manager/scripts/pomodoro.nix
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
{ pkgs, ... }:
|
||||
let
|
||||
pootis = ./pootis.m4a;
|
||||
in
|
||||
{
|
||||
home.packages = [
|
||||
pkgs.openpomodoro-cli
|
||||
(pkgs.writeShellScriptBin "pomostart" ''
|
||||
clear
|
||||
${pkgs.openpomodoro-cli}/bin/openpomodoro-cli start --wait $@
|
||||
while ${pkgs.mpv}/bin/mpv ${pootis} > /dev/null 2>&1; do :; done
|
||||
'')
|
||||
(pkgs.writeShellScriptBin "pomobreak" ''
|
||||
clear
|
||||
${pkgs.openpomodoro-cli}/bin/openpomodoro-cli break --wait $@
|
||||
while ${pkgs.mpv}/bin/mpv ${pootis} > /dev/null 2>&1; do :; done
|
||||
'')
|
||||
];
|
||||
}
|
||||
BIN
modules/home-manager/scripts/pootis.m4a
Normal file
BIN
modules/home-manager/scripts/pootis.m4a
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue