Note, the pubs configuration file uses ConfigObj syntax, which is similar to the INI files syntax but with extra functionalities like nested sections. This prevents it from using Nix's INI format generator. Here is an example of pubs configuration that cannot be generated using Nix's INI format generator: [plugins] [[git]] manual=False For this reason, we opted for a stringly-typed configuration since the use of a structured `settings` option would require a custom parser.main
parent
abd221c4b3
commit
afe96e7433
@ -0,0 +1,60 @@ |
||||
{ config, lib, pkgs, ... }: |
||||
|
||||
with lib; |
||||
|
||||
let |
||||
|
||||
cfg = config.programs.pubs; |
||||
|
||||
in { |
||||
meta.maintainers = [ hm.maintainers.loicreynier ]; |
||||
|
||||
options.programs.pubs = { |
||||
enable = mkEnableOption "pubs"; |
||||
|
||||
package = mkOption { |
||||
type = types.package; |
||||
default = pkgs.pubs; |
||||
defaultText = literalExpression "pkgs.pubs"; |
||||
description = "The package to use for the pubs script."; |
||||
}; |
||||
|
||||
extraConfig = mkOption { |
||||
type = types.lines; |
||||
default = ""; |
||||
example = literalExpression '' |
||||
''' |
||||
[main] |
||||
pubsdir = ''${config.home.homeDirectory}/.pubs |
||||
docsdir = ''${config.home.homeDirectory}/.pubs/doc |
||||
doc_add = link |
||||
open_cmd = xdg-open |
||||
|
||||
[plugins] |
||||
active = git,alias |
||||
|
||||
[[alias]] |
||||
|
||||
[[[la]]] |
||||
command = list -a |
||||
description = lists papers in lexicographic order |
||||
|
||||
[[git]] |
||||
quiet = True |
||||
manual = False |
||||
force_color = False |
||||
'''''; |
||||
description = '' |
||||
Configuration using syntax written to |
||||
<filename>$HOME/.pubsrc</filename>. |
||||
''; |
||||
}; |
||||
}; |
||||
|
||||
config = mkIf cfg.enable { |
||||
home.packages = [ cfg.package ]; |
||||
|
||||
home.file.".pubsrc" = |
||||
mkIf (cfg.extraConfig != "") { text = cfg.extraConfig; }; |
||||
}; |
||||
} |
@ -0,0 +1 @@ |
||||
{ pubs-example-settings = ./pubs-example-settings.nix; } |
@ -0,0 +1,19 @@ |
||||
[main] |
||||
pubsdir = ~/.pubs |
||||
docsdir = ~/.pubs/doc |
||||
doc_add = link |
||||
open_cmd = xdg-open |
||||
|
||||
[plugins] |
||||
active = git,alias |
||||
|
||||
[[alias]] |
||||
|
||||
[[[la]]] |
||||
command = list -a |
||||
description = lists papers in lexicographic order |
||||
|
||||
[[git]] |
||||
quiet = True |
||||
manual = False |
||||
force_color = False |
@ -0,0 +1,36 @@ |
||||
{ config, lib, pkgs, ... }: |
||||
|
||||
{ |
||||
programs.pubs = { |
||||
enable = true; |
||||
|
||||
extraConfig = '' |
||||
[main] |
||||
pubsdir = ~/.pubs |
||||
docsdir = ~/.pubs/doc |
||||
doc_add = link |
||||
open_cmd = xdg-open |
||||
|
||||
[plugins] |
||||
active = git,alias |
||||
|
||||
[[alias]] |
||||
|
||||
[[[la]]] |
||||
command = list -a |
||||
description = lists papers in lexicographic order |
||||
|
||||
[[git]] |
||||
quiet = True |
||||
manual = False |
||||
force_color = False |
||||
''; |
||||
}; |
||||
|
||||
test.stubs.pubs = { }; |
||||
|
||||
nmt.script = '' |
||||
assertFileContent \ |
||||
home-files/.pubsrc ${./pubs-example-settings-expected-pubsrc} |
||||
''; |
||||
} |
Loading…
Reference in new issue