mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 11:39:46 +01:00
pubs: add module
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.
This commit is contained in:
parent
abd221c4b3
commit
afe96e7433
9 changed files with 134 additions and 0 deletions
3
.github/CODEOWNERS
vendored
3
.github/CODEOWNERS
vendored
|
@ -201,6 +201,9 @@
|
||||||
|
|
||||||
/modules/programs/powerline-go.nix @DamienCassou
|
/modules/programs/powerline-go.nix @DamienCassou
|
||||||
|
|
||||||
|
/modules/programs/pubs.nix @loicreynier
|
||||||
|
/tests/modules/programs/pubs @loicreynier
|
||||||
|
|
||||||
/modules/programs/rbw.nix @ambroisie
|
/modules/programs/rbw.nix @ambroisie
|
||||||
/tests/modules/programs/rbw @ambroisie
|
/tests/modules/programs/rbw @ambroisie
|
||||||
|
|
||||||
|
|
|
@ -83,6 +83,12 @@
|
||||||
github = "kubukoz";
|
github = "kubukoz";
|
||||||
githubId = 894884;
|
githubId = 894884;
|
||||||
};
|
};
|
||||||
|
loicreynier = {
|
||||||
|
name = "Loïc Reynier";
|
||||||
|
email = "loic@loireynier.fr";
|
||||||
|
github = "loicreynier";
|
||||||
|
githubId = 88983487;
|
||||||
|
};
|
||||||
matrss = {
|
matrss = {
|
||||||
name = "Matthias Riße";
|
name = "Matthias Riße";
|
||||||
email = "matrss@users.noreply.github.com";
|
email = "matrss@users.noreply.github.com";
|
||||||
|
|
|
@ -2449,6 +2449,13 @@ in
|
||||||
A new module is available: 'programs.just'.
|
A new module is available: 'programs.just'.
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
time = "2022-03-06T09:40:17+00:00";
|
||||||
|
message = ''
|
||||||
|
A new module is available: 'programs.pubs'.
|
||||||
|
'';
|
||||||
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,6 +130,7 @@ let
|
||||||
./programs/pidgin.nix
|
./programs/pidgin.nix
|
||||||
./programs/piston-cli.nix
|
./programs/piston-cli.nix
|
||||||
./programs/powerline-go.nix
|
./programs/powerline-go.nix
|
||||||
|
./programs/pubs.nix
|
||||||
./programs/qutebrowser.nix
|
./programs/qutebrowser.nix
|
||||||
./programs/rbw.nix
|
./programs/rbw.nix
|
||||||
./programs/readline.nix
|
./programs/readline.nix
|
||||||
|
|
60
modules/programs/pubs.nix
Normal file
60
modules/programs/pubs.nix
Normal file
|
@ -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; };
|
||||||
|
};
|
||||||
|
}
|
|
@ -86,6 +86,7 @@ import nmt {
|
||||||
./modules/programs/pandoc
|
./modules/programs/pandoc
|
||||||
./modules/programs/pet
|
./modules/programs/pet
|
||||||
./modules/programs/powerline-go
|
./modules/programs/powerline-go
|
||||||
|
./modules/programs/pubs
|
||||||
./modules/programs/qutebrowser
|
./modules/programs/qutebrowser
|
||||||
./modules/programs/readline
|
./modules/programs/readline
|
||||||
./modules/programs/sagemath
|
./modules/programs/sagemath
|
||||||
|
|
1
tests/modules/programs/pubs/default.nix
Normal file
1
tests/modules/programs/pubs/default.nix
Normal file
|
@ -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
|
36
tests/modules/programs/pubs/pubs-example-settings.nix
Normal file
36
tests/modules/programs/pubs/pubs-example-settings.nix
Normal file
|
@ -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 a new issue