summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ymir/mlmmj-expose.nix12
1 files changed, 9 insertions, 3 deletions
diff --git a/ymir/mlmmj-expose.nix b/ymir/mlmmj-expose.nix
index f7d23565..b07396aa 100644
--- a/ymir/mlmmj-expose.nix
+++ b/ymir/mlmmj-expose.nix
@@ -1,7 +1,7 @@
1{ config, pkgs, ... }: 1{ config, pkgs, ... }:
2 2
3let 3let
4 haskellEnv = pkgs.haskellPackages.ghcWithPackages (pkgs: with pkgs; [ filepath directory cryptonite bytestring ]); 4 haskellEnv = pkgs.haskellPackages.ghcWithPackages (pkgs: with pkgs; [ filepath directory cryptonite bytestring uuid ]);
5 mlmmj-exposed = pkgs.stdenv.mkDerivation { 5 mlmmj-exposed = pkgs.stdenv.mkDerivation {
6 name = "mlmmj-exposed"; 6 name = "mlmmj-exposed";
7 src = pkgs.writeText "mlmmj-exposed.hs" '' 7 src = pkgs.writeText "mlmmj-exposed.hs" ''
@@ -30,6 +30,9 @@ let
30 30
31 -- import Data.Hex 31 -- import Data.Hex
32 32
33 import qualified Data.UUID as UUID (toString)
34 import qualified Data.UUID.V4 as UUID (nextRandom)
35
33 main :: IO () 36 main :: IO ()
34 main = do 37 main = do
35 progName <- takeFileName <$> getProgName 38 progName <- takeFileName <$> getProgName
@@ -44,8 +47,11 @@ let
44 let hashes = filter ((==) extension . snd) [((ident, sub), hash' (ident, sub)) | ident <- identities, sub <- subscribers] 47 let hashes = filter ((==) extension . snd) [((ident, sub), hash' (ident, sub)) | ident <- identities, sub <- subscribers]
45 case hashes of 48 case hashes of
46 [((_, recipient), _)] -> do 49 [((_, recipient), _)] -> do
47 getContents >>= writeFile "queue/exposed" 50 uuid <- UUID.nextRandom
48 callProcess "${pkgs.mlmmj}/bin/mlmmj-send" ["-L", listDir, "-l", "6", "-m", "queue/exposed", "-T", recipient] 51 let fName = "queue" </> "exposed" <.> UUID.toString uuid
52 getContents >>= writeFile fName
53 callProcess "${pkgs.mlmmj}/bin/mlmmj-send" ["-L", listDir, "-l", "6", "-m", fName, "-T", recipient]
54 removeFile fName
49 [] -> die "Unknown extension" 55 [] -> die "Unknown extension"
50 _ -> die "Ambiguous extension" 56 _ -> die "Ambiguous extension"
51 _ -> hPutStrLn stderr ("Called without expected arguments (<listDirectory> <recipientExtension>)") >> exitWith (ExitFailure 2) 57 _ -> hPutStrLn stderr ("Called without expected arguments (<listDirectory> <recipientExtension>)") >> exitWith (ExitFailure 2)