summaryrefslogtreecommitdiff
path: root/pkgs/still-awake/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/still-awake/default.nix')
-rw-r--r--pkgs/still-awake/default.nix38
1 files changed, 38 insertions, 0 deletions
diff --git a/pkgs/still-awake/default.nix b/pkgs/still-awake/default.nix
new file mode 100644
index 0000000..a83dd63
--- /dev/null
+++ b/pkgs/still-awake/default.nix
@@ -0,0 +1,38 @@
+{ stdenv, pypy3, lib }:
+
+let
+ # Needs python interpreter with tkinter support.
+ python3' = pypy3;
+in
+stdenv.mkDerivation {
+ pname = "still-awake";
+ version = "10-09-2023";
+
+ src = builtins.readFile ./still_awake.py;
+ passAsFile = [ "buildCommand" "src" ];
+
+ # Building basically boils down to writing source to a file
+ # and making it executable.
+ buildCommand = ''
+ mkdir -p $out/bin
+
+ echo "#!${python3'.interpreter}" >$out/bin/still-awake
+
+ if [ -e "$srcPath" ]; then
+ cat "$srcPath" >>$out/bin/still-awake
+ else
+ echo -n "$src" >>$out/bin/still-awake
+ fi
+
+ chmod +x $out/bin/still-awake
+ '';
+
+ # It doesn't make sense to do this remotely.
+ preferLocalBuild = true;
+ allowSubstitute = false;
+
+ meta = with lib; {
+ description = "Small program which shuts down Mac, if user is asleep";
+ platforms = platforms.darwin;
+ };
+}