summaryrefslogtreecommitdiff
path: root/custom/tinc/generate_hostfile.hs
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2015-07-02 20:48:08 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2015-07-02 20:48:08 +0200
commit17d901fdd0f0cbd6fddbca62bb4b4d835e9f059b (patch)
treea27f0391123c67239de909f3bd00679e5ee66d94 /custom/tinc/generate_hostfile.hs
parent18fb5f4e19249c725eaf816b4b71e9058ee12bf1 (diff)
downloadnixos-17d901fdd0f0cbd6fddbca62bb4b4d835e9f059b.tar
nixos-17d901fdd0f0cbd6fddbca62bb4b4d835e9f059b.tar.gz
nixos-17d901fdd0f0cbd6fddbca62bb4b4d835e9f059b.tar.bz2
nixos-17d901fdd0f0cbd6fddbca62bb4b4d835e9f059b.tar.xz
nixos-17d901fdd0f0cbd6fddbca62bb4b4d835e9f059b.zip
First work an tinc
Diffstat (limited to 'custom/tinc/generate_hostfile.hs')
-rwxr-xr-xcustom/tinc/generate_hostfile.hs19
1 files changed, 19 insertions, 0 deletions
diff --git a/custom/tinc/generate_hostfile.hs b/custom/tinc/generate_hostfile.hs
new file mode 100755
index 00000000..a8420780
--- /dev/null
+++ b/custom/tinc/generate_hostfile.hs
@@ -0,0 +1,19 @@
1#!/usr/bin/env runhaskell
2
3import System.Directory.Tree
4import Data.List
5
6main :: IO ()
7main = readDirectory "." >>= putStrLn . genHostFile
8
9genHostFile :: AnchoredDirTree String -> String
10genHostFile (_ :/ (Dir _ contents)) = "{\n" ++ entries ++ "\n}\n"
11 where
12 entries = concat [ genEntry name content | (File name content) <- contents, name `notElem` hidden ]
13 genEntry fileName fileContent = unlines . indent $ [ "\"" ++ fileName ++ "\" = ''" ] ++ indent (lines fileContent) ++ [ "'';" ]
14 hidden = [ "to_nix.sh"
15 , "signup.sh"
16 ]
17
18indent :: [String] -> [String]
19indent = map (" " ++)