Initial import
This commit is contained in:
parent
e4c63eb66a
commit
d7d02c3ce8
26 changed files with 1749 additions and 0 deletions
159
modules/programs/bash.nix
Normal file
159
modules/programs/bash.nix
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.programs.bash;
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
options = {
|
||||
programs.bash = {
|
||||
enable = mkEnableOption "GNU Bourne-Again SHell";
|
||||
|
||||
historySize = mkOption {
|
||||
type = types.int;
|
||||
default = 10000;
|
||||
description = "Number of history lines to keep in memory.";
|
||||
};
|
||||
|
||||
historyFileSize = mkOption {
|
||||
type = types.int;
|
||||
default = 100000;
|
||||
description = "Number of history lines to keep on file.";
|
||||
};
|
||||
|
||||
historyControl = mkOption {
|
||||
type = types.listOf (types.enum [
|
||||
"erasedups"
|
||||
"ignoredups"
|
||||
"ignorespace"
|
||||
]);
|
||||
default = [];
|
||||
description = "Controlling how commands are saved on the history list.";
|
||||
};
|
||||
|
||||
historyIgnore = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
description = "List of commands that should not be saved to the history list.";
|
||||
};
|
||||
|
||||
shellOptions = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [
|
||||
# Append to history file rather than replacing it.
|
||||
"histappend"
|
||||
|
||||
# check the window size after each command and, if
|
||||
# necessary, update the values of LINES and COLUMNS.
|
||||
"checkwinsize"
|
||||
|
||||
# Extended globbing.
|
||||
"extglob"
|
||||
"globstar"
|
||||
|
||||
# Warn if closing shell with running jobs.
|
||||
"checkjobs"
|
||||
];
|
||||
description = "Shell options to set.";
|
||||
};
|
||||
|
||||
shellAliases = mkOption {
|
||||
default = {};
|
||||
example = { ll = "ls -l"; ".." = "cd .."; };
|
||||
description = ''
|
||||
An attribute set that maps aliases (the top level attribute names in
|
||||
this option) to command strings or directly to build outputs. The
|
||||
aliases are added to all users' shells.
|
||||
'';
|
||||
type = types.attrs;
|
||||
};
|
||||
|
||||
enableAutojump = mkOption {
|
||||
default = false;
|
||||
type = types.bool;
|
||||
description = "Enable the autojump navigation tool.";
|
||||
};
|
||||
|
||||
profileExtra = mkOption {
|
||||
default = "";
|
||||
type = types.lines;
|
||||
description = "Extra commands that should be added to .profile.";
|
||||
};
|
||||
|
||||
initExtra = mkOption {
|
||||
default = "";
|
||||
type = types.lines;
|
||||
description = "Extra commands that should be added to .bashrc.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = (
|
||||
let
|
||||
aliasesStr = concatStringsSep "\n" (
|
||||
mapAttrsToList (k: v: "alias ${k}='${v}'") cfg.shellAliases
|
||||
);
|
||||
|
||||
shoptsStr = concatStringsSep "\n" (
|
||||
map (v: "shopt -s ${v}") cfg.shellOptions
|
||||
);
|
||||
|
||||
export = n: v: "export ${n}=\"${toString v}\"";
|
||||
exportIfNonNull = n: v: optionalString (v != null) (export n v);
|
||||
exportIfNonEmpty = n: v: optionalString (v != "") (export n v);
|
||||
|
||||
histControlStr = concatStringsSep ":" cfg.historyControl;
|
||||
histIgnoreStr = concatStringsSep ":" cfg.historyIgnore;
|
||||
|
||||
envVarsStr = concatStringsSep "\n" (
|
||||
mapAttrsToList export config.home.sessionVariables
|
||||
);
|
||||
in mkIf cfg.enable {
|
||||
home.file.".bash_profile".text = ''
|
||||
# -*- mode: sh -*-
|
||||
|
||||
# include .profile if it exists
|
||||
[[ -f ~/.profile ]] && . ~/.profile
|
||||
|
||||
# include .bashrc if it exists
|
||||
[[ -f ~/.bashrc ]] && . ~/.bashrc
|
||||
'';
|
||||
|
||||
home.file.".profile".text = ''
|
||||
# -*- mode: sh -*-
|
||||
|
||||
${envVarsStr}
|
||||
|
||||
${cfg.profileExtra}
|
||||
'';
|
||||
|
||||
home.file.".bashrc".text = ''
|
||||
# -*- mode: sh -*-
|
||||
|
||||
# Skip if not running interactively.
|
||||
[ -z "$PS1" ] && return
|
||||
|
||||
${export "HISTSIZE" cfg.historySize}
|
||||
${export "HISTFILESIZE" cfg.historyFileSize}
|
||||
${exportIfNonEmpty "HISTCONTROL" histControlStr}
|
||||
${exportIfNonEmpty "HISTIGNORE" histIgnoreStr}
|
||||
|
||||
${shoptsStr}
|
||||
|
||||
${aliasesStr}
|
||||
|
||||
${cfg.initExtra}
|
||||
|
||||
${optionalString cfg.enableAutojump
|
||||
". ${pkgs.autojump}/share/autojump/autojump.bash"}
|
||||
'';
|
||||
|
||||
home.packages =
|
||||
optional (cfg.enableAutojump) pkgs.autojump;
|
||||
}
|
||||
);
|
||||
}
|
||||
28
modules/programs/beets.nix
Normal file
28
modules/programs/beets.nix
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.programs.beets;
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
options = {
|
||||
programs.beets = {
|
||||
settings = mkOption {
|
||||
type = types.attrs;
|
||||
default = {};
|
||||
description = "Configuration written to ~/.config/beets/config.yaml";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf (cfg.settings != {}) {
|
||||
home.packages = [ pkgs.beets ];
|
||||
|
||||
home.file.".config/beets/config.yaml".text =
|
||||
builtins.toJSON config.programs.beets.settings;
|
||||
};
|
||||
}
|
||||
39
modules/programs/eclipse.nix
Normal file
39
modules/programs/eclipse.nix
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.programs.eclipse;
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
options = {
|
||||
programs.eclipse = {
|
||||
enable = mkEnableOption "Eclipse";
|
||||
|
||||
jvmArgs = mkOption {
|
||||
type = types.listOf types.str;
|
||||
default = [];
|
||||
description = "JVM arguments to use for the Eclipse process.";
|
||||
};
|
||||
|
||||
plugins = mkOption {
|
||||
type = types.listOf types.package;
|
||||
default = [];
|
||||
description = "Plugins that should be added to Eclipse.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [
|
||||
(pkgs.eclipses.eclipseWithPlugins {
|
||||
eclipse = pkgs.eclipses.eclipse-platform;
|
||||
jvmArgs = cfg.jvmArgs;
|
||||
plugins = cfg.plugins;
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
||||
29
modules/programs/emacs.nix
Normal file
29
modules/programs/emacs.nix
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.programs.emacs;
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
options = {
|
||||
programs.emacs = {
|
||||
enable = mkEnableOption "Emacs";
|
||||
|
||||
extraPackages = mkOption {
|
||||
default = self: [];
|
||||
example = literalExample ''
|
||||
epkgs: [ epkgs.emms epkgs.magit ]
|
||||
'';
|
||||
description = "Extra packages available to Emacs.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [ (pkgs.emacsWithPackages cfg.extraPackages) ];
|
||||
};
|
||||
}
|
||||
102
modules/programs/git.nix
Normal file
102
modules/programs/git.nix
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.programs.git;
|
||||
|
||||
toINI = (import ../lib/generators.nix).toINI {};
|
||||
|
||||
signModule = types.submodule (
|
||||
{ ... }: {
|
||||
options = {
|
||||
key = mkOption {
|
||||
type = types.str;
|
||||
default = null;
|
||||
description = "The default GPG signing key fingerprint.";
|
||||
};
|
||||
|
||||
signByDefault = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Whether commits should be signed by default.";
|
||||
};
|
||||
|
||||
gpgPath = mkOption {
|
||||
type = types.str;
|
||||
default = "${pkgs.gnupg}/bin/gpg2";
|
||||
defaultText = "''${pkgs.gnupg}/bin/gpg2";
|
||||
description = "Path to GnuPG binary to use.";
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
options = {
|
||||
programs.git = {
|
||||
enable = mkEnableOption "Git";
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.git;
|
||||
defaultText = "pkgs.git";
|
||||
description = "Git package to install.";
|
||||
};
|
||||
|
||||
userName = mkOption {
|
||||
type = types.str;
|
||||
description = "Default user name to use.";
|
||||
};
|
||||
|
||||
userEmail = mkOption {
|
||||
type = types.str;
|
||||
description = "Default user email to use.";
|
||||
};
|
||||
|
||||
aliases = mkOption {
|
||||
type = types.attrs;
|
||||
default = {};
|
||||
description = "Git aliases to define.";
|
||||
};
|
||||
|
||||
signing = mkOption {
|
||||
type = types.nullOr signModule;
|
||||
default = null;
|
||||
description = "Options related to signing commits using GnuPG.";
|
||||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
type = types.lines;
|
||||
default = null;
|
||||
description = "Additional configuration to add.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (
|
||||
let
|
||||
ini = {
|
||||
user = {
|
||||
name = cfg.userName;
|
||||
email = cfg.userEmail;
|
||||
} // optionalAttrs (cfg.signing != null) {
|
||||
signingKey = cfg.signing.key;
|
||||
};
|
||||
} // optionalAttrs (cfg.signing != null) {
|
||||
commit.gpgSign = cfg.signing.signByDefault;
|
||||
gpg.program = cfg.signing.gpgPath;
|
||||
} // optionalAttrs (cfg.aliases != {}) {
|
||||
alias = cfg.aliases;
|
||||
};
|
||||
in
|
||||
{
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
home.file.".gitconfig".text = toINI ini + "\n" + cfg.extraConfig;
|
||||
}
|
||||
);
|
||||
}
|
||||
186
modules/programs/gnome-terminal.nix
Normal file
186
modules/programs/gnome-terminal.nix
Normal file
|
|
@ -0,0 +1,186 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.programs.gnome-terminal;
|
||||
|
||||
profileColorsSubModule = types.submodule (
|
||||
{ ... }: {
|
||||
options = {
|
||||
foregroundColor = mkOption {
|
||||
type = types.str;
|
||||
description = "The foreground color.";
|
||||
};
|
||||
|
||||
backgroundColor = mkOption {
|
||||
type = types.str;
|
||||
description = "The background color.";
|
||||
};
|
||||
|
||||
boldColor = mkOption {
|
||||
default = null;
|
||||
type = types.nullOr types.str;
|
||||
description = "The bold color, null to use same as foreground.";
|
||||
};
|
||||
|
||||
palette = mkOption {
|
||||
type = types.listOf types.str;
|
||||
description = "The terminal palette.";
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
profileSubModule = types.submodule (
|
||||
{ name, config, ... }: {
|
||||
options = {
|
||||
default = mkOption {
|
||||
default = false;
|
||||
type = types.bool;
|
||||
description = "Whether this should be the default profile.";
|
||||
};
|
||||
|
||||
visibleName = mkOption {
|
||||
type = types.str;
|
||||
description = "The profile name.";
|
||||
};
|
||||
|
||||
colors = mkOption {
|
||||
default = null;
|
||||
type = types.nullOr profileColorsSubModule;
|
||||
description = "The terminal colors, null to use system default.";
|
||||
};
|
||||
|
||||
cursorShape = mkOption {
|
||||
default = "block";
|
||||
type = types.enum [ "block" "ibeam" "underline" ];
|
||||
description = "The cursor shape.";
|
||||
};
|
||||
|
||||
font = mkOption {
|
||||
default = null;
|
||||
type = types.nullOr types.str;
|
||||
description = "The font name, null to use system default.";
|
||||
};
|
||||
|
||||
scrollOnOutput = mkOption {
|
||||
default = true;
|
||||
type = types.bool;
|
||||
description = "Whether to scroll when output is written.";
|
||||
};
|
||||
|
||||
showScrollbar = mkOption {
|
||||
default = true;
|
||||
type = types.bool;
|
||||
description = "Whether the scroll bar should be visible.";
|
||||
};
|
||||
|
||||
scrollbackLines = mkOption {
|
||||
default = 10000;
|
||||
type = types.nullOr types.int;
|
||||
description =
|
||||
''
|
||||
The number of scrollback lines to keep, null for infinite.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
toINI = (import ../lib/generators.nix).toINI { mkKeyValue = mkIniKeyValue; };
|
||||
|
||||
mkIniKeyValue = key: value:
|
||||
let
|
||||
tweakVal = v:
|
||||
if isString v then "'${v}'"
|
||||
else if isList v then "[" + concatStringsSep "," (map tweakVal v) + "]"
|
||||
else if isBool v && v then "true"
|
||||
else if isBool v && !v then "false"
|
||||
else toString v;
|
||||
in
|
||||
"${key}=${tweakVal value}";
|
||||
|
||||
buildProfileSet = pcfg:
|
||||
{
|
||||
visible-name = pcfg.visibleName;
|
||||
scrollbar-policy = if pcfg.showScrollbar then "always" else "never";
|
||||
scrollback-lines = pcfg.scrollbackLines;
|
||||
cursor-shape = pcfg.cursorShape;
|
||||
}
|
||||
// (
|
||||
if (pcfg.font == null)
|
||||
then { use-system-font = true; }
|
||||
else { use-system-font = false; font = pcfg.font; }
|
||||
) // (
|
||||
if (pcfg.colors == null)
|
||||
then { use-theme-colors = true; }
|
||||
else (
|
||||
{
|
||||
use-theme-colors = false;
|
||||
foreground-color = pcfg.colors.foregroundColor;
|
||||
background-color = pcfg.colors.backgroundColor;
|
||||
palette = pcfg.colors.palette;
|
||||
}
|
||||
// (
|
||||
if (pcfg.colors.boldColor == null)
|
||||
then { bold-color-same-as-fg = true; }
|
||||
else {
|
||||
bold-color-same-as-fg = false;
|
||||
bold-color = pcfg.colors.boldColor;
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
buildIniSet = cfg:
|
||||
{
|
||||
"/" = {
|
||||
default-show-menubar = cfg.showMenubar;
|
||||
schema-version = 3;
|
||||
};
|
||||
}
|
||||
//
|
||||
{
|
||||
"profiles:" = {
|
||||
default = head (attrNames (filterAttrs (n: v: v.default) cfg.profile));
|
||||
list = attrNames cfg.profile; #mapAttrsToList (n: v: n) cfg.profile;
|
||||
};
|
||||
}
|
||||
//
|
||||
mapAttrs' (name: value:
|
||||
nameValuePair ("profiles:/:${name}") (buildProfileSet value)
|
||||
) cfg.profile;
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
options = {
|
||||
programs.gnome-terminal = {
|
||||
enable = mkEnableOption "Gnome Terminal";
|
||||
|
||||
showMenubar = mkOption {
|
||||
default = true;
|
||||
type = types.bool;
|
||||
description = "Whether to show the menubar by default";
|
||||
};
|
||||
|
||||
profile = mkOption {
|
||||
default = {};
|
||||
type = types.loaOf profileSubModule;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.activation.gnome-terminal =
|
||||
let
|
||||
sf = pkgs.writeText "gnome-terminal.ini" (toINI (buildIniSet cfg));
|
||||
dconfPath = "/org/gnome/terminal/legacy/";
|
||||
in
|
||||
''
|
||||
${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} < ${sf}
|
||||
'';
|
||||
};
|
||||
}
|
||||
17
modules/programs/lesspipe.nix
Normal file
17
modules/programs/lesspipe.nix
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
{
|
||||
options = {
|
||||
programs.lesspipe = {
|
||||
enable = mkEnableOption "lesspipe preprocessor for less";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf config.programs.lesspipe.enable {
|
||||
home.sessionVariables = {
|
||||
LESSOPEN = "|${pkgs.lesspipe}/bin/lesspipe.sh %s";
|
||||
};
|
||||
};
|
||||
}
|
||||
32
modules/programs/texlive.nix
Normal file
32
modules/programs/texlive.nix
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.programs.texlive;
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
options = {
|
||||
programs.texlive = {
|
||||
enable = mkEnableOption "Texlive";
|
||||
|
||||
extraPackages = mkOption {
|
||||
default = self: {};
|
||||
example = literalExample ''
|
||||
tpkgs: { inherit (tpkgs) collection-fontsrecommended algorithms; }
|
||||
'';
|
||||
description = "Extra packages available to Texlive.";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [
|
||||
(pkgs.texlive.combine (cfg.extraPackages pkgs.texlive))
|
||||
];
|
||||
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue