summaryrefslogtreecommitdiff
path: root/modules/devenv
diff options
context:
space:
mode:
Diffstat (limited to 'modules/devenv')
-rw-r--r--modules/devenv/default.nix6
-rw-r--r--modules/devenv/dotfiles.nix84
-rw-r--r--modules/devenv/integrations/default.nix5
-rw-r--r--modules/devenv/integrations/emacs.nix38
-rw-r--r--modules/devenv/integrations/gitignore.nix65
-rw-r--r--modules/devenv/languages/default.nix5
-rw-r--r--modules/devenv/languages/latex.nix147
7 files changed, 194 insertions, 156 deletions
diff --git a/modules/devenv/default.nix b/modules/devenv/default.nix
index 8aedcf6..42d9593 100644
--- a/modules/devenv/default.nix
+++ b/modules/devenv/default.nix
@@ -1,3 +1,7 @@
{
- imports = [./dotfiles.nix ./integrations ./languages];
+ imports = [
+ ./dotfiles.nix
+ ./integrations
+ ./languages
+ ];
}
diff --git a/modules/devenv/dotfiles.nix b/modules/devenv/dotfiles.nix
index ca3108c..994b50f 100644
--- a/modules/devenv/dotfiles.nix
+++ b/modules/devenv/dotfiles.nix
@@ -2,24 +2,25 @@
config,
lib,
...
-}: let
+}:
+let
cfg = config.dotfiles;
- dotfilesToIgnore = lib.attrNames (lib.filterAttrs (_: {gitignore, ...}: gitignore) cfg);
-in {
+ dotfilesToIgnore = lib.attrNames (lib.filterAttrs (_: { gitignore, ... }: gitignore) cfg);
+in
+{
options.dotfiles = lib.mkOption {
- type = with lib.types;
- # this cannot be a lazyAttrsOf, see https://nixos.org/manual/nixos/unstable/#sec-option-types-composed
+ type =
+ with lib.types;
+ # this cannot be a lazyAttrsOf, see https://nixos.org/manual/nixos/unstable/#sec-option-types-composed
attrsOf (submodule {
options = {
- gitignore =
- lib.mkEnableOption ""
- // {
- description = ''
- Whether git should ignore this dotfile, typically if it is
- generated to contain absolute paths and is specific to this
- project (and may not be ignored system-wide by the user).
- '';
- };
+ gitignore = lib.mkEnableOption "" // {
+ description = ''
+ Whether git should ignore this dotfile, typically if it is
+ generated to contain absolute paths and is specific to this
+ project (and may not be ignored system-wide by the user).
+ '';
+ };
text = lib.mkOption {
type = lib.types.lines;
default = "";
@@ -29,31 +30,32 @@ in {
});
};
- config.enterShell =
- lib.mkIf (cfg != {})
- (''
- echo Installing dotfiles...
- ''
- + lib.concatStringsSep "\n" (lib.mapAttrsToList (
- name: {
- text,
- gitignore,
- }:
- # this has to be done here to avoid infinite recursion
- let
- content =
- text
- + lib.optionalString (name == ".gitignore" && dotfilesToIgnore != []) ''
- ### dotfiles
- ${lib.concatStringsSep "\n" dotfilesToIgnore}
- '';
- in ''
- ${
- if gitignore
- then "ln --symbolic --force"
- else "install --mode=644"
- } "${builtins.toFile name content}" "${name}"
- ''
- )
- cfg));
+ config.enterShell = lib.mkIf (cfg != { }) (
+ ''
+ echo Installing dotfiles...
+ ''
+ + lib.concatStringsSep "\n" (
+ lib.mapAttrsToList (
+ name:
+ {
+ text,
+ gitignore,
+ }:
+ # this has to be done here to avoid infinite recursion
+ let
+ content =
+ text
+ + lib.optionalString (name == ".gitignore" && dotfilesToIgnore != [ ]) ''
+ ### dotfiles
+ ${lib.concatStringsSep "\n" dotfilesToIgnore}
+ '';
+ in
+ ''
+ ${
+ if gitignore then "ln --symbolic --force" else "install --mode=644"
+ } "${builtins.toFile name content}" "${name}"
+ ''
+ ) cfg
+ )
+ );
}
diff --git a/modules/devenv/integrations/default.nix b/modules/devenv/integrations/default.nix
index 7fa74bd..79c104d 100644
--- a/modules/devenv/integrations/default.nix
+++ b/modules/devenv/integrations/default.nix
@@ -1,3 +1,6 @@
{
- imports = [./emacs.nix ./gitignore.nix];
+ imports = [
+ ./emacs.nix
+ ./gitignore.nix
+ ];
}
diff --git a/modules/devenv/integrations/emacs.nix b/modules/devenv/integrations/emacs.nix
index 347132f..ed20734 100644
--- a/modules/devenv/integrations/emacs.nix
+++ b/modules/devenv/integrations/emacs.nix
@@ -2,33 +2,31 @@
config,
lib,
...
-}: let
+}:
+let
cfg = config.emacs;
- attrs2alist = value:
- if lib.isAttrs value
- then "(${lib.concatStringsSep "\n" (lib.mapAttrsToList (name: value: "(${name} . ${attrs2alist value})") value)})"
+ attrs2alist =
+ value:
+ if lib.isAttrs value then
+ "(${
+ lib.concatStringsSep "\n" (
+ lib.mapAttrsToList (name: value: "(${name} . ${attrs2alist value})") value
+ )
+ })"
else
(
- if lib.isList value
- then "(${lib.concatStringsSep " " value})"
+ if lib.isList value then
+ "(${lib.concatStringsSep " " value})"
else
- (
- if lib.isBool value
- then
- (
- if value
- then "t"
- else "nil"
- )
- else builtins.toString value
- )
+ (if lib.isBool value then (if value then "t" else "nil") else builtins.toString value)
);
-in {
+in
+{
options.emacs = {
enable = lib.mkEnableOption "emacs integration";
dirLocals = lib.mkOption {
type = with lib.types; attrsOf (attrsOf anything);
- default = {};
+ default = { };
example =
# the first example from https://www.gnu.org/software/emacs/manual/html_node/emacs/Directory-Variables.html
{
@@ -46,7 +44,5 @@ in {
};
};
- config.dotfiles.".dir-locals.el".text =
- lib.mkIf (cfg.dirLocals != {})
- (attrs2alist cfg.dirLocals);
+ config.dotfiles.".dir-locals.el".text = lib.mkIf (cfg.dirLocals != { }) (attrs2alist cfg.dirLocals);
}
diff --git a/modules/devenv/integrations/gitignore.nix b/modules/devenv/integrations/gitignore.nix
index bb216a7..3db8dfe 100644
--- a/modules/devenv/integrations/gitignore.nix
+++ b/modules/devenv/integrations/gitignore.nix
@@ -4,41 +4,56 @@
pkgs,
inputs,
...
-}: let
+}:
+let
cfg = config.gitignore;
ignoreDevenv = cfg.devenv.enable or false;
- templates = lib.attrNames (lib.filterAttrs (name: value: (value.enable or false) && name != "devenv") cfg);
+ templates = lib.attrNames (
+ lib.filterAttrs (name: value: (value.enable or false) && name != "devenv") cfg
+ );
toUncomment = builtins.concatLists (lib.collect lib.isList cfg);
-in {
+in
+{
options.gitignore = lib.mkOption {
- type = with lib.types; (submodule {
- freeformType = with lib.types;
- attrsOf (submodule {
- options = {
- enable = lib.mkEnableOption "";
- uncomment = lib.mkOption {
- type = with lib.types; listOf str;
- default = [];
- description = "Lines that should be uncommented and thus enabled in the template file.";
+ type =
+ with lib.types;
+ (submodule {
+ freeformType =
+ with lib.types;
+ attrsOf (submodule {
+ options = {
+ enable = lib.mkEnableOption "";
+ uncomment = lib.mkOption {
+ type = with lib.types; listOf str;
+ default = [ ];
+ description = "Lines that should be uncommented and thus enabled in the template file.";
+ };
};
- };
- });
- options.extra = lib.mkOption {
- type = lib.types.lines;
- default = "";
- example = ''
- *.my-file-extension
- '';
- };
- });
- default = {extra = "";};
+ });
+ options.extra = lib.mkOption {
+ type = lib.types.lines;
+ default = "";
+ example = ''
+ *.my-file-extension
+ '';
+ };
+ });
+ default = {
+ extra = "";
+ };
};
config = {
- dotfiles.".gitignore" = lib.mkIf (templates != {} || cfg.extra != "") {
+ dotfiles.".gitignore" = lib.mkIf (templates != { } || cfg.extra != "") {
gitignore = lib.mkDefault false;
text =
- lib.optionalString (templates != []) (builtins.readFile ((pkgs.extend inputs.my-nixpkgs.overlays.personal).personal.static.gitignore.override {inherit templates toUncomment;}))
+ lib.optionalString (templates != [ ]) (
+ builtins.readFile (
+ (pkgs.extend inputs.my-nixpkgs.overlays.personal).personal.static.gitignore.override {
+ inherit templates toUncomment;
+ }
+ )
+ )
+ lib.optionalString ignoreDevenv ''
### devenv
.devenv/
diff --git a/modules/devenv/languages/default.nix b/modules/devenv/languages/default.nix
index a97402c..c415dfc 100644
--- a/modules/devenv/languages/default.nix
+++ b/modules/devenv/languages/default.nix
@@ -1,3 +1,6 @@
{
- imports = [./latex.nix ./nix.nix];
+ imports = [
+ ./latex.nix
+ ./nix.nix
+ ];
}
diff --git a/modules/devenv/languages/latex.nix b/modules/devenv/languages/latex.nix
index 6e23d4b..40dcc7a 100644
--- a/modules/devenv/languages/latex.nix
+++ b/modules/devenv/languages/latex.nix
@@ -4,7 +4,8 @@
pkgs,
devenv,
...
-}: let
+}:
+let
cfg = config.languages.texlive;
pdfModes = {
"pdflatex" = "1";
@@ -17,21 +18,14 @@
"latex" = "1";
"lualatex" = "2";
};
- latexmkrc = with cfg.latexmk; let
- pdfMode = with output.pdf;
- if enable
- then pdfModes."${mode}"
- else "0";
- dviMode = with output.dvi;
- if enable
- then dviModes."${mode}"
- else "0";
- psMode =
- if output.ps.enable
- then "1"
- else "0";
- in
- lib.optionalString (extraFlags != []) ''
+ latexmkrc =
+ with cfg.latexmk;
+ let
+ pdfMode = with output.pdf; if enable then pdfModes."${mode}" else "0";
+ dviMode = with output.dvi; if enable then dviModes."${mode}" else "0";
+ psMode = if output.ps.enable then "1" else "0";
+ in
+ lib.optionalString (extraFlags != [ ]) ''
set_tex_cmds('${lib.concatStringsSep " " extraFlags}');
''
+ ''
@@ -47,8 +41,9 @@
packages = cfg.packages cfg.base;
packagesRequireShellEscape = packages ? minted;
texlive = cfg.base.combine packages;
-in {
- disabledModules = [(devenv.modules + "/languages/texlive.nix")];
+in
+{
+ disabledModules = [ (devenv.modules + "/languages/texlive.nix") ];
options.languages.texlive = {
enable = lib.mkEnableOption "TeX Live";
@@ -57,13 +52,16 @@ in {
description = "TeX Live package set to use";
};
packages = lib.mkOption {
- type = with lib.types;
- functionTo (attrsOf (submodule {
- options.pkgs = lib.mkOption {
- type = listOf (either package (attrsOf anything));
- };
- }));
- default = tl: {inherit (tl) scheme-medium;};
+ type =
+ with lib.types;
+ functionTo (
+ attrsOf (submodule {
+ options.pkgs = lib.mkOption {
+ type = listOf (either package (attrsOf anything));
+ };
+ })
+ );
+ default = tl: { inherit (tl) scheme-medium; };
description = "Packages available to TeX Live.";
};
@@ -71,27 +69,40 @@ in {
enable = lib.mkEnableOption "latexmk";
cleanExt = lib.mkOption {
type = with lib.types; listOf str;
- default = ["fdb_latexmk" "nav" "prv_%R.fmt" "prv_%R.log" "prv/*/*" "prv/*" "prv" "-SAVE-ERROR" "snm" "vrb"];
+ default = [
+ "fdb_latexmk"
+ "nav"
+ "prv_%R.fmt"
+ "prv_%R.log"
+ "prv/*/*"
+ "prv/*"
+ "prv"
+ "-SAVE-ERROR"
+ "snm"
+ "vrb"
+ ];
};
cleanFullExt = lib.mkOption {
type = with lib.types; listOf str;
- default = ["bbl"];
+ default = [ "bbl" ];
};
shellEscape.enable = lib.mkEnableOption "shell escaping";
extraFlags = lib.mkOption {
type = with lib.types; listOf str;
- default = [];
- example = ["--interaction=nonstopmode"];
+ default = [ ];
+ example = [ "--interaction=nonstopmode" ];
};
- output = let
- mkOutputOptions = formats:
- lib.mapAttrs (format: extra:
- lib.recursiveUpdate {
- enable = lib.mkEnableOption "${format} output";
- }
- extra)
- formats;
- in
+ output =
+ let
+ mkOutputOptions =
+ formats:
+ lib.mapAttrs (
+ format: extra:
+ lib.recursiveUpdate {
+ enable = lib.mkEnableOption "${format} output";
+ } extra
+ ) formats;
+ in
mkOutputOptions {
pdf = {
enable.default = true;
@@ -108,7 +119,7 @@ in {
description = "How to generate the dvi file.";
};
};
- ps = {};
+ ps = { };
};
extraConfig = lib.mkOption {
type = lib.types.lines;
@@ -118,35 +129,39 @@ in {
};
};
- config = lib.mkIf cfg.enable (lib.mkMerge [
- {
- packages = [texlive];
- gitignore = {
- TeX.enable = true;
- extra = ''
- *-SAVE-ERROR
- '';
- };
- }
- (lib.mkIf cfg.latexmk.enable {
- languages.texlive = {
- packages = tl: {inherit (tl) latexmk;};
- latexmk = {
- shellEscape.enable = lib.mkDefault packagesRequireShellEscape;
- extraFlags = lib.optional cfg.latexmk.shellEscape.enable "-shell-escape";
+ config = lib.mkIf cfg.enable (
+ lib.mkMerge [
+ {
+ packages = [ texlive ];
+ gitignore = {
+ TeX.enable = true;
+ extra = ''
+ *-SAVE-ERROR
+ '';
+ };
+ }
+ (lib.mkIf cfg.latexmk.enable {
+ languages.texlive = {
+ packages = tl: { inherit (tl) latexmk; };
+ latexmk = {
+ shellEscape.enable = lib.mkDefault packagesRequireShellEscape;
+ extraFlags = lib.optional cfg.latexmk.shellEscape.enable "-shell-escape";
+ };
};
- };
- scripts.latexmk.exec = ''
- ${texlive}/bin/latexmk -r ${config.devenv.root}/.latexmkrc $@
- '';
+ scripts.latexmk.exec = ''
+ ${texlive}/bin/latexmk -r ${config.devenv.root}/.latexmkrc $@
+ '';
- gitignore.LaTeX.uncomment = with cfg.latexmk.output; lib.optional pdf.enable "*.pdf" ++ lib.optional dvi.enable "*.dvi" ++ lib.optional ps.enable "*.ps";
+ gitignore.LaTeX.uncomment =
+ with cfg.latexmk.output;
+ lib.optional pdf.enable "*.pdf" ++ lib.optional dvi.enable "*.dvi" ++ lib.optional ps.enable "*.ps";
- dotfiles.".latexmkrc" = {
- gitignore = lib.mkDefault false;
- text = latexmkrc;
- };
- })
- ]);
+ dotfiles.".latexmkrc" = {
+ gitignore = lib.mkDefault false;
+ text = latexmkrc;
+ };
+ })
+ ]
+ );
}