diff options
author | Gregor Kleen <gkleen@yggdrasil.li> | 2015-07-02 20:48:08 +0200 |
---|---|---|
committer | Gregor Kleen <gkleen@yggdrasil.li> | 2015-07-02 20:48:08 +0200 |
commit | 17d901fdd0f0cbd6fddbca62bb4b4d835e9f059b (patch) | |
tree | a27f0391123c67239de909f3bd00679e5ee66d94 /custom/tinc/generate_hostfile.hs | |
parent | 18fb5f4e19249c725eaf816b4b71e9058ee12bf1 (diff) | |
download | nixos-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-x | custom/tinc/generate_hostfile.hs | 19 |
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 | |||
3 | import System.Directory.Tree | ||
4 | import Data.List | ||
5 | |||
6 | main :: IO () | ||
7 | main = readDirectory "." >>= putStrLn . genHostFile | ||
8 | |||
9 | genHostFile :: AnchoredDirTree String -> String | ||
10 | genHostFile (_ :/ (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 | |||
18 | indent :: [String] -> [String] | ||
19 | indent = map (" " ++) | ||