git.iko.soy/typeable/cabal2nix
on 1663fb8 help sign in
165 lines 10 kB history raw
1module Cabal2Nix.Name ( toNixName, toNixName', libNixName, buildToolNixName ) where
3import Data.Char
5-- | Map Cabal names to Nix attribute names.
6toNixName :: String -> String
7toNixName = id
9-- | The old mapping function. This may be useful to generate a compatibility layer.
10toNixName' :: String -> String
11toNixName' [] = error "toNixName: empty string is not a valid argument"
12toNixName' name = f name
13 where
14 f [] = []
15 f ('-':c:cs) | c `notElem` "-" = toUpper c : f cs
16 f ('-':_) = error ("unexpected package name " ++ show name)
17 f (c:cs) = c : f cs
19-- | Map libraries to Nix packages.
20-- TODO: This should probably be configurable. We also need to consider the
21-- possibility of name clashes with Haskell libraries. I have included
22-- identity mappings to incicate that I have verified their correctness.
23libNixName :: String -> [String]
24libNixName "adns" = return "adns"
25libNixName "alsa" = return "alsaLib"
26libNixName "alut" = return "freealut"
27libNixName "appindicator-0.1" = return "appindicator"
28libNixName "appindicator3-0.1" = return "appindicator"
29libNixName "asound" = return "alsaLib"
30libNixName "awesomium-1.6.5" = return "awesomium"
31libNixName "bz2" = return "bzip2"
32libNixName "cairo-pdf" = return "cairo"
33libNixName "cairo-ps" = return "cairo"
34libNixName "cairo" = return "cairo"
35libNixName "cairo-svg" = return "cairo"
36libNixName "CEGUIBase-0.7.7" = return "CEGUIBase"
37libNixName "CEGUIOgreRenderer-0.7.7" = return "CEGUIOgreRenderer"
38libNixName "clutter-1.0" = return "clutter"
39libNixName "crypto" = return "openssl"
40libNixName "crypt" = [] -- provided by glibc
41libNixName "curses" = return "ncurses"
42libNixName "c++" = [] -- What is that?
43libNixName "dl" = [] -- provided by glibc
44libNixName "fftw3f" = return "fftwFloat"
45libNixName "fftw3" = return "fftw"
46libNixName "gconf-2.0" = return "GConf"
47libNixName "gconf" = return "GConf"
48libNixName "gdk-2.0" = return "gtk"
49libNixName "gdk-pixbuf-2.0" = return "gdk_pixbuf"
50libNixName "gdk-x11-2.0" = return "gdk_x11"
51libNixName "gio-2.0" = return "glib"
52libNixName "glib-2.0" = return "glib"
53libNixName "GL" = return "mesa"
54libNixName "GLU" = ["freeglut","mesa"]
55libNixName "glut" = ["freeglut","mesa"]
56libNixName "gmime-2.4" = return "gmime"
57libNixName "gnome-keyring-1" = return "gnome_keyring"
58libNixName "gnome-keyring" = return "gnome_keyring"
59libNixName "gnome-vfs-2.0" = return "gnome_vfs"
60libNixName "gnome-vfs-module-2.0" = return "gnome_vfs_module"
61libNixName "gobject-2.0" = return "glib"
62libNixName "gstreamer-0.10" = return "gstreamer"
63libNixName "gstreamer-audio-0.10" = return "gst_plugins_base"
64libNixName "gstreamer-base-0.10" = return "gst_plugins_base"
65libNixName "gstreamer-controller-0.10" = return "gstreamer"
66libNixName "gstreamer-dataprotocol-0.10" = return "gstreamer"
67libNixName "gstreamer-net-0.10" = return "gst_plugins_base"
68libNixName "gstreamer-plugins-base-0.10" = return "gst_plugins_base"
69libNixName "gthread-2.0" = return "glib"
70libNixName "gtk+-2.0" = return "gtk"
71libNixName "gtk+-3.0" = return "gtk3"
72libNixName "gtkglext-1.0" = return "gtkglext"
73libNixName "gtksourceview-2.0" = return "gtksourceview"
74libNixName "gtksourceview-3.0" = return "gtksourceview"
75libNixName "gtk-x11-2.0" = return "gtk_x11"
76libNixName "icudata" = return "icu"
77libNixName "icui18n" = return "icu"
78libNixName "icuuc" = return "icu"
79libNixName "idn" = return "libidn"
80libNixName "IL" = return "libdevil"
81libNixName "Imlib2" = return "imlib2"
82libNixName "iw" = return "wirelesstools"
83libNixName "jack" = return "jack2"
84libNixName "jpeg" = return "libjpeg"
85libNixName "ldap" = return "openldap"
86libNixName "libavutil" = return "ffmpeg"
87libNixName "libglade-2.0" = return "libglade"
88libNixName "libgsasl" = return "gsasl"
89libNixName "librsvg-2.0" = return "librsvg"
90libNixName "libsoup-gnome-2.4" = return "libsoup"
91libNixName "libsystemd" = return "systemd"
92libNixName "libusb-1.0" = return "libusb"
93libNixName "libxml-2.0" = return "libxml2"
94libNixName "libzip" = return "libzip"
95libNixName "libzmq" = return "zeromq"
96libNixName "m" = [] -- in stdenv
97libNixName "mono-2.0" = return "mono"
98libNixName "mpi" = return "openmpi"
99libNixName "ncursesw" = return "ncurses"
100libNixName "netsnmp" = return "net_snmp"
101libNixName "notify" = return "libnotify"
102libNixName "odbc" = return "unixODBC"
103libNixName "panelw" = return "ncurses"
104libNixName "pangocairo" = return "pango"
105libNixName "pcap" = return "libpcap"
106libNixName "pcre" = return "pcre"
107libNixName "pfs-1.2" = return "pfstools"
108libNixName "png" = return "libpng"
109libNixName "poppler-glib" = return "poppler"
110libNixName "portaudio-2.0" = return "portaudio"
111libNixName "pq" = return "postgresql"
112libNixName "pthread" = []
113libNixName "pulse-simple" = return "libpulseaudio"
114libNixName "python-3.3" = return "python3"
115libNixName "Qt5Core" = return "qt5"
116libNixName "Qt5Gui" = return "qt5"
117libNixName "Qt5Qml" = return "qt5"
118libNixName "Qt5Quick" = return "qt5"
119libNixName "Qt5Widgets" = return "qt5"
120libNixName "rtlsdr" = return "rtl-sdr"
121libNixName "rt" = return [] -- in glibc
122libNixName "ruby1.8" = return "ruby"
123libNixName "sane-backends" = return "saneBackends"
124libNixName "SDL2-2.0" = return "SDL2"
125libNixName "sdl2" = return "SDL2"
126libNixName "sndfile" = return "libsndfile"
127libNixName "sqlite3" = return "sqlite"
128libNixName "ssl" = return "openssl"
129libNixName "stdc++.dll" = [] -- What is that?
130libNixName "stdc++" = [] -- What is that?
131libNixName "systemd-journal" = return "systemd"
132libNixName "tag_c" = return "taglib"
133libNixName "taglib_c" = return "taglib"
134libNixName "udev" = return "systemd";
135libNixName "uuid" = return "libossp_uuid";
136libNixName "vte-2.90" = return "vte"
137libNixName "webkit-1.0" = return "webkit"
138libNixName "webkitgtk-3.0" = return "webkit"
139libNixName "webkitgtk" = return "webkit"
140libNixName "X11" = return "libX11"
141libNixName "xau" = return "libXau"
142libNixName "Xcursor" = return "libXcursor"
143libNixName "xerces-c" = return "xercesc"
144libNixName "Xext" = return "libXext"
145libNixName "xft" = return "libXft"
146libNixName "Xinerama" = return "libXinerama"
147libNixName "Xi" = return "libXi"
148libNixName "xkbcommon" = return "libxkbcommon"
149libNixName "xml2" = return "libxml2"
150libNixName "Xpm" = return "libXpm"
151libNixName "Xrandr" = return "libXrandr"
152libNixName "Xss" = return "libXScrnSaver"
153libNixName "Xtst" = return "libXtst"
154libNixName "Xxf86vm" = return "libXxf86vm"
155libNixName "zmq" = return "zeromq"
156libNixName "z" = return "zlib"
157libNixName x = return x
159-- | Map build tool names to Nix attribute names.
160buildToolNixName :: String -> [String]
161buildToolNixName "cabal" = return "cabal-install"
162buildToolNixName "gtk2hsC2hs" = return "gtk2hs-buildtools"
163buildToolNixName "gtk2hsHookGenerator" = return "gtk2hs-buildtools"
164buildToolNixName "gtk2hsTypeGen" = return "gtk2hs-buildtools"
165buildToolNixName x = return (toNixName x)