diff --git a/lib/nixos/home-manager/default.nix b/lib/nixos/home-manager/default.nix index 9e643cd4..3a25f566 100644 --- a/lib/nixos/home-manager/default.nix +++ b/lib/nixos/home-manager/default.nix @@ -24,7 +24,9 @@ let username ; }; - shared-packages = import "${self}/lib/shared/home-manager-packages.nix" { inherit inputs pkgs; }; + shared-packages = import "${self}/lib/shared/home-manager-packages.nix" { + inherit desktop inputs pkgs; + }; in { imports = diff --git a/lib/shared/home-manager-packages.nix b/lib/shared/home-manager-packages.nix index 5cdb740b..3206050b 100644 --- a/lib/shared/home-manager-packages.nix +++ b/lib/shared/home-manager-packages.nix @@ -1,22 +1,23 @@ -{ inputs, pkgs, ... }: +{ + desktop, + inputs, + pkgs, + ... +}: let php = pkgs.php82; phpPackages = pkgs.php82Packages; inherit (pkgs) writeShellApplication; - scripts = { - notetaker = writeShellApplication (import ./scripts/notetaker.nix); - run = writeShellApplication (import ./scripts/run.nix { inherit pkgs; }); - t = writeShellApplication (import ./scripts/t.nix { inherit pkgs; }); - }; + _timer = writeShellApplication (import ./scripts/_timer.nix); + notetaker = writeShellApplication (import ./scripts/notetaker.nix); + run = writeShellApplication (import ./scripts/run.nix { inherit pkgs; }); + t = writeShellApplication (import ./scripts/t.nix { inherit pkgs; }); + timer = writeShellApplication (import ./scripts/timer.nix); in with pkgs; [ - scripts.notetaker - scripts.run - scripts.t - age awscli2 bitwarden-cli @@ -58,4 +59,14 @@ with pkgs; xdg-utils xh yarn + + # Scripts. + notetaker + run + t +] +++ pkgs.lib.optionals desktop [ + # Scripts. + _timer + timer ] diff --git a/lib/shared/scripts/_timer.nix b/lib/shared/scripts/_timer.nix new file mode 100644 index 00000000..d670e909 --- /dev/null +++ b/lib/shared/scripts/_timer.nix @@ -0,0 +1,13 @@ +{ + name = "_timer"; + + runtimeInputs = [ ]; + + text = '' + mins=$1 + message=''${2:-Time out!} + + sleep -- "$mins" * 60 + notify-send -t 0 "''${message}" "Your timer of $mins min is over" -u normal + ''; +} diff --git a/lib/shared/scripts/timer.nix b/lib/shared/scripts/timer.nix new file mode 100644 index 00000000..ee261589 --- /dev/null +++ b/lib/shared/scripts/timer.nix @@ -0,0 +1,20 @@ +{ + name = "timer"; + + runtimeInputs = [ ]; + + text = '' + if [[ "$1" == "" ]]; then + echo "Usage: ''${0##*/} [message]" + exit 1 + fi + + mins=$1 + message=$2 + + nohup _timer "$mins" "$message" &> /dev/null & + + echo "timer started for $mins min" + echo "timer started for $mins min, message: '$message'" | systemd-cat -t timer + ''; +} diff --git a/lib/wsl2/default.nix b/lib/wsl2/default.nix index c9dc7c16..a6d51976 100644 --- a/lib/wsl2/default.nix +++ b/lib/wsl2/default.nix @@ -16,7 +16,11 @@ let username ; }; - shared-packages = import "${self}/lib/shared/home-manager-packages.nix" { inherit inputs pkgs; }; + + shared-packages = import "${self}/lib/shared/home-manager-packages.nix" { + inherit inputs pkgs; + desktop = false; + }; in inputs.home-manager.lib.homeManagerConfiguration { inherit pkgs;