From 002823adceee104f061a90f2c53f4dffeec73436 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 13 May 2018 12:29:00 +0200 Subject: recv --- nix/default.nix | 1 + nix/module.nix | 6 ++++++ nix/recv.nix | 24 ++++++++++++++++++++++++ recv | 13 +++++++++++++ 4 files changed, 44 insertions(+) create mode 100644 nix/recv.nix create mode 100644 recv diff --git a/nix/default.nix b/nix/default.nix index dc225a3..b872f6a 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -6,4 +6,5 @@ self: super: pulseaudio-ctl = self.callPackage ./pulseaudio-ctl.nix {}; monitor-uucp = self.callPackage ./monitor-uucp.nix {}; rolling-directory = self.callPackage ./rolling-directory.nix {}; + recv = self.callPackage ./recv.nix {}; } diff --git a/nix/module.nix b/nix/module.nix index edc9bfb..40082b1 100644 --- a/nix/module.nix +++ b/nix/module.nix @@ -45,11 +45,17 @@ in { type = with types; listOf (submodule dirConfig); default = []; }; + + programs.recv.enable = mkEnableOption "the ‘recv’ program"; }; config = { nixpkgs.overlays = [ (import ./default.nix) ]; systemd.services = listToAttrs (map dirService config.services.rollingDirectories); + + security.wrappers = mkIf config.programs.recv.enable { + recv.source = "${pkgs.recv}/bin/recv"; + }; }; } diff --git a/nix/recv.nix b/nix/recv.nix new file mode 100644 index 0000000..6bdc559 --- /dev/null +++ b/nix/recv.nix @@ -0,0 +1,24 @@ +{ stdenv +, zsh, gnutar +}: + +stdenv.mkDerivation rec { + name = "recv-${version}"; + version = "0.1"; + src = ../recv; + + phases = [ "buildPhase" "installPhase" ]; + + inherit zsh gnutar; + + buildPhase = '' + substituteAll $src recv + ''; + + installPhase = '' + mkdir -p $out/bin + + install -m 755 -t $out/bin \ + recv + ''; +} diff --git a/recv b/recv new file mode 100644 index 0000000..8d28884 --- /dev/null +++ b/recv @@ -0,0 +1,13 @@ +#!@zsh@/bin/zsh + +user="$0" +[[ -n "$user" ]] || exit 2 + +homeDir=$(getent passwd "$user" | cut -f6 -d:) +recvDir="${homeDir}/uucppublic" + +[[ -d "$recvDir" ]] || exit 1 + +umask 007 + +exec @gnutar@/bin/tar -xv -C $(mktemp -d -p "$recvDir" recv.XXXXXXXXXX) --owner "$user" --no-same-permissions \ No newline at end of file -- cgit v1.2.3