Skip to content

Commit bcb1c60

Browse files
Fix various issues (#80)
1 parent 2502d6f commit bcb1c60

File tree

10 files changed

+137
-151
lines changed

10 files changed

+137
-151
lines changed

README.md

+4-13
Original file line numberDiff line numberDiff line change
@@ -108,25 +108,20 @@ Type `--help` for some more information.
108108
```shell
109109
dconf2nix - Nixify dconf configuration files
110110

111-
Usage: dconf2nix [-v|--version]
112-
[[-r|--root ARG] [-t|--timeout ARG] [-e|--emoji] [--verbose] |
113-
(-i|--input ARG) (-o|--output ARG) [-r|--root ARG]
114-
[-t|--timeout ARG] [-e|--emoji] [--verbose]]
111+
Usage: dconf2nix [-v|--version]
112+
[[-r|--root ARG] [-e|--emoji] [--verbose] | (-i|--input ARG)
113+
(-o|--output ARG) [-r|--root ARG] [-e|--emoji] [--verbose]]
115114
Convert a dconf file into a Nix file, as expected by Home Manager.
116115

117116
Available options:
118117
-h,--help Show this help text
119118
-v,--version Show the current version
120119
-r,--root ARG Custom root path. e.g.: system/locale/
121-
-t,--timeout ARG Timeout in seconds for the conversion
122-
process (default: 5)
123120
-e,--emoji Enable emoji support (adds a bit of overhead)
124121
--verbose Verbose mode (debug)
125122
-i,--input ARG Path to the dconf file (input)
126123
-o,--output ARG Path to the Nix output file (to be created)
127124
-r,--root ARG Custom root path. e.g.: system/locale/
128-
-t,--timeout ARG Timeout in seconds for the conversion
129-
process (default: 5)
130125
-e,--emoji Enable emoji support (adds a bit of overhead)
131126
--verbose Verbose mode (debug)
132127
```
@@ -221,11 +216,7 @@ Have a look at the [latest releases](https://github.com/gvolpe/dconf2nix/release
221216

222217
### Troubleshooting
223218

224-
![error](img/error.png)
225-
226-
The default timeout is of 5 seconds. You can see it by running `dconf2nix --help`.
227-
228-
Do also consider the caveats mentioned above in the [Supported Types](#supported-types) section.
219+
Do consider the caveats mentioned above in the [Supported Types](#supported-types) section.
229220

230221
### Development
231222

app/Main.hs

+4-22
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,13 @@ import CommandLine ( FileArgs(..)
77
, StdinArgs(..)
88
, runArgs
99
)
10-
import Data.Foldable ( traverse_ )
11-
import DConf.Data ( ProcessTimeout(..)
12-
, Verbosity(..)
13-
)
1410
import DConf2Nix ( dconf2nixFile
1511
, dconf2nixStdin
1612
)
17-
import System.Timeout ( timeout )
18-
19-
timeoutMessage = unlines
20-
[ "💥 The process timed out."
21-
, ""
22-
, " 💡 You can try increasing the timeout using --timeout."
23-
, ""
24-
, " ⛔ If the issue persists, run it again using --verbose and report the issue on Github, indicating dconf2nix's version. Sorry 😞."
25-
]
26-
27-
dconf2nix :: ProcessTimeout -> IO () -> Maybe String -> IO ()
28-
dconf2nix (ProcessTimeout t) fa successMsg = timeout (t * 1000000) fa >>= \case
29-
Just _ -> traverse_ putStrLn successMsg
30-
Nothing -> error timeoutMessage
3113

3214
main :: IO ()
3315
main = runArgs >>= \case
34-
FileInput (FileArgs i o r t e v) ->
35-
dconf2nix t (dconf2nixFile i o r e v) (Just "🚀 Successfully Nixified! ❄️")
36-
StdinInput (StdinArgs r t e v) ->
37-
dconf2nix t (dconf2nixStdin r e v) Nothing
16+
FileInput (FileArgs i o r e v) ->
17+
dconf2nixFile i o r e v
18+
StdinInput (StdinArgs r e v) ->
19+
dconf2nixStdin r e v

dconf2nix.cabal

+2
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ library
2727
, text
2828
hs-source-dirs: src
2929
default-language: Haskell2010
30+
ghc-options: -Wall
3031

3132
test-Suite dconf2nix-tests
3233
type: exitcode-stdio-1.0
@@ -50,3 +51,4 @@ executable dconf2nix
5051
, dconf2nix
5152
hs-source-dirs: app
5253
default-language: Haskell2010
54+
ghc-options: -Wall

img/error.png

-49.7 KB
Binary file not shown.

output/dconf.nix

+19-15
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ with lib.hm.gvariant;
1515

1616
"org/gnome/desktop/interface" = {
1717
clock-show-weekday = true;
18-
document-font-name = "JetBrainsMono Nerd Font 11";
18+
document-font-name = " JetBrainsMono Nerd Font 11 ";
1919
enable-hot-corners = false;
20-
font-name = "JetBrainsMono Nerd Font 11";
21-
gtk-im-module = "gtk-im-context-simple";
22-
gtk-theme = "Adwaita-dark";
23-
icon-theme = "Adwaita";
24-
monospace-font-name = "JetBrainsMono Nerd Font 10";
20+
font-name = " JetBrainsMono Nerd Font 11 ";
21+
gtk-im-module = " gtk-im-context-simple ";
22+
gtk-theme = " Adwaita-dark ";
23+
icon-theme = " Adwaita ";
24+
monospace-font-name = " JetBrainsMono Nerd Font 10 ";
2525
show-battery-percentage = true;
2626
};
2727

@@ -36,7 +36,7 @@ with lib.hm.gvariant;
3636
};
3737

3838
"org/gnome/desktop/screensaver" = {
39-
picture-uri = "file:///home/gvolpe/Pictures/nixos.png";
39+
picture-uri = " file:///home/gvolpe/Pictures/nixos.png ";
4040
};
4141

4242
"org/gnome/desktop/sound" = {
@@ -53,7 +53,7 @@ with lib.hm.gvariant;
5353
};
5454

5555
"org/gnome/desktop/wm/preferences" = {
56-
button-layout = "close,minimize,maximize:";
56+
button-layout = " close,minimize,maximize:";
5757
titlebar-font = "JetBrainsMono Nerd Font Mono 11";
5858
workspace-names = [];
5959
};
@@ -98,7 +98,7 @@ with lib.hm.gvariant;
9898
"org/gnome/desktop/input-sources" = {
9999
current = mkUint32 0;
100100
sources = [ (mkTuple [ "xkb" "us" ]) ];
101-
xkb-options = [ "terminate:ctrl_alt_bksp" "lv3:ralt_switch" "caps:ctrl_modifier" ];
101+
xkb-options = [ " terminate:ctrl_alt_bksp " " lv3:ralt_switch " " caps:ctrl_modifier " ];
102102
};
103103

104104
"org/gnome/desktop/interface" = {
@@ -286,7 +286,7 @@ with lib.hm.gvariant;
286286

287287
"org/gnome/shell/extensions/dash-to-dock" = {
288288
dock-fixed = false;
289-
dock-position = "BOTTOM";
289+
dock-position = " BOTTOM ";
290290
};
291291

292292
"org/gnome/shell/extensions/dash-to-dock" = {
@@ -334,7 +334,7 @@ with lib.hm.gvariant;
334334
};
335335

336336
"org/gnome/shell/world-clocks" = {
337-
locations = "@av []";
337+
locations = [];
338338
};
339339

340340
"org/gnome/software" = {
@@ -361,20 +361,20 @@ with lib.hm.gvariant;
361361
};
362362

363363
"org/gnome/Weather" = {
364-
locations = "[<(uint32 2, <('Gdańsk', 'EPGD', true, [(0.94916821905848536, 0.32230414101938371)], [(0.94858644845891815, 0.32579479952337237)])>)>, <(uint32 2, <('Gdynia, Działdowo County, Warmian-Masurian Voivodeship', '', false, [(0.93027949445787339, 0.34699627038777753)], [(0.93861053042695397, 0.35744550775024858)])>)>, <(uint32 2, <('Gdynia, Pomeranian Voivodeship', '', false, [(0.95149239024756216, 0.32358882203124067)], [(0.94858644845891815, 0.32579479952337237)])>)>]";
364+
locations = [ (mkVariant [ (mkUint32 2) (mkVariant [ "Gda\324sk" "EPGD" true [ (mkTuple [ 0.9491682190584854 0.3223041410193837 ]) ] [ (mkTuple [ 0.9485864484589182 0.32579479952337237 ]) ] ]) ]) (mkVariant [ (mkUint32 2) (mkVariant [ "Gdynia, Dzia\322dowo County, Warmian-Masurian Voivodeship" "" false [ (mkTuple [ 0.9302794944578734 0.34699627038777753 ]) ] [ (mkTuple [ 0.938610530426954 0.3574455077502486 ]) ] ]) ]) (mkVariant [ (mkUint32 2) (mkVariant [ "Gdynia, Pomeranian Voivodeship" "" false [ (mkTuple [ 0.9514923902475622 0.3235888220312407 ]) ] [ (mkTuple [ 0.9485864484589182 0.32579479952337237 ]) ] ]) ]) ];
365365
};
366366

367367
"org/gnome/shell/weather" = {
368368
automatic-location = true;
369-
locations = "[<(uint32 2, <('Gdańsk', 'EPGD', true, [(0.94916821905848536, 0.32230414101938371)], [(0.94858644845891815, 0.32579479952337237)])>)>, <(uint32 2, <('Gdynia, Działdowo County, Warmian-Masurian Voivodeship', '', false, [(0.93027949445787339, 0.34699627038777753)], [(0.93861053042695397, 0.35744550775024858)])>)>, <(uint32 2, <('Gdynia, Pomeranian Voivodeship', '', false, [(0.95149239024756216, 0.32358882203124067)], [(0.94858644845891815, 0.32579479952337237)])>)>]";
369+
locations = [ (mkVariant [ (mkUint32 2) (mkVariant [ "Gda\324sk" "EPGD" true [ (mkTuple [ 0.9491682190584854 0.3223041410193837 ]) ] [ (mkTuple [ 0.9485864484589182 0.32579479952337237 ]) ] ]) ]) (mkVariant [ (mkUint32 2) (mkVariant [ "Gdynia, Dzia\322dowo County, Warmian-Masurian Voivodeship" "" false [ (mkTuple [ 0.9302794944578734 0.34699627038777753 ]) ] [ (mkTuple [ 0.938610530426954 0.3574455077502486 ]) ] ]) ]) (mkVariant [ (mkUint32 2) (mkVariant [ "Gdynia, Pomeranian Voivodeship" "" false [ (mkTuple [ 0.9514923902475622 0.3235888220312407 ]) ] [ (mkTuple [ 0.9485864484589182 0.32579479952337237 ]) ] ]) ]) ];
370370
};
371371

372372
"system/locale" = {
373373
region = "en_US.UTF-8";
374374
};
375375

376376
"issue28/desktop/ibus/panel/emoji" = {
377-
favorites = [ "\8211" "\8594" "\8593" "\8595" "\8482" "\\u00ad" "\176" "\\v" "\160" "\171" "\8451" ];
377+
favorites = [ "\137" "\396" "\395" "\397" "\322" "\\u00ad" "\176" "\\v" "\160" "\171" "\297" ];
378378
};
379379

380380
"issue28/org/gnome/desktop/input-sources" = {
@@ -384,7 +384,11 @@ with lib.hm.gvariant;
384384
};
385385

386386
"issue28/org/gnome/clocks" = {
387-
world-clocks = "[{'location': <(uint32 2, <('Houston', 'KHOU', false, [(0.51727195705981943, -1.6629933445314968)], [(0.51727195705981943, -1.6629933445314968)])>)>}, {'location': <(uint32 2, <('Singapore', 'WSAP', true, [(0.023852838928353343, 1.8136879868485383)], [(0.022568084612667797, 1.8126262332513803)])>)>}]";
387+
world-clocks = [ {
388+
location = mkVariant [ (mkUint32 2) (mkVariant [ "Houston" "KHOU" false [ (mkTuple [ 0.5172719570598194 (-1.6629933445314968) ]) ] [ (mkTuple [ 0.5172719570598194 (-1.6629933445314968) ]) ] ]) ];
389+
} {
390+
location = mkVariant [ (mkUint32 2) (mkVariant [ "Singapore" "WSAP" true [ (mkTuple [ 2.3852838928353343e-2 1.8136879868485383 ]) ] [ (mkTuple [ 2.2568084612667797e-2 1.8126262332513803 ]) ] ]) ];
391+
} ];
388392
};
389393

390394
"org/gnome/shell/extensions/arcmenu" = {

output/headers.nix

+3-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ with lib.hm.gvariant;
1616
"uk/co/ibboard/cawbird" = {
1717
round-avatars = false;
1818
startup-accounts = [ "account_name" ];
19-
window-geometry = "{'account_name': (30, 26, 694, 1182)}";
19+
window-geometry = {
20+
account_name = mkTuple [ 30 26 694 1182 ];
21+
};
2022
};
2123

2224
"org/gnome/shell/extensions/bluetooth_battery_indicator" = {

src/CommandLine.hs

+1-10
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,16 @@ data FileArgs = FileArgs
1818
{ fileInput :: InputFilePath
1919
, fileOutput :: OutputFilePath
2020
, fileRoot :: Root
21-
, fileTimeout :: ProcessTimeout
2221
, fileEmojiSupport :: EmojiSupport
2322
, fileVerbosity :: Verbosity
2423
}
2524

2625
data StdinArgs = StdinArgs
2726
{ stdinRoot :: Root
28-
, stdinTimeout :: ProcessTimeout
2927
, stdinEmojiSupport :: EmojiSupport
3028
, stdinVerbosity :: Verbosity
3129
}
3230

33-
timeoutArgs :: Parser ProcessTimeout
34-
timeoutArgs = ProcessTimeout <$> option auto
35-
(long "timeout" <> short 't' <> showDefault <> value 5 <> help
36-
"Timeout in seconds for the conversion process"
37-
)
38-
3931
verbosityArgs :: Parser Verbosity
4032
verbosityArgs =
4133
flag Normal Verbose (long "verbose" <> help "Verbose mode (debug)")
@@ -61,13 +53,12 @@ fileArgs = fmap FileInput $ FileArgs
6153
)
6254
)
6355
<*> rootArgs
64-
<*> timeoutArgs
6556
<*> emojiArgs
6657
<*> verbosityArgs
6758

6859
stdinArgs :: Parser Input
6960
stdinArgs =
70-
StdinInput <$> (StdinArgs <$> rootArgs <*> timeoutArgs <*> emojiArgs <*> verbosityArgs)
61+
StdinInput <$> (StdinArgs <$> rootArgs <*> emojiArgs <*> verbosityArgs)
7162

7263
versionInfo :: String
7364
versionInfo = unlines

0 commit comments

Comments
 (0)