feat(wrapperModules.television): init#528
Conversation
BirdeeHub
left a comment
There was a problem hiding this comment.
Some improvements about the types of paths things can accept and some convenience things, but it looks good!
| description = "Television configuration options."; | ||
| }; | ||
| channels = lib.mkOption { | ||
| type = types.lazyAttrsOf (types.either types.path tomlFmtType); |
There was a problem hiding this comment.
| type = types.lazyAttrsOf (types.either types.path tomlFmtType); | |
| type = types.lazyAttrsOf (types.either wlib.types.stringable tomlFmtType); |
| ''; | ||
| }; | ||
| themes = lib.mkOption { | ||
| type = types.lazyAttrsOf (types.either types.path tomlFmtType); |
There was a problem hiding this comment.
| type = types.lazyAttrsOf (types.either types.path tomlFmtType); | |
| type = types.lazyAttrsOf (types.either wlib.types.stringable tomlFmtType); |
| output = lib.mkOverride 0 config.configDrvOutput; | ||
| ${if isPathLike v then null else "content"} = builtins.toJSON v; | ||
| "builder" = | ||
| if isPathLike v then ''cp ${v} "$2"'' else ''${pkgs.remarshal}/bin/json2toml "$1" "$2"''; |
There was a problem hiding this comment.
| if isPathLike v then ''cp ${v} "$2"'' else ''${pkgs.remarshal}/bin/json2toml "$1" "$2"''; | |
| if isPathLike v then ''ln -s ${v} "$2"'' else ''${pkgs.remarshal}/bin/json2toml "$1" "$2"''; |
There was a problem hiding this comment.
ln -s allows them to use an impure path without needing to wlib.mkOutOfStoreSymlink (and we also adjusted the type to wlib.types.stringable to allow them to pass drvs and just a regular string in addition to a store path)
| output = lib.mkOverride 0 config.configDrvOutput; | ||
| ${if isPathLike v then null else "content"} = builtins.toJSON v; | ||
| "builder" = | ||
| if isPathLike v then ''cp ${v} "$2"'' else ''${pkgs.remarshal}/bin/json2toml "$1" "$2"''; |
There was a problem hiding this comment.
| if isPathLike v then ''cp ${v} "$2"'' else ''${pkgs.remarshal}/bin/json2toml "$1" "$2"''; | |
| if isPathLike v then ''ln-s ${v} "$2"'' else ''${pkgs.remarshal}/bin/json2toml "$1" "$2"''; |
| "--cable-dir" = lib.mkIf (config.channels != { }) config.channelsDir; | ||
| }; | ||
| constructFiles = { | ||
| generatedConfig = { |
There was a problem hiding this comment.
This is the way we have been handling toml yes.
The mapAttrs you did for the other 2 sets is somewhat more complex because you also wanted to accept paths, but also construct files if not a path.
But it looks good I think.
| ''; | ||
| }; | ||
| }; | ||
| config = { |
There was a problem hiding this comment.
| config = { | |
| config = { | |
| passthru.generatedThemesDir = "${config.wrapper.${config.configDrvOutput}}/${baseNameOf config.themesDir}"; | |
| passthru.generatedChannelsDir = "${config.wrapper.${config.configDrvOutput}}/${baseNameOf config.channelsDir}"; |
There was a problem hiding this comment.
Gives an easier way to access the non-placeholder versions of the dirs of these paths.
Of course they could also grab configFiles.<somename>.outPath to get it but like, this is nicer.
| typeName = "TOML"; | ||
| }; | ||
| isPathLike = | ||
| x: builtins.isPath x || (builtins.isString x && lib.hasPrefix "/" x) || lib.isStorePath x; |
There was a problem hiding this comment.
| x: builtins.isPath x || (builtins.isString x && lib.hasPrefix "/" x) || lib.isStorePath x; | |
| x: builtins.isPath x || (lib.isStringLike x && ! builtins.isString x) || (builtins.isString x && lib.hasPrefix "/" x) || lib.isStorePath x; |
There was a problem hiding this comment.
This honestly may be worth adding as wlib.isPathLike at some point but that would be a separate PR
Wrapper module for Television.
Not sure what is the best/recommended way to handle TOML, so I just imitated what other wrapper modules did.