From 153a3e9ea154a733e38a9f61e358f2aa01194155 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Sun, 19 May 2024 17:46:37 +0200 Subject: [PATCH] Add NixOS support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NixOS 23.11 received support for creating dconf databases in NixOS configuration. The GVariant library in Nixpkgs has slightly different syntax, though, so let’s make the output style configurable and add support for that. https://www.github.com/NixOS/nixpkgs/pull/234615 --- README.md | 26 +- app/Main.hs | 8 +- dconf2nix.cabal | 4 +- src/CommandLine.hs | 8 +- src/DConf/Data.hs | 3 + src/DConf2Nix.hs | 21 +- src/Nix.hs | 70 +++- test/DConf2NixTest.hs | 30 +- test/Main.hs | 6 +- test/output/bytestring-nixos.nix | 28 ++ test/output/clocks-nixos.nix | 23 ++ test/output/custom-nixos.nix | 25 ++ test/output/dict-nixos.nix | 51 +++ test/output/dump-nixos.nix | 390 ++++++++++++++++++++++ test/output/emoji-nixos.nix | 19 ++ test/output/headers-nixos.nix | 33 ++ test/output/indexer-nixos.nix | 17 + test/output/json-nixos.nix | 29 ++ test/output/keybindings-nixos.nix | 19 ++ test/output/nested-nixos.nix | 23 ++ test/output/numbers-nixos.nix | 51 +++ test/output/scientific-notation-nixos.nix | 19 ++ test/output/strings-nixos.nix | 39 +++ test/output/tuples-nixos.nix | 24 ++ test/output/typed-nixos.nix | 37 ++ test/output/unicode-nixos.nix | 18 + test/output/variant-nixos.nix | 26 ++ 27 files changed, 994 insertions(+), 53 deletions(-) create mode 100644 test/output/bytestring-nixos.nix create mode 100644 test/output/clocks-nixos.nix create mode 100644 test/output/custom-nixos.nix create mode 100644 test/output/dict-nixos.nix create mode 100644 test/output/dump-nixos.nix create mode 100644 test/output/emoji-nixos.nix create mode 100644 test/output/headers-nixos.nix create mode 100644 test/output/indexer-nixos.nix create mode 100644 test/output/json-nixos.nix create mode 100644 test/output/keybindings-nixos.nix create mode 100644 test/output/nested-nixos.nix create mode 100644 test/output/numbers-nixos.nix create mode 100644 test/output/scientific-notation-nixos.nix create mode 100644 test/output/strings-nixos.nix create mode 100644 test/output/tuples-nixos.nix create mode 100644 test/output/typed-nixos.nix create mode 100644 test/output/unicode-nixos.nix create mode 100644 test/output/variant-nixos.nix diff --git a/README.md b/README.md index 8bd28cb..04bb434 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![CI Status](https://github.com/nix-commmunity/dconf2nix/workflows/Haskell%20CI/badge.svg)](https://github.com/nix-commmunity/dconf2nix/actions) -A convenient converter of [dconf](https://gitlab.gnome.org/GNOME/dconf) files to Nix, as expected by [Home Manager's dconf settings](https://rycee.gitlab.io/home-manager/options.xhtml#opt-dconf.settings). So you can Nixify your [GNOME Shell](https://gitlab.gnome.org/GNOME/gnome-shell) configuration :wink: +A convenient converter of [dconf](https://gitlab.gnome.org/GNOME/dconf) files to Nix, as expected by [Home Manager’s](https://rycee.gitlab.io/home-manager/options.xhtml#opt-dconf.settings) or [NixOS](https://nixos.org/manual/nixos/unstable/options.html#opt-programs.dconf.profiles) dconf settings. So you can Nixify your [GNOME Shell](https://gitlab.gnome.org/GNOME/gnome-shell) configuration :wink: * [Benchmarks](#benchmarks) @@ -46,12 +46,14 @@ xkb-options=['terminate:ctrl_alt_bksp', 'lv3:ralt_switch', 'caps:ctrl_modifier'] picture-uri='file:///home/gvolpe/Pictures/nixos.png' ``` -You will get the following output when running `dconf2nix`: +You will get the following output when running `dconf2nix --home-manager`: ```nix +# Generated via dconf2nix: https://github.com/nix-commmunity/dconf2nix { lib, ... }: with lib.hm.gvariant; + { dconf.settings = { "org/gnome/desktop/peripherals/mouse" = { @@ -73,8 +75,8 @@ with lib.hm.gvariant; "org/gnome/desktop/screensaver" = { picture-uri = "file:///home/gvolpe/Pictures/nixos.png"; }; - }; + }; } ``` @@ -91,13 +93,19 @@ dconf dump / > dconf.settings The easiest way is to pipe the standard input to `dconf2nix` and expect the result in the standard output: ```shell -dconf dump / | dconf2nix > dconf.nix +dconf dump / | dconf2nix --home-manager > dconf.nix +``` + +If you want to use the result in a NixOS configuration, use `--nixos` instead of `--home-manager`: + +```shell +dconf dump / | dconf2nix --nixos > dconf.nix ``` If you have an input file instead, you can run the following command: ```shell -dconf2nix -i data/dconf.settings -o output/dconf.nix +dconf2nix --home-manager -i data/dconf.settings -o output/dconf.nix ``` Type `--help` for some more information. @@ -105,8 +113,8 @@ Type `--help` for some more information. ```shell dconf2nix - Nixify dconf configuration files -Usage: dconf2nix [-v|--version] [-r|--root ARG] [--verbose] - [(-i|--input ARG) (-o|--output ARG)] +Usage: dconf2nix [-v|--version] [-r|--root ARG] (--home-manager | --nixos) + [--verbose] [(-i|--input ARG) (-o|--output ARG)] Convert a dconf file into a Nix file, as expected by Home Manager. @@ -114,6 +122,8 @@ Available options: -h,--help Show this help text -v,--version Show the current version -r,--root ARG Custom root path. e.g.: system/locale/ + --home-manager Use NixOS syntax + --nixos Use home-manager syntax --verbose Verbose mode (debug) -i,--input ARG Path to the dconf file (input) -o,--output ARG Path to the Nix output file (to be created) @@ -124,7 +134,7 @@ Available options: By default, `dconf2nix` expects the root to be `/`. If you want to create a dump of a custom root, you can use the `--root` flag. For example: ```shell -dconf dump /system/locale/ | dconf2nix --root system/locale > dconf.nix +dconf dump /system/locale/ | dconf2nix --home-manager --root system/locale > dconf.nix ``` This will generate an output similar to the one below. diff --git a/app/Main.hs b/app/Main.hs index 8d54205..79c2e8f 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -13,7 +13,7 @@ import DConf2Nix ( dconf2nixFile main :: IO () main = runArgs >>= \case - Args r v (FileInput (FileArgs i o)) -> - dconf2nixFile i o r v - Args r v StdinInput -> - dconf2nixStdin r v + Args r s v (FileInput (FileArgs i o)) -> + dconf2nixFile i o r s v + Args r s v StdinInput -> + dconf2nixStdin r s v diff --git a/dconf2nix.cabal b/dconf2nix.cabal index 51c4ea1..828d9c2 100644 --- a/dconf2nix.cabal +++ b/dconf2nix.cabal @@ -2,8 +2,8 @@ cabal-version: 2.4 name: dconf2nix version: 0.1.1 -synopsis: Convert dconf files to Nix, as expected by Home Manager. -description: A convenient converter of dconf files to Nix, as expected by Home Manager’s dconf settings. So you can Nixify your GNOME Shell configuration ;) +synopsis: Convert dconf files to Nix, as expected by Home Manager or NixOS. +description: A convenient converter of dconf files to Nix, as expected by Home Manager or NixOS’s dconf settings. So you can Nixify your GNOME Shell configuration ;) bug-reports: https://github.com/nix-commmunity/dconf2nix/issues license: Apache-2.0 license-file: LICENSE diff --git a/src/CommandLine.hs b/src/CommandLine.hs index 02a499f..06a88b9 100644 --- a/src/CommandLine.hs +++ b/src/CommandLine.hs @@ -14,6 +14,7 @@ import Paths_dconf2nix ( version ) data Args = Args { argsRoot :: Root + , argsStyle :: Style , argsVerbosity :: Verbosity , argsInput :: Input } @@ -25,6 +26,11 @@ data FileArgs = FileArgs , fileOutput :: OutputFilePath } +styleArgs :: Parser Style +styleArgs = + flag' HomeManager (long "home-manager" <> help "Use NixOS syntax") + <|> flag' NixOS (long "nixos" <> help "Use home-manager syntax") + verbosityArgs :: Parser Verbosity verbosityArgs = flag Normal Verbose (long "verbose" <> help "Verbose mode (debug)") @@ -71,7 +77,7 @@ versionOpt = infoOption versionInfo runArgs :: IO Args runArgs = let - args = Args <$> rootArgs <*> verbosityArgs <*> (stdinArgs <|> fileArgs) + args = Args <$> rootArgs <*> styleArgs <*> verbosityArgs <*> (stdinArgs <|> fileArgs) opts = info (helper <*> versionOpt <*> args) diff --git a/src/DConf/Data.hs b/src/DConf/Data.hs index 95e397d..f9682b7 100644 --- a/src/DConf/Data.hs +++ b/src/DConf/Data.hs @@ -7,6 +7,9 @@ import Data.Word ( Word8 ) newtype InputFilePath = InputFilePath FilePath deriving Show newtype OutputFilePath = OutputFilePath FilePath deriving Show +data Style = HomeManager | NixOS + deriving Eq + data Verbosity = Normal | Verbose newtype Nix = Nix { unNix :: Text } deriving Show diff --git a/src/DConf2Nix.hs b/src/DConf2Nix.hs index 14d1ffa..c669e88 100644 --- a/src/DConf2Nix.hs +++ b/src/DConf2Nix.hs @@ -13,15 +13,15 @@ import Text.Parsec ( ParseError , runParser ) -dconf2nixFile :: InputFilePath -> OutputFilePath -> Root -> Verbosity -> IO () -dconf2nixFile (InputFilePath input) (OutputFilePath output) root v = - let run = handler (T.writeFile output) (T.appendFile output) root +dconf2nixFile :: InputFilePath -> OutputFilePath -> Root -> Style -> Verbosity -> IO () +dconf2nixFile (InputFilePath input) (OutputFilePath output) root s v = + let run = handler (T.writeFile output) (T.appendFile output) root s parse = parseFromFile (dconfParser v) input in run =<< parse -dconf2nixStdin :: Root -> Verbosity -> IO () -dconf2nixStdin root v = - let run = handler T.putStr T.putStr root +dconf2nixStdin :: Root -> Style -> Verbosity -> IO () +dconf2nixStdin root s v = + let run = handler T.putStr T.putStr root s parse = runParser (dconfParser v) () "" in run . parse =<< T.getContents @@ -29,11 +29,12 @@ handler :: (T.Text -> IO ()) -> (T.Text -> IO ()) -> Root + -> Style -> Either ParseError [Entry] -> IO () -handler writer appender root = \case +handler writer appender root s = \case Left err -> error $ show err Right xs -> do - writer Nix.renderHeader - traverse_ (\e -> appender (unNix $ Nix.renderEntry e root)) xs - appender Nix.renderFooter + writer (Nix.renderHeader s) + traverse_ (\e -> appender (unNix $ Nix.renderEntry s e root)) xs + appender (Nix.renderFooter s) diff --git a/src/Nix.hs b/src/Nix.hs index d52e778..2fdc9a9 100644 --- a/src/Nix.hs +++ b/src/Nix.hs @@ -16,8 +16,12 @@ import qualified Data.Text as T import Data.Word ( Word8 ) import DConf.Data -renderHeader :: Header -renderHeader = T.unlines +renderHeader :: Style -> Header +renderHeader HomeManager = renderHeaderHm +renderHeader NixOS = renderHeaderNixOS + +renderHeaderHm :: Header +renderHeaderHm = T.unlines [ "# Generated via dconf2nix: https://github.com/nix-commmunity/dconf2nix" , "{ lib, ... }:" , "" @@ -27,8 +31,33 @@ renderHeader = T.unlines , " dconf.settings = {" ] -renderFooter :: Header -renderFooter = T.unlines [" };", "}"] +renderHeaderNixOS :: Header +renderHeaderNixOS = T.unlines + [ "# Generated via dconf2nix: https://github.com/nix-commmunity/dconf2nix" + , "{ lib, ... }:" + , "" + , "with lib.gvariant;" + , "" + , "{" + , " programs.dconf.profiles.user.databases = [" + , " {" + , " settings = {" + ] + +renderFooter :: Style -> Header +renderFooter HomeManager = renderFooterHm +renderFooter NixOS = renderFooterNixOS + +renderFooterHm :: Header +renderFooterHm = T.unlines [" };", "}"] + +renderFooterNixOS :: Header +renderFooterNixOS = T.unlines + [ " };" + , " }" + , " ];" + , "}" + ] normalizeRoot :: T.Text -> T.Text normalizeRoot r | T.null r = r @@ -43,15 +72,20 @@ normalizeHeader h (Root r) = normalizeRoot r <> T.replace "." "/" h mkSpaces :: Int -> T.Text mkSpaces = T.pack . flip replicate ' ' -renderEntry :: Entry -> Root -> Nix -renderEntry (Entry h c) root = - let header = mkSpaces 4 <> "\"" <> normalizeHeader h root <> "\" = {\n" +indentBase :: Style -> Int +indentBase HomeManager = 4 +indentBase NixOS = 8 + +renderEntry :: Style -> Entry -> Root -> Nix +renderEntry s (Entry h c) root = + let base = indentBase s + header = mkSpaces base <> "\"" <> normalizeHeader h root <> "\" = {\n" body = Map.toList c >>= \(Key k, v) -> - T.unpack $ mkSpaces 6 <> k <> " = " <> unNix (renderValue v) <> "\n" - close = mkSpaces 4 <> "};\n\n" + T.unpack $ mkSpaces (base + 2) <> k <> " = " <> unNix (renderValue s v) <> "\n" + close = mkSpaces base <> "};\n\n" in Nix $ header <> T.pack body <> close --- | Converts type to home-manager constructor function name. +-- | Converts type to NixOS/home-manager constructor function name. -- | Most constructors will prefix the value with type annotation, we have to avoid those that don’t or we might get ambiguous expressions. constrName :: Ty -> Maybe String constrName TyObjectpath = Just "mkObjectpath" @@ -72,10 +106,10 @@ constrName _ = Nothing -- arguments or list items (e.g. function application). data NixExpr = NeedsParens T.Text | Atomic T.Text -renderValue :: Value -> Nix -renderValue raw = Nix $ unparens (renderValue' initialIndent raw) <> ";" +renderValue :: Style -> Value -> Nix +renderValue s raw = Nix $ unparens (renderValue' initialIndent raw) <> ";" where - initialIndent = 6 + initialIndent = indentBase s + 2 parens :: NixExpr -> T.Text parens (NeedsParens v) = "(" <> v <> ")" @@ -95,7 +129,10 @@ renderValue raw = Nix $ unparens (renderValue' initialIndent raw) <> ";" renderValue' _indent (S v) = renderString v renderValue' _indent (B v) = Atomic $ T.toLower . T.pack $ show v renderValue' _indent (No ) = error "Standalone nothing not supported" - renderValue' _indent (I v) = (if v < 0 then NeedsParens else Atomic) (T.pack $ show v) + renderValue' _indent (I v) = + case s of + HomeManager -> (if v < 0 then NeedsParens else Atomic) (T.pack $ show v) + NixOS -> NeedsParens $ "mkInt32 " <> parens ((if v < 0 then NeedsParens else Atomic) (T.pack $ show v)) renderValue' _indent (D v) = NeedsParens $ "mkDouble \"" <> (T.pack $ show v) <> "\"" renderValue' indent (C ty v) = NeedsParens $ case constrName ty of @@ -117,7 +154,10 @@ renderValue raw = Nix $ unparens (renderValue' initialIndent raw) <> ";" Atomic $ "''\n" <> mkSpaces (indent + 2) <> T.strip v <> "\n" <> mkSpaces indent <> "''" renderValue' indent (R kvs) = Atomic $ "[\n" <> mconcat (fmap (\(k,v) -> mkSpaces (indent + 2) <> renderItem (indent + 2) (DE k v) <> "\n") kvs) <> mkSpaces indent <> "]" - renderValue' indent (DE k v) = NeedsParens $ "mkDictionaryEntry [" <> renderItem indent k <> " " <> renderItem indent v <> "]" + renderValue' indent (DE k v) = + case s of + HomeManager -> NeedsParens $ "mkDictionaryEntry [" <> renderItem indent k <> " " <> renderItem indent v <> "]" + NixOS -> NeedsParens $ "mkDictionaryEntry " <> renderItem indent k <> " " <> renderItem indent v renderString :: T.Text -> NixExpr renderString text = Atomic $ "\"" <> escaped <> "\"" diff --git a/test/DConf2NixTest.hs b/test/DConf2NixTest.hs index 83e0db0..e2df946 100644 --- a/test/DConf2NixTest.hs +++ b/test/DConf2NixTest.hs @@ -1,7 +1,8 @@ {-# LANGUAGE OverloadedStrings #-} module DConf2NixTest - ( dconf2nixTests + ( dconf2nixHmTests + , dconf2nixNixOSTests ) where @@ -15,9 +16,13 @@ import DConf.Data import Hedgehog import Text.Parsec ( runParser ) -dconf2nixTests :: Group -dconf2nixTests = Group "Tests" - [(fromString name, runOnce (inputTestProperty (fromString name) root)) | InputTest name root <- inputTests] +dconf2nixHmTests :: Group +dconf2nixHmTests = Group "Home Manager tests" + [(fromString name, runOnce (inputTestProperty HomeManager (fromString name) root)) | InputTest name root <- inputTests] + +dconf2nixNixOSTests :: Group +dconf2nixNixOSTests = Group "NixOS tests" + [(fromString name, runOnce (inputTestProperty NixOS (fromString name) root)) | InputTest name root <- inputTests] inputTests :: [InputTest] inputTests = @@ -53,11 +58,11 @@ it name = InputTest { itName = name, itRoot = (Root T.empty) } runOnce :: Property -> Property runOnce = withTests 1 -baseProperty :: FilePath -> FilePath -> Root -> Property -baseProperty i o root = property $ do +baseProperty :: Style -> FilePath -> FilePath -> Root -> Property +baseProperty s i o root = property $ do input <- evalIO $ T.readFile i ref <- evalIO $ newIORef T.empty - evalIO $ handler (writer ref) (writer ref) root (entries input) + evalIO $ handler (writer ref) (writer ref) root s (entries input) result <- evalIO $ readIORef ref -- Uncomment to overwrite the output files. -- evalIO $ T.writeFile o result @@ -67,8 +72,11 @@ baseProperty i o root = property $ do entries = runParser (dconfParser Normal) () "" writer ref x = modifyIORef ref (`T.append` x) -inputTestProperty :: FilePath -> Root -> Property -inputTestProperty name root = +inputTestProperty :: Style -> FilePath -> Root -> Property +inputTestProperty s name root = let input = "test/data/" <> name <> ".settings" - output = "test/output/" <> name <> ".nix" - in baseProperty input output root + output = "test/output/" <> name <> suffix <> ".nix" + suffix = case s of + HomeManager -> "" + NixOS -> "-nixos" + in baseProperty s input output root diff --git a/test/Main.hs b/test/Main.hs index a31e770..96c6b75 100644 --- a/test/Main.hs +++ b/test/Main.hs @@ -2,12 +2,14 @@ module Main where import Control.Monad ( unless ) import DConfTest ( dconfParserTests ) -import DConf2NixTest ( dconf2nixTests ) +import DConf2NixTest ( dconf2nixHmTests, dconf2nixNixOSTests ) import Hedgehog import System.Exit main :: IO () main = do results <- sequence - [checkParallel dconfParserTests, checkParallel dconf2nixTests] + [ checkParallel dconfParserTests + , checkParallel dconf2nixHmTests + , checkParallel dconf2nixNixOSTests] unless (and results) exitFailure diff --git a/test/output/bytestring-nixos.nix b/test/output/bytestring-nixos.nix new file mode 100644 index 0000000..9cc0f41 --- /dev/null +++ b/test/output/bytestring-nixos.nix @@ -0,0 +1,28 @@ +# Generated via dconf2nix: https://github.com/nix-commmunity/dconf2nix +{ lib, ... }: + +with lib.gvariant; + +{ + programs.dconf.profiles.user.databases = [ + { + settings = { + "bytestring" = { + basic-double = mkByteString ''foo''; + basic-single = mkByteString ''bar''; + empty-double = mkByteString ''''; + empty-single = mkByteString ''''; + escapes-double = mkByteString ''\\\a\b\f\n\r\t\vcde"${"'"}${"'"}''; + escapes-single = mkByteString ''\\\a\b\f\n\r\t\vcde""${"'"}''; + line-continues-double = mkByteString ''start more''; + line-continues-single = mkByteString ''start more''; + nix-dollar = mkByteString ''${"$"}''; + no-unicode = mkByteString ''u202F''; + octal = mkByteString ''\3777\1\28\33${"$"}9m8"~\177''; + spaces = mkByteString '' foo\n bar ''; + }; + + }; + } + ]; +} diff --git a/test/output/clocks-nixos.nix b/test/output/clocks-nixos.nix new file mode 100644 index 0000000..aa3412b --- /dev/null +++ b/test/output/clocks-nixos.nix @@ -0,0 +1,23 @@ +# Generated via dconf2nix: https://github.com/nix-commmunity/dconf2nix +{ lib, ... }: + +with lib.gvariant; + +{ + programs.dconf.profiles.user.databases = [ + { + settings = { + "org/gnome/clocks" = { + world-clocks = "[{'location': <(uint32 2, <('San Francisco', 'KOAK', true, [(0.65832848982162007, -2.133408063190589)], [(0.659296885757089, -2.1366218601153339)])>)>}, {'location': <(uint32 2, <('London', 'EGWU', true, [(0.89971722940307675, -0.007272211034407213)], [(0.89884456477707964, -0.0020362232784242244)])>)>}, {'location': <(uint32 2, <('Stockholm', 'ESSB', true, [(1.0358529110586345, 0.31328660073298215)], [(1.0355620170322046, 0.31503192998497648)])>)>}]"; + }; + + "org/gnome/shell/extensions/dash-to-panel" = { + panel-element-positions = '' + {"0":[{"element":"showAppsButton","visible":false,"position":"stackedTL"},{"element":"activitiesButton","visible":false,"position":"stackedTL"},{"element":"leftBox","visible":true,"position":"stackedTL"},{"element":"taskbar","visible":true,"position":"stackedTL"},{"element":"centerBox","visible":true,"position":"stackedBR"},{"element":"rightBox","visible":true,"position":"stackedBR"},{"element":"systemMenu","visible":true,"position":"stackedBR"},{"element":"dateMenu","visible":true,"position":"stackedBR"},{"element":"desktopButton","visible":false,"position":"stackedBR"}]} + ''; + }; + + }; + } + ]; +} diff --git a/test/output/custom-nixos.nix b/test/output/custom-nixos.nix new file mode 100644 index 0000000..682e07b --- /dev/null +++ b/test/output/custom-nixos.nix @@ -0,0 +1,25 @@ +# Generated via dconf2nix: https://github.com/nix-commmunity/dconf2nix +{ lib, ... }: + +with lib.gvariant; + +{ + programs.dconf.profiles.user.databases = [ + { + settings = { + "ca/desrt/dconf-editor" = { + saved-pathbar-path = "/org/gnome/desktop/input-sources/"; + saved-view = "/org/gnome/desktop/input-sources/"; + window-height = mkInt32 709; + window-is-maximized = false; + window-width = mkInt32 785; + }; + + "ca/desrt/dconf-editor/foo" = { + services = [ "service1|wg-quick@wg0.service" "service2|wg-quick@wg1.service" ]; + }; + + }; + } + ]; +} diff --git a/test/output/dict-nixos.nix b/test/output/dict-nixos.nix new file mode 100644 index 0000000..51f4630 --- /dev/null +++ b/test/output/dict-nixos.nix @@ -0,0 +1,51 @@ +# Generated via dconf2nix: https://github.com/nix-commmunity/dconf2nix +{ lib, ... }: + +with lib.gvariant; + +{ + programs.dconf.profiles.user.databases = [ + { + settings = { + "dict" = { + alarms = [ [ + (mkDictionaryEntry "name" (mkVariant "")) + (mkDictionaryEntry "id" (mkVariant "39d68c6c283032ad5549c9bd5f5161c4")) + (mkDictionaryEntry "active" (mkVariant false)) + (mkDictionaryEntry "hour" (mkVariant (mkInt32 17))) + (mkDictionaryEntry "minute" (mkVariant (mkInt32 50))) + (mkDictionaryEntry "days" (mkVariant (mkArray "i" []))) + (mkDictionaryEntry "snooze_minutes" (mkVariant (mkInt32 10))) + (mkDictionaryEntry "ring_minutes" (mkVariant (mkInt32 5))) + ] ]; + dict = [ + (mkDictionaryEntry (mkInt32 1) "one") + (mkDictionaryEntry (mkInt32 2) "two") + (mkDictionaryEntry (mkInt32 3) "three") + ]; + dict-entry = mkDictionaryEntry (mkInt32 1) "one"; + empty-arr-dict = mkArray "{sv}" []; + empty-dict = mkTyped "a{sv}" [ + ]; + entry-arr = [ (mkDictionaryEntry (mkInt32 1) "one") (mkDictionaryEntry (mkInt32 2) "two") (mkDictionaryEntry (mkInt32 3) "three") ]; + nested = [ [ + (mkDictionaryEntry "org.gnome.Contacts.desktop" (mkVariant [ + (mkDictionaryEntry "position" (mkVariant (mkInt32 0))) + ])) + (mkDictionaryEntry "org.gnome.Maps.desktop" (mkVariant [ + (mkDictionaryEntry "position" (mkVariant (mkInt32 1))) + ])) + (mkDictionaryEntry "org.gnome.Calculator.desktop" (mkVariant [ + (mkDictionaryEntry "position" (mkVariant (mkInt32 2))) + ])) + ] ]; + timers = [ [ + (mkDictionaryEntry "duration" (mkVariant (mkInt32 300))) + (mkDictionaryEntry "name" (mkVariant "")) + ] ]; + }; + + }; + } + ]; +} diff --git a/test/output/dump-nixos.nix b/test/output/dump-nixos.nix new file mode 100644 index 0000000..1da81ea --- /dev/null +++ b/test/output/dump-nixos.nix @@ -0,0 +1,390 @@ +# Generated via dconf2nix: https://github.com/nix-commmunity/dconf2nix +{ lib, ... }: + +with lib.gvariant; + +{ + programs.dconf.profiles.user.databases = [ + { + settings = { + "org/virt-manager/virt-manager/urls" = { + isos = [ "/home/bbigras/Downloads/something {ddsa}" ]; + }; + + "org/gnome/terminal/legacy/profiles:/:b1dcc9dd-5262-4d8d-a863-c897e6d979b9" = { + foo = true; + }; + + "org/gnome/desktop/wm/keybindings" = { + close = [ "w" ]; + switch-applications = []; + switch-applications-backward = []; + switch-windows = [ "Tab" ]; + switch-windows-backward = [ "Tab" ]; + }; + + "ca/desrt/dconf-editor" = { + saved-pathbar-path = "/org/gnome/desktop/input-sources/"; + saved-view = "/org/gnome/desktop/input-sources/"; + window-height = mkInt32 709; + window-is-maximized = false; + window-width = mkInt32 785; + }; + + "org/gnome/control-center" = { + last-panel = "sound"; + }; + + "org/gnome/desktop/app-folders" = { + folder-children = [ "Utilities" "YaST" ]; + }; + + "org/gnome/desktop/app-folders/folders/Utilities" = { + apps = [ "gnome-abrt.desktop" "gnome-system-log.desktop" "gnome-system-monitor.desktop" "gucharmap.desktop" "nm-connection-editor.desktop" "org.gnome.baobab.desktop" "org.gnome.Calculator.desktop" "org.gnome.DejaDup.desktop" "org.gnome.Dictionary.desktop" "org.gnome.DiskUtility.desktop" "org.gnome.eog.desktop" "org.gnome.Evince.desktop" "org.gnome.FileRoller.desktop" "org.gnome.fonts.desktop" "org.gnome.Screenshot.desktop" "org.gnome.seahorse.Application.desktop" "org.gnome.Terminal.desktop" "org.gnome.tweaks.desktop" "org.gnome.Usage.desktop" "simple-scan.desktop" "vinagre.desktop" "yelp.desktop" ]; + categories = [ "X-GNOME-Utilities" ]; + name = "X-GNOME-Utilities.directory"; + translate = true; + }; + + "org/gnome/desktop/app-folders/folders/YaST" = { + categories = [ "X-SuSE-YaST" ]; + name = "suse-yast.directory"; + translate = true; + }; + + "org/gnome/desktop/background" = { + color-shading-type = "solid"; + picture-options = "zoom"; + picture-uri = "file:///home/gvolpe/Pictures/nixos.png"; + primary-color = "#000000000000"; + secondary-color = "#000000000000"; + }; + + "org/gnome/desktop/input-sources" = { + current = mkUint32 (mkInt32 0); + sources = [ (mkTuple [ "xkb" "us" ]) ]; + xkb-options = [ " terminate:ctrl_alt_bksp " " lv3:ralt_switch " " caps:ctrl_modifier " ]; + }; + + "org/gnome/desktop/interface" = { + clock-show-weekday = true; + document-font-name = "JetBrainsMono Nerd Font 11"; + enable-hot-corners = false; + font-name = "JetBrainsMono Nerd Font 11"; + gtk-im-module = "gtk-im-context-simple"; + gtk-theme = "Adwaita-dark"; + icon-theme = "Adwaita"; + monospace-font-name = "JetBrainsMono Nerd Font 10"; + show-battery-percentage = true; + }; + + "org/gnome/desktop/notifications" = { + application-children = [ "gnome-network-panel" "spotify" "slack" "gnome-power-panel" "org-gnome-tweaks" "chromium-browser" "telegramdesktop" "chrome-knipolnnllmklapflnccelgolnpehhpl-default" ]; + }; + + "org/gnome/desktop/notifications/application/chrome-knipolnnllmklapflnccelgolnpehhpl-default" = { + application-id = "chrome-knipolnnllmklapflnccelgolnpehhpl-Default.desktop"; + }; + + "org/gnome/desktop/notifications/application/chromium-browser" = { + application-id = "chromium-browser.desktop"; + }; + + "org/gnome/desktop/notifications/application/gnome-network-panel" = { + application-id = "gnome-network-panel.desktop"; + }; + + "org/gnome/desktop/notifications/application/gnome-power-panel" = { + application-id = "gnome-power-panel.desktop"; + }; + + "org/gnome/desktop/notifications/application/org-gnome-tweaks" = { + application-id = "org.gnome.tweaks.desktop"; + }; + + "org/gnome/desktop/notifications/application/slack" = { + application-id = "slack.desktop"; + }; + + "org/gnome/desktop/notifications/application/spotify" = { + application-id = "spotify.desktop"; + }; + + "org/gnome/desktop/notifications/application/telegramdesktop" = { + application-id = "telegramdesktop.desktop"; + }; + + "org/gnome/desktop/peripherals/mouse" = { + natural-scroll = false; + speed = mkDouble "-0.5"; + }; + + "org/gnome/desktop/peripherals/touchpad" = { + tap-to-click = false; + two-finger-scrolling-enabled = true; + }; + + "org/gnome/desktop/privacy" = { + report-technical-problems = true; + }; + + "org/gnome/desktop/screensaver" = { + picture-uri = "file:///home/gvolpe/Pictures/nixos.png"; + }; + + "org/gnome/desktop/search-providers" = { + sort-order = [ "org.gnome.Contacts.desktop" "org.gnome.Documents.desktop" "org.gnome.Nautilus.desktop" ]; + }; + + "org/gnome/desktop/session" = { + idle-delay = mkUint32 (mkInt32 0); + }; + + "org/gnome/desktop/sound" = { + allow-volume-above-100-percent = true; + event-sounds = true; + }; + + "org/gnome/desktop/wm/keybindings" = { + close = [ "w" ]; + }; + + "org/gnome/desktop/wm/preferences" = { + button-layout = "close,minimize,maximize:"; + num-workspaces = mkInt32 4; + titlebar-font = "JetBrainsMono Nerd Font Mono 11"; + workspace-names = "@as []"; + }; + + "org/gnome/eog/view" = { + background-color = "rgb(0,0,0)"; + use-background-color = true; + }; + + "org/gnome/epiphany/state" = { + is-maximized = false; + window-position = mkTuple [ (mkInt32 (-1)) (mkInt32 (-1)) ]; + window-size = mkTuple [ (mkInt32 1024) (mkInt32 768) ]; + }; + + "org/gnome/evince/default" = { + window-ratio = mkTuple [ (mkDouble "1.0081699346405228") (mkDouble "0.7121212121212122") ]; + }; + + "org/gnome/evolution-data-server" = { + migrated = true; + network-monitor-gio-name = ""; + }; + + "org/gnome/file-roller/listing" = { + list-mode = "as-folder"; + name-column-width = mkInt32 250; + show-path = false; + sort-method = "name"; + sort-type = "ascending"; + }; + + "org/gnome/file-roller/ui" = { + sidebar-width = mkInt32 200; + window-height = mkInt32 480; + window-width = mkInt32 600; + }; + + "org/gnome/gnome-screenshot" = { + border-effect = "none"; + delay = mkInt32 0; + include-border = true; + include-pointer = false; + last-save-directory = "file:///home/gvolpe/Pictures"; + }; + + "org/gnome/mutter" = { + attach-modal-dialogs = true; + dynamic-workspaces = true; + edge-tiling = true; + focus-change-on-pointer-rest = true; + workspaces-only-on-primary = true; + }; + + "org/gnome/nautilus/icon-view" = { + default-zoom-level = "small"; + }; + + "org/gnome/nautilus/preferences" = { + default-folder-viewer = "icon-view"; + search-filter-time-type = "last_modified"; + search-view = "list-view"; + }; + + "org/gnome/nautilus/window-state" = { + initial-size = mkTuple [ (mkInt32 890) (mkInt32 550) ]; + maximized = false; + sidebar-width = mkInt32 189; + }; + + "org/gnome/settings-daemon/plugins/color" = { + night-light-last-coordinates = mkTuple [ (mkDouble "43.68419928005759") (mkDouble "-79.3472") ]; + }; + + "org/gnome/settings-daemon/plugins/media-keys" = { + custom-keybindings = [ "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/" ]; + }; + + "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0" = { + binding = "t"; + command = "terminator"; + name = "terminator"; + }; + + "org/gnome/settings-daemon/plugins/power" = { + sleep-inactive-ac-type = "nothing"; + sleep-inactive-battery-type = "nothing"; + }; + + "org/gnome/settings-daemon/plugins/xsettings" = { + antialiasing = "grayscale"; + hinting = "slight"; + }; + + "org/gnome/shell" = { + command-history = [ "gnome-tweaks" ]; + disabled-extensions = [ "apps-menu@gnome-shell-extensions.gcampax.github.com" "places-menu@gnome-shell-extensions.gcampax.github.com" "window-list@gnome-shell-extensions.gcampax.github.com" "windowsNavigator@gnome-shell-extensions.gcampax.github.com" ]; + enabled-extensions = [ "horizontal-workspaces@gnome-shell-extensions.gcampax.github.com" "drive-menu@gnome-shell-extensions.gcampax.github.com" "screenshot-window-sizer@gnome-shell-extensions.gcampax.github.com" "workspace-indicator@gnome-shell-extensions.gcampax.github.com" "user-theme@gnome-shell-extensions.gcampax.github.com" "dash-to-dock@micxgx.gmail.com" "timepp@zagortenay333" "TopIcons@phocean.net" ]; + favorite-apps = [ "chromium-browser.desktop" "spotify.desktop" "slack.desktop" "telegramdesktop.desktop" "org.gnome.Nautilus.desktop" "org.gnome.tweaks.desktop" "terminator.desktop" ]; + }; + + "org/gnome/shell/extensions/dash-to-dock" = { + background-opacity = mkDouble "0.8"; + custom-theme-shrink = false; + dash-max-icon-size = mkInt32 48; + dock-fixed = false; + dock-position = "BOTTOM"; + extend-height = false; + force-straight-corner = false; + height-fraction = mkDouble "0.9"; + hot-keys = false; + icon-size-fixed = false; + intellihide-mode = "FOCUS_APPLICATION_WINDOWS"; + isolate-workspaces = true; + running-indicator-style = "DEFAULT"; + show-trash = false; + transparency-mode = "DEFAULT"; + }; + + "org/gnome/shell/extensions/desktop-icons" = { + show-home = false; + show-trash = false; + }; + + "org/gnome/shell/extensions/timepp" = { + alarms-fullscreen-monitor-pos = mkInt32 0; + alarms-sound-file-path = "file:///home/gvolpe/.nix-profile/share/gnome-shell/extensions/timepp@zagortenay333/data/sounds/beeps.ogg"; + pomodoro-fullscreen-monitor-pos = mkInt32 0; + pomodoro-sound-file-path-long-break = "file:///home/gvolpe/.nix-profile/share/gnome-shell/extensions/timepp@zagortenay333/data/sounds/beeps.ogg"; + pomodoro-sound-file-path-pomo = "file:///home/gvolpe/.nix-profile/share/gnome-shell/extensions/timepp@zagortenay333/data/sounds/beeps.ogg"; + pomodoro-sound-file-path-short-break = "file:///home/gvolpe/.nix-profile/share/gnome-shell/extensions/timepp@zagortenay333/data/sounds/beeps.ogg"; + stopwatch-fullscreen-monitor-pos = mkInt32 0; + timer-fullscreen-monitor-pos = mkInt32 0; + timer-sound-file-path = "file:///home/gvolpe/.nix-profile/share/gnome-shell/extensions/timepp@zagortenay333/data/sounds/beeps.ogg"; + }; + + "org/gnome/shell/extensions/user-theme" = { + name = ""; + }; + + "org/gnome/shell/world-clocks" = { + locations = mkArray "v" []; + }; + + "org/gnome/software" = { + check-timestamp = mkInt64 (mkInt32 1592897410); + }; + + "org/gnome/system/location" = { + enabled = false; + }; + + "org/gtk/settings/file-chooser" = { + date-format = "regular"; + location-mode = "path-bar"; + show-hidden = false; + show-size-column = true; + show-type-column = true; + sidebar-width = mkInt32 189; + sort-column = "name"; + sort-directories-first = false; + sort-order = "ascending"; + type-format = "category"; + window-position = mkTuple [ (mkInt32 345) (mkInt32 79) ]; + window-size = mkTuple [ (mkInt32 1231) (mkInt32 902) ]; + }; + + "org/gnome/Weather" = { + locations = [ (mkVariant (mkTuple [ (mkUint32 (mkInt32 2)) (mkVariant (mkTuple [ "Gdańsk" "EPGD" true [ (mkTuple [ (mkDouble "0.9491682190584854") (mkDouble "0.3223041410193837") ]) ] [ (mkTuple [ (mkDouble "0.9485864484589182") (mkDouble "0.32579479952337237") ]) ] ])) ])) (mkVariant (mkTuple [ (mkUint32 (mkInt32 2)) (mkVariant (mkTuple [ "Gdynia, Działdowo County, Warmian-Masurian Voivodeship" "" false [ (mkTuple [ (mkDouble "0.9302794944578734") (mkDouble "0.34699627038777753") ]) ] [ (mkTuple [ (mkDouble "0.938610530426954") (mkDouble "0.3574455077502486") ]) ] ])) ])) (mkVariant (mkTuple [ (mkUint32 (mkInt32 2)) (mkVariant (mkTuple [ "Gdynia, Pomeranian Voivodeship" "" false [ (mkTuple [ (mkDouble "0.9514923902475622") (mkDouble "0.3235888220312407") ]) ] [ (mkTuple [ (mkDouble "0.9485864484589182") (mkDouble "0.32579479952337237") ]) ] ])) ])) ]; + }; + + "org/gnome/shell/weather" = { + automatic-location = true; + locations = [ (mkVariant (mkTuple [ (mkUint32 (mkInt32 2)) (mkVariant (mkTuple [ "Gdańsk" "EPGD" true [ (mkTuple [ (mkDouble "0.9491682190584854") (mkDouble "0.3223041410193837") ]) ] [ (mkTuple [ (mkDouble "0.9485864484589182") (mkDouble "0.32579479952337237") ]) ] ])) ])) (mkVariant (mkTuple [ (mkUint32 (mkInt32 2)) (mkVariant (mkTuple [ "Gdynia, Działdowo County, Warmian-Masurian Voivodeship" "" false [ (mkTuple [ (mkDouble "0.9302794944578734") (mkDouble "0.34699627038777753") ]) ] [ (mkTuple [ (mkDouble "0.938610530426954") (mkDouble "0.3574455077502486") ]) ] ])) ])) (mkVariant (mkTuple [ (mkUint32 (mkInt32 2)) (mkVariant (mkTuple [ "Gdynia, Pomeranian Voivodeship" "" false [ (mkTuple [ (mkDouble "0.9514923902475622") (mkDouble "0.3235888220312407") ]) ] [ (mkTuple [ (mkDouble "0.9485864484589182") (mkDouble "0.32579479952337237") ]) ] ])) ])) ]; + }; + + "system/locale" = { + region = "en_US.UTF-8"; + }; + + "issue28/desktop/ibus/panel/emoji" = { + favorites = [ "–" "→" "↑" "↓" "™" "­" "°" " " " " "«" "℃" ]; + }; + + "issue28/org/gnome/desktop/input-sources" = { + mru-sources = [ (mkTuple [ "xkb" "us+altgr-intl" ]) (mkTuple [ "ibus" "mozc-jp" ]) ]; + nxkb-options = [ "terminate:ctrl_alt_bksp" ]; + sources = [ (mkTuple [ "xkb" "us+altgr-intl" ]) (mkTuple [ "ibus" "mozc-jp" ]) ]; + }; + + "issue28/org/gnome/clocks" = { + world-clocks = [ [ + (mkDictionaryEntry "location" (mkVariant (mkTuple [ (mkUint32 (mkInt32 2)) (mkVariant (mkTuple [ "Houston" "KHOU" false [ (mkTuple [ (mkDouble "0.5172719570598194") (mkDouble "-1.6629933445314968") ]) ] [ (mkTuple [ (mkDouble "0.5172719570598194") (mkDouble "-1.6629933445314968") ]) ] ])) ]))) + ] [ + (mkDictionaryEntry "location" (mkVariant (mkTuple [ (mkUint32 (mkInt32 2)) (mkVariant (mkTuple [ "Singapore" "WSAP" true [ (mkTuple [ (mkDouble "2.3852838928353343e-2") (mkDouble "1.8136879868485383") ]) ] [ (mkTuple [ (mkDouble "2.2568084612667797e-2") (mkDouble "1.8126262332513803") ]) ] ])) ]))) + ] ]; + }; + + "org/gnome/shell/extensions/arcmenu" = { + hot-corners = "Disabled"; + recently-installed-apps = [ "RollerCoaster Tycoon 3 Platinum!.desktop" "RollerCoaster Tycoon Deluxe.desktop" "RollerCoaster Tycoon 2 Triple Thrill Pack.desktop" "American Truck Simulator.desktop" "Halo The Master Chief Collection.desktop" "Bejeweled 3.desktop" ]; + }; + + "org/gnome/evolution-data-server/calendar/list-of-equal" = { + reminders-snoozed = [ "=" ]; + }; + + "org/gnome/Tetravex" = { + saved-game = mkNothing "(yyda(yyyyyyyy)ua(yyyyu))"; + }; + + "org/gnome/evince" = { + document-directory = mkNothing "s"; + pictures-directory = mkNothing "s"; + }; + + "org/gnome/easytag" = { + default-path = mkByteString ''/home/alice/Music''; + }; + + " test / *#@= All the special characters " = { + foo_bar = "test"; + }; + + "com/github/wwmm/easyeffects/streamoutputs/compressor#0" = { + sidechain-input-device = "alsa_input.platform-snd_aloop.0.analog-stereo"; + }; + + "org/gnome/gnome-commander/preferences/general" = { + file-list-tabs = [ (mkTuple [ "file:///home/alice" (mkUchar (mkInt32 0)) (mkUchar (mkInt32 1)) false false ]) (mkTuple [ "file:///home/alice" (mkInt32 1) (mkInt32 1) false false ]) ]; + }; + + }; + } + ]; +} diff --git a/test/output/emoji-nixos.nix b/test/output/emoji-nixos.nix new file mode 100644 index 0000000..7417500 --- /dev/null +++ b/test/output/emoji-nixos.nix @@ -0,0 +1,19 @@ +# Generated via dconf2nix: https://github.com/nix-commmunity/dconf2nix +{ lib, ... }: + +with lib.gvariant; + +{ + programs.dconf.profiles.user.databases = [ + { + settings = { + "org/gnome/Characters" = { + emoji-in-double-quotes = [ "🔥" ]; + recent-characters = [ "💡" ]; + some-other-character = [ "🤓" ]; + }; + + }; + } + ]; +} diff --git a/test/output/headers-nixos.nix b/test/output/headers-nixos.nix new file mode 100644 index 0000000..ece9fef --- /dev/null +++ b/test/output/headers-nixos.nix @@ -0,0 +1,33 @@ +# Generated via dconf2nix: https://github.com/nix-commmunity/dconf2nix +{ lib, ... }: + +with lib.gvariant; + +{ + programs.dconf.profiles.user.databases = [ + { + settings = { + "gnome/desktop/interface" = { + cursor-theme = "Yaru"; + }; + + "gnome/desktop/theme" = { + name = "Yaru"; + }; + + "uk/co/ibboard/cawbird" = { + round-avatars = false; + startup-accounts = [ "account_name" ]; + window-geometry = [ + (mkDictionaryEntry "account_name" (mkTuple [ (mkInt32 30) (mkInt32 26) (mkInt32 694) (mkInt32 1182) ])) + ]; + }; + + "org/gnome/shell/extensions/bluetooth_battery_indicator" = { + hide-indicator = true; + }; + + }; + } + ]; +} diff --git a/test/output/indexer-nixos.nix b/test/output/indexer-nixos.nix new file mode 100644 index 0000000..9577a51 --- /dev/null +++ b/test/output/indexer-nixos.nix @@ -0,0 +1,17 @@ +# Generated via dconf2nix: https://github.com/nix-commmunity/dconf2nix +{ lib, ... }: + +with lib.gvariant; + +{ + programs.dconf.profiles.user.databases = [ + { + settings = { + "org/freedesktop/tracker/miner/files" = { + index-recursive-directories = [ "&DESKTOP" "&DOCUMENTS" "&MUSIC" "&PICTURES" "&VIDEOS" "&DOWNLOAD" "/data" ]; + }; + + }; + } + ]; +} diff --git a/test/output/json-nixos.nix b/test/output/json-nixos.nix new file mode 100644 index 0000000..d1fe782 --- /dev/null +++ b/test/output/json-nixos.nix @@ -0,0 +1,29 @@ +# Generated via dconf2nix: https://github.com/nix-commmunity/dconf2nix +{ lib, ... }: + +with lib.gvariant; + +{ + programs.dconf.profiles.user.databases = [ + { + settings = { + "org/gnome/shell/extensions/sound-output-device-chooser" = { + hide-on-single-device = true; + ports-settings = '' + {"version":2,"ports":[]} + ''; + }; + + "org/gnome/shell/extensions/list-of-json" = { + devices = [ '' + {"_model":{},"name":"FakeName","isConnected":false,"isPaired":true,"mac":"00:16:00:29:00:83","isDefault":false,"active":true,"icon":"audio-headphones-symbolic"} + '' ]; + foo = [ '' + {"_model":{}} + '' ]; + }; + + }; + } + ]; +} diff --git a/test/output/keybindings-nixos.nix b/test/output/keybindings-nixos.nix new file mode 100644 index 0000000..bcc5a85 --- /dev/null +++ b/test/output/keybindings-nixos.nix @@ -0,0 +1,19 @@ +# Generated via dconf2nix: https://github.com/nix-commmunity/dconf2nix +{ lib, ... }: + +with lib.gvariant; + +{ + programs.dconf.profiles.user.databases = [ + { + settings = { + "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom2" = { + binding = "space"; + command = "gnome-terminal -e \"vim --cmd startinsert\""; + name = "Launch scratchpad"; + }; + + }; + } + ]; +} diff --git a/test/output/nested-nixos.nix b/test/output/nested-nixos.nix new file mode 100644 index 0000000..1eecd91 --- /dev/null +++ b/test/output/nested-nixos.nix @@ -0,0 +1,23 @@ +# Generated via dconf2nix: https://github.com/nix-commmunity/dconf2nix +{ lib, ... }: + +with lib.gvariant; + +{ + programs.dconf.profiles.user.databases = [ + { + settings = { + "org/gnome/desktop/peripherals/mouse" = { + natural-scroll = false; + speed = mkDouble "-0.5"; + }; + + "org/gnome/desktop/peripherals/touchpad" = { + tap-to-click = false; + two-finger-scrolling-enabled = true; + }; + + }; + } + ]; +} diff --git a/test/output/numbers-nixos.nix b/test/output/numbers-nixos.nix new file mode 100644 index 0000000..621ec4e --- /dev/null +++ b/test/output/numbers-nixos.nix @@ -0,0 +1,51 @@ +# Generated via dconf2nix: https://github.com/nix-commmunity/dconf2nix +{ lib, ... }: + +with lib.gvariant; + +{ + programs.dconf.profiles.user.databases = [ + { + settings = { + "floats" = { + avogadro = mkDouble "6.283185307179586"; + basic = mkDouble "1.2345678901234567e9"; + negative = mkDouble "-72.02"; + positive = mkDouble "72.02"; + sci = mkDouble "6.022e23"; + sci-exp-neg = mkDouble "7.51e-9"; + sci-neg = mkDouble "-72020.0"; + sci-neg-exp-neg = mkDouble "-9.11e-17"; + zero = mkDouble "0.0"; + zero-neg = mkDouble "-0.0"; + zero-pos = mkDouble "0.0"; + }; + + "int" = { + dec = mkInt32 1234567890; + dec-neg = mkInt32 (-987654321); + dec-one = mkInt32 1; + dec-pos = mkInt32 987654321; + dec-zero = mkInt32 0; + hex = mkInt32 1311768467463790320; + hex-dec-only = mkInt32 78187493520; + hex-neg = mkInt32 (-4660); + hex-neg-e = mkInt32 (-30); + hex-neg-e2 = mkInt32 (-482); + hex-pos = mkInt32 4660; + hex-zero = mkInt32 0; + hex-zero-neg = mkInt32 0; + hex-zero-pos = mkInt32 0; + oct = mkInt32 2739128; + oct-byte-max = mkInt32 255; + oct-neg = mkInt32 (-255); + oct-pos = mkInt32 255; + oct-zero = mkInt32 0; + oct-zero-neg = mkInt32 0; + oct-zero-pos = mkInt32 0; + }; + + }; + } + ]; +} diff --git a/test/output/scientific-notation-nixos.nix b/test/output/scientific-notation-nixos.nix new file mode 100644 index 0000000..4915934 --- /dev/null +++ b/test/output/scientific-notation-nixos.nix @@ -0,0 +1,19 @@ +# Generated via dconf2nix: https://github.com/nix-commmunity/dconf2nix +{ lib, ... }: + +with lib.gvariant; + +{ + programs.dconf.profiles.user.databases = [ + { + settings = { + "com/github/wwmm/easyeffects/streamoutputs/bassenhancer" = { + amount = mkDouble "-6.938893903907228e-16"; + blend = mkDouble "0.0"; + listen = true; + }; + + }; + } + ]; +} diff --git a/test/output/strings-nixos.nix b/test/output/strings-nixos.nix new file mode 100644 index 0000000..7ab808b --- /dev/null +++ b/test/output/strings-nixos.nix @@ -0,0 +1,39 @@ +# Generated via dconf2nix: https://github.com/nix-commmunity/dconf2nix +{ lib, ... }: + +with lib.gvariant; + +{ + programs.dconf.profiles.user.databases = [ + { + settings = { + "strings" = { + escapes-double = "\\ \n cde\"''"; + escapes-single = "\\ \n cde\"\"'"; + spaces = " foo\n bar "; + }; + + "org/gnome/evince" = { + document-directory = "@ms 'file:///home/user/Downloads'"; + }; + + "empty/double/quotes" = { + foo-bar = ""; + }; + + "empty/single/quotes" = { + foo-bar = ""; + }; + + "org/gnome/shell/extensions/arcmenu" = { + arc-menu-placement = "DTP"; + available-placement = [ false true false ]; + escaped-double-quotes = "sh -c 'notify-send \"\$(date)\"'"; + simple-command = "sh -c notify-send \$(date)"; + single-quotes-command = "sh -c \"notify-send \$(date)\""; + }; + + }; + } + ]; +} diff --git a/test/output/tuples-nixos.nix b/test/output/tuples-nixos.nix new file mode 100644 index 0000000..b94b6dd --- /dev/null +++ b/test/output/tuples-nixos.nix @@ -0,0 +1,24 @@ +# Generated via dconf2nix: https://github.com/nix-commmunity/dconf2nix +{ lib, ... }: + +with lib.gvariant; + +{ + programs.dconf.profiles.user.databases = [ + { + settings = { + "org/gnome/tuples" = { + n1 = mkTuple [ false (mkTuple [ "xkb" "us" ]) "nested" ]; + n2 = mkTuple [ "hi" (mkTuple [ true "us" (mkTuple [ (mkInt32 (-787)) "lvl" ]) ]) "super-nested" ]; + t0 = mkTuple []; + t1 = mkTuple [ (mkInt32 5) ]; + t1-sp = mkTuple [ (mkInt32 5) ]; + t2 = mkTuple [ true "woman" ]; + t3 = mkTuple [ false "man" (mkInt32 (-2)) ]; + t4 = mkTuple [ "hello" (mkInt32 22) "world" true ]; + }; + + }; + } + ]; +} diff --git a/test/output/typed-nixos.nix b/test/output/typed-nixos.nix new file mode 100644 index 0000000..b1e8877 --- /dev/null +++ b/test/output/typed-nixos.nix @@ -0,0 +1,37 @@ +# Generated via dconf2nix: https://github.com/nix-commmunity/dconf2nix +{ lib, ... }: + +with lib.gvariant; + +{ + programs.dconf.profiles.user.databases = [ + { + settings = { + "typed" = { + at-u = mkTyped "u" (mkInt32 5); + boolean = mkCast "boolean" true; + byte = mkUchar (mkInt32 23); + double = mkCast "double" (mkDouble "28.2"); + doubletime = mkUint32 (mkUint32 (mkInt32 7)); + empty-arr = mkArray "(dd)" []; + empty-array-dict = mkArray "{sv}" []; + empty-dict = mkTyped "a{sv}" [ + ]; + handle = mkCast "handle" (mkInt32 22); + int16 = mkInt16 (mkInt32 30); + int32 = mkCast "int32" (mkInt32 26); + int64 = mkInt64 (mkInt32 27); + just-empty-str = mkTyped "ms" ""; + just-str = mkTyped "ms" "hello"; + objectpath = mkObjectpath "/org/gnome/xyz"; + string = mkCast "string" "foo"; + uint16 = mkUint16 (mkInt32 25); + uint32 = mkUint32 (mkInt32 24); + uint64 = mkUint64 (mkInt32 21); + var-empty-arr = mkVariant (mkArray "i" []); + }; + + }; + } + ]; +} diff --git a/test/output/unicode-nixos.nix b/test/output/unicode-nixos.nix new file mode 100644 index 0000000..3d4ba75 --- /dev/null +++ b/test/output/unicode-nixos.nix @@ -0,0 +1,18 @@ +# Generated via dconf2nix: https://github.com/nix-commmunity/dconf2nix +{ lib, ... }: + +with lib.gvariant; + +{ + programs.dconf.profiles.user.databases = [ + { + settings = { + "org/gnome/font-manager" = { + compare-preview-text = "🤣"; + preview-text = "příliš žluťoučký kůň úpěl ďábelské ódy\nprilis zlutoucky kun upel dabelske ody\n◌̍◌̍ff̍ ̍čěů\n◌̎\n"; + }; + + }; + } + ]; +} diff --git a/test/output/variant-nixos.nix b/test/output/variant-nixos.nix new file mode 100644 index 0000000..824f3af --- /dev/null +++ b/test/output/variant-nixos.nix @@ -0,0 +1,26 @@ +# Generated via dconf2nix: https://github.com/nix-commmunity/dconf2nix +{ lib, ... }: + +with lib.gvariant; + +{ + programs.dconf.profiles.user.databases = [ + { + settings = { + "foo" = { + array = mkVariant [ (mkInt32 1) (mkInt32 2) (mkInt32 3) ]; + false = mkVariant false; + in-array = [ (mkVariant (mkInt32 5)) (mkVariant (mkInt32 6)) ]; + int32 = mkVariant (mkInt32 0); + string = mkVariant "#polari"; + true = mkVariant true; + tuple = mkVariant (mkTuple [ (mkUint32 (mkInt32 2)) "ABC" ]); + typed = mkVariant (mkArray "i" []); + uint32 = mkVariant (mkUint32 (mkInt32 2)); + variant = mkVariant (mkVariant (mkInt32 7)); + }; + + }; + } + ]; +}