From d49dd672463aff72bd754d657abbd11cf8a0d8e0 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sat, 2 Jun 2018 17:58:57 +0200 Subject: revamp uucp-mediaclient --- custom/notify-users.nix | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 custom/notify-users.nix (limited to 'custom/notify-users.nix') diff --git a/custom/notify-users.nix b/custom/notify-users.nix new file mode 100644 index 00000000..e68b0be2 --- /dev/null +++ b/custom/notify-users.nix @@ -0,0 +1,53 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + cfg = config.services.notify-users; + + notify-user = userName: with pkgs; stdenv.mkDerivation { + name = "notify-${userName}"; + src = ./notify-user.hs; + + phases = [ "unpackPhase" "buildPhase" "installPhase" ]; + + unpackPhase = '' + cp $src notify-user.hs + ''; + + inherit userName; + userHome = config.users.users."${userName}".home; + + buildPhase = '' + substituteAllInPlace notify-user.hs + ${ghcWithPackages (p: with p; [ Glob process libnotify getopt-simple containers ])}/bin/ghc -odir . -hidir . $src -o notify-${userName} + ''; + + installPhase = '' + mkdir -p $out/bin + + install -m 755 -t $out/bin \ + notify-${userName} + ''; + }; +in { + options = { + services.notify-users = mkOption { + type = with types; listOf str; + default = []; + description = '' + Users to install a notify-user script for + ''; + }; + }; + + config = mkIf (cfg != []) { + security.wrappers = listToAttrs (map (user: nameValuePair "notify-${user}" { + owner = user; + setuid = true; + setgid = false; + permissions = "u+rx,g+x,o+x"; + source = "${notify-user user}/bin/notify-${user}"; + }) cfg); + }; +} -- cgit v1.2.3