diff options
author | Gregor Kleen <pngwjpgh@users.noreply.github.com> | 2016-07-08 14:05:41 +0200 |
---|---|---|
committer | Gregor Kleen <pngwjpgh@users.noreply.github.com> | 2016-07-08 15:44:55 +0200 |
commit | 022b0ca4c442581a5c389d28083be25f44387d33 (patch) | |
tree | 02c31dc2758a0f89be54d699d0cba327d2c4c2ff /ymir/mlmmj-expose.nix | |
parent | fa3775b1d6dee5c6e72de701094bb1fce164a312 (diff) | |
download | nixos-022b0ca4c442581a5c389d28083be25f44387d33.tar nixos-022b0ca4c442581a5c389d28083be25f44387d33.tar.gz nixos-022b0ca4c442581a5c389d28083be25f44387d33.tar.bz2 nixos-022b0ca4c442581a5c389d28083be25f44387d33.tar.xz nixos-022b0ca4c442581a5c389d28083be25f44387d33.zip |
Prevent shadowing
Diffstat (limited to 'ymir/mlmmj-expose.nix')
-rw-r--r-- | ymir/mlmmj-expose.nix | 12 |
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 | ||
3 | let | 3 | let |
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) |