Merge pull request #304773 from acid-bong/no-libs

treewide: remove file-wide `with lib;` uses in nixos/modules/programs

Changed files
+1053 -1269
nixos
modules
programs
bash
command-not-found
digitalbitbox
wayland
zsh
+7 -9
nixos/modules/programs/_1password-gui.nix
···
{ config, pkgs, lib, ... }:
-
with lib;
-
let
cfg = config.programs._1password-gui;
···
in
{
imports = [
-
(mkRemovedOptionModule [ "programs" "_1password-gui" "gid" ] ''
A preallocated GID will be used instead.
'')
];
options = {
programs._1password-gui = {
-
enable = mkEnableOption "the 1Password GUI application";
-
polkitPolicyOwners = mkOption {
-
type = types.listOf types.str;
default = [ ];
-
example = literalExpression ''["user1" "user2" "user3"]'';
description = ''
A list of users who should be able to integrate 1Password with polkit-based authentication mechanisms.
'';
};
-
package = mkPackageOption pkgs "1Password GUI" {
default = [ "_1password-gui" ];
};
};
···
polkitPolicyOwners = cfg.polkitPolicyOwners;
};
in
-
mkIf cfg.enable {
environment.systemPackages = [ package ];
users.groups.onepassword.gid = config.ids.gids.onepassword;
···
{ config, pkgs, lib, ... }:
let
cfg = config.programs._1password-gui;
···
in
{
imports = [
+
(lib.mkRemovedOptionModule [ "programs" "_1password-gui" "gid" ] ''
A preallocated GID will be used instead.
'')
];
options = {
programs._1password-gui = {
+
enable = lib.mkEnableOption "the 1Password GUI application";
+
polkitPolicyOwners = lib.mkOption {
+
type = lib.types.listOf lib.types.str;
default = [ ];
+
example = lib.literalExpression ''["user1" "user2" "user3"]'';
description = ''
A list of users who should be able to integrate 1Password with polkit-based authentication mechanisms.
'';
};
+
package = lib.mkPackageOption pkgs "1Password GUI" {
default = [ "_1password-gui" ];
};
};
···
polkitPolicyOwners = cfg.polkitPolicyOwners;
};
in
+
lib.mkIf cfg.enable {
environment.systemPackages = [ package ];
users.groups.onepassword.gid = config.ids.gids.onepassword;
+4 -6
nixos/modules/programs/_1password.nix
···
{ config, pkgs, lib, ... }:
-
with lib;
-
let
cfg = config.programs._1password;
···
in
{
imports = [
-
(mkRemovedOptionModule [ "programs" "_1password" "gid" ] ''
A preallocated GID will be used instead.
'')
];
options = {
programs._1password = {
-
enable = mkEnableOption "the 1Password CLI tool";
-
package = mkPackageOption pkgs "1Password CLI" {
default = [ "_1password" ];
};
};
};
-
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
users.groups.onepassword-cli.gid = config.ids.gids.onepassword-cli;
···
{ config, pkgs, lib, ... }:
let
cfg = config.programs._1password;
···
in
{
imports = [
+
(lib.mkRemovedOptionModule [ "programs" "_1password" "gid" ] ''
A preallocated GID will be used instead.
'')
];
options = {
programs._1password = {
+
enable = lib.mkEnableOption "the 1Password CLI tool";
+
package = lib.mkPackageOption pkgs "1Password CLI" {
default = [ "_1password" ];
};
};
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
users.groups.onepassword-cli.gid = config.ids.gids.onepassword-cli;
+4 -6
nixos/modules/programs/adb.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
{
-
meta.maintainers = [ maintainers.mic92 ];
###### interface
options = {
programs.adb = {
-
enable = mkOption {
default = false;
-
type = types.bool;
description = ''
Whether to configure system to use Android Debug Bridge (adb).
To grant access to a user, it must be part of adbusers group:
···
};
###### implementation
-
config = mkIf config.programs.adb.enable {
services.udev.packages = [ pkgs.android-udev-rules ];
environment.systemPackages = [ pkgs.android-tools ];
users.groups.adbusers = {};
···
{ config, lib, pkgs, ... }:
{
+
meta.maintainers = [ lib.maintainers.mic92 ];
###### interface
options = {
programs.adb = {
+
enable = lib.mkOption {
default = false;
+
type = lib.types.bool;
description = ''
Whether to configure system to use Android Debug Bridge (adb).
To grant access to a user, it must be part of adbusers group:
···
};
###### implementation
+
config = lib.mkIf config.programs.adb.enable {
services.udev.packages = [ pkgs.android-udev-rules ];
environment.systemPackages = [ pkgs.android-tools ];
users.groups.adbusers = {};
+7 -9
nixos/modules/programs/alvr.nix
···
{ config, pkgs, lib, ... }:
-
with lib;
-
let
cfg = config.programs.alvr;
in
{
options = {
programs.alvr = {
-
enable = mkEnableOption "ALVR, the VR desktop streamer";
-
package = mkPackageOption pkgs "alvr" { };
-
openFirewall = mkOption {
-
type = types.bool;
default = false;
description = ''
Whether to open the default ports in the firewall for the ALVR server.
···
};
};
-
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
-
networking.firewall = mkIf cfg.openFirewall {
allowedTCPPorts = [ 9943 9944 ];
allowedUDPPorts = [ 9943 9944 ];
};
};
-
meta.maintainers = with maintainers; [ passivelemon ];
}
···
{ config, pkgs, lib, ... }:
let
cfg = config.programs.alvr;
in
{
options = {
programs.alvr = {
+
enable = lib.mkEnableOption "ALVR, the VR desktop streamer";
+
package = lib.mkPackageOption pkgs "alvr" { };
+
openFirewall = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Whether to open the default ports in the firewall for the ALVR server.
···
};
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
+
networking.firewall = lib.mkIf cfg.openFirewall {
allowedTCPPorts = [ 9943 9944 ];
allowedUDPPorts = [ 9943 9944 ];
};
};
+
meta.maintainers = with lib.maintainers; [ passivelemon ];
}
+2 -4
nixos/modules/programs/appgate-sdp.nix
···
{ config, pkgs, lib, ... }:
-
with lib;
-
{
options = {
programs.appgate-sdp = {
-
enable = mkEnableOption "the AppGate SDP VPN client";
};
};
-
config = mkIf config.programs.appgate-sdp.enable {
boot.kernelModules = [ "tun" ];
environment.systemPackages = [ pkgs.appgate-sdp ];
services.dbus.packages = [ pkgs.appgate-sdp ];
···
{ config, pkgs, lib, ... }:
{
options = {
programs.appgate-sdp = {
+
enable = lib.mkEnableOption "the AppGate SDP VPN client";
};
};
+
config = lib.mkIf config.programs.appgate-sdp.enable {
boot.kernelModules = [ "tun" ];
environment.systemPackages = [ pkgs.appgate-sdp ];
services.dbus.packages = [ pkgs.appgate-sdp ];
+26 -28
nixos/modules/programs/atop.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let cfg = config.programs.atop;
in
···
programs.atop = rec {
-
enable = mkEnableOption "Atop, a tool for monitoring system resources";
-
package = mkPackageOption pkgs "atop" { };
netatop = {
-
enable = mkOption {
-
type = types.bool;
default = false;
description = ''
Whether to install and enable the netatop kernel module.
Note: this sets the kernel taint flag "O" for loading out-of-tree modules.
'';
};
-
package = mkOption {
-
type = types.package;
default = config.boot.kernelPackages.netatop;
-
defaultText = literalExpression "config.boot.kernelPackages.netatop";
description = ''
Which package to use for netatop.
'';
};
};
-
atopgpu.enable = mkOption {
-
type = types.bool;
default = false;
description = ''
Whether to install and enable the atopgpud daemon to get information about
···
'';
};
-
setuidWrapper.enable = mkOption {
-
type = types.bool;
default = false;
description = ''
Whether to install a setuid wrapper for Atop. This is required to use some of
···
'';
};
-
atopService.enable = mkOption {
-
type = types.bool;
default = true;
description = ''
Whether to enable the atop service responsible for storing statistics for
long-term analysis.
'';
};
-
atopRotateTimer.enable = mkOption {
-
type = types.bool;
default = true;
description = ''
Whether to enable the atop-rotate timer, which restarts the atop service
daily to make sure the data files are rotate.
'';
};
-
atopacctService.enable = mkOption {
-
type = types.bool;
default = true;
description = ''
Whether to enable the atopacct service which manages process accounting.
···
two refresh intervals.
'';
};
-
settings = mkOption {
-
type = types.attrs;
default = { };
example = {
flags = "a1f";
···
};
};
-
config = mkIf cfg.enable (
let
atop =
if cfg.atopgpu.enable then
···
cfg.package;
in
{
-
environment.etc = mkIf (cfg.settings != { }) {
-
atoprc.text = concatStrings
-
(mapAttrsToList
(n: v: ''
-
${n} ${toString v}
'')
cfg.settings);
};
···
wantedBy = [ (if type == "services" then "multi-user.target" else if type == "timers" then "timers.target" else null) ];
};
};
-
mkService = mkSystemd "services";
-
mkTimer = mkSystemd "timers";
in
{
packages = [ atop (lib.mkIf cfg.netatop.enable cfg.netatop.package) ];
···
{ config, lib, pkgs, ... }:
let cfg = config.programs.atop;
in
···
programs.atop = rec {
+
enable = lib.mkEnableOption "Atop, a tool for monitoring system resources";
+
package = lib.mkPackageOption pkgs "atop" { };
netatop = {
+
enable = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Whether to install and enable the netatop kernel module.
Note: this sets the kernel taint flag "O" for loading out-of-tree modules.
'';
};
+
package = lib.mkOption {
+
type = lib.types.package;
default = config.boot.kernelPackages.netatop;
+
defaultText = lib.literalExpression "config.boot.kernelPackages.netatop";
description = ''
Which package to use for netatop.
'';
};
};
+
atopgpu.enable = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Whether to install and enable the atopgpud daemon to get information about
···
'';
};
+
setuidWrapper.enable = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Whether to install a setuid wrapper for Atop. This is required to use some of
···
'';
};
+
atopService.enable = lib.mkOption {
+
type = lib.types.bool;
default = true;
description = ''
Whether to enable the atop service responsible for storing statistics for
long-term analysis.
'';
};
+
atopRotateTimer.enable = lib.mkOption {
+
type = lib.types.bool;
default = true;
description = ''
Whether to enable the atop-rotate timer, which restarts the atop service
daily to make sure the data files are rotate.
'';
};
+
atopacctService.enable = lib.mkOption {
+
type = lib.types.bool;
default = true;
description = ''
Whether to enable the atopacct service which manages process accounting.
···
two refresh intervals.
'';
};
+
settings = lib.mkOption {
+
type = lib.types.attrs;
default = { };
example = {
flags = "a1f";
···
};
};
+
config = lib.mkIf cfg.enable (
let
atop =
if cfg.atopgpu.enable then
···
cfg.package;
in
{
+
environment.etc = lib.mkIf (cfg.settings != { }) {
+
atoprc.text = lib.concatStrings
+
(lib.mapAttrsToList
(n: v: ''
+
${n} ${builtins.toString v}
'')
cfg.settings);
};
···
wantedBy = [ (if type == "services" then "multi-user.target" else if type == "timers" then "timers.target" else null) ];
};
};
+
mkService = lib.mkSystemd "services";
+
mkTimer = lib.mkSystemd "timers";
in
{
packages = [ atop (lib.mkIf cfg.netatop.enable cfg.netatop.package) ];
+3 -5
nixos/modules/programs/ausweisapp.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.ausweisapp;
in
{
options.programs.ausweisapp = {
-
enable = mkEnableOption "AusweisApp";
-
openFirewall = mkOption {
description = ''
Whether to open the required firewall ports for the Smartphone as Card Reader (SaC) functionality of AusweisApp.
'';
···
};
};
-
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [ ausweisapp ];
networking.firewall.allowedUDPPorts = lib.optionals cfg.openFirewall [ 24727 ];
};
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.ausweisapp;
in
{
options.programs.ausweisapp = {
+
enable = lib.mkEnableOption "AusweisApp";
+
openFirewall = lib.mkOption {
description = ''
Whether to open the required firewall ports for the Smartphone as Card Reader (SaC) functionality of AusweisApp.
'';
···
};
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ ausweisapp ];
networking.firewall.allowedUDPPorts = lib.optionals cfg.openFirewall [ 24727 ];
};
+5 -7
nixos/modules/programs/autojump.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.autojump;
prg = config.programs;
···
options = {
programs.autojump = {
-
enable = mkOption {
-
type = types.bool;
default = false;
description = ''
Whether to enable autojump.
···
###### implementation
-
config = mkIf cfg.enable {
environment.pathsToLink = [ "/share/autojump" ];
environment.systemPackages = [ pkgs.autojump ];
programs.bash.interactiveShellInit = "source ${pkgs.autojump}/share/autojump/autojump.bash";
-
programs.zsh.interactiveShellInit = mkIf prg.zsh.enable "source ${pkgs.autojump}/share/autojump/autojump.zsh";
-
programs.fish.interactiveShellInit = mkIf prg.fish.enable "source ${pkgs.autojump}/share/autojump/autojump.fish";
};
}
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.autojump;
prg = config.programs;
···
options = {
programs.autojump = {
+
enable = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Whether to enable autojump.
···
###### implementation
+
config = lib.mkIf cfg.enable {
environment.pathsToLink = [ "/share/autojump" ];
environment.systemPackages = [ pkgs.autojump ];
programs.bash.interactiveShellInit = "source ${pkgs.autojump}/share/autojump/autojump.bash";
+
programs.zsh.interactiveShellInit = lib.mkIf prg.zsh.enable "source ${pkgs.autojump}/share/autojump/autojump.zsh";
+
programs.fish.interactiveShellInit = lib.mkIf prg.fish.enable "source ${pkgs.autojump}/share/autojump/autojump.fish";
};
}
+4 -6
nixos/modules/programs/bandwhich.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let cfg = config.programs.bandwhich;
in {
-
meta.maintainers = with maintainers; [ Br1ght0ne ];
options = {
programs.bandwhich = {
-
enable = mkOption {
-
type = types.bool;
default = false;
description = ''
Whether to add bandwhich to the global environment and configure a
···
};
};
-
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [ bandwhich ];
security.wrappers.bandwhich = {
owner = "root";
···
{ config, lib, pkgs, ... }:
let cfg = config.programs.bandwhich;
in {
+
meta.maintainers = with lib.maintainers; [ Br1ght0ne ];
options = {
programs.bandwhich = {
+
enable = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Whether to add bandwhich to the global environment and configure a
···
};
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ bandwhich ];
security.wrappers.bandwhich = {
owner = "root";
+2 -4
nixos/modules/programs/bash-my-aws.nix
···
{ config, pkgs, lib, ... }:
-
with lib;
-
let
prg = config.programs;
cfg = prg.bash-my-aws;
···
{
options = {
programs.bash-my-aws = {
-
enable = mkEnableOption "bash-my-aws";
};
};
-
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [ bash-my-aws ];
programs.bash.interactiveShellInit = initScript;
···
{ config, pkgs, lib, ... }:
let
prg = config.programs;
cfg = prg.bash-my-aws;
···
{
options = {
programs.bash-my-aws = {
+
enable = lib.mkEnableOption "bash-my-aws";
};
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ bash-my-aws ];
programs.bash.interactiveShellInit = initScript;
+2 -4
nixos/modules/programs/bash/bash-completion.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
enable = config.programs.bash.enableCompletion;
in
{
options = {
-
programs.bash.enableCompletion = mkEnableOption "Bash completion for all interactive bash shells" // {
default = true;
};
};
-
config = mkIf enable {
programs.bash.promptPluginInit = ''
# Check whether we're running a version of Bash that has support for
# programmable completion. If we do, enable all modules installed in
···
{ config, lib, pkgs, ... }:
let
enable = config.programs.bash.enableCompletion;
in
{
options = {
+
programs.bash.enableCompletion = lib.mkEnableOption "Bash completion for all interactive bash shells" // {
default = true;
};
};
+
config = lib.mkIf enable {
programs.bash.promptPluginInit = ''
# Check whether we're running a version of Bash that has support for
# programmable completion. If we do, enable all modules installed in
+23 -25
nixos/modules/programs/bash/bash.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfge = config.environment;
cfg = config.programs.bash;
-
bashAliases = concatStringsSep "\n" (
-
mapAttrsFlatten (k: v: "alias -- ${k}=${escapeShellArg v}")
-
(filterAttrs (k: v: v != null) cfg.shellAliases)
);
in
{
imports = [
-
(mkRemovedOptionModule [ "programs" "bash" "enable" ] "")
];
options = {
···
programs.bash = {
/*
-
enable = mkOption {
default = true;
description = ''
Whenever to configure Bash as an interactive shell.
···
set this variable if you have another shell configured
with NixOS.
'';
-
type = types.bool;
};
*/
-
shellAliases = mkOption {
default = {};
description = ''
Set of aliases for bash shell, which overrides {option}`environment.shellAliases`.
See {option}`environment.shellAliases` for an option format description.
'';
-
type = with types; attrsOf (nullOr (either str path));
};
-
shellInit = mkOption {
default = "";
description = ''
Shell script code called during bash shell initialisation.
'';
-
type = types.lines;
};
-
loginShellInit = mkOption {
default = "";
description = ''
Shell script code called during login bash shell initialisation.
'';
-
type = types.lines;
};
-
interactiveShellInit = mkOption {
default = "";
description = ''
Shell script code called during interactive bash shell initialisation.
'';
-
type = types.lines;
};
-
promptInit = mkOption {
default = ''
# Provide a nice prompt if the terminal supports it.
if [ "$TERM" != "dumb" ] || [ -n "$INSIDE_EMACS" ]; then
···
description = ''
Shell script code used to initialise the bash prompt.
'';
-
type = types.lines;
};
-
promptPluginInit = mkOption {
default = "";
description = ''
Shell script code used to initialise bash prompt plugins.
'';
-
type = types.lines;
internal = true;
};
···
};
-
config = /* mkIf cfg.enable */ {
programs.bash = {
-
shellAliases = mapAttrs (name: mkDefault) cfge.shellAliases;
shellInit = ''
if [ -z "$__NIXOS_SET_ENVIRONMENT_DONE" ]; then
···
# Configuration for readline in bash. We use "option default"
# priority to allow user override using both .text and .source.
-
environment.etc.inputrc.source = mkOptionDefault ./inputrc;
-
users.defaultUserShell = mkDefault pkgs.bashInteractive;
-
environment.pathsToLink = optionals cfg.enableCompletion [
"/etc/bash_completion.d"
"/share/bash-completion"
];
···
{ config, lib, pkgs, ... }:
let
cfge = config.environment;
cfg = config.programs.bash;
+
bashAliases = builtins.concatStringsSep "\n" (
+
lib.mapAttrsFlatten (k: v: "alias -- ${k}=${lib.escapeShellArg v}")
+
(lib.filterAttrs (k: v: v != null) cfg.shellAliases)
);
in
{
imports = [
+
(lib.mkRemovedOptionModule [ "programs" "bash" "enable" ] "")
];
options = {
···
programs.bash = {
/*
+
enable = lib.mkOption {
default = true;
description = ''
Whenever to configure Bash as an interactive shell.
···
set this variable if you have another shell configured
with NixOS.
'';
+
type = lib.types.bool;
};
*/
+
shellAliases = lib.mkOption {
default = {};
description = ''
Set of aliases for bash shell, which overrides {option}`environment.shellAliases`.
See {option}`environment.shellAliases` for an option format description.
'';
+
type = with lib.types; attrsOf (nullOr (either str path));
};
+
shellInit = lib.mkOption {
default = "";
description = ''
Shell script code called during bash shell initialisation.
'';
+
type = lib.types.lines;
};
+
loginShellInit = lib.mkOption {
default = "";
description = ''
Shell script code called during login bash shell initialisation.
'';
+
type = lib.types.lines;
};
+
interactiveShellInit = lib.mkOption {
default = "";
description = ''
Shell script code called during interactive bash shell initialisation.
'';
+
type = lib.types.lines;
};
+
promptInit = lib.mkOption {
default = ''
# Provide a nice prompt if the terminal supports it.
if [ "$TERM" != "dumb" ] || [ -n "$INSIDE_EMACS" ]; then
···
description = ''
Shell script code used to initialise the bash prompt.
'';
+
type = lib.types.lines;
};
+
promptPluginInit = lib.mkOption {
default = "";
description = ''
Shell script code used to initialise bash prompt plugins.
'';
+
type = lib.types.lines;
internal = true;
};
···
};
+
config = /* lib.mkIf cfg.enable */ {
programs.bash = {
+
shellAliases = builtins.mapAttrs (name: lib.mkDefault) cfge.shellAliases;
shellInit = ''
if [ -z "$__NIXOS_SET_ENVIRONMENT_DONE" ]; then
···
# Configuration for readline in bash. We use "option default"
# priority to allow user override using both .text and .source.
+
environment.etc.inputrc.source = lib.mkOptionDefault ./inputrc;
+
users.defaultUserShell = lib.mkDefault pkgs.bashInteractive;
+
environment.pathsToLink = lib.optionals cfg.enableCompletion [
"/etc/bash_completion.d"
"/share/bash-completion"
];
+4 -5
nixos/modules/programs/bash/blesh.nix
···
{ lib, config, pkgs, ... }:
-
with lib;
let
cfg = config.programs.bash.blesh;
in {
options = {
-
programs.bash.blesh.enable = mkEnableOption "blesh, a full-featured line editor written in pure Bash";
};
-
config = mkIf cfg.enable {
-
programs.bash.interactiveShellInit = mkBefore ''
source ${pkgs.blesh}/share/blesh/ble.sh
'';
};
-
meta.maintainers = with maintainers; [ laalsaas ];
}
···
{ lib, config, pkgs, ... }:
let
cfg = config.programs.bash.blesh;
in {
options = {
+
programs.bash.blesh.enable = lib.mkEnableOption "blesh, a full-featured line editor written in pure Bash";
};
+
config = lib.mkIf cfg.enable {
+
programs.bash.interactiveShellInit = lib.mkBefore ''
source ${pkgs.blesh}/share/blesh/ble.sh
'';
};
+
meta.maintainers = with lib.maintainers; [ laalsaas ];
}
+2 -4
nixos/modules/programs/bash/ls-colors.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
enable = config.programs.bash.enableLsColors;
in
{
options = {
-
programs.bash.enableLsColors = mkEnableOption "extra colors in directory listings" // {
default = true;
};
};
-
config = mkIf enable {
programs.bash.promptPluginInit = ''
eval "$(${pkgs.coreutils}/bin/dircolors -b)"
'';
···
{ config, lib, pkgs, ... }:
let
enable = config.programs.bash.enableLsColors;
in
{
options = {
+
programs.bash.enableLsColors = lib.mkEnableOption "extra colors in directory listings" // {
default = true;
};
};
+
config = lib.mkIf enable {
programs.bash.promptPluginInit = ''
eval "$(${pkgs.coreutils}/bin/dircolors -b)"
'';
+7 -9
nixos/modules/programs/bash/undistract-me.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.bash.undistractMe;
in
{
options = {
programs.bash.undistractMe = {
-
enable = mkEnableOption "notifications when long-running terminal commands complete";
-
playSound = mkEnableOption "notification sounds when long-running terminal commands complete";
-
timeout = mkOption {
default = 10;
description = ''
Number of seconds it would take for a command to be considered long-running.
'';
-
type = types.int;
};
};
};
-
config = mkIf cfg.enable {
programs.bash.promptPluginInit = ''
-
export LONG_RUNNING_COMMAND_TIMEOUT=${toString cfg.timeout}
export UDM_PLAY_SOUND=${if cfg.playSound then "1" else "0"}
. "${pkgs.undistract-me}/etc/profile.d/undistract-me.sh"
'';
};
meta = {
-
maintainers = with maintainers; [ kira-bruneau ];
};
}
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.bash.undistractMe;
in
{
options = {
programs.bash.undistractMe = {
+
enable = lib.mkEnableOption "notifications when long-running terminal commands complete";
+
playSound = lib.mkEnableOption "notification sounds when long-running terminal commands complete";
+
timeout = lib.mkOption {
default = 10;
description = ''
Number of seconds it would take for a command to be considered long-running.
'';
+
type = lib.types.int;
};
};
};
+
config = lib.mkIf cfg.enable {
programs.bash.promptPluginInit = ''
+
export LONG_RUNNING_COMMAND_TIMEOUT=${builtins.toString cfg.timeout}
export UDM_PLAY_SOUND=${if cfg.playSound then "1" else "0"}
. "${pkgs.undistract-me}/etc/profile.d/undistract-me.sh"
'';
};
meta = {
+
maintainers = with lib.maintainers; [ kira-bruneau ];
};
}
+2 -4
nixos/modules/programs/browserpass.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
{
-
options.programs.browserpass.enable = mkEnableOption "Browserpass native messaging host";
-
config = mkIf config.programs.browserpass.enable {
environment.etc = let
appId = "com.github.browserpass.native.json";
source = part: "${pkgs.browserpass}/lib/browserpass/${part}/${appId}";
···
{ config, lib, pkgs, ... }:
{
+
options.programs.browserpass.enable = lib.mkEnableOption "Browserpass native messaging host";
+
config = lib.mkIf config.programs.browserpass.enable {
environment.etc = let
appId = "com.github.browserpass.native.json";
source = part: "${pkgs.browserpass}/lib/browserpass/${part}/${appId}";
+2 -4
nixos/modules/programs/calls.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.calls;
in {
options = {
programs.calls = {
-
enable = mkEnableOption ''
GNOME calls: a phone dialer and call handler
'';
};
};
-
config = mkIf cfg.enable {
programs.dconf.enable = true;
environment.systemPackages = [
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.calls;
in {
options = {
programs.calls = {
+
enable = lib.mkEnableOption ''
GNOME calls: a phone dialer and call handler
'';
};
};
+
config = lib.mkIf cfg.enable {
programs.dconf.enable = true;
environment.systemPackages = [
+11 -13
nixos/modules/programs/cdemu.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let cfg = config.programs.cdemu;
in {
options = {
programs.cdemu = {
-
enable = mkOption {
-
type = types.bool;
default = false;
description = ''
{command}`cdemu` for members of
{option}`programs.cdemu.group`.
'';
};
-
group = mkOption {
-
type = types.str;
default = "cdrom";
description = ''
Group that users must be in to use {command}`cdemu`.
'';
};
-
gui = mkOption {
-
type = types.bool;
default = true;
description = ''
Whether to install the {command}`cdemu` GUI (gCDEmu).
'';
};
-
image-analyzer = mkOption {
-
type = types.bool;
default = true;
description = ''
Whether to install the image analyzer.
···
};
};
-
config = mkIf cfg.enable {
boot = {
extraModulePackages = [ config.boot.kernelPackages.vhba ];
···
environment.systemPackages =
[ pkgs.cdemu-daemon pkgs.cdemu-client ]
-
++ optional cfg.gui pkgs.gcdemu
-
++ optional cfg.image-analyzer pkgs.image-analyzer;
};
}
···
{ config, lib, pkgs, ... }:
let cfg = config.programs.cdemu;
in {
options = {
programs.cdemu = {
+
enable = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
{command}`cdemu` for members of
{option}`programs.cdemu.group`.
'';
};
+
group = lib.mkOption {
+
type = lib.types.str;
default = "cdrom";
description = ''
Group that users must be in to use {command}`cdemu`.
'';
};
+
gui = lib.mkOption {
+
type = lib.types.bool;
default = true;
description = ''
Whether to install the {command}`cdemu` GUI (gCDEmu).
'';
};
+
image-analyzer = lib.mkOption {
+
type = lib.types.bool;
default = true;
description = ''
Whether to install the image analyzer.
···
};
};
+
config = lib.mkIf cfg.enable {
boot = {
extraModulePackages = [ config.boot.kernelPackages.vhba ];
···
environment.systemPackages =
[ pkgs.cdemu-daemon pkgs.cdemu-client ]
+
++ lib.optional cfg.gui pkgs.gcdemu
+
++ lib.optional cfg.image-analyzer pkgs.image-analyzer;
};
}
+3 -5
nixos/modules/programs/cfs-zen-tweaks.nix
···
{ config, pkgs, lib, ... }:
-
with lib;
-
let
cfg = config.programs.cfs-zen-tweaks;
···
{
meta = {
-
maintainers = with maintainers; [ mkg20001 ];
};
options = {
-
programs.cfs-zen-tweaks.enable = mkEnableOption "CFS Zen Tweaks";
};
-
config = mkIf cfg.enable {
systemd.packages = [ pkgs.cfs-zen-tweaks ];
systemd.services.set-cfs-tweaks.wantedBy = [
···
{ config, pkgs, lib, ... }:
let
cfg = config.programs.cfs-zen-tweaks;
···
{
meta = {
+
maintainers = with lib.maintainers; [ mkg20001 ];
};
options = {
+
programs.cfs-zen-tweaks.enable = lib.mkEnableOption "CFS Zen Tweaks";
};
+
config = lib.mkIf cfg.enable {
systemd.packages = [ pkgs.cfs-zen-tweaks ];
systemd.services.set-cfs-tweaks.wantedBy = [
+21 -23
nixos/modules/programs/chromium.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.chromium;
-
defaultProfile = filterAttrs (k: v: v != null) {
HomepageLocation = cfg.homepageLocation;
DefaultSearchProviderEnabled = cfg.defaultSearchProviderEnabled;
DefaultSearchProviderSearchURL = cfg.defaultSearchProviderSearchURL;
···
options = {
programs.chromium = {
-
enable = mkEnableOption "{command}`chromium` policies";
-
enablePlasmaBrowserIntegration = mkEnableOption "Native Messaging Host for Plasma Browser Integration";
-
plasmaBrowserIntegrationPackage = mkPackageOption pkgs [ "plasma5Packages" "plasma-browser-integration" ] { };
-
extensions = mkOption {
-
type = with types; nullOr (listOf str);
description = ''
List of chromium extensions to install.
For list of plugins ids see id in url of extensions on
···
for additional details.
'';
default = null;
-
example = literalExpression ''
[
"chlffgpmiacpedhhbkiomidkjlcfhogd" # pushbullet
"mbniclmhobmnbdlbpiphghaielnnpgdp" # lightshot
···
'';
};
-
homepageLocation = mkOption {
-
type = types.nullOr types.str;
description = "Chromium default homepage";
default = null;
example = "https://nixos.org";
};
-
defaultSearchProviderEnabled = mkOption {
-
type = types.nullOr types.bool;
description = "Enable the default search provider.";
default = null;
example = true;
};
-
defaultSearchProviderSearchURL = mkOption {
-
type = types.nullOr types.str;
description = "Chromium default search provider url.";
default = null;
example = "https://encrypted.google.com/search?q={searchTerms}&{google:RLZ}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchFieldtrialParameter}{google:searchClient}{google:sourceId}{google:instantExtendedEnabledParameter}ie={inputEncoding}";
};
-
defaultSearchProviderSuggestURL = mkOption {
-
type = types.nullOr types.str;
description = "Chromium default search provider url for suggestions.";
default = null;
example = "https://encrypted.google.com/complete/search?output=chrome&q={searchTerms}";
};
-
extraOpts = mkOption {
-
type = types.attrs;
description = ''
Extra chromium policy options. A list of available policies
can be found in the Chrome Enterprise documentation:
···
Make sure the selected policy is supported on Linux and your browser version.
'';
default = {};
-
example = literalExpression ''
{
"BrowserSignin" = 0;
"SyncDisabled" = true;
···
'';
};
-
initialPrefs = mkOption {
-
type = types.attrs;
description = ''
Initial preferences are used to configure the browser for the first run.
Unlike {option}`programs.chromium.extraOpts`, initialPrefs can be changed by users in the browser settings.
···
<https://www.chromium.org/administrators/configuring-other-preferences/>
'';
default = {};
-
example = literalExpression ''
{
"first_run_tabs" = [
"https://nixos.org/"
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.chromium;
+
defaultProfile = lib.filterAttrs (k: v: v != null) {
HomepageLocation = cfg.homepageLocation;
DefaultSearchProviderEnabled = cfg.defaultSearchProviderEnabled;
DefaultSearchProviderSearchURL = cfg.defaultSearchProviderSearchURL;
···
options = {
programs.chromium = {
+
enable = lib.mkEnableOption "{command}`chromium` policies";
+
enablePlasmaBrowserIntegration = lib.mkEnableOption "Native Messaging Host for Plasma Browser Integration";
+
plasmaBrowserIntegrationPackage = lib.mkPackageOption pkgs [ "plasma5Packages" "plasma-browser-integration" ] { };
+
extensions = lib.mkOption {
+
type = with lib.types; nullOr (listOf str);
description = ''
List of chromium extensions to install.
For list of plugins ids see id in url of extensions on
···
for additional details.
'';
default = null;
+
example = lib.literalExpression ''
[
"chlffgpmiacpedhhbkiomidkjlcfhogd" # pushbullet
"mbniclmhobmnbdlbpiphghaielnnpgdp" # lightshot
···
'';
};
+
homepageLocation = lib.mkOption {
+
type = lib.types.nullOr lib.types.str;
description = "Chromium default homepage";
default = null;
example = "https://nixos.org";
};
+
defaultSearchProviderEnabled = lib.mkOption {
+
type = lib.types.nullOr lib.types.bool;
description = "Enable the default search provider.";
default = null;
example = true;
};
+
defaultSearchProviderSearchURL = lib.mkOption {
+
type = lib.types.nullOr lib.types.str;
description = "Chromium default search provider url.";
default = null;
example = "https://encrypted.google.com/search?q={searchTerms}&{google:RLZ}{google:originalQueryForSuggestion}{google:assistedQueryStats}{google:searchFieldtrialParameter}{google:searchClient}{google:sourceId}{google:instantExtendedEnabledParameter}ie={inputEncoding}";
};
+
defaultSearchProviderSuggestURL = lib.mkOption {
+
type = lib.types.nullOr lib.types.str;
description = "Chromium default search provider url for suggestions.";
default = null;
example = "https://encrypted.google.com/complete/search?output=chrome&q={searchTerms}";
};
+
extraOpts = lib.mkOption {
+
type = lib.types.attrs;
description = ''
Extra chromium policy options. A list of available policies
can be found in the Chrome Enterprise documentation:
···
Make sure the selected policy is supported on Linux and your browser version.
'';
default = {};
+
example = lib.literalExpression ''
{
"BrowserSignin" = 0;
"SyncDisabled" = true;
···
'';
};
+
initialPrefs = lib.mkOption {
+
type = lib.types.attrs;
description = ''
Initial preferences are used to configure the browser for the first run.
Unlike {option}`programs.chromium.extraOpts`, initialPrefs can be changed by users in the browser settings.
···
<https://www.chromium.org/administrators/configuring-other-preferences/>
'';
default = {};
+
example = lib.literalExpression ''
{
"first_run_tabs" = [
"https://nixos.org/"
+2 -4
nixos/modules/programs/cnping.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.cnping;
in
{
options = {
programs.cnping = {
-
enable = mkEnableOption "a setcap wrapper for cnping";
};
};
-
config = mkIf cfg.enable {
security.wrappers.cnping = {
source = "${pkgs.cnping}/bin/cnping";
capabilities = "cap_net_raw+ep";
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.cnping;
in
{
options = {
programs.cnping = {
+
enable = lib.mkEnableOption "a setcap wrapper for cnping";
};
};
+
config = lib.mkIf cfg.enable {
security.wrappers.cnping = {
source = "${pkgs.cnping}/bin/cnping";
capabilities = "cap_net_raw+ep";
+5 -7
nixos/modules/programs/command-not-found/command-not-found.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.command-not-found;
commandNotFound = pkgs.substituteAll {
···
{
options.programs.command-not-found = {
-
enable = mkOption {
-
type = types.bool;
default = true;
description = ''
Whether interactive shells should show which Nix package (if
···
'';
};
-
dbPath = mkOption {
default = "/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite" ;
description = ''
Absolute path to programs.sqlite.
···
By default this file will be provided by your channel
(nixexprs.tar.xz).
'';
-
type = types.path;
};
};
-
config = mkIf cfg.enable {
programs.bash.interactiveShellInit =
''
# This function is called whenever a command is not found.
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.command-not-found;
commandNotFound = pkgs.substituteAll {
···
{
options.programs.command-not-found = {
+
enable = lib.mkOption {
+
type = lib.types.bool;
default = true;
description = ''
Whether interactive shells should show which Nix package (if
···
'';
};
+
dbPath = lib.mkOption {
default = "/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite" ;
description = ''
Absolute path to programs.sqlite.
···
By default this file will be provided by your channel
(nixexprs.tar.xz).
'';
+
type = lib.types.path;
};
};
+
config = lib.mkIf cfg.enable {
programs.bash.interactiveShellInit =
''
# This function is called whenever a command is not found.
+3 -5
nixos/modules/programs/criu.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let cfg = config.programs.criu;
in {
options = {
programs.criu = {
-
enable = mkOption {
-
type = types.bool;
default = false;
description = ''
Install {command}`criu` along with necessary kernel options.
···
};
};
};
-
config = mkIf cfg.enable {
system.requiredKernelConfig = with config.lib.kernelConfig; [
(isYes "CHECKPOINT_RESTORE")
];
···
{ config, lib, pkgs, ... }:
let cfg = config.programs.criu;
in {
options = {
programs.criu = {
+
enable = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Install {command}`criu` along with necessary kernel options.
···
};
};
};
+
config = lib.mkIf cfg.enable {
system.requiredKernelConfig = with config.lib.kernelConfig; [
(isYes "CHECKPOINT_RESTORE")
];
+4 -6
nixos/modules/programs/digitalbitbox/default.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.digitalbitbox;
in
{
options.programs.digitalbitbox = {
-
enable = mkOption {
-
type = types.bool;
default = false;
description = ''
Installs the Digital Bitbox application and enables the complementary hardware module.
'';
};
-
package = mkPackageOption pkgs "digitalbitbox" {
extraDescription = ''
This can be used to install a package with udev rules that differ from the defaults.
'';
};
};
-
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
hardware.digitalbitbox = {
enable = true;
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.digitalbitbox;
in
{
options.programs.digitalbitbox = {
+
enable = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Installs the Digital Bitbox application and enables the complementary hardware module.
'';
};
+
package = lib.mkPackageOption pkgs "digitalbitbox" {
extraDescription = ''
This can be used to install a package with udev rules that differ from the defaults.
'';
};
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
hardware.digitalbitbox = {
enable = true;
+5 -7
nixos/modules/programs/dmrconfig.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.dmrconfig;
in {
-
meta.maintainers = with maintainers; [ ];
###### interface
options = {
programs.dmrconfig = {
-
enable = mkOption {
default = false;
-
type = types.bool;
description = ''
Whether to configure system to enable use of dmrconfig. This
enables the required udev rules and installs the program.
···
relatedPackages = [ "dmrconfig" ];
};
-
package = mkPackageOption pkgs "dmrconfig" { };
};
};
###### implementation
-
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
services.udev.packages = [ cfg.package ];
};
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.dmrconfig;
in {
+
meta.maintainers = with lib.maintainers; [ ];
###### interface
options = {
programs.dmrconfig = {
+
enable = lib.mkOption {
default = false;
+
type = lib.types.bool;
description = ''
Whether to configure system to enable use of dmrconfig. This
enables the required udev rules and installs the program.
···
relatedPackages = [ "dmrconfig" ];
};
+
package = lib.mkPackageOption pkgs "dmrconfig" { };
};
};
###### implementation
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
services.udev.packages = [ cfg.package ];
};
+1 -3
nixos/modules/programs/droidcam.nix
···
{ lib, pkgs, config, ... }:
-
with lib;
-
{
options.programs.droidcam = {
-
enable = mkEnableOption "DroidCam client";
};
config = lib.mkIf config.programs.droidcam.enable {
···
{ lib, pkgs, config, ... }:
{
options.programs.droidcam = {
+
enable = lib.mkEnableOption "DroidCam client";
};
config = lib.mkIf config.programs.droidcam.enable {
+4 -6
nixos/modules/programs/dublin-traceroute.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.dublin-traceroute;
···
options = {
programs.dublin-traceroute = {
-
enable = mkEnableOption ''
dublin-traceroute, add it to the global environment and configure a setcap wrapper for it.
'';
-
package = mkPackageOption pkgs "dublin-traceroute" { };
};
};
-
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
security.wrappers.dublin-traceroute = {
owner = "root";
group = "root";
capabilities = "cap_net_raw+p";
-
source = getExe cfg.package;
};
};
}
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.dublin-traceroute;
···
options = {
programs.dublin-traceroute = {
+
enable = lib.mkEnableOption ''
dublin-traceroute, add it to the global environment and configure a setcap wrapper for it.
'';
+
package = lib.mkPackageOption pkgs "dublin-traceroute" { };
};
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
security.wrappers.dublin-traceroute = {
owner = "root";
group = "root";
capabilities = "cap_net_raw+p";
+
source = lib.getExe cfg.package;
};
};
}
+2 -4
nixos/modules/programs/ecryptfs.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.ecryptfs;
in {
options.programs.ecryptfs = {
-
enable = mkEnableOption "ecryptfs setuid mount wrappers";
};
-
config = mkIf cfg.enable {
security.wrappers = {
"mount.ecryptfs_private" = {
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.ecryptfs;
in {
options.programs.ecryptfs = {
+
enable = lib.mkEnableOption "ecryptfs setuid mount wrappers";
};
+
config = lib.mkIf cfg.enable {
security.wrappers = {
"mount.ecryptfs_private" = {
+4 -6
nixos/modules/programs/environment.nix
···
{ config, lib, ... }:
-
with lib;
-
let
cfg = config.environment;
···
{ NIXPKGS_CONFIG = "/etc/nix/nixpkgs-config.nix";
# note: many programs exec() this directly, so default options for less must not
# be specified here; do so in the default value of programs.less.envVariables instead
-
PAGER = mkDefault "less";
-
EDITOR = mkDefault "nano";
};
# since we set PAGER to this above, make sure it's installed
programs.less.enable = true;
-
environment.profiles = mkAfter
[ "/nix/var/nix/profiles/default"
"/run/current-system/sw"
];
···
environment.extraInit =
''
export NIX_USER_PROFILE_DIR="/nix/var/nix/profiles/per-user/$USER"
-
export NIX_PROFILES="${concatStringsSep " " (reverseList cfg.profiles)}"
'';
};
···
{ config, lib, ... }:
let
cfg = config.environment;
···
{ NIXPKGS_CONFIG = "/etc/nix/nixpkgs-config.nix";
# note: many programs exec() this directly, so default options for less must not
# be specified here; do so in the default value of programs.less.envVariables instead
+
PAGER = lib.mkDefault "less";
+
EDITOR = lib.mkDefault "nano";
};
# since we set PAGER to this above, make sure it's installed
programs.less.enable = true;
+
environment.profiles = lib.mkAfter
[ "/nix/var/nix/profiles/default"
"/run/current-system/sw"
];
···
environment.extraInit =
''
export NIX_USER_PROFILE_DIR="/nix/var/nix/profiles/per-user/$USER"
+
export NIX_PROFILES="${builtins.concatStringsSep " " (lib.reverseList cfg.profiles)}"
'';
};
+2 -3
nixos/modules/programs/extra-container.nix
···
{ config, pkgs, lib, ... }:
-
with lib;
let
cfg = config.programs.extra-container;
in {
options = {
-
programs.extra-container.enable = mkEnableOption ''
extra-container, a tool for running declarative NixOS containers
without host system rebuilds
'';
};
-
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.extra-container ];
boot.extraSystemdUnitPaths = [ "/etc/systemd-mutable/system" ];
};
···
{ config, pkgs, lib, ... }:
let
cfg = config.programs.extra-container;
in {
options = {
+
programs.extra-container.enable = lib.mkEnableOption ''
extra-container, a tool for running declarative NixOS containers
without host system rebuilds
'';
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.extra-container ];
boot.extraSystemdUnitPaths = [ "/etc/systemd-mutable/system" ];
};
+3 -5
nixos/modules/programs/feedbackd.nix
···
{ pkgs, lib, config, ... }:
-
with lib;
-
let
cfg = config.programs.feedbackd;
in {
options = {
programs.feedbackd = {
-
enable = mkEnableOption ''
the feedbackd D-BUS service and udev rules.
Your user needs to be in the `feedbackd` group to trigger effects
'';
-
package = mkPackageOption pkgs "feedbackd" { };
};
};
-
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
services.dbus.packages = [ cfg.package ];
···
{ pkgs, lib, config, ... }:
let
cfg = config.programs.feedbackd;
in {
options = {
programs.feedbackd = {
+
enable = lib.mkEnableOption ''
the feedbackd D-BUS service and udev rules.
Your user needs to be in the `feedbackd` group to trigger effects
'';
+
package = lib.mkPackageOption pkgs "feedbackd" { };
};
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
services.dbus.packages = [ cfg.package ];
+25 -27
nixos/modules/programs/firefox.nix
···
{ pkgs, config, lib, ... }:
-
with lib;
-
let
cfg = config.programs.firefox;
···
in
{
options.programs.firefox = {
-
enable = mkEnableOption "the Firefox web browser";
-
package = mkOption {
-
type = types.package;
default = pkgs.firefox;
description = "Firefox package to use.";
-
defaultText = literalExpression "pkgs.firefox";
relatedPackages = [
"firefox"
"firefox-beta-bin"
···
];
};
-
wrapperConfig = mkOption {
-
type = types.attrs;
default = {};
description = "Arguments to pass to Firefox wrapper";
};
-
policies = mkOption {
type = policyFormat.type;
default = { };
description = ''
···
'';
};
-
preferences = mkOption {
-
type = with types; attrsOf (oneOf [ bool int str ]);
default = { };
description = ''
Preferences to set from `about:config`.
···
'';
};
-
preferencesStatus = mkOption {
-
type = types.enum [ "default" "locked" "user" "clear" ];
default = "locked";
description = ''
The status of `firefox.preferences`.
···
'';
};
-
languagePacks = mkOption {
# Available languages can be found in https://releases.mozilla.org/pub/firefox/releases/${cfg.package.version}/linux-x86_64/xpi/
-
type = types.listOf (types.enum ([
"ach"
"af"
"an"
···
'';
};
-
autoConfig = mkOption {
-
type = types.lines;
default = "";
description = ''
AutoConfig files can be used to set and lock preferences that are not covered
···
};
nativeMessagingHosts = ({
-
packages = mkOption {
-
type = types.listOf types.package;
default = [];
description = ''
Additional packages containing native messaging hosts that should be made available to Firefox extensions.
'';
};
-
}) // (mapAttrs (k: v: mkEnableOption "${v.name} support") nmhOptions);
};
config = let
-
forEachEnabledNmh = fn: flatten (mapAttrsToList (k: v: lib.optional cfg.nativeMessagingHosts.${k} (fn k v)) nmhOptions);
-
in mkIf cfg.enable {
warnings = forEachEnabledNmh (k: v:
"The `programs.firefox.nativeMessagingHosts.${k}` option is deprecated, " +
"please add `${v.package.pname}` to `programs.firefox.nativeMessagingHosts.packages` instead."
···
let
policiesJSON = policyFormat.generate "firefox-policies.json" { inherit (cfg) policies; };
in
-
mkIf (cfg.policies != { }) {
"firefox/policies/policies.json".source = "${policiesJSON}";
};
# Preferences are converted into a policy
programs.firefox.policies = {
DisableAppUpdate = true;
-
Preferences = (mapAttrs
(_: value: { Value = value; Status = cfg.preferencesStatus; })
cfg.preferences);
-
ExtensionSettings = listToAttrs (map
-
(lang: nameValuePair
"langpack-${lang}@firefox.mozilla.org"
{
installation_mode = "normal_installed";
···
};
};
-
meta.maintainers = with maintainers; [ danth ];
}
···
{ pkgs, config, lib, ... }:
let
cfg = config.programs.firefox;
···
in
{
options.programs.firefox = {
+
enable = lib.mkEnableOption "the Firefox web browser";
+
package = lib.mkOption {
+
type = lib.types.package;
default = pkgs.firefox;
description = "Firefox package to use.";
+
defaultText = lib.literalExpression "pkgs.firefox";
relatedPackages = [
"firefox"
"firefox-beta-bin"
···
];
};
+
wrapperConfig = lib.mkOption {
+
type = lib.types.attrs;
default = {};
description = "Arguments to pass to Firefox wrapper";
};
+
policies = lib.mkOption {
type = policyFormat.type;
default = { };
description = ''
···
'';
};
+
preferences = lib.mkOption {
+
type = with lib.types; attrsOf (oneOf [ bool int str ]);
default = { };
description = ''
Preferences to set from `about:config`.
···
'';
};
+
preferencesStatus = lib.mkOption {
+
type = lib.types.enum [ "default" "locked" "user" "clear" ];
default = "locked";
description = ''
The status of `firefox.preferences`.
···
'';
};
+
languagePacks = lib.mkOption {
# Available languages can be found in https://releases.mozilla.org/pub/firefox/releases/${cfg.package.version}/linux-x86_64/xpi/
+
type = lib.types.listOf (lib.types.enum ([
"ach"
"af"
"an"
···
'';
};
+
autoConfig = lib.mkOption {
+
type = lib.types.lines;
default = "";
description = ''
AutoConfig files can be used to set and lock preferences that are not covered
···
};
nativeMessagingHosts = ({
+
packages = lib.mkOption {
+
type = lib.types.listOf lib.types.package;
default = [];
description = ''
Additional packages containing native messaging hosts that should be made available to Firefox extensions.
'';
};
+
}) // (builtins.mapAttrs (k: v: lib.mkEnableOption "${v.name} support") nmhOptions);
};
config = let
+
forEachEnabledNmh = fn: lib.flatten (lib.mapAttrsToList (k: v: lib.optional cfg.nativeMessagingHosts.${k} (fn k v)) nmhOptions);
+
in lib.mkIf cfg.enable {
warnings = forEachEnabledNmh (k: v:
"The `programs.firefox.nativeMessagingHosts.${k}` option is deprecated, " +
"please add `${v.package.pname}` to `programs.firefox.nativeMessagingHosts.packages` instead."
···
let
policiesJSON = policyFormat.generate "firefox-policies.json" { inherit (cfg) policies; };
in
+
lib.mkIf (cfg.policies != { }) {
"firefox/policies/policies.json".source = "${policiesJSON}";
};
# Preferences are converted into a policy
programs.firefox.policies = {
DisableAppUpdate = true;
+
Preferences = (builtins.mapAttrs
(_: value: { Value = value; Status = cfg.preferencesStatus; })
cfg.preferences);
+
ExtensionSettings = builtins.listToAttrs (builtins.map
+
(lang: builtins.nameValuePair
"langpack-${lang}@firefox.mozilla.org"
{
installation_mode = "normal_installed";
···
};
};
+
meta.maintainers = with lib.maintainers; [ danth ];
}
+19 -21
nixos/modules/programs/firejail.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.firejail;
···
else { executable = value; desktop = null; profile = null; extraArgs = []; };
args = lib.escapeShellArgs (
opts.extraArgs
-
++ (optional (opts.profile != null) "--profile=${toString opts.profile}")
);
in
''
cat <<_EOF >$out/bin/${command}
#! ${pkgs.runtimeShell} -e
-
exec /run/wrappers/bin/firejail ${args} -- ${toString opts.executable} "\$@"
_EOF
chmod 0755 $out/bin/${command}
···
in {
options.programs.firejail = {
-
enable = mkEnableOption "firejail, a sandboxing tool for Linux";
-
wrappedBinaries = mkOption {
-
type = types.attrsOf (types.either types.path (types.submodule {
options = {
-
executable = mkOption {
-
type = types.path;
description = "Executable to run sandboxed";
-
example = literalExpression ''"''${lib.getBin pkgs.firefox}/bin/firefox"'';
};
-
desktop = mkOption {
-
type = types.nullOr types.path;
default = null;
description = ".desktop file to modify. Only necessary if it uses the absolute path to the executable.";
-
example = literalExpression ''"''${pkgs.firefox}/share/applications/firefox.desktop"'';
};
-
profile = mkOption {
-
type = types.nullOr types.path;
default = null;
description = "Profile to use";
-
example = literalExpression ''"''${pkgs.firejail}/etc/firejail/firefox.profile"'';
};
-
extraArgs = mkOption {
-
type = types.listOf types.str;
default = [];
description = "Extra arguments to pass to firejail";
example = [ "--private=~/.firejail_home" ];
···
};
}));
default = {};
-
example = literalExpression ''
{
firefox = {
executable = "''${lib.getBin pkgs.firefox}/bin/firefox";
···
};
};
-
config = mkIf cfg.enable {
security.wrappers.firejail =
{ setuid = true;
owner = "root";
···
environment.systemPackages = [ pkgs.firejail ] ++ [ wrappedBins ];
};
-
meta.maintainers = with maintainers; [ peterhoeg ];
}
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.firejail;
···
else { executable = value; desktop = null; profile = null; extraArgs = []; };
args = lib.escapeShellArgs (
opts.extraArgs
+
++ (lib.optional (opts.profile != null) "--profile=${builtins.toString opts.profile}")
);
in
''
cat <<_EOF >$out/bin/${command}
#! ${pkgs.runtimeShell} -e
+
exec /run/wrappers/bin/firejail ${args} -- ${builtins.toString opts.executable} "\$@"
_EOF
chmod 0755 $out/bin/${command}
···
in {
options.programs.firejail = {
+
enable = lib.mkEnableOption "firejail, a sandboxing tool for Linux";
+
wrappedBinaries = lib.mkOption {
+
type = lib.types.attrsOf (lib.types.either lib.types.path (lib.types.submodule {
options = {
+
executable = lib.mkOption {
+
type = lib.types.path;
description = "Executable to run sandboxed";
+
example = lib.literalExpression ''"''${lib.getBin pkgs.firefox}/bin/firefox"'';
};
+
desktop = lib.mkOption {
+
type = lib.types.nullOr lib.types.path;
default = null;
description = ".desktop file to modify. Only necessary if it uses the absolute path to the executable.";
+
example = lib.literalExpression ''"''${pkgs.firefox}/share/applications/firefox.desktop"'';
};
+
profile = lib.mkOption {
+
type = lib.types.nullOr lib.types.path;
default = null;
description = "Profile to use";
+
example = lib.literalExpression ''"''${pkgs.firejail}/etc/firejail/firefox.profile"'';
};
+
extraArgs = lib.mkOption {
+
type = lib.types.listOf lib.types.str;
default = [];
description = "Extra arguments to pass to firejail";
example = [ "--private=~/.firejail_home" ];
···
};
}));
default = {};
+
example = lib.literalExpression ''
{
firefox = {
executable = "''${lib.getBin pkgs.firefox}/bin/firefox";
···
};
};
+
config = lib.mkIf cfg.enable {
security.wrappers.firejail =
{ setuid = true;
owner = "root";
···
environment.systemPackages = [ pkgs.firejail ] ++ [ wrappedBins ];
};
+
meta.maintainers = with lib.maintainers; [ peterhoeg ];
}
+38 -40
nixos/modules/programs/fish.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfge = config.environment;
cfg = config.programs.fish;
-
fishAbbrs = concatStringsSep "\n" (
-
mapAttrsFlatten (k: v: "abbr -ag ${k} ${escapeShellArg v}")
cfg.shellAbbrs
);
-
fishAliases = concatStringsSep "\n" (
-
mapAttrsFlatten (k: v: "alias ${k} ${escapeShellArg v}")
-
(filterAttrs (k: v: v != null) cfg.shellAliases)
);
envShellInit = pkgs.writeText "shellInit" cfge.shellInit;
···
programs.fish = {
-
enable = mkOption {
default = false;
description = ''
Whether to configure fish as an interactive shell.
'';
-
type = types.bool;
};
-
package = mkPackageOption pkgs "fish" { };
-
useBabelfish = mkOption {
-
type = types.bool;
default = false;
description = ''
If enabled, the configured environment will be translated to native fish using [babelfish](https://github.com/bouk/babelfish).
···
'';
};
-
vendor.config.enable = mkOption {
-
type = types.bool;
default = true;
description = ''
Whether fish should source configuration snippets provided by other packages.
'';
};
-
vendor.completions.enable = mkOption {
-
type = types.bool;
default = true;
description = ''
Whether fish should use completion files provided by other packages.
'';
};
-
vendor.functions.enable = mkOption {
-
type = types.bool;
default = true;
description = ''
Whether fish should autoload fish functions provided by other packages.
'';
};
-
shellAbbrs = mkOption {
default = {};
example = {
gco = "git checkout";
···
description = ''
Set of fish abbreviations.
'';
-
type = with types; attrsOf str;
};
-
shellAliases = mkOption {
default = {};
description = ''
Set of aliases for fish shell, which overrides {option}`environment.shellAliases`.
See {option}`environment.shellAliases` for an option format description.
'';
-
type = with types; attrsOf (nullOr (either str path));
};
-
shellInit = mkOption {
default = "";
description = ''
Shell script code called during fish shell initialisation.
'';
-
type = types.lines;
};
-
loginShellInit = mkOption {
default = "";
description = ''
Shell script code called during fish login shell initialisation.
'';
-
type = types.lines;
};
-
interactiveShellInit = mkOption {
default = "";
description = ''
Shell script code called during interactive fish shell initialisation.
'';
-
type = types.lines;
};
-
promptInit = mkOption {
default = "";
description = ''
Shell script code used to initialise fish prompt.
'';
-
type = types.lines;
};
};
};
-
config = mkIf cfg.enable {
-
programs.fish.shellAliases = mapAttrs (name: mkDefault) cfge.shellAliases;
# Required for man completions
documentation.man.generateCaches = lib.mkDefault true;
-
environment = mkMerge [
-
(mkIf cfg.useBabelfish
{
etc."fish/setEnvironment.fish".source = babelfishTranslate config.system.build.setEnvironment "setEnvironment";
etc."fish/shellInit.fish".source = babelfishTranslate envShellInit "shellInit";
···
etc."fish/interactiveShellInit.fish".source = babelfishTranslate envInteractiveShellInit "interactiveShellInit";
})
-
(mkIf (!cfg.useBabelfish)
{
etc."fish/foreign-env/shellInit".source = envShellInit;
etc."fish/foreign-env/loginShellInit".source = envLoginShellInit;
···
pathName = substring storeLength (stringLength package - storeLength) package;
in (package.name or pathName) + "_fish-completions")
( { inherit package; } //
-
optionalAttrs (package ? meta.priority) { meta.priority = package.meta.priority; })
''
mkdir -p $out
if [ -d $package/share/man ]; then
···
pkgs.buildEnv {
name = "system_fish-completions";
ignoreCollisions = true;
-
paths = map generateCompletions config.environment.systemPackages;
};
}
# include programs that bring their own completions
{
pathsToLink = []
-
++ optional cfg.vendor.config.enable "/share/fish/vendor_conf.d"
-
++ optional cfg.vendor.completions.enable "/share/fish/vendor_completions.d"
-
++ optional cfg.vendor.functions.enable "/share/fish/vendor_functions.d";
}
{ systemPackages = [ cfg.package ]; }
···
{ config, lib, pkgs, ... }:
let
cfge = config.environment;
cfg = config.programs.fish;
+
fishAbbrs = builtins.concatStringsSep "\n" (
+
lib.mapAttrsFlatten (k: v: "abbr -ag ${k} ${builtins.escapeShellArg v}")
cfg.shellAbbrs
);
+
fishAliases = builtins.concatStringsSep "\n" (
+
builtins.mapAttrsFlatten (k: v: "alias ${k} ${builtins.escapeShellArg v}")
+
(builtins.filterAttrs (k: v: v != null) cfg.shellAliases)
);
envShellInit = pkgs.writeText "shellInit" cfge.shellInit;
···
programs.fish = {
+
enable = lib.mkOption {
default = false;
description = ''
Whether to configure fish as an interactive shell.
'';
+
type = lib.types.bool;
};
+
package = lib.mkPackageOption pkgs "fish" { };
+
useBabelfish = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
If enabled, the configured environment will be translated to native fish using [babelfish](https://github.com/bouk/babelfish).
···
'';
};
+
vendor.config.enable = lib.mkOption {
+
type = lib.types.bool;
default = true;
description = ''
Whether fish should source configuration snippets provided by other packages.
'';
};
+
vendor.completions.enable = lib.mkOption {
+
type = lib.types.bool;
default = true;
description = ''
Whether fish should use completion files provided by other packages.
'';
};
+
vendor.functions.enable = lib.mkOption {
+
type = lib.types.bool;
default = true;
description = ''
Whether fish should autoload fish functions provided by other packages.
'';
};
+
shellAbbrs = lib.mkOption {
default = {};
example = {
gco = "git checkout";
···
description = ''
Set of fish abbreviations.
'';
+
type = with lib.types; attrsOf str;
};
+
shellAliases = lib.mkOption {
default = {};
description = ''
Set of aliases for fish shell, which overrides {option}`environment.shellAliases`.
See {option}`environment.shellAliases` for an option format description.
'';
+
type = with lib.types; attrsOf (nullOr (either str path));
};
+
shellInit = lib.mkOption {
default = "";
description = ''
Shell script code called during fish shell initialisation.
'';
+
type = lib.types.lines;
};
+
loginShellInit = lib.mkOption {
default = "";
description = ''
Shell script code called during fish login shell initialisation.
'';
+
type = lib.types.lines;
};
+
interactiveShellInit = lib.mkOption {
default = "";
description = ''
Shell script code called during interactive fish shell initialisation.
'';
+
type = lib.types.lines;
};
+
promptInit = lib.mkOption {
default = "";
description = ''
Shell script code used to initialise fish prompt.
'';
+
type = lib.types.lines;
};
};
};
+
config = lib.mkIf cfg.enable {
+
programs.fish.shellAliases = builtins.mapAttrs (name: lib.mkDefault) cfge.shellAliases;
# Required for man completions
documentation.man.generateCaches = lib.mkDefault true;
+
environment = lib.mkMerge [
+
(lib.mkIf cfg.useBabelfish
{
etc."fish/setEnvironment.fish".source = babelfishTranslate config.system.build.setEnvironment "setEnvironment";
etc."fish/shellInit.fish".source = babelfishTranslate envShellInit "shellInit";
···
etc."fish/interactiveShellInit.fish".source = babelfishTranslate envInteractiveShellInit "interactiveShellInit";
})
+
(lib.mkIf (!cfg.useBabelfish)
{
etc."fish/foreign-env/shellInit".source = envShellInit;
etc."fish/foreign-env/loginShellInit".source = envLoginShellInit;
···
pathName = substring storeLength (stringLength package - storeLength) package;
in (package.name or pathName) + "_fish-completions")
( { inherit package; } //
+
lib.optionalAttrs (package ? meta.priority) { meta.priority = package.meta.priority; })
''
mkdir -p $out
if [ -d $package/share/man ]; then
···
pkgs.buildEnv {
name = "system_fish-completions";
ignoreCollisions = true;
+
paths = builtins.map generateCompletions config.environment.systemPackages;
};
}
# include programs that bring their own completions
{
pathsToLink = []
+
++ lib.optional cfg.vendor.config.enable "/share/fish/vendor_conf.d"
+
++ lib.optional cfg.vendor.completions.enable "/share/fish/vendor_completions.d"
+
++ lib.optional cfg.vendor.functions.enable "/share/fish/vendor_functions.d";
}
{ systemPackages = [ cfg.package ]; }
+4 -6
nixos/modules/programs/flashrom.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.flashrom;
in
{
options.programs.flashrom = {
-
enable = mkOption {
-
type = types.bool;
default = false;
description = ''
Installs flashrom and configures udev rules for programmers
···
group.
'';
};
-
package = mkPackageOption pkgs "flashrom" { };
};
-
config = mkIf cfg.enable {
services.udev.packages = [ cfg.package ];
environment.systemPackages = [ cfg.package ];
};
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.flashrom;
in
{
options.programs.flashrom = {
+
enable = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Installs flashrom and configures udev rules for programmers
···
group.
'';
};
+
package = lib.mkPackageOption pkgs "flashrom" { };
};
+
config = lib.mkIf cfg.enable {
services.udev.packages = [ cfg.package ];
environment.systemPackages = [ cfg.package ];
};
+3 -5
nixos/modules/programs/flexoptix-app.nix
···
{ config, pkgs, lib, ... }:
-
with lib;
-
let
cfg = config.programs.flexoptix-app;
in {
options = {
programs.flexoptix-app = {
-
enable = mkEnableOption "FLEXOPTIX app + udev rules";
-
package = mkPackageOption pkgs "flexoptix-app" { };
};
};
-
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
services.udev.packages = [ cfg.package ];
};
···
{ config, pkgs, lib, ... }:
let
cfg = config.programs.flexoptix-app;
in {
options = {
programs.flexoptix-app = {
+
enable = lib.mkEnableOption "FLEXOPTIX app + udev rules";
+
package = lib.mkPackageOption pkgs "flexoptix-app" { };
};
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
services.udev.packages = [ cfg.package ];
};
+5 -7
nixos/modules/programs/freetds.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.environment.freetds;
···
options = {
-
environment.freetds = mkOption {
-
type = types.attrsOf types.str;
default = {};
-
example = literalExpression ''
{ MYDATABASE = '''
host = 10.0.2.100
port = 1433
···
###### implementation
-
config = mkIf (length (attrNames cfg) > 0) {
environment.variables.FREETDSCONF = "/etc/freetds.conf";
environment.variables.FREETDS = "/etc/freetds.conf";
environment.variables.SYBASE = "${pkgs.freetds}";
environment.etc."freetds.conf" = { text =
-
(concatStrings (mapAttrsToList (name: value:
''
[${name}]
${value}
···
{ config, lib, pkgs, ... }:
let
cfg = config.environment.freetds;
···
options = {
+
environment.freetds = lib.mkOption {
+
type = lib.types.attrsOf lib.types.str;
default = {};
+
example = lib.literalExpression ''
{ MYDATABASE = '''
host = 10.0.2.100
port = 1433
···
###### implementation
+
config = lib.mkIf (builtins.length (builtins.attrNames cfg) > 0) {
environment.variables.FREETDSCONF = "/etc/freetds.conf";
environment.variables.FREETDS = "/etc/freetds.conf";
environment.variables.SYBASE = "${pkgs.freetds}";
environment.etc."freetds.conf" = { text =
+
(lib.concatStrings (lib.mapAttrsToList (name: value:
''
[${name}]
${value}
+7 -9
nixos/modules/programs/fuse.nix
···
{ config, lib, ... }:
-
with lib;
-
let
cfg = config.programs.fuse;
in {
-
meta.maintainers = with maintainers; [ primeos ];
options.programs.fuse = {
-
mountMax = mkOption {
# In the C code it's an "int" (i.e. signed and at least 16 bit), but
# negative numbers obviously make no sense:
-
type = types.ints.between 0 32767; # 2^15 - 1
default = 1000;
description = ''
Set the maximum number of FUSE mounts allowed to non-root users.
'';
};
-
userAllowOther = mkOption {
-
type = types.bool;
default = false;
description = ''
Allow non-root users to specify the allow_other or allow_root mount
···
config = {
environment.etc."fuse.conf".text = ''
-
${optionalString (!cfg.userAllowOther) "#"}user_allow_other
-
mount_max = ${toString cfg.mountMax}
'';
};
}
···
{ config, lib, ... }:
let
cfg = config.programs.fuse;
in {
+
meta.maintainers = with lib.maintainers; [ primeos ];
options.programs.fuse = {
+
mountMax = lib.mkOption {
# In the C code it's an "int" (i.e. signed and at least 16 bit), but
# negative numbers obviously make no sense:
+
type = lib.types.ints.between 0 32767; # 2^15 - 1
default = 1000;
description = ''
Set the maximum number of FUSE mounts allowed to non-root users.
'';
};
+
userAllowOther = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Allow non-root users to specify the allow_other or allow_root mount
···
config = {
environment.etc."fuse.conf".text = ''
+
${lib.optionalString (!cfg.userAllowOther) "#"}user_allow_other
+
mount_max = ${builtins.toString cfg.mountMax}
'';
};
}
+9 -11
nixos/modules/programs/gamemode.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.gamemode;
settingsFormat = pkgs.formats.ini { };
···
{
options = {
programs.gamemode = {
-
enable = mkEnableOption "GameMode to optimise system performance on demand";
-
enableRenice = mkEnableOption "CAP_SYS_NICE on gamemoded to support lowering process niceness" // {
default = true;
};
-
settings = mkOption {
type = settingsFormat.type;
default = { };
description = ''
System-wide configuration for GameMode (/etc/gamemode.ini).
See gamemoded(8) man page for available settings.
'';
-
example = literalExpression ''
{
general = {
renice = 10;
···
};
};
-
config = mkIf cfg.enable {
environment = {
systemPackages = [ pkgs.gamemode ];
etc."gamemode.ini".source = configFile;
···
security = {
polkit.enable = true;
-
wrappers = mkIf cfg.enableRenice {
gamemoded = {
owner = "root";
group = "root";
···
#
# This uses a link farm to make sure other wrapped executables
# aren't included in PATH.
-
environment.PATH = mkForce (pkgs.linkFarm "pkexec" [
{
name = "pkexec";
path = "${config.security.wrapperDir}/pkexec";
}
]);
-
serviceConfig.ExecStart = mkIf cfg.enableRenice [
"" # Tell systemd to clear the existing ExecStart list, to prevent appending to it.
"${config.security.wrapperDir}/gamemoded"
];
···
};
meta = {
-
maintainers = with maintainers; [ kira-bruneau ];
};
}
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.gamemode;
settingsFormat = pkgs.formats.ini { };
···
{
options = {
programs.gamemode = {
+
enable = lib.mkEnableOption "GameMode to optimise system performance on demand";
+
enableRenice = lib.mkEnableOption "CAP_SYS_NICE on gamemoded to support lowering process niceness" // {
default = true;
};
+
settings = lib.mkOption {
type = settingsFormat.type;
default = { };
description = ''
System-wide configuration for GameMode (/etc/gamemode.ini).
See gamemoded(8) man page for available settings.
'';
+
example = lib.literalExpression ''
{
general = {
renice = 10;
···
};
};
+
config = lib.mkIf cfg.enable {
environment = {
systemPackages = [ pkgs.gamemode ];
etc."gamemode.ini".source = configFile;
···
security = {
polkit.enable = true;
+
wrappers = lib.mkIf cfg.enableRenice {
gamemoded = {
owner = "root";
group = "root";
···
#
# This uses a link farm to make sure other wrapped executables
# aren't included in PATH.
+
environment.PATH = lib.mkForce (pkgs.linkFarm "pkexec" [
{
name = "pkexec";
path = "${config.security.wrapperDir}/pkexec";
}
]);
+
serviceConfig.ExecStart = lib.mkIf cfg.enableRenice [
"" # Tell systemd to clear the existing ExecStart list, to prevent appending to it.
"${config.security.wrapperDir}/gamemoded"
];
···
};
meta = {
+
maintainers = with lib.maintainers; [ kira-bruneau ];
};
}
+18 -18
nixos/modules/programs/gamescope.nix
···
, pkgs
, ...
}:
-
with lib; let
cfg = config.programs.gamescope;
gamescope =
let
wrapperArgs =
-
optional (cfg.args != [ ])
-
''--add-flags "${toString cfg.args}"''
-
++ builtins.attrValues (mapAttrs (var: val: "--set-default ${var} ${val}") cfg.env);
in
pkgs.runCommand "gamescope" { nativeBuildInputs = [ pkgs.makeBinaryWrapper ]; } ''
mkdir -p $out/bin
makeWrapper ${cfg.package}/bin/gamescope $out/bin/gamescope --inherit-argv0 \
-
${toString wrapperArgs}
'';
in
{
options.programs.gamescope = {
-
enable = mkEnableOption "gamescope, the SteamOS session compositing window manager";
-
package = mkPackageOption pkgs "gamescope" { };
-
capSysNice = mkOption {
-
type = types.bool;
default = false;
description = ''
Add cap_sys_nice capability to the GameScope
···
'';
};
-
args = mkOption {
-
type = types.listOf types.str;
default = [ ];
example = [ "--rt" "--prefer-vk-device 8086:9bc4" ];
description = ''
···
'';
};
-
env = mkOption {
-
type = types.attrsOf types.str;
default = { };
-
example = literalExpression ''
# for Prime render offload on Nvidia laptops.
# Also requires `hardware.nvidia.prime.offload.enable`.
{
···
};
};
-
config = mkIf cfg.enable {
-
security.wrappers = mkIf cfg.capSysNice {
gamescope = {
owner = "root";
group = "root";
···
};
};
-
environment.systemPackages = mkIf (!cfg.capSysNice) [ gamescope ];
};
-
meta.maintainers = with maintainers; [ nrdxp ];
}
···
, pkgs
, ...
}:
+
let
cfg = config.programs.gamescope;
gamescope =
let
wrapperArgs =
+
lib.optional (cfg.args != [ ])
+
''--add-flags "${builtins.toString cfg.args}"''
+
++ builtins.attrValues (builtins.mapAttrs (var: val: "--set-default ${var} ${val}") cfg.env);
in
pkgs.runCommand "gamescope" { nativeBuildInputs = [ pkgs.makeBinaryWrapper ]; } ''
mkdir -p $out/bin
makeWrapper ${cfg.package}/bin/gamescope $out/bin/gamescope --inherit-argv0 \
+
${builtins.toString wrapperArgs}
'';
in
{
options.programs.gamescope = {
+
enable = lib.mkEnableOption "gamescope, the SteamOS session compositing window manager";
+
package = lib.mkPackageOption pkgs "gamescope" { };
+
capSysNice = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Add cap_sys_nice capability to the GameScope
···
'';
};
+
args = lib.mkOption {
+
type = lib.types.listOf lib.types.str;
default = [ ];
example = [ "--rt" "--prefer-vk-device 8086:9bc4" ];
description = ''
···
'';
};
+
env = lib.mkOption {
+
type = lib.types.attrsOf lib.types.str;
default = { };
+
example = lib.literalExpression ''
# for Prime render offload on Nvidia laptops.
# Also requires `hardware.nvidia.prime.offload.enable`.
{
···
};
};
+
config = lib.mkIf cfg.enable {
+
security.wrappers = lib.mkIf cfg.capSysNice {
gamescope = {
owner = "root";
group = "root";
···
};
};
+
environment.systemPackages = lib.mkIf (!cfg.capSysNice) [ gamescope ];
};
+
meta.maintainers = with lib.maintainers; [ nrdxp ];
}
+3 -5
nixos/modules/programs/geary.nix
···
{ config, pkgs, lib, ... }:
-
with lib;
-
let
cfg = config.programs.geary;
in {
meta = {
-
maintainers = teams.gnome.members;
};
options = {
-
programs.geary.enable = mkEnableOption "Geary, a Mail client for GNOME";
};
-
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.gnome.geary ];
programs.dconf.enable = true;
services.gnome.gnome-keyring.enable = true;
···
{ config, pkgs, lib, ... }:
let
cfg = config.programs.geary;
in {
meta = {
+
maintainers = lib.teams.gnome.members;
};
options = {
+
programs.geary.enable = lib.mkEnableOption "Geary, a Mail client for GNOME";
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.gnome.geary ];
programs.dconf.enable = true;
services.gnome.gnome-keyring.enable = true;
+16 -18
nixos/modules/programs/git.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.git;
in
···
{
options = {
programs.git = {
-
enable = mkEnableOption "git, a distributed version control system";
-
package = mkPackageOption pkgs "git" {
example = "gitFull";
};
-
config = mkOption {
type =
-
with types;
let
gitini = attrsOf (attrsOf anything);
in
either gitini (listOf gitini) // {
merge = loc: defs:
let
-
config = foldl'
-
(acc: { value, ... }@x: acc // (if isList value then {
ordered = acc.ordered ++ value;
} else {
unordered = acc.unordered ++ [ x ];
···
};
prompt = {
-
enable = mkEnableOption "automatically sourcing git-prompt.sh. This does not change $PS1; it simply provides relevant utility functions";
};
lfs = {
-
enable = mkEnableOption "git-lfs (Large File Storage)";
-
package = mkPackageOption pkgs "git-lfs" { };
};
};
};
-
config = mkMerge [
-
(mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
-
environment.etc.gitconfig = mkIf (cfg.config != [ ]) {
-
text = concatMapStringsSep "\n" generators.toGitINI cfg.config;
};
})
-
(mkIf (cfg.enable && cfg.lfs.enable) {
environment.systemPackages = [ cfg.lfs.package ];
programs.git.config = {
filter.lfs = {
···
};
};
})
-
(mkIf (cfg.enable && cfg.prompt.enable) {
environment.interactiveShellInit = ''
source ${cfg.package}/share/bash-completion/completions/git-prompt.sh
'';
})
];
-
meta.maintainers = with maintainers; [ figsoda ];
}
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.git;
in
···
{
options = {
programs.git = {
+
enable = lib.mkEnableOption "git, a distributed version control system";
+
package = lib.mkPackageOption pkgs "git" {
example = "gitFull";
};
+
config = lib.mkOption {
type =
+
with lib.types;
let
gitini = attrsOf (attrsOf anything);
in
either gitini (listOf gitini) // {
merge = loc: defs:
let
+
config = builtins.foldl'
+
(acc: { value, ... }@x: acc // (if builtins.isList value then {
ordered = acc.ordered ++ value;
} else {
unordered = acc.unordered ++ [ x ];
···
};
prompt = {
+
enable = lib.mkEnableOption "automatically sourcing git-prompt.sh. This does not change $PS1; it simply provides relevant utility functions";
};
lfs = {
+
enable = lib.mkEnableOption "git-lfs (Large File Storage)";
+
package = lib.mkPackageOption pkgs "git-lfs" { };
};
};
};
+
config = lib.mkMerge [
+
(lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
+
environment.etc.gitconfig = lib.mkIf (cfg.config != [ ]) {
+
text = lib.concatMapStringsSep "\n" lib.generators.toGitINI cfg.config;
};
})
+
(lib.mkIf (cfg.enable && cfg.lfs.enable) {
environment.systemPackages = [ cfg.lfs.package ];
programs.git.config = {
filter.lfs = {
···
};
};
})
+
(lib.mkIf (cfg.enable && cfg.prompt.enable) {
environment.interactiveShellInit = ''
source ${cfg.package}/share/bash-completion/completions/git-prompt.sh
'';
})
];
+
meta.maintainers = with lib.maintainers; [ figsoda ];
}
+4 -6
nixos/modules/programs/gphoto2.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
{
-
meta.maintainers = [ maintainers.league ];
###### interface
options = {
programs.gphoto2 = {
-
enable = mkOption {
default = false;
-
type = types.bool;
description = ''
Whether to configure system to use gphoto2.
To grant digital camera access to a user, the user must
···
};
###### implementation
-
config = mkIf config.programs.gphoto2.enable {
services.udev.packages = [ pkgs.libgphoto2 ];
environment.systemPackages = [ pkgs.gphoto2 ];
users.groups.camera = {};
···
{ config, lib, pkgs, ... }:
{
+
meta.maintainers = [ lib.maintainers.league ];
###### interface
options = {
programs.gphoto2 = {
+
enable = lib.mkOption {
default = false;
+
type = lib.types.bool;
description = ''
Whether to configure system to use gphoto2.
To grant digital camera access to a user, the user must
···
};
###### implementation
+
config = lib.mkIf config.programs.gphoto2.enable {
services.udev.packages = [ pkgs.libgphoto2 ];
environment.systemPackages = [ pkgs.gphoto2 ];
users.groups.camera = {};
+2 -4
nixos/modules/programs/haguichi.nix
···
{ lib, pkgs, config, ... }:
-
with lib;
-
{
options.programs.haguichi = {
-
enable = mkEnableOption "Haguichi, a Linux GUI frontend to the proprietary LogMeIn Hamachi";
};
-
config = mkIf config.programs.haguichi.enable {
environment.systemPackages = with pkgs; [ haguichi ];
services.logmein-hamachi.enable = true;
···
{ lib, pkgs, config, ... }:
{
options.programs.haguichi = {
+
enable = lib.mkEnableOption "Haguichi, a Linux GUI frontend to the proprietary LogMeIn Hamachi";
};
+
config = lib.mkIf config.programs.haguichi.enable {
environment.systemPackages = with pkgs; [ haguichi ];
services.logmein-hamachi.enable = true;
+1 -3
nixos/modules/programs/hamster.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
{
meta.maintainers = pkgs.hamster.meta.maintainers;
options.programs.hamster.enable =
-
mkEnableOption "hamster, a time tracking program";
config = lib.mkIf config.programs.hamster.enable {
environment.systemPackages = [ pkgs.hamster ];
···
{ config, lib, pkgs, ... }:
{
meta.maintainers = pkgs.hamster.meta.maintainers;
options.programs.hamster.enable =
+
lib.mkEnableOption "hamster, a time tracking program";
config = lib.mkIf config.programs.hamster.enable {
environment.systemPackages = [ pkgs.hamster ];
+11 -13
nixos/modules/programs/htop.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.htop;
fmt = value:
-
if isList value then concatStringsSep " " (map fmt value) else
-
if isString value then value else
-
if isBool value then if value then "1" else "0" else
-
if isInt value then toString value else
-
throw "Unrecognized type ${typeOf value} in htop settings";
in
{
options.programs.htop = {
-
package = mkPackageOption pkgs "htop" { };
-
enable = mkEnableOption "htop process monitor";
-
settings = mkOption {
-
type = with types; attrsOf (oneOf [ str int bool (listOf (oneOf [ str int bool ])) ]);
default = {};
example = {
hide_kernel_threads = true;
···
};
};
-
config = mkIf cfg.enable {
environment.systemPackages = [
cfg.package
];
···
environment.etc."htoprc".text = ''
# Global htop configuration
# To change set: programs.htop.settings.KEY = VALUE;
-
'' + concatStringsSep "\n" (mapAttrsToList (key: value: "${key}=${fmt value}") cfg.settings);
};
}
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.htop;
fmt = value:
+
if builtins.isList value then builtins.concatStringsSep " " (builtins.map fmt value) else
+
if builtins.isString value then value else
+
if builtins.isBool value then if value then "1" else "0" else
+
if builtins.isInt value then builtins.toString value else
+
throw "Unrecognized type ${builtins.typeOf value} in htop settings";
in
{
options.programs.htop = {
+
package = lib.mkPackageOption pkgs "htop" { };
+
enable = lib.mkEnableOption "htop process monitor";
+
settings = lib.mkOption {
+
type = with lib.types; attrsOf (oneOf [ str int bool (listOf (oneOf [ str int bool ])) ]);
default = {};
example = {
hide_kernel_threads = true;
···
};
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [
cfg.package
];
···
environment.etc."htoprc".text = ''
# Global htop configuration
# To change set: programs.htop.settings.KEY = VALUE;
+
'' + builtins.concatStringsSep "\n" (lib.mapAttrsToList (key: value: "${key}=${fmt value}") cfg.settings);
};
}
+6 -8
nixos/modules/programs/i3lock.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.i3lock;
···
options = {
programs.i3lock = {
-
enable = mkEnableOption "i3lock";
-
package = mkPackageOption pkgs "i3lock" {
example = "i3lock-color";
extraDescription = ''
::: {.note}
···
:::
'';
};
-
u2fSupport = mkOption {
-
type = types.bool;
default = false;
example = true;
description = ''
···
###### implementation
-
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
-
security.wrappers.i3lock = mkIf cfg.u2fSupport {
setuid = true;
owner = "root";
group = "root";
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.i3lock;
···
options = {
programs.i3lock = {
+
enable = lib.mkEnableOption "i3lock";
+
package = lib.mkPackageOption pkgs "i3lock" {
example = "i3lock-color";
extraDescription = ''
::: {.note}
···
:::
'';
};
+
u2fSupport = lib.mkOption {
+
type = lib.types.bool;
default = false;
example = true;
description = ''
···
###### implementation
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
+
security.wrappers.i3lock = lib.mkIf cfg.u2fSupport {
setuid = true;
owner = "root";
group = "root";
+2 -4
nixos/modules/programs/iftop.nix
···
{ config, pkgs, lib, ... }:
-
with lib;
-
let
cfg = config.programs.iftop;
in {
options = {
-
programs.iftop.enable = mkEnableOption "iftop + setcap wrapper";
};
-
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.iftop ];
security.wrappers.iftop = {
owner = "root";
···
{ config, pkgs, lib, ... }:
let
cfg = config.programs.iftop;
in {
options = {
+
programs.iftop.enable = lib.mkEnableOption "iftop + setcap wrapper";
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.iftop ];
security.wrappers.iftop = {
owner = "root";
+2 -4
nixos/modules/programs/iotop.nix
···
{ config, pkgs, lib, ... }:
-
with lib;
-
let
cfg = config.programs.iotop;
in {
options = {
-
programs.iotop.enable = mkEnableOption "iotop + setcap wrapper";
};
-
config = mkIf cfg.enable {
security.wrappers.iotop = {
owner = "root";
group = "root";
···
{ config, pkgs, lib, ... }:
let
cfg = config.programs.iotop;
in {
options = {
+
programs.iotop.enable = lib.mkEnableOption "iotop + setcap wrapper";
};
+
config = lib.mkIf cfg.enable {
security.wrappers.iotop = {
owner = "root";
group = "root";
+5 -7
nixos/modules/programs/java.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.java;
in
···
programs.java = {
-
enable = mkEnableOption "java" // {
description = ''
Install and setup the Java development kit.
···
'';
};
-
package = mkPackageOption pkgs "jdk" {
example = "jre";
};
-
binfmt = mkEnableOption "binfmt to execute java jar's and classes";
};
};
-
config = mkIf cfg.enable {
-
boot.binfmt.registrations = mkIf cfg.binfmt {
java-class = {
recognitionType = "extension";
magicOrExtension = "class";
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.java;
in
···
programs.java = {
+
enable = lib.mkEnableOption "java" // {
description = ''
Install and setup the Java development kit.
···
'';
};
+
package = lib.mkPackageOption pkgs "jdk" {
example = "jre";
};
+
binfmt = lib.mkEnableOption "binfmt to execute java jar's and classes";
};
};
+
config = lib.mkIf cfg.enable {
+
boot.binfmt.registrations = lib.mkIf cfg.binfmt {
java-class = {
recognitionType = "extension";
magicOrExtension = "class";
+1 -2
nixos/modules/programs/joycond-cemuhook.nix
···
{ lib, pkgs, config, ... }:
-
with lib;
{
options.programs.joycond-cemuhook = {
-
enable = mkEnableOption "joycond-cemuhook, a program to enable support for cemuhook's UDP protocol for joycond devices.";
};
config = lib.mkIf config.programs.joycond-cemuhook.enable {
···
{ lib, pkgs, config, ... }:
{
options.programs.joycond-cemuhook = {
+
enable = lib.mkEnableOption "joycond-cemuhook, a program to enable support for cemuhook's UDP protocol for joycond devices.";
};
config = lib.mkIf config.programs.joycond-cemuhook.enable {
+3 -5
nixos/modules/programs/k3b.nix
···
{ config, pkgs, lib, ... }:
-
with lib;
-
{
# interface
options.programs.k3b = {
-
enable = mkOption {
-
type = types.bool;
default = false;
description = ''
Whether to enable k3b, the KDE disk burning application.
···
};
# implementation
-
config = mkIf config.programs.k3b.enable {
environment.systemPackages = with pkgs; [
k3b
···
{ config, pkgs, lib, ... }:
{
# interface
options.programs.k3b = {
+
enable = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Whether to enable k3b, the KDE disk burning application.
···
};
# implementation
+
config = lib.mkIf config.programs.k3b.enable {
environment.systemPackages = with pkgs; [
k3b
+5 -7
nixos/modules/programs/k40-whisperer.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.k40-whisperer;
pkg = cfg.package.override {
···
in
{
options.programs.k40-whisperer = {
-
enable = mkEnableOption "K40-Whisperer";
-
group = mkOption {
-
type = types.str;
description = ''
Group assigned to the device when connected.
'';
default = "k40";
};
-
package = mkPackageOption pkgs "k40-whisperer" { };
};
-
config = mkIf cfg.enable {
users.groups.${cfg.group} = {};
environment.systemPackages = [ pkg ];
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.k40-whisperer;
pkg = cfg.package.override {
···
in
{
options.programs.k40-whisperer = {
+
enable = lib.mkEnableOption "K40-Whisperer";
+
group = lib.mkOption {
+
type = lib.types.str;
description = ''
Group assigned to the device when connected.
'';
default = "k40";
};
+
package = lib.mkPackageOption pkgs "k40-whisperer" { };
};
+
config = lib.mkIf cfg.enable {
users.groups.${cfg.group} = {};
environment.systemPackages = [ pkg ];
+2 -4
nixos/modules/programs/kbdlight.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.kbdlight;
in
{
-
options.programs.kbdlight.enable = mkEnableOption "kbdlight";
-
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.kbdlight ];
security.wrappers.kbdlight =
{ setuid = true;
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.kbdlight;
in
{
+
options.programs.kbdlight.enable = lib.mkEnableOption "kbdlight";
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.kbdlight ];
security.wrappers.kbdlight =
{ setuid = true;
+2 -3
nixos/modules/programs/kclock.nix
···
{ lib, pkgs, config, ... }:
-
with lib;
let
cfg = config.programs.kclock;
kclockPkg = pkgs.libsForQt5.kclock;
in {
-
options.programs.kclock = { enable = mkEnableOption "KClock"; };
-
config = mkIf cfg.enable {
services.dbus.packages = [ kclockPkg ];
environment.systemPackages = [ kclockPkg ];
};
···
{ lib, pkgs, config, ... }:
let
cfg = config.programs.kclock;
kclockPkg = pkgs.libsForQt5.kclock;
in {
+
options.programs.kclock = { enable = lib.mkEnableOption "KClock"; };
+
config = lib.mkIf cfg.enable {
services.dbus.packages = [ kclockPkg ];
environment.systemPackages = [ kclockPkg ];
};
+3 -4
nixos/modules/programs/kdeconnect.nix
···
{ config, pkgs, lib, ... }:
-
with lib;
{
options.programs.kdeconnect = {
-
enable = mkEnableOption ''
kdeconnect.
Note that it will open the TCP and UDP port from
···
`gnomeExtensions.gsconnect` as an alternative
implementation if you use Gnome
'';
-
package = mkPackageOption pkgs [ "plasma5Packages" "kdeconnect-kde" ] {
example = "gnomeExtensions.gsconnect";
};
};
···
let
cfg = config.programs.kdeconnect;
in
-
mkIf cfg.enable {
environment.systemPackages = [
cfg.package
pkgs.sshfs
···
{ config, pkgs, lib, ... }:
{
options.programs.kdeconnect = {
+
enable = lib.mkEnableOption ''
kdeconnect.
Note that it will open the TCP and UDP port from
···
`gnomeExtensions.gsconnect` as an alternative
implementation if you use Gnome
'';
+
package = lib.mkPackageOption pkgs [ "plasma5Packages" "kdeconnect-kde" ] {
example = "gnomeExtensions.gsconnect";
};
};
···
let
cfg = config.programs.kdeconnect;
in
+
lib.mkIf cfg.enable {
environment.systemPackages = [
cfg.package
pkgs.sshfs
+31 -33
nixos/modules/programs/less.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.less;
configText = if (cfg.configFile != null) then (builtins.readFile cfg.configFile) else ''
#command
-
${concatStringsSep "\n"
-
(mapAttrsToList (command: action: "${command} ${action}") cfg.commands)
}
-
${optionalString cfg.clearDefaultCommands "#stop"}
#line-edit
-
${concatStringsSep "\n"
-
(mapAttrsToList (command: action: "${command} ${action}") cfg.lineEditingKeys)
}
#env
-
${concatStringsSep "\n"
-
(mapAttrsToList (variable: values: "${variable}=${values}") cfg.envVariables)
}
'';
···
# note that environment.nix sets PAGER=less, and
# therefore also enables this module
-
enable = mkEnableOption "less, a file pager";
-
configFile = mkOption {
-
type = types.nullOr types.path;
default = null;
-
example = literalExpression ''"''${pkgs.my-configs}/lesskey"'';
description = ''
Path to lesskey configuration file.
···
'';
};
-
commands = mkOption {
-
type = types.attrsOf types.str;
default = {};
example = {
h = "noaction 5\\e(";
···
description = "Defines new command keys.";
};
-
clearDefaultCommands = mkOption {
-
type = types.bool;
default = false;
description = ''
Clear all default commands.
···
'';
};
-
lineEditingKeys = mkOption {
-
type = types.attrsOf types.str;
default = {};
example = {
e = "abort";
···
description = "Defines new line-editing keys.";
};
-
envVariables = mkOption {
-
type = types.attrsOf types.str;
default = {
LESS = "-R";
};
···
description = "Defines environment variables.";
};
-
lessopen = mkOption {
-
type = types.nullOr types.str;
default = "|${pkgs.lesspipe}/bin/lesspipe.sh %s";
-
defaultText = literalExpression ''"|''${pkgs.lesspipe}/bin/lesspipe.sh %s"'';
description = ''
Before less opens a file, it first gives your input preprocessor a chance to modify the way the contents of the file are displayed.
'';
};
-
lessclose = mkOption {
-
type = types.nullOr types.str;
default = null;
description = ''
When less closes a file opened in such a way, it will call another program, called the input postprocessor,
···
};
};
-
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.less ];
environment.variables = {
-
LESSKEYIN_SYSTEM = toString lessKey;
-
} // optionalAttrs (cfg.lessopen != null) {
LESSOPEN = cfg.lessopen;
-
} // optionalAttrs (cfg.lessclose != null) {
LESSCLOSE = cfg.lessclose;
};
-
warnings = optional (
-
cfg.clearDefaultCommands && (all (x: x != "quit") (attrValues cfg.commands))
) ''
config.programs.less.clearDefaultCommands clears all default commands of less but there is no alternative binding for exiting.
Consider adding a binding for 'quit'.
'';
};
-
meta.maintainers = with maintainers; [ johnazoidberg ];
}
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.less;
configText = if (cfg.configFile != null) then (builtins.readFile cfg.configFile) else ''
#command
+
${builtins.concatStringsSep "\n"
+
(lib.mapAttrsToList (command: action: "${command} ${action}") cfg.commands)
}
+
${lib.optionalString cfg.clearDefaultCommands "#stop"}
#line-edit
+
${builtins.concatStringsSep "\n"
+
(lib.mapAttrsToList (command: action: "${command} ${action}") cfg.lineEditingKeys)
}
#env
+
${builtins.concatStringsSep "\n"
+
(lib.mapAttrsToList (variable: values: "${variable}=${values}") cfg.envVariables)
}
'';
···
# note that environment.nix sets PAGER=less, and
# therefore also enables this module
+
enable = lib.mkEnableOption "less, a file pager";
+
configFile = lib.mkOption {
+
type = lib.types.nullOr lib.types.path;
default = null;
+
example = lib.literalExpression ''"''${pkgs.my-configs}/lesskey"'';
description = ''
Path to lesskey configuration file.
···
'';
};
+
commands = lib.mkOption {
+
type = lib.types.attrsOf lib.types.str;
default = {};
example = {
h = "noaction 5\\e(";
···
description = "Defines new command keys.";
};
+
clearDefaultCommands = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Clear all default commands.
···
'';
};
+
lineEditingKeys = lib.mkOption {
+
type = lib.types.attrsOf lib.types.str;
default = {};
example = {
e = "abort";
···
description = "Defines new line-editing keys.";
};
+
envVariables = lib.mkOption {
+
type = lib.types.attrsOf lib.types.str;
default = {
LESS = "-R";
};
···
description = "Defines environment variables.";
};
+
lessopen = lib.mkOption {
+
type = lib.types.nullOr lib.types.str;
default = "|${pkgs.lesspipe}/bin/lesspipe.sh %s";
+
defaultText = lib.literalExpression ''"|''${pkgs.lesspipe}/bin/lesspipe.sh %s"'';
description = ''
Before less opens a file, it first gives your input preprocessor a chance to modify the way the contents of the file are displayed.
'';
};
+
lessclose = lib.mkOption {
+
type = lib.types.nullOr lib.types.str;
default = null;
description = ''
When less closes a file opened in such a way, it will call another program, called the input postprocessor,
···
};
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.less ];
environment.variables = {
+
LESSKEYIN_SYSTEM = builtins.toString lessKey;
+
} // lib.optionalAttrs (cfg.lessopen != null) {
LESSOPEN = cfg.lessopen;
+
} // lib.optionalAttrs (cfg.lessclose != null) {
LESSCLOSE = cfg.lessclose;
};
+
warnings = lib.optional (
+
cfg.clearDefaultCommands && (builtins.all (x: x != "quit") (builtins.attrValues cfg.commands))
) ''
config.programs.less.clearDefaultCommands clears all default commands of less but there is no alternative binding for exiting.
Consider adding a binding for 'quit'.
'';
};
+
meta.maintainers = with lib.maintainers; [ johnazoidberg ];
}
+3 -5
nixos/modules/programs/liboping.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.liboping;
in {
options.programs.liboping = {
-
enable = mkEnableOption "liboping";
};
-
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [ liboping ];
-
security.wrappers = mkMerge (map (
exec: {
"${exec}" = {
owner = "root";
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.liboping;
in {
options.programs.liboping = {
+
enable = lib.mkEnableOption "liboping";
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ liboping ];
+
security.wrappers = lib.mkMerge (builtins.map (
exec: {
"${exec}" = {
owner = "root";
+9 -11
nixos/modules/programs/light.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.light;
···
options = {
programs.light = {
-
enable = mkOption {
default = false;
-
type = types.bool;
description = ''
Whether to install Light backlight control command
and udev rules granting access to members of the "video" group.
···
};
brightnessKeys = {
-
enable = mkOption {
-
type = types.bool;
default = false;
description = ''
Whether to enable brightness control with keyboard keys.
···
'';
};
-
step = mkOption {
-
type = types.int;
default = 10;
description = ''
The percentage value by which to increase/decrease brightness.
···
};
};
-
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.light ];
services.udev.packages = [ pkgs.light ];
-
services.actkbd = mkIf cfg.brightnessKeys.enable {
enable = true;
bindings = let
light = "${pkgs.light}/bin/light";
-
step = toString cfg.brightnessKeys.step;
in [
{
keys = [ 224 ];
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.light;
···
options = {
programs.light = {
+
enable = lib.mkOption {
default = false;
+
type = lib.types.bool;
description = ''
Whether to install Light backlight control command
and udev rules granting access to members of the "video" group.
···
};
brightnessKeys = {
+
enable = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Whether to enable brightness control with keyboard keys.
···
'';
};
+
step = lib.mkOption {
+
type = lib.types.int;
default = 10;
description = ''
The percentage value by which to increase/decrease brightness.
···
};
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.light ];
services.udev.packages = [ pkgs.light ];
+
services.actkbd = lib.mkIf cfg.brightnessKeys.enable {
enable = true;
bindings = let
light = "${pkgs.light}/bin/light";
+
step = builtins.toString cfg.brightnessKeys.step;
in [
{
keys = [ 224 ];
+2 -3
nixos/modules/programs/mdevctl.nix
···
{ config, pkgs, lib, ... }:
-
with lib;
let
cfg = config.programs.mdevctl;
in {
options.programs.mdevctl = {
-
enable = mkEnableOption "Mediated Device Management";
};
-
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [ mdevctl ];
environment.etc."mdevctl.d/scripts.d/notifiers/.keep".text = "";
···
{ config, pkgs, lib, ... }:
let
cfg = config.programs.mdevctl;
in {
options.programs.mdevctl = {
+
enable = lib.mkEnableOption "Mediated Device Management";
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ mdevctl ];
environment.etc."mdevctl.d/scripts.d/notifiers/.keep".text = "";
+8 -9
nixos/modules/programs/mepo.nix
···
{ pkgs, config, lib, ...}:
-
with lib;
let
cfg = config.programs.mepo;
in
{
options.programs.mepo = {
-
enable = mkEnableOption "Mepo, a fast, simple and hackable OSM map viewer";
locationBackends = {
-
gpsd = mkOption {
-
type = types.bool;
default = false;
description = ''
Whether to enable location detection via gpsd.
···
'';
};
-
geoclue = mkOption {
-
type = types.bool;
default = true;
description = "Whether to enable location detection via geoclue";
};
};
};
-
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [
mepo
] ++ lib.optional cfg.locationBackends.geoclue geoclue2-with-demo-agent
++ lib.optional cfg.locationBackends.gpsd gpsd;
-
services.geoclue2 = mkIf cfg.locationBackends.geoclue {
enable = true;
appConfig.where-am-i = {
isAllowed = true;
···
services.gpsd.enable = cfg.locationBackends.gpsd;
};
-
meta.maintainers = with maintainers; [ laalsaas ];
}
···
{ pkgs, config, lib, ...}:
let
cfg = config.programs.mepo;
in
{
options.programs.mepo = {
+
enable = lib.mkEnableOption "Mepo, a fast, simple and hackable OSM map viewer";
locationBackends = {
+
gpsd = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Whether to enable location detection via gpsd.
···
'';
};
+
geoclue = lib.mkOption {
+
type = lib.types.bool;
default = true;
description = "Whether to enable location detection via geoclue";
};
};
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [
mepo
] ++ lib.optional cfg.locationBackends.geoclue geoclue2-with-demo-agent
++ lib.optional cfg.locationBackends.gpsd gpsd;
+
services.geoclue2 = lib.mkIf cfg.locationBackends.geoclue {
enable = true;
appConfig.where-am-i = {
isAllowed = true;
···
services.gpsd.enable = cfg.locationBackends.gpsd;
};
+
meta.maintainers = with lib.maintainers; [ laalsaas ];
}
+2 -4
nixos/modules/programs/mininet.nix
···
# kernel must have NETNS/VETH/SCHED
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.mininet;
in
{
-
options.programs.mininet.enable = mkEnableOption "Mininet, an emulator for rapid prototyping of Software Defined Networks";
-
config = mkIf cfg.enable {
virtualisation.vswitch.enable = true;
···
# kernel must have NETNS/VETH/SCHED
{ config, lib, pkgs, ... }:
let
cfg = config.programs.mininet;
in
{
+
options.programs.mininet.enable = lib.mkEnableOption "Mininet, an emulator for rapid prototyping of Software Defined Networks";
+
config = lib.mkIf cfg.enable {
virtualisation.vswitch.enable = true;
+15 -17
nixos/modules/programs/msmtp.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.msmtp;
in {
-
meta.maintainers = with maintainers; [ pacien ];
options = {
programs.msmtp = {
-
enable = mkEnableOption "msmtp - an SMTP client";
-
setSendmail = mkOption {
-
type = types.bool;
default = true;
description = ''
Whether to set the system sendmail to msmtp's.
'';
};
-
defaults = mkOption {
-
type = types.attrs;
default = {};
example = {
aliases = "/etc/aliases";
···
'';
};
-
accounts = mkOption {
-
type = with types; attrsOf attrs;
default = {};
example = {
"default" = {
···
'';
};
-
extraConfig = mkOption {
-
type = types.lines;
default = "";
description = ''
Extra lines to add to the msmtp configuration verbatim.
···
};
};
-
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.msmtp ];
-
services.mail.sendmailSetuidWrapper = mkIf cfg.setSendmail {
program = "sendmail";
source = "${pkgs.msmtp}/bin/sendmail";
setuid = false;
···
mkValueString = v:
if v == true then "on"
else if v == false then "off"
-
else generators.mkValueStringDefault {} v;
mkKeyValueString = k: v: "${k} ${mkValueString v}";
mkInnerSectionString =
-
attrs: concatStringsSep "\n" (mapAttrsToList mkKeyValueString attrs);
mkAccountString = name: attrs: ''
account ${name}
${mkInnerSectionString attrs}
···
defaults
${mkInnerSectionString cfg.defaults}
-
${concatStringsSep "\n" (mapAttrsToList mkAccountString cfg.accounts)}
${cfg.extraConfig}
'';
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.msmtp;
in {
+
meta.maintainers = with lib.maintainers; [ pacien ];
options = {
programs.msmtp = {
+
enable = lib.mkEnableOption "msmtp - an SMTP client";
+
setSendmail = lib.mkOption {
+
type = lib.types.bool;
default = true;
description = ''
Whether to set the system sendmail to msmtp's.
'';
};
+
defaults = lib.mkOption {
+
type = lib.types.attrs;
default = {};
example = {
aliases = "/etc/aliases";
···
'';
};
+
accounts = lib.mkOption {
+
type = with lib.types; attrsOf attrs;
default = {};
example = {
"default" = {
···
'';
};
+
extraConfig = lib.mkOption {
+
type = lib.types.lines;
default = "";
description = ''
Extra lines to add to the msmtp configuration verbatim.
···
};
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.msmtp ];
+
services.mail.sendmailSetuidWrapper = lib.mkIf cfg.setSendmail {
program = "sendmail";
source = "${pkgs.msmtp}/bin/sendmail";
setuid = false;
···
mkValueString = v:
if v == true then "on"
else if v == false then "off"
+
else lib.generators.mkValueStringDefault {} v;
mkKeyValueString = k: v: "${k} ${mkValueString v}";
mkInnerSectionString =
+
attrs: builtins.concatStringsSep "\n" (lib.mapAttrsToList mkKeyValueString attrs);
mkAccountString = name: attrs: ''
account ${name}
${mkInnerSectionString attrs}
···
defaults
${mkInnerSectionString cfg.defaults}
+
${builtins.concatStringsSep "\n" (lib.mapAttrsToList mkAccountString cfg.accounts)}
${cfg.extraConfig}
'';
+5 -7
nixos/modules/programs/mtr.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.mtr;
in {
options = {
programs.mtr = {
-
enable = mkOption {
-
type = types.bool;
default = false;
description = ''
Whether to add mtr to the global environment and configure a
···
'';
};
-
package = mkPackageOption pkgs "mtr" { };
};
};
-
config = mkIf cfg.enable {
-
environment.systemPackages = with pkgs; [ cfg.package ];
security.wrappers.mtr-packet = {
owner = "root";
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.mtr;
in {
options = {
programs.mtr = {
+
enable = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Whether to add mtr to the global environment and configure a
···
'';
};
+
package = lib.mkPackageOption pkgs "mtr" { };
};
};
+
config = lib.mkIf cfg.enable {
+
environment.systemPackages = [ cfg.package ];
security.wrappers.mtr-packet = {
owner = "root";
+2 -4
nixos/modules/programs/nbd.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.nbd;
in
{
options = {
programs.nbd = {
-
enable = mkEnableOption "Network Block Device (nbd) support";
};
};
-
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [ nbd ];
boot.kernelModules = [ "nbd" ];
};
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.nbd;
in
{
options = {
programs.nbd = {
+
enable = lib.mkEnableOption "Network Block Device (nbd) support";
};
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ nbd ];
boot.kernelModules = [ "nbd" ];
};
+37 -39
nixos/modules/programs/neovim.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.neovim;
in
{
options.programs.neovim = {
-
enable = mkOption {
-
type = types.bool;
default = false;
example = true;
description = ''
···
'';
};
-
defaultEditor = mkOption {
-
type = types.bool;
default = false;
description = ''
When enabled, installs neovim and configures neovim to be the default editor
···
'';
};
-
viAlias = mkOption {
-
type = types.bool;
default = false;
description = ''
Symlink {command}`vi` to {command}`nvim` binary.
'';
};
-
vimAlias = mkOption {
-
type = types.bool;
default = false;
description = ''
Symlink {command}`vim` to {command}`nvim` binary.
'';
};
-
withRuby = mkOption {
-
type = types.bool;
default = true;
description = "Enable Ruby provider.";
};
-
withPython3 = mkOption {
-
type = types.bool;
default = true;
description = "Enable Python 3 provider.";
};
-
withNodeJs = mkOption {
-
type = types.bool;
default = false;
description = "Enable Node provider.";
};
-
configure = mkOption {
-
type = types.attrs;
default = { };
-
example = literalExpression ''
{
customRC = '''
" here your custom configuration goes!
···
'';
};
-
package = mkPackageOption pkgs "neovim-unwrapped" { };
-
finalPackage = mkOption {
-
type = types.package;
visible = false;
readOnly = true;
description = "Resulting customized neovim package.";
};
-
runtime = mkOption {
default = { };
-
example = literalExpression ''
{ "ftplugin/c.vim".text = "setlocal omnifunc=v:lua.vim.lsp.omnifunc"; }
'';
description = ''
Set of files that have to be linked in {file}`runtime`.
'';
-
type = with types; attrsOf (submodule (
{ name, config, ... }:
{
options = {
-
enable = mkOption {
-
type = types.bool;
default = true;
description = ''
Whether this runtime directory should be generated. This
···
'';
};
-
target = mkOption {
-
type = types.str;
description = ''
Name of symlink. Defaults to the attribute
name.
'';
};
-
text = mkOption {
default = null;
-
type = types.nullOr types.lines;
description = "Text of the file.";
};
-
source = mkOption {
default = null;
-
type = types.nullOr types.path;
description = "Path of the source file.";
};
};
-
config.target = mkDefault name;
}
));
};
};
-
config = mkIf cfg.enable {
environment.systemPackages = [
cfg.finalPackage
];
-
environment.variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "nvim");
-
environment.etc = listToAttrs (attrValues (mapAttrs
(name: value: {
name = "xdg/nvim/${name}";
-
value = removeAttrs
(value // {
target = "xdg/nvim/${value.target}";
})
-
(optionals (isNull value.source) [ "source" ]);
})
cfg.runtime));
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.neovim;
in
{
options.programs.neovim = {
+
enable = lib.mkOption {
+
type = lib.types.bool;
default = false;
example = true;
description = ''
···
'';
};
+
defaultEditor = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
When enabled, installs neovim and configures neovim to be the default editor
···
'';
};
+
viAlias = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Symlink {command}`vi` to {command}`nvim` binary.
'';
};
+
vimAlias = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Symlink {command}`vim` to {command}`nvim` binary.
'';
};
+
withRuby = lib.mkOption {
+
type = lib.types.bool;
default = true;
description = "Enable Ruby provider.";
};
+
withPython3 = lib.mkOption {
+
type = lib.types.bool;
default = true;
description = "Enable Python 3 provider.";
};
+
withNodeJs = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = "Enable Node provider.";
};
+
configure = lib.mkOption {
+
type = lib.types.attrs;
default = { };
+
example = lib.literalExpression ''
{
customRC = '''
" here your custom configuration goes!
···
'';
};
+
package = lib.mkPackageOption pkgs "neovim-unwrapped" { };
+
finalPackage = lib.mkOption {
+
type = lib.types.package;
visible = false;
readOnly = true;
description = "Resulting customized neovim package.";
};
+
runtime = lib.mkOption {
default = { };
+
example = lib.literalExpression ''
{ "ftplugin/c.vim".text = "setlocal omnifunc=v:lua.vim.lsp.omnifunc"; }
'';
description = ''
Set of files that have to be linked in {file}`runtime`.
'';
+
type = with lib.types; attrsOf (submodule (
{ name, config, ... }:
{
options = {
+
enable = lib.mkOption {
+
type = lib.types.bool;
default = true;
description = ''
Whether this runtime directory should be generated. This
···
'';
};
+
target = lib.mkOption {
+
type = lib.types.str;
description = ''
Name of symlink. Defaults to the attribute
name.
'';
};
+
text = lib.mkOption {
default = null;
+
type = lib.types.nullOr lib.types.lines;
description = "Text of the file.";
};
+
source = lib.mkOption {
default = null;
+
type = lib.types.nullOr lib.types.path;
description = "Path of the source file.";
};
};
+
config.target = lib.mkDefault name;
}
));
};
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [
cfg.finalPackage
];
+
environment.variables.EDITOR = lib.mkIf cfg.defaultEditor (lib.mkOverride 900 "nvim");
+
environment.etc = builtins.listToAttrs (builtins.attrValues (builtins.mapAttrs
(name: value: {
name = "xdg/nvim/${name}";
+
value = builtins.removeAttrs
(value // {
target = "xdg/nvim/${value.target}";
})
+
(lib.optionals (builtins.isNull value.source) [ "source" ]);
})
cfg.runtime));
+4 -6
nixos/modules/programs/nethoscope.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let cfg = config.programs.nethoscope;
in
{
-
meta.maintainers = with maintainers; [ _0x4A6F ];
options = {
programs.nethoscope = {
-
enable = mkOption {
-
type = types.bool;
default = false;
description = ''
Whether to add nethoscope to the global environment and configure a
···
};
};
-
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [ nethoscope ];
security.wrappers.nethoscope = {
source = "${pkgs.nethoscope}/bin/nethoscope";
···
{ config, lib, pkgs, ... }:
let cfg = config.programs.nethoscope;
in
{
+
meta.maintainers = with lib.maintainers; [ _0x4A6F ];
options = {
programs.nethoscope = {
+
enable = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Whether to add nethoscope to the global environment and configure a
···
};
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ nethoscope ];
security.wrappers.nethoscope = {
source = "${pkgs.nethoscope}/bin/nethoscope";
+11 -12
nixos/modules/programs/nncp.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
let
nncpCfgFile = "/run/nncp.hjson";
programCfg = config.programs.nncp;
···
options.programs.nncp = {
enable =
-
mkEnableOption "NNCP (Node to Node copy) utilities and configuration";
-
group = mkOption {
-
type = types.str;
default = "uucp";
description = ''
The group under which NNCP files shall be owned.
···
'';
};
-
package = mkPackageOption pkgs "nncp" { };
-
secrets = mkOption {
-
type = with types; listOf str;
example = [ "/run/keys/nncp.hjson" ];
description = ''
A list of paths to NNCP configuration files that should not be
···
'';
};
-
settings = mkOption {
type = settingsFormat.type;
description = ''
NNCP configuration, see
···
};
-
config = mkIf programCfg.enable {
environment = {
systemPackages = [ pkg ];
···
};
programs.nncp.settings = {
-
spool = mkDefault "/var/spool/nncp";
-
log = mkDefault "/var/spool/nncp/log";
};
systemd.tmpfiles.rules = [
···
script = ''
umask u=rw
nncpCfgDir=$(mktemp --directory nncp.XXX)
-
for f in ${jsonCfgFile} ${toString config.programs.nncp.secrets}; do
tmpdir=$(mktemp --directory nncp.XXX)
nncp-cfgdir -cfg $f -dump $tmpdir
find $tmpdir -size 1c -delete
···
{ config, lib, pkgs, ... }:
let
nncpCfgFile = "/run/nncp.hjson";
programCfg = config.programs.nncp;
···
options.programs.nncp = {
enable =
+
lib.mkEnableOption "NNCP (Node to Node copy) utilities and configuration";
+
group = lib.mkOption {
+
type = lib.types.str;
default = "uucp";
description = ''
The group under which NNCP files shall be owned.
···
'';
};
+
package = lib.mkPackageOption pkgs "nncp" { };
+
secrets = lib.mkOption {
+
type = with lib.types; listOf str;
example = [ "/run/keys/nncp.hjson" ];
description = ''
A list of paths to NNCP configuration files that should not be
···
'';
};
+
settings = lib.mkOption {
type = settingsFormat.type;
description = ''
NNCP configuration, see
···
};
+
config = lib.mkIf programCfg.enable {
environment = {
systemPackages = [ pkg ];
···
};
programs.nncp.settings = {
+
spool = lib.mkDefault "/var/spool/nncp";
+
log = lib.mkDefault "/var/spool/nncp/log";
};
systemd.tmpfiles.rules = [
···
script = ''
umask u=rw
nncpCfgDir=$(mktemp --directory nncp.XXX)
+
for f in ${jsonCfgFile} ${builtins.toString config.programs.nncp.secrets}; do
tmpdir=$(mktemp --directory nncp.XXX)
nncp-cfgdir -cfg $f -dump $tmpdir
find $tmpdir -size 1c -delete
+3 -5
nixos/modules/programs/noisetorch.nix
···
{ config, pkgs, lib, ... }:
-
with lib;
-
let cfg = config.programs.noisetorch;
in
{
options.programs.noisetorch = {
-
enable = mkEnableOption "noisetorch (+ setcap wrapper), a virtual microphone device with noise suppression";
-
package = mkPackageOption pkgs "noisetorch" { };
};
-
config = mkIf cfg.enable {
security.wrappers.noisetorch = {
owner = "root";
group = "root";
···
{ config, pkgs, lib, ... }:
let cfg = config.programs.noisetorch;
in
{
options.programs.noisetorch = {
+
enable = lib.mkEnableOption "noisetorch (+ setcap wrapper), a virtual microphone device with noise suppression";
+
package = lib.mkPackageOption pkgs "noisetorch" { };
};
+
config = lib.mkIf cfg.enable {
security.wrappers.noisetorch = {
owner = "root";
group = "root";
+3 -5
nixos/modules/programs/npm.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.npm;
in
···
options = {
programs.npm = {
-
enable = mkEnableOption "{command}`npm` global config";
-
package = mkPackageOption pkgs [ "nodePackages" "npm" ] {
example = "nodePackages_13_x.npm";
};
-
npmrc = mkOption {
type = lib.types.lines;
description = ''
The system-wide npm configuration.
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.npm;
in
···
options = {
programs.npm = {
+
enable = lib.mkEnableOption "{command}`npm` global config";
+
package = lib.mkPackageOption pkgs [ "nodePackages" "npm" ] {
example = "nodePackages_13_x.npm";
};
+
npmrc = lib.mkOption {
type = lib.types.lines;
description = ''
The system-wide npm configuration.
+1 -3
nixos/modules/programs/oblogout.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
{
imports = [
-
(mkRemovedOptionModule [ "programs" "oblogout" ] "programs.oblogout has been removed from NixOS. This is because the oblogout repository has been archived upstream.")
];
}
···
{ config, lib, pkgs, ... }:
{
imports = [
+
(lib.mkRemovedOptionModule [ "programs" "oblogout" ] "programs.oblogout has been removed from NixOS. This is because the oblogout repository has been archived upstream.")
];
}
+5 -7
nixos/modules/programs/openvpn3.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.openvpn3;
in
{
options.programs.openvpn3 = {
-
enable = mkEnableOption "the openvpn3 client";
-
package = mkOption {
-
type = types.package;
default = pkgs.openvpn3.override {
enableSystemdResolved = config.services.resolved.enable;
};
-
defaultText = literalExpression ''pkgs.openvpn3.override {
enableSystemdResolved = config.services.resolved.enable;
}'';
description = ''
···
};
};
-
config = mkIf cfg.enable {
services.dbus.packages = [
cfg.package
];
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.openvpn3;
in
{
options.programs.openvpn3 = {
+
enable = lib.mkEnableOption "the openvpn3 client";
+
package = lib.mkOption {
+
type = lib.types.package;
default = pkgs.openvpn3.override {
enableSystemdResolved = config.services.resolved.enable;
};
+
defaultText = lib.literalExpression ''pkgs.openvpn3.override {
enableSystemdResolved = config.services.resolved.enable;
}'';
description = ''
···
};
};
+
config = lib.mkIf cfg.enable {
services.dbus.packages = [
cfg.package
];
+3 -5
nixos/modules/programs/pantheon-tweaks.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
{
meta = {
-
maintainers = teams.pantheon.members;
};
###### interface
options = {
-
programs.pantheon-tweaks.enable = mkEnableOption "Pantheon Tweaks, an unofficial system settings panel for Pantheon";
};
###### implementation
-
config = mkIf config.programs.pantheon-tweaks.enable {
services.xserver.desktopManager.pantheon.extraSwitchboardPlugs = [ pkgs.pantheon-tweaks ];
};
}
···
{ config, lib, pkgs, ... }:
{
meta = {
+
maintainers = lib.teams.pantheon.members;
};
###### interface
options = {
+
programs.pantheon-tweaks.enable = lib.mkEnableOption "Pantheon Tweaks, an unofficial system settings panel for Pantheon";
};
###### implementation
+
config = lib.mkIf config.programs.pantheon-tweaks.enable {
services.xserver.desktopManager.pantheon.extraSwitchboardPlugs = [ pkgs.pantheon-tweaks ];
};
}
+3 -5
nixos/modules/programs/plotinus.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.plotinus;
in
···
options = {
programs.plotinus = {
-
enable = mkOption {
default = false;
description = ''
Whether to enable the Plotinus GTK 3 plugin. Plotinus provides a
popup (triggered by Ctrl-Shift-P) to search the menus of a
compatible application.
'';
-
type = types.bool;
};
};
};
###### implementation
-
config = mkIf cfg.enable {
environment.sessionVariables.XDG_DATA_DIRS = [ "${pkgs.plotinus}/share/gsettings-schemas/${pkgs.plotinus.name}" ];
environment.variables.GTK3_MODULES = [ "${pkgs.plotinus}/lib/libplotinus.so" ];
};
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.plotinus;
in
···
options = {
programs.plotinus = {
+
enable = lib.mkOption {
default = false;
description = ''
Whether to enable the Plotinus GTK 3 plugin. Plotinus provides a
popup (triggered by Ctrl-Shift-P) to search the menus of a
compatible application.
'';
+
type = lib.types.bool;
};
};
};
###### implementation
+
config = lib.mkIf cfg.enable {
environment.sessionVariables.XDG_DATA_DIRS = [ "${pkgs.plotinus}/share/gsettings-schemas/${pkgs.plotinus.name}" ];
environment.variables.GTK3_MODULES = [ "${pkgs.plotinus}/lib/libplotinus.so" ];
};
+35 -36
nixos/modules/programs/proxychains.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
let
cfg = config.programs.proxychains;
configFile = ''
${cfg.chain.type}_chain
-
${optionalString (cfg.chain.type == "random")
"chain_len = ${builtins.toString cfg.chain.length}"}
-
${optionalString cfg.proxyDNS "proxy_dns"}
-
${optionalString cfg.quietMode "quiet_mode"}
remote_dns_subnet ${builtins.toString cfg.remoteDNSSubnet}
tcp_read_time_out ${builtins.toString cfg.tcpReadTimeOut}
tcp_connect_time_out ${builtins.toString cfg.tcpConnectTimeOut}
···
proxyOptions = {
options = {
-
enable = mkEnableOption "this proxy";
-
type = mkOption {
-
type = types.enum [ "http" "socks4" "socks5" ];
description = "Proxy type.";
};
-
host = mkOption {
-
type = types.str;
description = "Proxy host or IP address.";
};
-
port = mkOption {
-
type = types.port;
description = "Proxy port";
};
};
···
programs.proxychains = {
-
enable = mkEnableOption "proxychains configuration";
-
package = mkPackageOption pkgs "proxychains" {
example = "proxychains-ng";
};
chain = {
-
type = mkOption {
-
type = types.enum [ "dynamic" "strict" "random" ];
default = "strict";
description = ''
`dynamic` - Each connection will be done via chained proxies
···
(or proxy chain, see {option}`programs.proxychains.chain.length`) from the list.
'';
};
-
length = mkOption {
-
type = types.nullOr types.int;
default = null;
description = ''
Chain length for random chain.
···
};
};
-
proxyDNS = mkOption {
-
type = types.bool;
default = true;
description = "Proxy DNS requests - no leak for DNS data.";
};
-
quietMode = mkEnableOption "Quiet mode (no output from the library)";
-
remoteDNSSubnet = mkOption {
-
type = types.enum [ 10 127 224 ];
default = 224;
description = ''
Set the class A subnet number to use for the internal remote DNS mapping, uses the reserved 224.x.x.x range by default.
'';
};
-
tcpReadTimeOut = mkOption {
-
type = types.int;
default = 15000;
description = "Connection read time-out in milliseconds.";
};
-
tcpConnectTimeOut = mkOption {
-
type = types.int;
default = 8000;
description = "Connection time-out in milliseconds.";
};
-
localnet = mkOption {
-
type = types.str;
default = "127.0.0.0/255.0.0.0";
description = "By default enable localnet for loopback address ranges.";
};
-
proxies = mkOption {
-
type = types.attrsOf (types.submodule proxyOptions);
description = ''
Proxies to be used by proxychains.
'';
-
example = literalExpression ''
{ myproxy =
{ type = "socks4";
host = "127.0.0.1";
···
###### implementation
-
meta.maintainers = with maintainers; [ sorki ];
-
config = mkIf cfg.enable {
-
assertions = singleton {
assertion = cfg.chain.type != "random" && cfg.chain.length == null;
message = ''
Option `programs.proxychains.chain.length`
···
'';
};
-
programs.proxychains.proxies = mkIf config.services.tor.client.enable
{
-
torproxy = mkDefault {
enable = true;
type = "socks4";
host = "127.0.0.1";
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.proxychains;
configFile = ''
${cfg.chain.type}_chain
+
${lib.optionalString (cfg.chain.type == "random")
"chain_len = ${builtins.toString cfg.chain.length}"}
+
${lib.optionalString cfg.proxyDNS "proxy_dns"}
+
${lib.optionalString cfg.quietMode "quiet_mode"}
remote_dns_subnet ${builtins.toString cfg.remoteDNSSubnet}
tcp_read_time_out ${builtins.toString cfg.tcpReadTimeOut}
tcp_connect_time_out ${builtins.toString cfg.tcpConnectTimeOut}
···
proxyOptions = {
options = {
+
enable = lib.mkEnableOption "this proxy";
+
type = lib.mkOption {
+
type = lib.types.enum [ "http" "socks4" "socks5" ];
description = "Proxy type.";
};
+
host = lib.mkOption {
+
type = lib.types.str;
description = "Proxy host or IP address.";
};
+
port = lib.mkOption {
+
type = lib.types.port;
description = "Proxy port";
};
};
···
programs.proxychains = {
+
enable = lib.mkEnableOption "proxychains configuration";
+
package = lib.mkPackageOption pkgs "proxychains" {
example = "proxychains-ng";
};
chain = {
+
type = lib.mkOption {
+
type = lib.types.enum [ "dynamic" "strict" "random" ];
default = "strict";
description = ''
`dynamic` - Each connection will be done via chained proxies
···
(or proxy chain, see {option}`programs.proxychains.chain.length`) from the list.
'';
};
+
length = lib.mkOption {
+
type = lib.types.nullOr lib.types.int;
default = null;
description = ''
Chain length for random chain.
···
};
};
+
proxyDNS = lib.mkOption {
+
type = lib.types.bool;
default = true;
description = "Proxy DNS requests - no leak for DNS data.";
};
+
quietMode = lib.mkEnableOption "Quiet mode (no output from the library)";
+
remoteDNSSubnet = lib.mkOption {
+
type = lib.types.enum [ 10 127 224 ];
default = 224;
description = ''
Set the class A subnet number to use for the internal remote DNS mapping, uses the reserved 224.x.x.x range by default.
'';
};
+
tcpReadTimeOut = lib.mkOption {
+
type = lib.types.int;
default = 15000;
description = "Connection read time-out in milliseconds.";
};
+
tcpConnectTimeOut = lib.mkOption {
+
type = lib.types.int;
default = 8000;
description = "Connection time-out in milliseconds.";
};
+
localnet = lib.mkOption {
+
type = lib.types.str;
default = "127.0.0.0/255.0.0.0";
description = "By default enable localnet for loopback address ranges.";
};
+
proxies = lib.mkOption {
+
type = lib.types.attrsOf (lib.types.submodule proxyOptions);
description = ''
Proxies to be used by proxychains.
'';
+
example = lib.literalExpression ''
{ myproxy =
{ type = "socks4";
host = "127.0.0.1";
···
###### implementation
+
meta.maintainers = with lib.maintainers; [ sorki ];
+
config = lib.mkIf cfg.enable {
+
assertions = lib.singleton {
assertion = cfg.chain.type != "random" && cfg.chain.length == null;
message = ''
Option `programs.proxychains.chain.length`
···
'';
};
+
programs.proxychains.proxies = lib.mkIf config.services.tor.client.enable
{
+
torproxy = lib.mkDefault {
enable = true;
type = "socks4";
host = "127.0.0.1";
+1 -3
nixos/modules/programs/qt5ct.nix
···
{ lib, ... }:
-
with lib;
-
{
imports = [
-
(mkRemovedOptionModule [ "programs" "qt5ct" "enable" ] "Use qt5.platformTheme = \"qt5ct\" instead.")
];
}
···
{ lib, ... }:
{
imports = [
+
(lib.mkRemovedOptionModule [ "programs" "qt5ct" "enable" ] "Use qt5.platformTheme = \"qt5ct\" instead.")
];
}
+16 -18
nixos/modules/programs/rust-motd.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.rust-motd;
format = pkgs.formats.toml { };
···
'';
in {
options.programs.rust-motd = {
-
enable = mkEnableOption "rust-motd, a Message Of The Day (MOTD) generator";
-
enableMotdInSSHD = mkOption {
default = true;
-
type = types.bool;
description = ''
Whether to let `openssh` print the
result when entering a new `ssh`-session.
···
the latter option is incompatible with this module.
'';
};
-
refreshInterval = mkOption {
default = "*:0/5";
-
type = types.str;
description = ''
Interval in which the {manpage}`motd(5)` file is refreshed.
For possible formats, please refer to {manpage}`systemd.time(7)`.
'';
};
-
order = mkOption {
-
type = types.listOf types.str;
-
default = attrNames cfg.settings;
-
defaultText = literalExpression "attrNames cfg.settings";
description = ''
The order of the sections in [](#opt-programs.rust-motd.settings).
By default they are ordered alphabetically.
···
makes sure that `uptime` is placed before `banner` in the motd.
'';
};
-
settings = mkOption {
-
type = types.attrsOf format.type;
description = ''
Settings on what to generate. Please read the
[upstream documentation](https://github.com/rust-motd/rust-motd/blob/main/README.md#configuration)
···
'';
};
};
-
config = mkIf cfg.enable {
assertions = [
{ assertion = config.users.motd == null;
message = ''
`programs.rust-motd` is incompatible with `users.motd`!
'';
}
-
{ assertion = sort (a: b: a < b) cfg.order == attrNames cfg.settings;
message = ''
Please ensure that every section from `programs.rust-motd.settings` is present in
`programs.rust-motd.order`.
···
wantedBy = [ "timers.target" ];
timerConfig.OnCalendar = cfg.refreshInterval;
};
-
security.pam.services.sshd.text = mkIf cfg.enableMotdInSSHD (mkDefault (mkAfter ''
session optional ${pkgs.pam}/lib/security/pam_motd.so motd=/var/lib/rust-motd/motd
''));
-
services.openssh.extraConfig = mkIf (cfg.settings ? last_login && cfg.settings.last_login != {}) ''
PrintLastLog no
'';
};
-
meta.maintainers = with maintainers; [ ma27 ];
}
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.rust-motd;
format = pkgs.formats.toml { };
···
'';
in {
options.programs.rust-motd = {
+
enable = lib.mkEnableOption "rust-motd, a Message Of The Day (MOTD) generator";
+
enableMotdInSSHD = lib.mkOption {
default = true;
+
type = lib.types.bool;
description = ''
Whether to let `openssh` print the
result when entering a new `ssh`-session.
···
the latter option is incompatible with this module.
'';
};
+
refreshInterval = lib.mkOption {
default = "*:0/5";
+
type = lib.types.str;
description = ''
Interval in which the {manpage}`motd(5)` file is refreshed.
For possible formats, please refer to {manpage}`systemd.time(7)`.
'';
};
+
order = lib.mkOption {
+
type = lib.types.listOf lib.types.str;
+
default = builtins.attrNames cfg.settings;
+
defaultText = lib.literalExpression "attrNames cfg.settings";
description = ''
The order of the sections in [](#opt-programs.rust-motd.settings).
By default they are ordered alphabetically.
···
makes sure that `uptime` is placed before `banner` in the motd.
'';
};
+
settings = lib.mkOption {
+
type = lib.types.attrsOf format.type;
description = ''
Settings on what to generate. Please read the
[upstream documentation](https://github.com/rust-motd/rust-motd/blob/main/README.md#configuration)
···
'';
};
};
+
config = lib.mkIf cfg.enable {
assertions = [
{ assertion = config.users.motd == null;
message = ''
`programs.rust-motd` is incompatible with `users.motd`!
'';
}
+
{ assertion = builtins.sort (a: b: a < b) cfg.order == builtins.attrNames cfg.settings;
message = ''
Please ensure that every section from `programs.rust-motd.settings` is present in
`programs.rust-motd.order`.
···
wantedBy = [ "timers.target" ];
timerConfig.OnCalendar = cfg.refreshInterval;
};
+
security.pam.services.sshd.text = lib.mkIf cfg.enableMotdInSSHD (lib.mkDefault (lib.mkAfter ''
session optional ${pkgs.pam}/lib/security/pam_motd.so motd=/var/lib/rust-motd/motd
''));
+
services.openssh.extraConfig = lib.mkIf (cfg.settings ? last_login && cfg.settings.last_login != {}) ''
PrintLastLog no
'';
};
+
meta.maintainers = with lib.maintainers; [ ma27 ];
}
+2 -4
nixos/modules/programs/sedutil.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.sedutil;
in {
-
options.programs.sedutil.enable = mkEnableOption "sedutil, to manage self encrypting drives that conform to the Trusted Computing Group OPAL 2.0 SSC specification";
-
config = mkIf cfg.enable {
boot.kernelParams = [
"libata.allow_tpm=1"
];
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.sedutil;
in {
+
options.programs.sedutil.enable = lib.mkEnableOption "sedutil, to manage self encrypting drives that conform to the Trusted Computing Group OPAL 2.0 SSC specification";
+
config = lib.mkIf cfg.enable {
boot.kernelParams = [
"libata.allow_tpm=1"
];
+26 -27
nixos/modules/programs/shadow.nix
···
# Configuration for the pwdutils suite of tools: passwd, useradd, etc.
{ config, lib, utils, pkgs, ... }:
-
with lib;
let
cfg = config.security.loginDefs;
in
{
-
options = with types; {
security.loginDefs = {
-
package = mkPackageOption pkgs "shadow" { };
-
chfnRestrict = mkOption {
description = ''
Use chfn SUID to allow non-root users to change their account GECOS information.
'';
···
default = null;
};
-
settings = mkOption {
description = ''
Config options for the /etc/login.defs file, that defines
the site-specific configuration for the shadow password suite.
···
by systemd for features like ConditionUser=@system and systemd-sysusers
*/
options = {
-
DEFAULT_HOME = mkOption {
description = "Indicate if login is allowed if we can't cd to the home directory.";
default = "yes";
type = enum [ "yes" "no" ];
};
-
ENCRYPT_METHOD = mkOption {
description = "This defines the system default encryption algorithm for encrypting passwords.";
# The default crypt() method, keep in sync with the PAM default
default = "YESCRYPT";
type = enum [ "YESCRYPT" "SHA512" "SHA256" "MD5" "DES"];
};
-
SYS_UID_MIN = mkOption {
description = "Range of user IDs used for the creation of system users by useradd or newusers.";
default = 400;
type = int;
};
-
SYS_UID_MAX = mkOption {
description = "Range of user IDs used for the creation of system users by useradd or newusers.";
default = 999;
type = int;
};
-
UID_MIN = mkOption {
description = "Range of user IDs used for the creation of regular users by useradd or newusers.";
default = 1000;
type = int;
};
-
UID_MAX = mkOption {
description = "Range of user IDs used for the creation of regular users by useradd or newusers.";
default = 29999;
type = int;
};
-
SYS_GID_MIN = mkOption {
description = "Range of group IDs used for the creation of system groups by useradd, groupadd, or newusers";
default = 400;
type = int;
};
-
SYS_GID_MAX = mkOption {
description = "Range of group IDs used for the creation of system groups by useradd, groupadd, or newusers";
default = 999;
type = int;
};
-
GID_MIN = mkOption {
description = "Range of group IDs used for the creation of regular groups by useradd, groupadd, or newusers.";
default = 1000;
type = int;
};
-
GID_MAX = mkOption {
description = "Range of group IDs used for the creation of regular groups by useradd, groupadd, or newusers.";
default = 29999;
type = int;
};
-
TTYGROUP = mkOption {
description = ''
The terminal permissions: the login tty will be owned by the TTYGROUP group,
and the permissions will be set to TTYPERM'';
···
type = str;
};
-
TTYPERM = mkOption {
description = ''
The terminal permissions: the login tty will be owned by the TTYGROUP group,
and the permissions will be set to TTYPERM'';
···
};
# Ensure privacy for newly created home directories.
-
UMASK = mkOption {
description = "The file mode creation mask is initialized to this value.";
default = "077";
type = str;
···
};
};
-
users.defaultUserShell = mkOption {
description = ''
This option defines the default shell assigned to user
accounts. This can be either a full system path or a shell package.
···
This must not be a store path, since the path is
used outside the store (in particular in /etc/passwd).
'';
-
example = literalExpression "pkgs.zsh";
type = either path shellPackage;
};
};
···
];
security.loginDefs.settings.CHFN_RESTRICT =
-
mkIf (cfg.chfnRestrict != null) cfg.chfnRestrict;
-
environment.systemPackages = optional config.users.mutableUsers cfg.package
-
++ optional (types.shellPackage.check config.users.defaultUserShell) config.users.defaultUserShell
-
++ optional (cfg.chfnRestrict != null) pkgs.util-linux;
environment.etc =
# Create custom toKeyValue generator
# see https://man7.org/linux/man-pages/man5/login.defs.5.html for config specification
let
-
toKeyValue = generators.toKeyValue {
-
mkKeyValue = generators.mkKeyValueDefault { } " ";
};
in
{
···
newuidmap = mkSetuidRoot "${cfg.package.out}/bin/newuidmap";
newgidmap = mkSetuidRoot "${cfg.package.out}/bin/newgidmap";
}
-
// optionalAttrs config.users.mutableUsers {
chsh = mkSetuidRoot "${cfg.package.out}/bin/chsh";
passwd = mkSetuidRoot "${cfg.package.out}/bin/passwd";
};
···
# Configuration for the pwdutils suite of tools: passwd, useradd, etc.
{ config, lib, utils, pkgs, ... }:
let
cfg = config.security.loginDefs;
in
{
+
options = with lib.types; {
security.loginDefs = {
+
package = lib.mkPackageOption pkgs "shadow" { };
+
chfnRestrict = lib.mkOption {
description = ''
Use chfn SUID to allow non-root users to change their account GECOS information.
'';
···
default = null;
};
+
settings = lib.mkOption {
description = ''
Config options for the /etc/login.defs file, that defines
the site-specific configuration for the shadow password suite.
···
by systemd for features like ConditionUser=@system and systemd-sysusers
*/
options = {
+
DEFAULT_HOME = lib.mkOption {
description = "Indicate if login is allowed if we can't cd to the home directory.";
default = "yes";
type = enum [ "yes" "no" ];
};
+
ENCRYPT_METHOD = lib.mkOption {
description = "This defines the system default encryption algorithm for encrypting passwords.";
# The default crypt() method, keep in sync with the PAM default
default = "YESCRYPT";
type = enum [ "YESCRYPT" "SHA512" "SHA256" "MD5" "DES"];
};
+
SYS_UID_MIN = lib.mkOption {
description = "Range of user IDs used for the creation of system users by useradd or newusers.";
default = 400;
type = int;
};
+
SYS_UID_MAX = lib.mkOption {
description = "Range of user IDs used for the creation of system users by useradd or newusers.";
default = 999;
type = int;
};
+
UID_MIN = lib.mkOption {
description = "Range of user IDs used for the creation of regular users by useradd or newusers.";
default = 1000;
type = int;
};
+
UID_MAX = lib.mkOption {
description = "Range of user IDs used for the creation of regular users by useradd or newusers.";
default = 29999;
type = int;
};
+
SYS_GID_MIN = lib.mkOption {
description = "Range of group IDs used for the creation of system groups by useradd, groupadd, or newusers";
default = 400;
type = int;
};
+
SYS_GID_MAX = lib.mkOption {
description = "Range of group IDs used for the creation of system groups by useradd, groupadd, or newusers";
default = 999;
type = int;
};
+
GID_MIN = lib.mkOption {
description = "Range of group IDs used for the creation of regular groups by useradd, groupadd, or newusers.";
default = 1000;
type = int;
};
+
GID_MAX = lib.mkOption {
description = "Range of group IDs used for the creation of regular groups by useradd, groupadd, or newusers.";
default = 29999;
type = int;
};
+
TTYGROUP = lib.mkOption {
description = ''
The terminal permissions: the login tty will be owned by the TTYGROUP group,
and the permissions will be set to TTYPERM'';
···
type = str;
};
+
TTYPERM = lib.mkOption {
description = ''
The terminal permissions: the login tty will be owned by the TTYGROUP group,
and the permissions will be set to TTYPERM'';
···
};
# Ensure privacy for newly created home directories.
+
UMASK = lib.mkOption {
description = "The file mode creation mask is initialized to this value.";
default = "077";
type = str;
···
};
};
+
users.defaultUserShell = lib.mkOption {
description = ''
This option defines the default shell assigned to user
accounts. This can be either a full system path or a shell package.
···
This must not be a store path, since the path is
used outside the store (in particular in /etc/passwd).
'';
+
example = lib.literalExpression "pkgs.zsh";
type = either path shellPackage;
};
};
···
];
security.loginDefs.settings.CHFN_RESTRICT =
+
lib.mkIf (cfg.chfnRestrict != null) cfg.chfnRestrict;
+
environment.systemPackages = lib.optional config.users.mutableUsers cfg.package
+
++ lib.optional (lib.types.shellPackage.check config.users.defaultUserShell) config.users.defaultUserShell
+
++ lib.optional (cfg.chfnRestrict != null) pkgs.util-linux;
environment.etc =
# Create custom toKeyValue generator
# see https://man7.org/linux/man-pages/man5/login.defs.5.html for config specification
let
+
toKeyValue = lib.generators.toKeyValue {
+
mkKeyValue = lib.generators.mkKeyValueDefault { } " ";
};
in
{
···
newuidmap = mkSetuidRoot "${cfg.package.out}/bin/newuidmap";
newgidmap = mkSetuidRoot "${cfg.package.out}/bin/newgidmap";
}
+
// lib.optionalAttrs config.users.mutableUsers {
chsh = mkSetuidRoot "${cfg.package.out}/bin/chsh";
passwd = mkSetuidRoot "${cfg.package.out}/bin/passwd";
};
+2 -3
nixos/modules/programs/sharing.nix
···
{ config, pkgs, lib, ... }:
-
with lib;
{
options.programs.sharing = {
-
enable = mkEnableOption ''
sharing, a CLI tool for sharing files.
Note that it will opens the 7478 port for TCP in the firewall, which is needed for it to function properly
···
let
cfg = config.programs.sharing;
in
-
mkIf cfg.enable {
environment.systemPackages = [ pkgs.sharing ];
networking.firewall.allowedTCPPorts = [ 7478 ];
};
···
{ config, pkgs, lib, ... }:
{
options.programs.sharing = {
+
enable = lib.mkEnableOption ''
sharing, a CLI tool for sharing files.
Note that it will opens the 7478 port for TCP in the firewall, which is needed for it to function properly
···
let
cfg = config.programs.sharing;
in
+
lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.sharing ];
networking.firewall.allowedTCPPorts = [ 7478 ];
};
+17 -18
nixos/modules/programs/singularity.nix
···
...
}:
-
with lib;
let
cfg = config.programs.singularity;
in
{
options.programs.singularity = {
-
enable = mkEnableOption "singularity" // {
description = ''
Whether to install Singularity/Apptainer with system-level overriding such as SUID support.
'';
};
-
package = mkPackageOption pkgs "singularity" { example = "apptainer"; };
-
packageOverriden = mkOption {
-
type = types.nullOr types.package;
default = null;
description = ''
This option provides access to the overridden result of `programs.singularity.package`.
···
Use `lib.mkForce` to forcefully specify the overridden package.
'';
};
-
enableExternalLocalStateDir = mkOption {
-
type = types.bool;
default = true;
example = false;
description = ''
···
`/var/lib/''${projectName}/mnt/session`.
'';
};
-
enableFakeroot = mkOption {
-
type = types.bool;
default = true;
example = false;
description = ''
Whether to enable the `--fakeroot` support of Singularity/Apptainer.
'';
};
-
enableSuid = mkOption {
-
type = types.bool;
# SingularityCE requires SETUID for most things. Apptainer prefers user
# namespaces, e.g. `apptainer exec --nv` would fail if built
# `--with-suid`:
# > `FATAL: nvidia-container-cli not allowed in setuid mode`
default = cfg.package.projectName != "apptainer";
-
defaultText = literalExpression ''config.services.singularity.package.projectName != "apptainer"'';
example = false;
description = ''
Whether to enable the SUID support of Singularity/Apptainer.
···
};
};
-
config = mkIf cfg.enable {
programs.singularity.packageOverriden = (
cfg.package.override (
-
optionalAttrs cfg.enableExternalLocalStateDir { externalLocalStateDir = "/var/lib"; }
-
// optionalAttrs cfg.enableFakeroot {
newuidmapPath = "/run/wrappers/bin/newuidmap";
newgidmapPath = "/run/wrappers/bin/newgidmap";
}
-
// optionalAttrs cfg.enableSuid {
enableSuid = true;
starterSuidPath = "/run/wrappers/bin/${cfg.package.projectName}-suid";
}
)
);
environment.systemPackages = [ cfg.packageOverriden ];
-
security.wrappers."${cfg.packageOverriden.projectName}-suid" = mkIf cfg.enableSuid {
setuid = true;
owner = "root";
group = "root";
source = "${cfg.packageOverriden}/libexec/${cfg.packageOverriden.projectName}/bin/starter-suid.orig";
};
-
systemd.tmpfiles.rules = mkIf cfg.enableExternalLocalStateDir [
"d /var/lib/${cfg.packageOverriden.projectName}/mnt/session 0770 root root -"
];
};
···
...
}:
let
cfg = config.programs.singularity;
in
{
options.programs.singularity = {
+
enable = lib.mkEnableOption "singularity" // {
description = ''
Whether to install Singularity/Apptainer with system-level overriding such as SUID support.
'';
};
+
package = lib.mkPackageOption pkgs "singularity" { example = "apptainer"; };
+
packageOverriden = lib.mkOption {
+
type = lib.types.nullOr lib.types.package;
default = null;
description = ''
This option provides access to the overridden result of `programs.singularity.package`.
···
Use `lib.mkForce` to forcefully specify the overridden package.
'';
};
+
enableExternalLocalStateDir = lib.mkOption {
+
type = lib.types.bool;
default = true;
example = false;
description = ''
···
`/var/lib/''${projectName}/mnt/session`.
'';
};
+
enableFakeroot = lib.mkOption {
+
type = lib.types.bool;
default = true;
example = false;
description = ''
Whether to enable the `--fakeroot` support of Singularity/Apptainer.
'';
};
+
enableSuid = lib.mkOption {
+
type = lib.types.bool;
# SingularityCE requires SETUID for most things. Apptainer prefers user
# namespaces, e.g. `apptainer exec --nv` would fail if built
# `--with-suid`:
# > `FATAL: nvidia-container-cli not allowed in setuid mode`
default = cfg.package.projectName != "apptainer";
+
defaultText = lib.literalExpression ''config.services.singularity.package.projectName != "apptainer"'';
example = false;
description = ''
Whether to enable the SUID support of Singularity/Apptainer.
···
};
};
+
config = lib.mkIf cfg.enable {
programs.singularity.packageOverriden = (
cfg.package.override (
+
lib.optionalAttrs cfg.enableExternalLocalStateDir { externalLocalStateDir = "/var/lib"; }
+
// lib.optionalAttrs cfg.enableFakeroot {
newuidmapPath = "/run/wrappers/bin/newuidmap";
newgidmapPath = "/run/wrappers/bin/newgidmap";
}
+
// lib.optionalAttrs cfg.enableSuid {
enableSuid = true;
starterSuidPath = "/run/wrappers/bin/${cfg.package.projectName}-suid";
}
)
);
environment.systemPackages = [ cfg.packageOverriden ];
+
security.wrappers."${cfg.packageOverriden.projectName}-suid" = lib.mkIf cfg.enableSuid {
setuid = true;
owner = "root";
group = "root";
source = "${cfg.packageOverriden}/libexec/${cfg.packageOverriden.projectName}/bin/starter-suid.orig";
};
+
systemd.tmpfiles.rules = lib.mkIf cfg.enableExternalLocalStateDir [
"d /var/lib/${cfg.packageOverriden.projectName}/mnt/session 0770 root root -"
];
};
+4 -6
nixos/modules/programs/slock.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.slock;
···
{
options = {
programs.slock = {
-
enable = mkOption {
default = false;
-
type = types.bool;
description = ''
Whether to install slock screen locker with setuid wrapper.
'';
};
-
package = mkPackageOption pkgs "slock" {};
};
};
-
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
security.wrappers.slock =
{ setuid = true;
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.slock;
···
{
options = {
programs.slock = {
+
enable = lib.mkOption {
default = false;
+
type = lib.types.bool;
description = ''
Whether to install slock screen locker with setuid wrapper.
'';
};
+
package = lib.mkPackageOption pkgs "slock" {};
};
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
security.wrappers.slock =
{ setuid = true;
+4 -6
nixos/modules/programs/soundmodem.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.soundmodem;
in
{
options = {
programs.soundmodem = {
-
enable = mkOption {
-
type = types.bool;
default = false;
description = ''
Whether to add Soundmodem to the global environment and configure a
wrapper for 'soundmodemconfig' for users in the 'soundmodem' group.
'';
};
-
package = mkPackageOption pkgs "soundmodem" { };
};
};
-
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
users.groups.soundmodem = { };
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.soundmodem;
in
{
options = {
programs.soundmodem = {
+
enable = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Whether to add Soundmodem to the global environment and configure a
wrapper for 'soundmodemconfig' for users in the 'soundmodem' group.
'';
};
+
package = lib.mkPackageOption pkgs "soundmodem" { };
};
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
users.groups.soundmodem = { };
+7 -9
nixos/modules/programs/spacefm.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let cfg = config.programs.spacefm;
in
···
programs.spacefm = {
-
enable = mkOption {
-
type = types.bool;
default = false;
description = ''
Whether to install SpaceFM and create {file}`/etc/spacefm/spacefm.conf`.
'';
};
-
settings = mkOption {
-
type = types.attrs;
default = {
tmp_dir = "/tmp";
terminal_su = "${pkgs.sudo}/bin/sudo";
};
-
defaultText = literalExpression ''
{
tmp_dir = "/tmp";
terminal_su = "''${pkgs.sudo}/bin/sudo";
···
###### implementation
-
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.spaceFM ];
environment.etc."spacefm/spacefm.conf".text =
-
concatStrings (mapAttrsToList (n: v: "${n}=${toString v}\n") cfg.settings);
};
}
···
{ config, lib, pkgs, ... }:
let cfg = config.programs.spacefm;
in
···
programs.spacefm = {
+
enable = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Whether to install SpaceFM and create {file}`/etc/spacefm/spacefm.conf`.
'';
};
+
settings = lib.mkOption {
+
type = lib.types.attrs;
default = {
tmp_dir = "/tmp";
terminal_su = "${pkgs.sudo}/bin/sudo";
};
+
defaultText = lib.literalExpression ''
{
tmp_dir = "/tmp";
terminal_su = "''${pkgs.sudo}/bin/sudo";
···
###### implementation
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.spaceFM ];
environment.etc."spacefm/spacefm.conf".text =
+
lib.concatStrings (lib.mapAttrsToList (n: v: "${n}=${builtins.toString v}\n") cfg.settings);
};
}
+67 -69
nixos/modules/programs/ssh.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.ssh;
···
exec ${cfg.askPassword} "$@"
'';
-
knownHosts = attrValues cfg.knownHosts;
-
knownHostsText = (flip (concatMapStringsSep "\n") knownHosts
(h: assert h.hostNames != [];
-
optionalString h.certAuthority "@cert-authority " + concatStringsSep "," h.hostNames + " "
-
+ (if h.publicKey != null then h.publicKey else readFile h.publicKeyFile)
)) + "\n";
knownHostsFiles = [ "/etc/ssh/ssh_known_hosts" ]
-
++ map pkgs.copyPathToStore cfg.knownHostsFiles;
in
{
···
programs.ssh = {
-
enableAskPassword = mkOption {
-
type = types.bool;
default = config.services.xserver.enable;
-
defaultText = literalExpression "config.services.xserver.enable";
description = "Whether to configure SSH_ASKPASS in the environment.";
};
-
askPassword = mkOption {
-
type = types.str;
default = "${pkgs.x11_ssh_askpass}/libexec/x11-ssh-askpass";
-
defaultText = literalExpression ''"''${pkgs.x11_ssh_askpass}/libexec/x11-ssh-askpass"'';
description = "Program used by SSH to ask for passwords.";
};
-
forwardX11 = mkOption {
type = with lib.types; nullOr bool;
default = false;
description = ''
···
'';
};
-
setXAuthLocation = mkOption {
-
type = types.bool;
description = ''
Whether to set the path to {command}`xauth` for X11-forwarded connections.
This causes a dependency on X11 packages.
'';
};
-
pubkeyAcceptedKeyTypes = mkOption {
-
type = types.listOf types.str;
default = [];
example = [ "ssh-ed25519" "ssh-rsa" ];
description = ''
-
Specifies the key types that will be used for public key authentication.
'';
};
-
hostKeyAlgorithms = mkOption {
-
type = types.listOf types.str;
default = [];
example = [ "ssh-ed25519" "ssh-rsa" ];
description = ''
···
'';
};
-
extraConfig = mkOption {
-
type = types.lines;
default = "";
description = ''
Extra configuration text prepended to {file}`ssh_config`. Other generated
···
'';
};
-
startAgent = mkOption {
-
type = types.bool;
default = false;
description = ''
Whether to start the OpenSSH agent when you log in. The OpenSSH agent
···
'';
};
-
agentTimeout = mkOption {
-
type = types.nullOr types.str;
default = null;
example = "1h";
description = ''
···
'';
};
-
agentPKCS11Whitelist = mkOption {
-
type = types.nullOr types.str;
default = null;
-
example = literalExpression ''"''${pkgs.opensc}/lib/opensc-pkcs11.so"'';
description = ''
A pattern-list of acceptable paths for PKCS#11 shared libraries
that may be used with the -s option to ssh-add.
'';
};
-
package = mkPackageOption pkgs "openssh" { };
-
knownHosts = mkOption {
default = {};
-
type = types.attrsOf (types.submodule ({ name, config, options, ... }: {
options = {
-
certAuthority = mkOption {
-
type = types.bool;
default = false;
description = ''
This public key is an SSH certificate authority, rather than an
individual host's key.
'';
};
-
hostNames = mkOption {
-
type = types.listOf types.str;
default = [ name ] ++ config.extraHostNames;
-
defaultText = literalExpression "[ ${name} ] ++ config.${options.extraHostNames}";
description = ''
A list of host names and/or IP numbers used for accessing
the host's ssh service. This list includes the name of the
···
`hostNames` list.
'';
};
-
extraHostNames = mkOption {
-
type = types.listOf types.str;
default = [];
description = ''
A list of additional host names and/or IP numbers used for
···
`hostNames` is set explicitly.
'';
};
-
publicKey = mkOption {
default = null;
-
type = types.nullOr types.str;
example = "ecdsa-sha2-nistp521 AAAAE2VjZHN...UEPg==";
description = ''
The public key data for the host. You can fetch a public key
···
the key type and the key itself.
'';
};
-
publicKeyFile = mkOption {
default = null;
-
type = types.nullOr types.path;
description = ''
The path to the public key file for the host. The public
key file is read at build time and saved in the Nix store.
···
`extraHostNames` to add additional host names without
disabling this default.
'';
-
example = literalExpression ''
{
myhost = {
extraHostNames = [ "myhost.mydomain.com" "10.10.1.4" ];
···
'';
};
-
knownHostsFiles = mkOption {
default = [];
-
type = with types; listOf path;
description = ''
Files containing SSH host keys to set as global known hosts.
`/etc/ssh/ssh_known_hosts` (which is
generated by {option}`programs.ssh.knownHosts`) is
always included.
'';
-
example = literalExpression ''
[
./known_hosts
(writeText "github.keys" '''
···
'';
};
-
kexAlgorithms = mkOption {
-
type = types.nullOr (types.listOf types.str);
default = null;
example = [ "curve25519-sha256@libssh.org" "diffie-hellman-group-exchange-sha256" ];
description = ''
···
'';
};
-
ciphers = mkOption {
-
type = types.nullOr (types.listOf types.str);
default = null;
example = [ "chacha20-poly1305@openssh.com" "aes256-gcm@openssh.com" ];
description = ''
···
'';
};
-
macs = mkOption {
-
type = types.nullOr (types.listOf types.str);
default = null;
example = [ "hmac-sha2-512-etm@openssh.com" "hmac-sha1" ];
description = ''
···
config = {
programs.ssh.setXAuthLocation =
-
mkDefault (config.services.xserver.enable || config.programs.ssh.forwardX11 == true || config.services.openssh.settings.X11Forwarding);
assertions =
[ { assertion = cfg.forwardX11 == true -> cfg.setXAuthLocation;
message = "cannot enable X11 forwarding without setting XAuth location";
}
-
] ++ flip mapAttrsToList cfg.knownHosts (name: data: {
assertion = (data.publicKey == null && data.publicKeyFile != null) ||
(data.publicKey != null && data.publicKeyFile == null);
message = "knownHost ${name} must contain either a publicKey or publicKeyFile";
···
# Generated options from other settings
Host *
AddressFamily ${if config.networking.enableIPv6 then "any" else "inet"}
-
GlobalKnownHostsFile ${concatStringsSep " " knownHostsFiles}
-
${optionalString cfg.setXAuthLocation "XAuthLocation ${pkgs.xorg.xauth}/bin/xauth"}
${lib.optionalString (cfg.forwardX11 != null) "ForwardX11 ${if cfg.forwardX11 then "yes" else "no"}"}
-
${optionalString (cfg.pubkeyAcceptedKeyTypes != []) "PubkeyAcceptedKeyTypes ${concatStringsSep "," cfg.pubkeyAcceptedKeyTypes}"}
-
${optionalString (cfg.hostKeyAlgorithms != []) "HostKeyAlgorithms ${concatStringsSep "," cfg.hostKeyAlgorithms}"}
-
${optionalString (cfg.kexAlgorithms != null) "KexAlgorithms ${concatStringsSep "," cfg.kexAlgorithms}"}
-
${optionalString (cfg.ciphers != null) "Ciphers ${concatStringsSep "," cfg.ciphers}"}
-
${optionalString (cfg.macs != null) "MACs ${concatStringsSep "," cfg.macs}"}
'';
environment.etc."ssh/ssh_known_hosts".text = knownHostsText;
# FIXME: this should really be socket-activated for über-awesomeness.
-
systemd.user.services.ssh-agent = mkIf cfg.startAgent
{ description = "SSH Agent";
wantedBy = [ "default.target" ];
unitConfig.ConditionUser = "!@system";
···
{ ExecStartPre = "${pkgs.coreutils}/bin/rm -f %t/ssh-agent";
ExecStart =
"${cfg.package}/bin/ssh-agent " +
-
optionalString (cfg.agentTimeout != null) ("-t ${cfg.agentTimeout} ") +
-
optionalString (cfg.agentPKCS11Whitelist != null) ("-P ${cfg.agentPKCS11Whitelist} ") +
"-a %t/ssh-agent";
StandardOutput = "null";
Type = "forking";
···
# Allow ssh-agent to ask for confirmation. This requires the
# unit to know about the user's $DISPLAY (via ‘systemctl
# import-environment’).
-
environment.SSH_ASKPASS = optionalString cfg.enableAskPassword askPasswordWrapper;
environment.DISPLAY = "fake"; # required to make ssh-agent start $SSH_ASKPASS
};
-
environment.extraInit = optionalString cfg.startAgent
''
if [ -z "$SSH_AUTH_SOCK" -a -n "$XDG_RUNTIME_DIR" ]; then
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent"
fi
'';
-
environment.variables.SSH_ASKPASS = optionalString cfg.enableAskPassword cfg.askPassword;
};
}
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.ssh;
···
exec ${cfg.askPassword} "$@"
'';
+
knownHosts = builtins.attrValues cfg.knownHosts;
+
knownHostsText = (lib.flip (lib.concatMapStringsSep "\n") knownHosts
(h: assert h.hostNames != [];
+
lib.optionalString h.certAuthority "@cert-authority " + builtins.concatStringsSep "," h.hostNames + " "
+
+ (if h.publicKey != null then h.publicKey else builtins.readFile h.publicKeyFile)
)) + "\n";
knownHostsFiles = [ "/etc/ssh/ssh_known_hosts" ]
+
++ builtins.map pkgs.copyPathToStore cfg.knownHostsFiles;
in
{
···
programs.ssh = {
+
enableAskPassword = lib.mkOption {
+
type = lib.types.bool;
default = config.services.xserver.enable;
+
defaultText = lib.literalExpression "config.services.xserver.enable";
description = "Whether to configure SSH_ASKPASS in the environment.";
};
+
askPassword = lib.mkOption {
+
type = lib.types.str;
default = "${pkgs.x11_ssh_askpass}/libexec/x11-ssh-askpass";
+
defaultText = lib.literalExpression ''"''${pkgs.x11_ssh_askpass}/libexec/x11-ssh-askpass"'';
description = "Program used by SSH to ask for passwords.";
};
+
forwardX11 = lib.mkOption {
type = with lib.types; nullOr bool;
default = false;
description = ''
···
'';
};
+
setXAuthLocation = lib.mkOption {
+
type = lib.types.bool;
description = ''
Whether to set the path to {command}`xauth` for X11-forwarded connections.
This causes a dependency on X11 packages.
'';
};
+
pubkeyAcceptedKeyTypes = lib.mkOption {
+
type = lib.types.listOf lib.types.str;
default = [];
example = [ "ssh-ed25519" "ssh-rsa" ];
description = ''
+
Specifies the key lib.types that will be used for public key authentication.
'';
};
+
hostKeyAlgorithms = lib.mkOption {
+
type = lib.types.listOf lib.types.str;
default = [];
example = [ "ssh-ed25519" "ssh-rsa" ];
description = ''
···
'';
};
+
extraConfig = lib.mkOption {
+
type = lib.types.lines;
default = "";
description = ''
Extra configuration text prepended to {file}`ssh_config`. Other generated
···
'';
};
+
startAgent = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Whether to start the OpenSSH agent when you log in. The OpenSSH agent
···
'';
};
+
agentTimeout = lib.mkOption {
+
type = lib.types.nullOr lib.types.str;
default = null;
example = "1h";
description = ''
···
'';
};
+
agentPKCS11Whitelist = lib.mkOption {
+
type = lib.types.nullOr lib.types.str;
default = null;
+
example = lib.literalExpression ''"''${pkgs.opensc}/lib/opensc-pkcs11.so"'';
description = ''
A pattern-list of acceptable paths for PKCS#11 shared libraries
that may be used with the -s option to ssh-add.
'';
};
+
package = lib.mkPackageOption pkgs "openssh" { };
+
knownHosts = lib.mkOption {
default = {};
+
type = lib.types.attrsOf (lib.types.submodule ({ name, config, options, ... }: {
options = {
+
certAuthority = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
This public key is an SSH certificate authority, rather than an
individual host's key.
'';
};
+
hostNames = lib.mkOption {
+
type = lib.types.listOf lib.types.str;
default = [ name ] ++ config.extraHostNames;
+
defaultText = lib.literalExpression "[ ${name} ] ++ config.${options.extraHostNames}";
description = ''
A list of host names and/or IP numbers used for accessing
the host's ssh service. This list includes the name of the
···
`hostNames` list.
'';
};
+
extraHostNames = lib.mkOption {
+
type = lib.types.listOf lib.types.str;
default = [];
description = ''
A list of additional host names and/or IP numbers used for
···
`hostNames` is set explicitly.
'';
};
+
publicKey = lib.mkOption {
default = null;
+
type = lib.types.nullOr lib.types.str;
example = "ecdsa-sha2-nistp521 AAAAE2VjZHN...UEPg==";
description = ''
The public key data for the host. You can fetch a public key
···
the key type and the key itself.
'';
};
+
publicKeyFile = lib.mkOption {
default = null;
+
type = lib.types.nullOr lib.types.path;
description = ''
The path to the public key file for the host. The public
key file is read at build time and saved in the Nix store.
···
`extraHostNames` to add additional host names without
disabling this default.
'';
+
example = lib.literalExpression ''
{
myhost = {
extraHostNames = [ "myhost.mydomain.com" "10.10.1.4" ];
···
'';
};
+
knownHostsFiles = lib.mkOption {
default = [];
+
type = with lib.types; listOf path;
description = ''
Files containing SSH host keys to set as global known hosts.
`/etc/ssh/ssh_known_hosts` (which is
generated by {option}`programs.ssh.knownHosts`) is
always included.
'';
+
example = lib.literalExpression ''
[
./known_hosts
(writeText "github.keys" '''
···
'';
};
+
kexAlgorithms = lib.mkOption {
+
type = lib.types.nullOr (lib.types.listOf lib.types.str);
default = null;
example = [ "curve25519-sha256@libssh.org" "diffie-hellman-group-exchange-sha256" ];
description = ''
···
'';
};
+
ciphers = lib.mkOption {
+
type = lib.types.nullOr (lib.types.listOf lib.types.str);
default = null;
example = [ "chacha20-poly1305@openssh.com" "aes256-gcm@openssh.com" ];
description = ''
···
'';
};
+
macs = lib.mkOption {
+
type = lib.types.nullOr (lib.types.listOf lib.types.str);
default = null;
example = [ "hmac-sha2-512-etm@openssh.com" "hmac-sha1" ];
description = ''
···
config = {
programs.ssh.setXAuthLocation =
+
lib.mkDefault (config.services.xserver.enable || config.programs.ssh.forwardX11 == true || config.services.openssh.settings.X11Forwarding);
assertions =
[ { assertion = cfg.forwardX11 == true -> cfg.setXAuthLocation;
message = "cannot enable X11 forwarding without setting XAuth location";
}
+
] ++ lib.flip lib.mapAttrsToList cfg.knownHosts (name: data: {
assertion = (data.publicKey == null && data.publicKeyFile != null) ||
(data.publicKey != null && data.publicKeyFile == null);
message = "knownHost ${name} must contain either a publicKey or publicKeyFile";
···
# Generated options from other settings
Host *
AddressFamily ${if config.networking.enableIPv6 then "any" else "inet"}
+
GlobalKnownHostsFile ${builtins.concatStringsSep " " knownHostsFiles}
+
${lib.optionalString cfg.setXAuthLocation "XAuthLocation ${pkgs.xorg.xauth}/bin/xauth"}
${lib.optionalString (cfg.forwardX11 != null) "ForwardX11 ${if cfg.forwardX11 then "yes" else "no"}"}
+
${lib.optionalString (cfg.pubkeyAcceptedKeyTypes != []) "PubkeyAcceptedKeyTypes ${builtins.concatStringsSep "," cfg.pubkeyAcceptedKeyTypes}"}
+
${lib.optionalString (cfg.hostKeyAlgorithms != []) "HostKeyAlgorithms ${builtins.concatStringsSep "," cfg.hostKeyAlgorithms}"}
+
${lib.optionalString (cfg.kexAlgorithms != null) "KexAlgorithms ${builtins.concatStringsSep "," cfg.kexAlgorithms}"}
+
${lib.optionalString (cfg.ciphers != null) "Ciphers ${builtins.concatStringsSep "," cfg.ciphers}"}
+
${lib.optionalString (cfg.macs != null) "MACs ${builtins.concatStringsSep "," cfg.macs}"}
'';
environment.etc."ssh/ssh_known_hosts".text = knownHostsText;
# FIXME: this should really be socket-activated for über-awesomeness.
+
systemd.user.services.ssh-agent = lib.mkIf cfg.startAgent
{ description = "SSH Agent";
wantedBy = [ "default.target" ];
unitConfig.ConditionUser = "!@system";
···
{ ExecStartPre = "${pkgs.coreutils}/bin/rm -f %t/ssh-agent";
ExecStart =
"${cfg.package}/bin/ssh-agent " +
+
lib.optionalString (cfg.agentTimeout != null) ("-t ${cfg.agentTimeout} ") +
+
lib.optionalString (cfg.agentPKCS11Whitelist != null) ("-P ${cfg.agentPKCS11Whitelist} ") +
"-a %t/ssh-agent";
StandardOutput = "null";
Type = "forking";
···
# Allow ssh-agent to ask for confirmation. This requires the
# unit to know about the user's $DISPLAY (via ‘systemctl
# import-environment’).
+
environment.SSH_ASKPASS = lib.optionalString cfg.enableAskPassword askPasswordWrapper;
environment.DISPLAY = "fake"; # required to make ssh-agent start $SSH_ASKPASS
};
+
environment.extraInit = lib.optionalString cfg.startAgent
''
if [ -z "$SSH_AUTH_SOCK" -a -n "$XDG_RUNTIME_DIR" ]; then
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent"
fi
'';
+
environment.variables.SSH_ASKPASS = lib.optionalString cfg.enableAskPassword cfg.askPassword;
};
}
+35 -37
nixos/modules/programs/steam.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.steam;
gamescopeCfg = config.programs.gamescope;
···
in
pkgs.writeShellScriptBin "steam-gamescope" ''
${builtins.concatStringsSep "\n" exports}
-
gamescope --steam ${toString cfg.gamescopeSession.args} -- steam -tenfoot -pipewire-dmabuf
'';
gamescopeSessionFile =
···
'').overrideAttrs (_: { passthru.providedSessions = [ "steam" ]; });
in {
options.programs.steam = {
-
enable = mkEnableOption "steam";
-
package = mkOption {
-
type = types.package;
default = pkgs.steam;
-
defaultText = literalExpression "pkgs.steam";
-
example = literalExpression ''
pkgs.steam-small.override {
extraEnv = {
MANGOHUD = true;
···
'';
apply = steam: steam.override (prev: {
extraEnv = (lib.optionalAttrs (cfg.extraCompatPackages != [ ]) {
-
STEAM_EXTRA_COMPAT_TOOLS_PATHS = makeSearchPathOutput "steamcompattool" "" cfg.extraCompatPackages;
-
}) // (optionalAttrs cfg.extest.enable {
LD_PRELOAD = "${pkgs.pkgsi686Linux.extest}/lib/libextest.so";
}) // (prev.extraEnv or {});
extraLibraries = pkgs: let
···
then [ package ] ++ extraPackages
else [ package32 ] ++ extraPackages32;
in prevLibs ++ additionalLibs;
-
} // optionalAttrs (cfg.gamescopeSession.enable && gamescopeCfg.capSysNice)
{
buildFHSEnv = pkgs.buildFHSEnv.override {
# use the setuid wrapped bubblewrap
···
'';
};
-
extraCompatPackages = mkOption {
-
type = types.listOf types.package;
default = [ ];
-
example = literalExpression ''
with pkgs; [
proton-ge-bin
]
···
'';
};
-
remotePlay.openFirewall = mkOption {
-
type = types.bool;
default = false;
description = ''
Open ports in the firewall for Steam Remote Play.
'';
};
-
dedicatedServer.openFirewall = mkOption {
-
type = types.bool;
default = false;
description = ''
Open ports in the firewall for Source Dedicated Server.
'';
};
-
localNetworkGameTransfers.openFirewall = mkOption {
-
type = types.bool;
default = false;
description = ''
Open ports in the firewall for Steam Local Network Game Transfers.
'';
};
-
gamescopeSession = mkOption {
description = "Run a GameScope driven Steam session from your display-manager";
default = {};
-
type = types.submodule {
options = {
-
enable = mkEnableOption "GameScope Session";
-
args = mkOption {
-
type = types.listOf types.str;
default = [ ];
description = ''
Arguments to be passed to GameScope for the session.
'';
};
-
env = mkOption {
-
type = types.attrsOf types.str;
default = { };
description = ''
Environmental variables to be passed to GameScope for the session.
···
};
};
-
extest.enable = mkEnableOption ''
Load the extest library into Steam, to translate X11 input events to
uinput events (e.g. for using Steam Input on Wayland)
'';
};
-
config = mkIf cfg.enable {
hardware.opengl = { # this fixes the "glXChooseVisual failed" bug, context: https://github.com/NixOS/nixpkgs/issues/47932
enable = true;
driSupport = true;
driSupport32Bit = true;
};
-
security.wrappers = mkIf (cfg.gamescopeSession.enable && gamescopeCfg.capSysNice) {
# needed or steam fails
bwrap = {
owner = "root";
···
};
};
-
programs.gamescope.enable = mkDefault cfg.gamescopeSession.enable;
-
services.displayManager.sessionPackages = mkIf cfg.gamescopeSession.enable [ gamescopeSessionFile ];
# optionally enable 32bit pulseaudio support if pulseaudio is enabled
hardware.pulseaudio.support32Bit = config.hardware.pulseaudio.enable;
···
] ++ lib.optional cfg.gamescopeSession.enable steam-gamescope;
networking.firewall = lib.mkMerge [
-
(mkIf (cfg.remotePlay.openFirewall || cfg.localNetworkGameTransfers.openFirewall) {
allowedUDPPorts = [ 27036 ]; # Peer discovery
})
-
(mkIf cfg.remotePlay.openFirewall {
allowedTCPPorts = [ 27036 ];
allowedUDPPortRanges = [ { from = 27031; to = 27035; } ];
})
-
(mkIf cfg.dedicatedServer.openFirewall {
allowedTCPPorts = [ 27015 ]; # SRCDS Rcon port
allowedUDPPorts = [ 27015 ]; # Gameplay traffic
})
-
(mkIf cfg.localNetworkGameTransfers.openFirewall {
allowedTCPPorts = [ 27040 ]; # Data transfers
})
];
};
-
meta.maintainers = teams.steam;
}
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.steam;
gamescopeCfg = config.programs.gamescope;
···
in
pkgs.writeShellScriptBin "steam-gamescope" ''
${builtins.concatStringsSep "\n" exports}
+
gamescope --steam ${builtins.toString cfg.gamescopeSession.args} -- steam -tenfoot -pipewire-dmabuf
'';
gamescopeSessionFile =
···
'').overrideAttrs (_: { passthru.providedSessions = [ "steam" ]; });
in {
options.programs.steam = {
+
enable = lib.mkEnableOption "steam";
+
package = lib.mkOption {
+
type = lib.types.package;
default = pkgs.steam;
+
defaultText = lib.literalExpression "pkgs.steam";
+
example = lib.literalExpression ''
pkgs.steam-small.override {
extraEnv = {
MANGOHUD = true;
···
'';
apply = steam: steam.override (prev: {
extraEnv = (lib.optionalAttrs (cfg.extraCompatPackages != [ ]) {
+
STEAM_EXTRA_COMPAT_TOOLS_PATHS = lib.makeSearchPathOutput "steamcompattool" "" cfg.extraCompatPackages;
+
}) // (lib.optionalAttrs cfg.extest.enable {
LD_PRELOAD = "${pkgs.pkgsi686Linux.extest}/lib/libextest.so";
}) // (prev.extraEnv or {});
extraLibraries = pkgs: let
···
then [ package ] ++ extraPackages
else [ package32 ] ++ extraPackages32;
in prevLibs ++ additionalLibs;
+
} // lib.optionalAttrs (cfg.gamescopeSession.enable && gamescopeCfg.capSysNice)
{
buildFHSEnv = pkgs.buildFHSEnv.override {
# use the setuid wrapped bubblewrap
···
'';
};
+
extraCompatPackages = lib.mkOption {
+
type = lib.types.listOf lib.types.package;
default = [ ];
+
example = lib.literalExpression ''
with pkgs; [
proton-ge-bin
]
···
'';
};
+
remotePlay.openFirewall = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Open ports in the firewall for Steam Remote Play.
'';
};
+
dedicatedServer.openFirewall = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Open ports in the firewall for Source Dedicated Server.
'';
};
+
localNetworkGameTransfers.openFirewall = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Open ports in the firewall for Steam Local Network Game Transfers.
'';
};
+
gamescopeSession = lib.mkOption {
description = "Run a GameScope driven Steam session from your display-manager";
default = {};
+
type = lib.types.submodule {
options = {
+
enable = lib.mkEnableOption "GameScope Session";
+
args = lib.mkOption {
+
type = lib.types.listOf lib.types.str;
default = [ ];
description = ''
Arguments to be passed to GameScope for the session.
'';
};
+
env = lib.mkOption {
+
type = lib.types.attrsOf lib.types.str;
default = { };
description = ''
Environmental variables to be passed to GameScope for the session.
···
};
};
+
extest.enable = lib.mkEnableOption ''
Load the extest library into Steam, to translate X11 input events to
uinput events (e.g. for using Steam Input on Wayland)
'';
};
+
config = lib.mkIf cfg.enable {
hardware.opengl = { # this fixes the "glXChooseVisual failed" bug, context: https://github.com/NixOS/nixpkgs/issues/47932
enable = true;
driSupport = true;
driSupport32Bit = true;
};
+
security.wrappers = lib.mkIf (cfg.gamescopeSession.enable && gamescopeCfg.capSysNice) {
# needed or steam fails
bwrap = {
owner = "root";
···
};
};
+
programs.gamescope.enable = lib.mkDefault cfg.gamescopeSession.enable;
+
services.displayManager.sessionPackages = lib.mkIf cfg.gamescopeSession.enable [ gamescopeSessionFile ];
# optionally enable 32bit pulseaudio support if pulseaudio is enabled
hardware.pulseaudio.support32Bit = config.hardware.pulseaudio.enable;
···
] ++ lib.optional cfg.gamescopeSession.enable steam-gamescope;
networking.firewall = lib.mkMerge [
+
(lib.mkIf (cfg.remotePlay.openFirewall || cfg.localNetworkGameTransfers.openFirewall) {
allowedUDPPorts = [ 27036 ]; # Peer discovery
})
+
(lib.mkIf cfg.remotePlay.openFirewall {
allowedTCPPorts = [ 27036 ];
allowedUDPPortRanges = [ { from = 27031; to = 27035; } ];
})
+
(lib.mkIf cfg.dedicatedServer.openFirewall {
allowedTCPPorts = [ 27015 ]; # SRCDS Rcon port
allowedUDPPorts = [ 27015 ]; # Gameplay traffic
})
+
(lib.mkIf cfg.localNetworkGameTransfers.openFirewall {
allowedTCPPorts = [ 27040 ]; # Data transfers
})
];
};
+
meta.maintainers = lib.teams.steam;
}
+8 -10
nixos/modules/programs/streamdeck-ui.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.streamdeck-ui;
in
{
options.programs.streamdeck-ui = {
-
enable = mkEnableOption "streamdeck-ui";
-
autoStart = mkOption {
default = true;
-
type = types.bool;
description = "Whether streamdeck-ui should be started automatically.";
};
-
package = mkPackageOption pkgs "streamdeck-ui" {
default = [ "streamdeck-ui" ];
};
};
-
config = mkIf cfg.enable {
-
environment.systemPackages = with pkgs; [
cfg.package
-
(mkIf cfg.autoStart (makeAutostartItem { name = "streamdeck-ui-noui"; package = cfg.package; }))
];
services.udev.packages = [ cfg.package ];
};
-
meta.maintainers = with maintainers; [ majiir ];
}
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.streamdeck-ui;
in
{
options.programs.streamdeck-ui = {
+
enable = lib.mkEnableOption "streamdeck-ui";
+
autoStart = lib.mkOption {
default = true;
+
type = lib.types.bool;
description = "Whether streamdeck-ui should be started automatically.";
};
+
package = lib.mkPackageOption pkgs "streamdeck-ui" {
default = [ "streamdeck-ui" ];
};
};
+
config = lib.mkIf cfg.enable {
+
environment.systemPackages = [
cfg.package
+
(lib.mkIf cfg.autoStart (pkgs.makeAutostartItem { name = "streamdeck-ui-noui"; package = cfg.package; }))
];
services.udev.packages = [ cfg.package ];
};
+
meta.maintainers = with lib.maintainers; [ majiir ];
}
+2 -4
nixos/modules/programs/sysdig.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.sysdig;
in {
-
options.programs.sysdig.enable = mkEnableOption "sysdig, a tracing tool";
-
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.sysdig ];
boot.extraModulePackages = [ config.boot.kernelPackages.sysdig ];
};
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.sysdig;
in {
+
options.programs.sysdig.enable = lib.mkEnableOption "sysdig, a tracing tool";
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.sysdig ];
boot.extraModulePackages = [ config.boot.kernelPackages.sysdig ];
};
+2 -4
nixos/modules/programs/system-config-printer.nix
···
{ config, pkgs, lib, ... }:
-
with lib;
-
{
###### interface
···
programs.system-config-printer = {
-
enable = mkEnableOption "system-config-printer, a Graphical user interface for CUPS administration";
};
···
###### implementation
-
config = mkIf config.programs.system-config-printer.enable {
environment.systemPackages = [
pkgs.system-config-printer
···
{ config, pkgs, lib, ... }:
{
###### interface
···
programs.system-config-printer = {
+
enable = lib.mkEnableOption "system-config-printer, a Graphical user interface for CUPS administration";
};
···
###### implementation
+
config = lib.mkIf config.programs.system-config-printer.enable {
environment.systemPackages = [
pkgs.system-config-printer
+3 -5
nixos/modules/programs/systemtap.nix
···
{ config, lib, ... }:
-
with lib;
-
let cfg = config.programs.systemtap;
in {
options = {
programs.systemtap = {
-
enable = mkOption {
-
type = types.bool;
default = false;
description = ''
Install {command}`systemtap` along with necessary kernel options.
···
};
};
};
-
config = mkIf cfg.enable {
system.requiredKernelConfig = with config.lib.kernelConfig; [
(isYes "DEBUG")
];
···
{ config, lib, ... }:
let cfg = config.programs.systemtap;
in {
options = {
programs.systemtap = {
+
enable = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Install {command}`systemtap` along with necessary kernel options.
···
};
};
};
+
config = lib.mkIf cfg.enable {
system.requiredKernelConfig = with config.lib.kernelConfig; [
(isYes "DEBUG")
];
+6 -8
nixos/modules/programs/thefuck.nix
···
{ config, pkgs, lib, ... }:
-
with lib;
-
let
prg = config.programs;
cfg = prg.thefuck;
···
{
options = {
programs.thefuck = {
-
enable = mkEnableOption "thefuck, an app which corrects your previous console command";
-
alias = mkOption {
default = "fuck";
-
type = types.str;
description = ''
`thefuck` needs an alias to be configured.
···
};
};
-
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [ thefuck ];
programs.bash.interactiveShellInit = bashAndZshInitScript;
-
programs.zsh.interactiveShellInit = mkIf prg.zsh.enable bashAndZshInitScript;
-
programs.fish.interactiveShellInit = mkIf prg.fish.enable fishInitScript;
};
}
···
{ config, pkgs, lib, ... }:
let
prg = config.programs;
cfg = prg.thefuck;
···
{
options = {
programs.thefuck = {
+
enable = lib.mkEnableOption "thefuck, an app which corrects your previous console command";
+
alias = lib.mkOption {
default = "fuck";
+
type = lib.types.str;
description = ''
`thefuck` needs an alias to be configured.
···
};
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ thefuck ];
programs.bash.interactiveShellInit = bashAndZshInitScript;
+
programs.zsh.interactiveShellInit = lib.mkIf prg.zsh.enable bashAndZshInitScript;
+
programs.fish.interactiveShellInit = lib.mkIf prg.fish.enable fishInitScript;
};
}
+6 -8
nixos/modules/programs/thunar.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let cfg = config.programs.thunar;
in {
meta = {
-
maintainers = teams.xfce.members;
};
options = {
programs.thunar = {
-
enable = mkEnableOption "Thunar, the Xfce file manager";
-
plugins = mkOption {
default = [];
-
type = types.listOf types.package;
description = "List of thunar plugins to install.";
-
example = literalExpression "with pkgs.xfce; [ thunar-archive-plugin thunar-volman ]";
};
};
};
-
config = mkIf cfg.enable (
let package = pkgs.xfce.thunar.override { thunarPlugins = cfg.plugins; };
in {
···
{ config, lib, pkgs, ... }:
let cfg = config.programs.thunar;
in {
meta = {
+
maintainers = lib.teams.xfce.members;
};
options = {
programs.thunar = {
+
enable = lib.mkEnableOption "Thunar, the Xfce file manager";
+
plugins = lib.mkOption {
default = [];
+
type = lib.types.listOf lib.types.package;
description = "List of thunar plugins to install.";
+
example = lib.literalExpression "with pkgs.xfce; [ thunar-archive-plugin thunar-volman ]";
};
};
};
+
config = lib.mkIf cfg.enable (
let package = pkgs.xfce.thunar.override { thunarPlugins = cfg.plugins; };
in {
+3 -5
nixos/modules/programs/traceroute.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.traceroute;
in {
options = {
programs.traceroute = {
-
enable = mkOption {
-
type = types.bool;
default = false;
description = ''
Whether to configure a setcap wrapper for traceroute.
···
};
};
-
config = mkIf cfg.enable {
security.wrappers.traceroute = {
owner = "root";
group = "root";
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.traceroute;
in {
options = {
programs.traceroute = {
+
enable = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Whether to configure a setcap wrapper for traceroute.
···
};
};
+
config = lib.mkIf cfg.enable {
security.wrappers.traceroute = {
owner = "root";
group = "root";
+3 -5
nixos/modules/programs/turbovnc.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.turbovnc;
in
···
programs.turbovnc = {
-
ensureHeadlessSoftwareOpenGL = mkOption {
-
type = types.bool;
default = false;
description = ''
Whether to set up NixOS such that TurboVNC's built-in software OpenGL
···
};
-
config = mkIf cfg.ensureHeadlessSoftwareOpenGL {
# TurboVNC has builtin support for Mesa llvmpipe's `swrast`
# software rendering to implement GLX (OpenGL on Xorg).
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.turbovnc;
in
···
programs.turbovnc = {
+
ensureHeadlessSoftwareOpenGL = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Whether to set up NixOS such that TurboVNC's built-in software OpenGL
···
};
+
config = lib.mkIf cfg.ensureHeadlessSoftwareOpenGL {
# TurboVNC has builtin support for Mesa llvmpipe's `swrast`
# software rendering to implement GLX (OpenGL on Xorg).
+2 -4
nixos/modules/programs/udevil.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.udevil;
in {
-
options.programs.udevil.enable = mkEnableOption "udevil, to mount filesystems without password";
-
config = mkIf cfg.enable {
security.wrappers.udevil =
{ setuid = true;
owner = "root";
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.udevil;
in {
+
options.programs.udevil.enable = lib.mkEnableOption "udevil, to mount filesystems without password";
+
config = lib.mkIf cfg.enable {
security.wrappers.udevil =
{ setuid = true;
owner = "root";
+2 -4
nixos/modules/programs/usbtop.nix
···
{ config, pkgs, lib, ... }:
-
with lib;
-
let
cfg = config.programs.usbtop;
in {
options = {
-
programs.usbtop.enable = mkEnableOption "usbtop and required kernel module, to show estimated USB bandwidth";
};
-
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [
usbtop
];
···
{ config, pkgs, lib, ... }:
let
cfg = config.programs.usbtop;
in {
options = {
+
programs.usbtop.enable = lib.mkEnableOption "usbtop and required kernel module, to show estimated USB bandwidth";
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [
usbtop
];
+5 -7
nixos/modules/programs/vim.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.vim;
in {
options.programs.vim = {
-
defaultEditor = mkOption {
-
type = types.bool;
default = false;
description = ''
When enabled, installs vim and configures vim to be the default editor
···
'';
};
-
package = mkPackageOption pkgs "vim" {
example = "vim-full";
};
};
-
config = mkIf cfg.defaultEditor {
environment.systemPackages = [ cfg.package ];
-
environment.variables = { EDITOR = mkOverride 900 "vim"; };
};
}
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.vim;
in {
options.programs.vim = {
+
defaultEditor = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
When enabled, installs vim and configures vim to be the default editor
···
'';
};
+
package = lib.mkPackageOption pkgs "vim" {
example = "vim-full";
};
};
+
config = lib.mkIf cfg.defaultEditor {
environment.systemPackages = [ cfg.package ];
+
environment.variables = { EDITOR = lib.mkOverride 900 "vim"; };
};
}
+3 -5
nixos/modules/programs/wavemon.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.wavemon;
in {
options = {
programs.wavemon = {
-
enable = mkOption {
-
type = types.bool;
default = false;
description = ''
Whether to add wavemon to the global environment and configure a
···
};
};
-
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [ wavemon ];
security.wrappers.wavemon = {
owner = "root";
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.wavemon;
in {
options = {
programs.wavemon = {
+
enable = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Whether to add wavemon to the global environment and configure a
···
};
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ wavemon ];
security.wrappers.wavemon = {
owner = "root";
+21 -21
nixos/modules/programs/wayland/hyprland.nix
···
, pkgs
, ...
}:
-
with lib; let
cfg = config.programs.hyprland;
finalPortalPackage = cfg.portalPackage.override {
···
in
{
options.programs.hyprland = {
-
enable = mkEnableOption null // {
description = ''
Whether to enable Hyprland, the dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
···
'';
};
-
package = mkPackageOption pkgs "hyprland" { };
-
finalPackage = mkOption {
-
type = types.package;
readOnly = true;
default = cfg.package.override {
enableXWayland = cfg.xwayland.enable;
};
-
defaultText = literalExpression
"`programs.hyprland.package` with applied configuration";
description = ''
The Hyprland package after applying configuration.
'';
};
-
portalPackage = mkPackageOption pkgs "xdg-desktop-portal-hyprland" { };
-
xwayland.enable = mkEnableOption ("XWayland") // { default = true; };
-
systemd.setPath.enable = mkEnableOption null // {
default = true;
example = false;
description = ''
···
};
};
-
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.finalPackage ];
-
fonts.enableDefaultPackages = mkDefault true;
-
hardware.opengl.enable = mkDefault true;
programs = {
-
dconf.enable = mkDefault true;
-
xwayland.enable = mkDefault cfg.xwayland.enable;
};
security.polkit.enable = true;
···
services.displayManager.sessionPackages = [ cfg.finalPackage ];
xdg.portal = {
-
enable = mkDefault true;
extraPortals = [ finalPortalPackage ];
-
configPackages = mkDefault [ cfg.finalPackage ];
};
-
systemd = mkIf cfg.systemd.setPath.enable {
user.extraConfig = ''
DefaultEnvironment="PATH=$PATH:/run/current-system/sw/bin:/etc/profiles/per-user/%u/bin:/run/wrappers/bin"
'';
};
};
-
imports = with lib; [
-
(mkRemovedOptionModule
[ "programs" "hyprland" "xwayland" "hidpi" ]
"XWayland patches are deprecated. Refer to https://wiki.hyprland.org/Configuring/XWayland"
)
-
(mkRemovedOptionModule
[ "programs" "hyprland" "enableNvidiaPatches" ]
"Nvidia patches are no longer needed"
)
-
(mkRemovedOptionModule
[ "programs" "hyprland" "nvidiaPatches" ]
"Nvidia patches are no longer needed"
)
···
, pkgs
, ...
}:
+
let
cfg = config.programs.hyprland;
finalPortalPackage = cfg.portalPackage.override {
···
in
{
options.programs.hyprland = {
+
enable = lib.mkEnableOption null // {
description = ''
Whether to enable Hyprland, the dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
···
'';
};
+
package = lib.mkPackageOption pkgs "hyprland" { };
+
finalPackage = lib.mkOption {
+
type = lib.types.package;
readOnly = true;
default = cfg.package.override {
enableXWayland = cfg.xwayland.enable;
};
+
defaultText = lib.literalExpression
"`programs.hyprland.package` with applied configuration";
description = ''
The Hyprland package after applying configuration.
'';
};
+
portalPackage = lib.mkPackageOption pkgs "xdg-desktop-portal-hyprland" { };
+
xwayland.enable = lib.mkEnableOption ("XWayland") // { default = true; };
+
systemd.setPath.enable = lib.mkEnableOption null // {
default = true;
example = false;
description = ''
···
};
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.finalPackage ];
+
fonts.enableDefaultPackages = lib.mkDefault true;
+
hardware.opengl.enable = lib.mkDefault true;
programs = {
+
dconf.enable = lib.mkDefault true;
+
xwayland.enable = lib.mkDefault cfg.xwayland.enable;
};
security.polkit.enable = true;
···
services.displayManager.sessionPackages = [ cfg.finalPackage ];
xdg.portal = {
+
enable = lib.mkDefault true;
extraPortals = [ finalPortalPackage ];
+
configPackages = lib.mkDefault [ cfg.finalPackage ];
};
+
systemd = lib.mkIf cfg.systemd.setPath.enable {
user.extraConfig = ''
DefaultEnvironment="PATH=$PATH:/run/current-system/sw/bin:/etc/profiles/per-user/%u/bin:/run/wrappers/bin"
'';
};
};
+
imports = [
+
(lib.mkRemovedOptionModule
[ "programs" "hyprland" "xwayland" "hidpi" ]
"XWayland patches are deprecated. Refer to https://wiki.hyprland.org/Configuring/XWayland"
)
+
(lib.mkRemovedOptionModule
[ "programs" "hyprland" "enableNvidiaPatches" ]
"Nvidia patches are no longer needed"
)
+
(lib.mkRemovedOptionModule
[ "programs" "hyprland" "nvidiaPatches" ]
"Nvidia patches are no longer needed"
)
+11 -11
nixos/modules/programs/wayland/river.nix
···
lib,
...
}:
-
with lib; let
cfg = config.programs.river;
in {
options.programs.river = {
-
enable = mkEnableOption "river, a dynamic tiling Wayland compositor";
-
package = mkPackageOption pkgs "river" {
nullable = true;
extraDescription = ''
Set to `null` to not add any River package to your path.
···
'';
};
-
extraPackages = mkOption {
-
type = with types; listOf package;
default = with pkgs; [
swaylock
foot
dmenu
];
-
defaultText = literalExpression ''
with pkgs; [ swaylock foot dmenu ];
'';
-
example = literalExpression ''
with pkgs; [
termite rofi light
]
···
};
config =
-
mkIf cfg.enable (mkMerge [
{
-
environment.systemPackages = optional (cfg.package != null) cfg.package ++ cfg.extraPackages;
# To make a river session available if a display manager like SDDM is enabled:
-
services.displayManager.sessionPackages = optionals (cfg.package != null) [ cfg.package ];
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1050913
-
xdg.portal.config.river.default = mkDefault [ "wlr" "gtk" ];
}
(import ./wayland-session.nix { inherit lib pkgs; })
]);
···
lib,
...
}:
+
let
cfg = config.programs.river;
in {
options.programs.river = {
+
enable = lib.mkEnableOption "river, a dynamic tiling Wayland compositor";
+
package = lib.mkPackageOption pkgs "river" {
nullable = true;
extraDescription = ''
Set to `null` to not add any River package to your path.
···
'';
};
+
extraPackages = lib.mkOption {
+
type = with lib.types; listOf package;
default = with pkgs; [
swaylock
foot
dmenu
];
+
defaultText = lib.literalExpression ''
with pkgs; [ swaylock foot dmenu ];
'';
+
example = lib.literalExpression ''
with pkgs; [
termite rofi light
]
···
};
config =
+
lib.mkIf cfg.enable (lib.mkMerge [
{
+
environment.systemPackages = lib.optional (cfg.package != null) cfg.package ++ cfg.extraPackages;
# To make a river session available if a display manager like SDDM is enabled:
+
services.displayManager.sessionPackages = lib.optionals (cfg.package != null) [ cfg.package ];
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1050913
+
xdg.portal.config.river.default = lib.mkDefault [ "wlr" "gtk" ];
}
(import ./wayland-session.nix { inherit lib pkgs; })
]);
+24 -26
nixos/modules/programs/wayland/sway.nix
···
{ config, pkgs, lib, ... }:
-
with lib;
-
let
cfg = config.programs.sway;
-
wrapperOptions = types.submodule {
options =
let
-
mkWrapperFeature = default: description: mkOption {
-
type = types.bool;
inherit default;
example = !default;
description = "Whether to make use of the ${description}";
···
};
in {
options.programs.sway = {
-
enable = mkEnableOption ''
Sway, the i3-compatible tiling Wayland compositor. You can manually launch
Sway by executing "exec sway" on a TTY. Copy /etc/sway/config to
~/.config/sway/config to modify the default configuration. See
<https://github.com/swaywm/sway/wiki> and
"man 5 sway" for more information'';
-
package = mkOption {
-
type = with types; nullOr package;
default = pkgs.sway;
apply = p: if p == null then null else genFinalPackage p;
-
defaultText = literalExpression "pkgs.sway";
description = ''
Sway package to use. If the package does not contain the override arguments
`extraSessionCommands`, `extraOptions`, `withBaseWrapper`, `withGtkWrapper`,
···
'';
};
-
wrapperFeatures = mkOption {
type = wrapperOptions;
default = { };
example = { gtk = true; };
···
'';
};
-
extraSessionCommands = mkOption {
-
type = types.lines;
default = "";
example = ''
# SDL:
···
'';
};
-
extraOptions = mkOption {
-
type = types.listOf types.str;
default = [];
example = [
"--verbose"
···
'';
};
-
extraPackages = mkOption {
-
type = with types; listOf package;
default = with pkgs; [
swaylock swayidle foot dmenu wmenu
];
-
defaultText = literalExpression ''
with pkgs; [ swaylock swayidle foot dmenu wmenu ];
'';
-
example = literalExpression ''
with pkgs; [
i3status i3status-rust
termite rofi light
···
};
-
config = mkIf cfg.enable
-
(mkMerge [
{
assertions = [
{
···
];
environment = {
-
systemPackages = optional (cfg.package != null) cfg.package ++ cfg.extraPackages;
# Needed for the default wallpaper:
-
pathsToLink = optionals (cfg.package != null) [ "/share/backgrounds/sway" ];
etc = {
"sway/config.d/nixos.conf".source = pkgs.writeText "nixos.conf" ''
# Import the most important environment variables into the D-Bus and systemd
# user environments (e.g. required for screen sharing and Pinentry prompts):
exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP
'';
-
} // optionalAttrs (cfg.package != null) {
-
"sway/config".source = mkOptionDefault "${cfg.package}/etc/sway/config";
};
};
programs.gnupg.agent.pinentryPackage = lib.mkDefault pkgs.pinentry-gnome3;
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1050913
-
xdg.portal.config.sway.default = mkDefault [ "wlr" "gtk" ];
# To make a Sway session available if a display manager like SDDM is enabled:
-
services.displayManager.sessionPackages = optionals (cfg.package != null) [ cfg.package ]; }
(import ./wayland-session.nix { inherit lib pkgs; })
]);
···
{ config, pkgs, lib, ... }:
let
cfg = config.programs.sway;
+
wrapperOptions = lib.types.submodule {
options =
let
+
mkWrapperFeature = default: description: lib.mkOption {
+
type = lib.types.bool;
inherit default;
example = !default;
description = "Whether to make use of the ${description}";
···
};
in {
options.programs.sway = {
+
enable = lib.mkEnableOption ''
Sway, the i3-compatible tiling Wayland compositor. You can manually launch
Sway by executing "exec sway" on a TTY. Copy /etc/sway/config to
~/.config/sway/config to modify the default configuration. See
<https://github.com/swaywm/sway/wiki> and
"man 5 sway" for more information'';
+
package = lib.mkOption {
+
type = with lib.types; nullOr package;
default = pkgs.sway;
apply = p: if p == null then null else genFinalPackage p;
+
defaultText = lib.literalExpression "pkgs.sway";
description = ''
Sway package to use. If the package does not contain the override arguments
`extraSessionCommands`, `extraOptions`, `withBaseWrapper`, `withGtkWrapper`,
···
'';
};
+
wrapperFeatures = lib.mkOption {
type = wrapperOptions;
default = { };
example = { gtk = true; };
···
'';
};
+
extraSessionCommands = lib.mkOption {
+
type = lib.types.lines;
default = "";
example = ''
# SDL:
···
'';
};
+
extraOptions = lib.mkOption {
+
type = lib.types.listOf lib.types.str;
default = [];
example = [
"--verbose"
···
'';
};
+
extraPackages = lib.mkOption {
+
type = with lib.types; listOf package;
default = with pkgs; [
swaylock swayidle foot dmenu wmenu
];
+
defaultText = lib.literalExpression ''
with pkgs; [ swaylock swayidle foot dmenu wmenu ];
'';
+
example = lib.literalExpression ''
with pkgs; [
i3status i3status-rust
termite rofi light
···
};
+
config = lib.mkIf cfg.enable
+
(lib.mkMerge [
{
assertions = [
{
···
];
environment = {
+
systemPackages = lib.optional (cfg.package != null) cfg.package ++ cfg.extraPackages;
# Needed for the default wallpaper:
+
pathsToLink = lib.optionals (cfg.package != null) [ "/share/backgrounds/sway" ];
etc = {
"sway/config.d/nixos.conf".source = pkgs.writeText "nixos.conf" ''
# Import the most important environment variables into the D-Bus and systemd
# user environments (e.g. required for screen sharing and Pinentry prompts):
exec dbus-update-activation-environment --systemd DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP
'';
+
} // lib.optionalAttrs (cfg.package != null) {
+
"sway/config".source = lib.mkOptionDefault "${cfg.package}/etc/sway/config";
};
};
programs.gnupg.agent.pinentryPackage = lib.mkDefault pkgs.pinentry-gnome3;
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1050913
+
xdg.portal.config.sway.default = lib.mkDefault [ "wlr" "gtk" ];
# To make a Sway session available if a display manager like SDDM is enabled:
+
services.displayManager.sessionPackages = lib.optionals (cfg.package != null) [ cfg.package ]; }
(import ./wayland-session.nix { inherit lib pkgs; })
]);
+4 -6
nixos/modules/programs/wayland/waybar.nix
···
{ lib, pkgs, config, ... }:
-
with lib;
-
let
cfg = config.programs.waybar;
in
{
options.programs.waybar = {
-
enable = mkEnableOption "waybar, a highly customizable Wayland bar for Sway and Wlroots based compositors";
-
package = mkPackageOption pkgs "waybar" { };
};
-
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
systemd.user.services.waybar = {
description = "Waybar as systemd service";
···
};
};
-
meta.maintainers = [ maintainers.FlorianFranzen ];
}
···
{ lib, pkgs, config, ... }:
let
cfg = config.programs.waybar;
in
{
options.programs.waybar = {
+
enable = lib.mkEnableOption "waybar, a highly customizable Wayland bar for Sway and Wlroots based compositors";
+
package = lib.mkPackageOption pkgs "waybar" { };
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
systemd.user.services.waybar = {
description = "Waybar as systemd service";
···
};
};
+
meta.maintainers = [ lib.maintainers.FlorianFranzen ];
}
+6 -6
nixos/modules/programs/wayland/wayland-session.nix
···
-
{ lib, pkgs, ... }: with lib; {
security = {
polkit.enable = true;
pam.services.swaylock = {};
};
-
hardware.opengl.enable = mkDefault true;
-
fonts.enableDefaultPackages = mkDefault true;
programs = {
-
dconf.enable = mkDefault true;
-
xwayland.enable = mkDefault true;
};
xdg.portal = {
-
enable = mkDefault true;
extraPortals = [
# For screen sharing
···
+
{ lib, pkgs, ... }: {
security = {
polkit.enable = true;
pam.services.swaylock = {};
};
+
hardware.opengl.enable = lib.mkDefault true;
+
fonts.enableDefaultPackages = lib.mkDefault true;
programs = {
+
dconf.enable = lib.mkDefault true;
+
xwayland.enable = lib.mkDefault true;
};
xdg.portal = {
+
enable = lib.mkDefault true;
extraPortals = [
# For screen sharing
+7 -9
nixos/modules/programs/weylus.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.weylus;
in
{
-
options.programs.weylus = with types; {
-
enable = mkEnableOption "weylus, which turns your smart phone into a graphic tablet/touch screen for your computer";
-
openFirewall = mkOption {
type = bool;
default = false;
description = ''
···
'';
};
-
users = mkOption {
type = listOf str;
default = [ ];
description = ''
···
'';
};
-
package = mkPackageOption pkgs "weylus" { };
};
-
config = mkIf cfg.enable {
-
networking.firewall = mkIf cfg.openFirewall {
allowedTCPPorts = [ 1701 9001 ];
};
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.weylus;
in
{
+
options.programs.weylus = with lib.types; {
+
enable = lib.mkEnableOption "weylus, which turns your smart phone into a graphic tablet/touch screen for your computer";
+
openFirewall = lib.mkOption {
type = bool;
default = false;
description = ''
···
'';
};
+
users = lib.mkOption {
type = listOf str;
default = [ ];
description = ''
···
'';
};
+
package = lib.mkPackageOption pkgs "weylus" { };
};
+
config = lib.mkIf cfg.enable {
+
networking.firewall = lib.mkIf cfg.openFirewall {
allowedTCPPorts = [ 1701 9001 ];
};
+4 -6
nixos/modules/programs/wireshark.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.wireshark;
wireshark = cfg.package;
in {
options = {
programs.wireshark = {
-
enable = mkOption {
-
type = types.bool;
default = false;
description = ''
Whether to add Wireshark to the global environment and configure a
setcap wrapper for 'dumpcap' for users in the 'wireshark' group.
'';
};
-
package = mkPackageOption pkgs "wireshark-cli" {
example = "wireshark";
};
};
};
-
config = mkIf cfg.enable {
environment.systemPackages = [ wireshark ];
users.groups.wireshark = {};
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.wireshark;
wireshark = cfg.package;
in {
options = {
programs.wireshark = {
+
enable = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Whether to add Wireshark to the global environment and configure a
setcap wrapper for 'dumpcap' for users in the 'wireshark' group.
'';
};
+
package = lib.mkPackageOption pkgs "wireshark-cli" {
example = "wireshark";
};
};
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [ wireshark ];
users.groups.wireshark = {};
+3 -5
nixos/modules/programs/xastir.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.xastir;
in {
-
meta.maintainers = with maintainers; [ melling ];
options.programs.xastir = {
-
enable = mkEnableOption "Xastir Graphical APRS client";
};
-
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [ xastir ];
security.wrappers.xastir = {
source = "${pkgs.xastir}/bin/xastir";
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.xastir;
in {
+
meta.maintainers = with lib.maintainers; [ melling ];
options.programs.xastir = {
+
enable = lib.mkEnableOption "Xastir Graphical APRS client";
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ xastir ];
security.wrappers.xastir = {
source = "${pkgs.xastir}/bin/xastir";
+3 -5
nixos/modules/programs/xfconf.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let cfg = config.programs.xfconf;
in {
meta = {
-
maintainers = teams.xfce.members;
};
options = {
programs.xfconf = {
-
enable = mkEnableOption "Xfconf, the Xfce configuration storage system";
};
};
-
config = mkIf cfg.enable {
environment.systemPackages = [
pkgs.xfce.xfconf
];
···
{ config, lib, pkgs, ... }:
let cfg = config.programs.xfconf;
in {
meta = {
+
maintainers = lib.teams.xfce.members;
};
options = {
programs.xfconf = {
+
enable = lib.mkEnableOption "Xfconf, the Xfce configuration storage system";
};
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [
pkgs.xfce.xfconf
];
+23 -25
nixos/modules/programs/xfs_quota.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.xfs_quota;
-
limitOptions = opts: concatStringsSep " " [
-
(optionalString (opts.sizeSoftLimit != null) "bsoft=${opts.sizeSoftLimit}")
-
(optionalString (opts.sizeHardLimit != null) "bhard=${opts.sizeHardLimit}")
];
in
···
options = {
programs.xfs_quota = {
-
projects = mkOption {
default = {};
-
type = types.attrsOf (types.submodule {
options = {
-
id = mkOption {
-
type = types.int;
description = "Project ID.";
};
-
fileSystem = mkOption {
-
type = types.str;
description = "XFS filesystem hosting the xfs_quota project.";
default = "/";
};
-
path = mkOption {
-
type = types.str;
description = "Project directory.";
};
-
sizeSoftLimit = mkOption {
-
type = types.nullOr types.str;
default = null;
example = "30g";
description = "Soft limit of the project size";
};
-
sizeHardLimit = mkOption {
-
type = types.nullOr types.str;
default = null;
example = "50g";
description = "Hard limit of the project size.";
···
###### implementation
-
config = mkIf (cfg.projects != {}) {
environment.etc.projects.source = pkgs.writeText "etc-project"
-
(concatStringsSep "\n" (mapAttrsToList
-
(name: opts: "${toString opts.id}:${opts.path}") cfg.projects));
environment.etc.projid.source = pkgs.writeText "etc-projid"
-
(concatStringsSep "\n" (mapAttrsToList
-
(name: opts: "${name}:${toString opts.id}") cfg.projects));
-
systemd.services = mapAttrs' (name: opts:
-
nameValuePair "xfs_quota-${name}" {
description = "Setup xfs_quota for project ${name}";
script = ''
${pkgs.xfsprogs.bin}/bin/xfs_quota -x -c 'project -s ${name}' ${opts.fileSystem}
···
'';
wantedBy = [ "multi-user.target" ];
-
after = [ ((replaceStrings [ "/" ] [ "-" ] opts.fileSystem) + ".mount") ];
restartTriggers = [ config.environment.etc.projects.source ];
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.xfs_quota;
+
limitOptions = opts: builtins.concatStringsSep " " [
+
(lib.optionalString (opts.sizeSoftLimit != null) "bsoft=${opts.sizeSoftLimit}")
+
(lib.optionalString (opts.sizeHardLimit != null) "bhard=${opts.sizeHardLimit}")
];
in
···
options = {
programs.xfs_quota = {
+
projects = lib.mkOption {
default = {};
+
type = lib.types.attrsOf (lib.types.submodule {
options = {
+
id = lib.mkOption {
+
type = lib.types.int;
description = "Project ID.";
};
+
fileSystem = lib.mkOption {
+
type = lib.types.str;
description = "XFS filesystem hosting the xfs_quota project.";
default = "/";
};
+
path = lib.mkOption {
+
type = lib.types.str;
description = "Project directory.";
};
+
sizeSoftLimit = lib.mkOption {
+
type = lib.types.nullOr lib.types.str;
default = null;
example = "30g";
description = "Soft limit of the project size";
};
+
sizeHardLimit = lib.mkOption {
+
type = lib.types.nullOr lib.types.str;
default = null;
example = "50g";
description = "Hard limit of the project size.";
···
###### implementation
+
config = lib.mkIf (cfg.projects != {}) {
environment.etc.projects.source = pkgs.writeText "etc-project"
+
(builtins.concatStringsSep "\n" (lib.mapAttrsToList
+
(name: opts: "${builtins.toString opts.id}:${opts.path}") cfg.projects));
environment.etc.projid.source = pkgs.writeText "etc-projid"
+
(builtins.concatStringsSep "\n" (lib.mapAttrsToList
+
(name: opts: "${name}:${builtins.toString opts.id}") cfg.projects));
+
systemd.services = lib.mapAttrs' (name: opts:
+
lib.nameValuePair "xfs_quota-${name}" {
description = "Setup xfs_quota for project ${name}";
script = ''
${pkgs.xfsprogs.bin}/bin/xfs_quota -x -c 'project -s ${name}' ${opts.fileSystem}
···
'';
wantedBy = [ "multi-user.target" ];
+
after = [ ((builtins.replaceStrings [ "/" ] [ "-" ] opts.fileSystem) + ".mount") ];
restartTriggers = [ config.environment.etc.projects.source ];
+6 -8
nixos/modules/programs/xonsh.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.xonsh;
···
programs.xonsh = {
-
enable = mkOption {
default = false;
description = ''
Whether to configure xonsh as an interactive shell.
'';
-
type = types.bool;
};
-
package = mkPackageOption pkgs "xonsh" {
example = "xonsh.override { extraPackages = ps: [ ps.requests ]; }";
};
-
config = mkOption {
default = "";
description = "Control file to customize your shell behavior.";
-
type = types.lines;
};
};
};
-
config = mkIf cfg.enable {
environment.etc."xonsh/xonshrc".text = ''
# /etc/xonsh/xonshrc: DO NOT EDIT -- this file has been generated automatically.
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.xonsh;
···
programs.xonsh = {
+
enable = lib.mkOption {
default = false;
description = ''
Whether to configure xonsh as an interactive shell.
'';
+
type = lib.types.bool;
};
+
package = lib.mkPackageOption pkgs "xonsh" {
example = "xonsh.override { extraPackages = ps: [ ps.requests ]; }";
};
+
config = lib.mkOption {
default = "";
description = "Control file to customize your shell behavior.";
+
type = lib.types.lines;
};
};
};
+
config = lib.mkIf cfg.enable {
environment.etc."xonsh/xonshrc".text = ''
# /etc/xonsh/xonshrc: DO NOT EDIT -- this file has been generated automatically.
+11 -13
nixos/modules/programs/xss-lock.nix
···
{ config, pkgs, lib, ... }:
-
with lib;
-
let
cfg = config.programs.xss-lock;
in
{
options.programs.xss-lock = {
-
enable = mkEnableOption "xss-lock";
-
lockerCommand = mkOption {
default = "${pkgs.i3lock}/bin/i3lock";
-
defaultText = literalExpression ''"''${pkgs.i3lock}/bin/i3lock"'';
-
example = literalExpression ''"''${pkgs.i3lock-fancy}/bin/i3lock-fancy"'';
-
type = types.separatedString " ";
description = "Locker to be used with xsslock";
};
-
extraOptions = mkOption {
default = [ ];
example = [ "--ignore-sleep" ];
-
type = types.listOf types.str;
description = ''
Additional command-line arguments to pass to
{command}`xss-lock`.
···
};
};
-
config = mkIf cfg.enable {
systemd.user.services.xss-lock = {
description = "XSS Lock Daemon";
wantedBy = [ "graphical-session.target" ];
partOf = [ "graphical-session.target" ];
-
serviceConfig.ExecStart = with lib;
-
strings.concatStringsSep " " ([
"${pkgs.xss-lock}/bin/xss-lock" "--session \${XDG_SESSION_ID}"
-
] ++ (map escapeShellArg cfg.extraOptions) ++ [
"--"
cfg.lockerCommand
]);
···
{ config, pkgs, lib, ... }:
let
cfg = config.programs.xss-lock;
in
{
options.programs.xss-lock = {
+
enable = lib.mkEnableOption "xss-lock";
+
lockerCommand = lib.mkOption {
default = "${pkgs.i3lock}/bin/i3lock";
+
defaultText = lib.literalExpression ''"''${pkgs.i3lock}/bin/i3lock"'';
+
example = lib.literalExpression ''"''${pkgs.i3lock-fancy}/bin/i3lock-fancy"'';
+
type = lib.types.separatedString " ";
description = "Locker to be used with xsslock";
};
+
extraOptions = lib.mkOption {
default = [ ];
example = [ "--ignore-sleep" ];
+
type = lib.types.listOf lib.types.str;
description = ''
Additional command-line arguments to pass to
{command}`xss-lock`.
···
};
};
+
config = lib.mkIf cfg.enable {
systemd.user.services.xss-lock = {
description = "XSS Lock Daemon";
wantedBy = [ "graphical-session.target" ];
partOf = [ "graphical-session.target" ];
+
serviceConfig.ExecStart =
+
builtins.concatStringsSep " " ([
"${pkgs.xss-lock}/bin/xss-lock" "--session \${XDG_SESSION_ID}"
+
] ++ (builtins.map lib.escapeShellArg cfg.extraOptions) ++ [
"--"
cfg.lockerCommand
]);
+9 -11
nixos/modules/programs/xwayland.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.xwayland;
···
{
options.programs.xwayland = {
-
enable = mkEnableOption "Xwayland (an X server for interfacing X11 apps with the Wayland protocol)";
-
defaultFontPath = mkOption {
-
type = types.str;
-
default = optionalString config.fonts.fontDir.enable
"/run/current-system/sw/share/X11/fonts";
-
defaultText = literalExpression ''
optionalString config.fonts.fontDir.enable "/run/current-system/sw/share/X11/fonts"
'';
description = ''
···
'';
};
-
package = mkOption {
-
type = types.path;
default = pkgs.xwayland.override (oldArgs: {
inherit (cfg) defaultFontPath;
});
-
defaultText = literalExpression ''
pkgs.xwayland.override (oldArgs: {
inherit (config.programs.xwayland) defaultFontPath;
})
···
};
-
config = mkIf cfg.enable {
# Needed by some applications for fonts and default settings
environment.pathsToLink = [ "/share/X11" ];
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.xwayland;
···
{
options.programs.xwayland = {
+
enable = lib.mkEnableOption "Xwayland (an X server for interfacing X11 apps with the Wayland protocol)";
+
defaultFontPath = lib.mkOption {
+
type = lib.types.str;
+
default = lib.optionalString config.fonts.fontDir.enable
"/run/current-system/sw/share/X11/fonts";
+
defaultText = lib.literalExpression ''
optionalString config.fonts.fontDir.enable "/run/current-system/sw/share/X11/fonts"
'';
description = ''
···
'';
};
+
package = lib.mkOption {
+
type = lib.types.path;
default = pkgs.xwayland.override (oldArgs: {
inherit (cfg) defaultFontPath;
});
+
defaultText = lib.literalExpression ''
pkgs.xwayland.override (oldArgs: {
inherit (config.programs.xwayland) defaultFontPath;
})
···
};
+
config = lib.mkIf cfg.enable {
# Needed by some applications for fonts and default settings
environment.pathsToLink = [ "/share/X11" ];
+29 -31
nixos/modules/programs/yabar.nix
···
{ lib, pkgs, config, ... }:
-
with lib;
-
let
cfg = config.programs.yabar;
-
mapExtra = v: lib.concatStringsSep "\n" (mapAttrsToList (
-
key: val: "${key} = ${if (isString val) then "\"${val}\"" else "${builtins.toString val}"};"
) v);
-
listKeys = r: concatStringsSep "," (map (n: "\"${n}\"") (attrNames r));
configFile = let
-
bars = mapAttrsToList (
name: cfg: ''
${name}: {
font: "${cfg.font}";
···
block-list: [${listKeys cfg.indicators}]
-
${concatStringsSep "\n" (mapAttrsToList (
name: cfg: ''
${name}: {
exec: "${cfg.exec}";
···
) cfg.bars;
in pkgs.writeText "yabar.conf" ''
bar-list = [${listKeys cfg.bars}];
-
${concatStringsSep "\n" bars}
'';
in
{
options.programs.yabar = {
-
enable = mkEnableOption "yabar, a status bar for X window managers";
-
package = mkOption {
default = pkgs.yabar-unstable;
-
defaultText = literalExpression "pkgs.yabar-unstable";
-
example = literalExpression "pkgs.yabar";
-
type = types.package;
# `yabar-stable` segfaults under certain conditions.
-
apply = x: if x == pkgs.yabar-unstable then x else flip warn x ''
It's not recommended to use `yabar' with `programs.yabar', the (old) stable release
tends to segfault under certain circumstances:
···
'';
};
-
bars = mkOption {
default = {};
-
type = types.attrsOf(types.submodule {
options = {
-
font = mkOption {
default = "sans bold 9";
example = "Droid Sans, FontAwesome Bold 9";
-
type = types.str;
description = ''
The font that will be used to draw the status bar.
'';
};
-
position = mkOption {
default = "top";
example = "bottom";
-
type = types.enum [ "top" "bottom" ];
description = ''
The position where the bar will be rendered.
'';
};
-
extra = mkOption {
default = {};
-
type = types.attrsOf types.str;
description = ''
An attribute set which contains further attributes of a bar.
'';
};
-
indicators = mkOption {
default = {};
-
type = types.attrsOf(types.submodule {
-
options.exec = mkOption {
example = "YABAR_DATE";
-
type = types.str;
description = ''
The type of the indicator to be executed.
'';
};
-
options.align = mkOption {
default = "left";
example = "right";
-
type = types.enum [ "left" "center" "right" ];
description = ''
Whether to align the indicator at the left or right of the bar.
'';
};
-
options.extra = mkOption {
default = {};
-
type = types.attrsOf (types.either types.str types.int);
description = ''
An attribute set which contains further attributes of a indicator.
···
};
};
-
config = mkIf cfg.enable {
systemd.user.services.yabar = {
description = "yabar service";
wantedBy = [ "graphical-session.target" ];
···
{ lib, pkgs, config, ... }:
let
cfg = config.programs.yabar;
+
mapExtra = v: lib.concatStringsSep "\n" (lib.mapAttrsToList (
+
key: val: "${key} = ${if (builtins.isString val) then "\"${val}\"" else "${builtins.toString val}"};"
) v);
+
listKeys = r: builtins.concatStringsSep "," (builtins.map (n: "\"${n}\"") (builtins.attrNames r));
configFile = let
+
bars = lib.mapAttrsToList (
name: cfg: ''
${name}: {
font: "${cfg.font}";
···
block-list: [${listKeys cfg.indicators}]
+
${builtins.concatStringsSep "\n" (lib.mapAttrsToList (
name: cfg: ''
${name}: {
exec: "${cfg.exec}";
···
) cfg.bars;
in pkgs.writeText "yabar.conf" ''
bar-list = [${listKeys cfg.bars}];
+
${builtins.concatStringsSep "\n" bars}
'';
in
{
options.programs.yabar = {
+
enable = lib.mkEnableOption "yabar, a status bar for X window managers";
+
package = lib.mkOption {
default = pkgs.yabar-unstable;
+
defaultText = lib.literalExpression "pkgs.yabar-unstable";
+
example = lib.literalExpression "pkgs.yabar";
+
type = lib.types.package;
# `yabar-stable` segfaults under certain conditions.
+
apply = x: if x == pkgs.yabar-unstable then x else lib.flip lib.warn x ''
It's not recommended to use `yabar' with `programs.yabar', the (old) stable release
tends to segfault under certain circumstances:
···
'';
};
+
bars = lib.mkOption {
default = {};
+
type = lib.types.attrsOf(lib.types.submodule {
options = {
+
font = lib.mkOption {
default = "sans bold 9";
example = "Droid Sans, FontAwesome Bold 9";
+
type = lib.types.str;
description = ''
The font that will be used to draw the status bar.
'';
};
+
position = lib.mkOption {
default = "top";
example = "bottom";
+
type = lib.types.enum [ "top" "bottom" ];
description = ''
The position where the bar will be rendered.
'';
};
+
extra = lib.mkOption {
default = {};
+
type = lib.types.attrsOf lib.types.str;
description = ''
An attribute set which contains further attributes of a bar.
'';
};
+
indicators = lib.mkOption {
default = {};
+
type = lib.types.attrsOf(lib.types.submodule {
+
options.exec = lib.mkOption {
example = "YABAR_DATE";
+
type = lib.types.str;
description = ''
The type of the indicator to be executed.
'';
};
+
options.align = lib.mkOption {
default = "left";
example = "right";
+
type = lib.types.enum [ "left" "center" "right" ];
description = ''
Whether to align the indicator at the left or right of the bar.
'';
};
+
options.extra = lib.mkOption {
default = {};
+
type = lib.types.attrsOf (lib.types.either lib.types.str lib.types.int);
description = ''
An attribute set which contains further attributes of a indicator.
···
};
};
+
config = lib.mkIf cfg.enable {
systemd.user.services.yabar = {
description = "yabar service";
wantedBy = [ "graphical-session.target" ];
+2 -4
nixos/modules/programs/zmap.nix
···
{ pkgs, config, lib, ... }:
-
with lib;
-
let
cfg = config.programs.zmap;
in {
options.programs.zmap = {
-
enable = mkEnableOption "ZMap, a network scanner designed for Internet-wide network surveys";
};
-
config = mkIf cfg.enable {
environment.systemPackages = [ pkgs.zmap ];
environment.etc."zmap/blacklist.conf".source = "${pkgs.zmap}/etc/zmap/blacklist.conf";
···
{ pkgs, config, lib, ... }:
let
cfg = config.programs.zmap;
in {
options.programs.zmap = {
+
enable = lib.mkEnableOption "ZMap, a network scanner designed for Internet-wide network surveys";
};
+
config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.zmap ];
environment.etc."zmap/blacklist.conf".source = "${pkgs.zmap}/etc/zmap/blacklist.conf";
+25 -27
nixos/modules/programs/zsh/oh-my-zsh.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.zsh.ohMyZsh;
···
custom =
if cfg.custom != null then cfg.custom
-
else if length cfg.customPkgs == 0 then null
else pkgs.linkFarm "oh-my-zsh-custom" [
(mkLinkFarmEntry' "themes")
(mkLinkFarmEntry "completions" "site-functions")
···
in
{
imports = [
-
(mkRenamedOptionModule [ "programs" "zsh" "oh-my-zsh" "enable" ] [ "programs" "zsh" "ohMyZsh" "enable" ])
-
(mkRenamedOptionModule [ "programs" "zsh" "oh-my-zsh" "theme" ] [ "programs" "zsh" "ohMyZsh" "theme" ])
-
(mkRenamedOptionModule [ "programs" "zsh" "oh-my-zsh" "custom" ] [ "programs" "zsh" "ohMyZsh" "custom" ])
-
(mkRenamedOptionModule [ "programs" "zsh" "oh-my-zsh" "plugins" ] [ "programs" "zsh" "ohMyZsh" "plugins" ])
];
options = {
programs.zsh.ohMyZsh = {
-
enable = mkOption {
-
type = types.bool;
default = false;
description = ''
Enable oh-my-zsh.
'';
};
-
package = mkPackageOption pkgs "oh-my-zsh" { };
-
plugins = mkOption {
default = [];
-
type = types.listOf(types.str);
description = ''
List of oh-my-zsh plugins
'';
};
-
custom = mkOption {
default = null;
-
type = with types; nullOr str;
description = ''
Path to a custom oh-my-zsh package to override config of oh-my-zsh.
(Can't be used along with `customPkgs`).
'';
};
-
customPkgs = mkOption {
default = [];
-
type = types.listOf types.package;
description = ''
List of custom packages that should be loaded into `oh-my-zsh`.
'';
};
-
theme = mkOption {
default = "";
-
type = types.str;
description = ''
Name of the theme to be used by oh-my-zsh.
'';
};
-
cacheDir = mkOption {
default = "$HOME/.cache/oh-my-zsh";
-
type = types.str;
description = ''
Cache directory to be used by `oh-my-zsh`.
Without this option it would default to the read-only nix store.
···
};
};
-
config = mkIf cfg.enable {
# Prevent zsh from overwriting oh-my-zsh's prompt
-
programs.zsh.promptInit = mkDefault "";
environment.systemPackages = [ cfg.package ];
···
# oh-my-zsh configuration generated by NixOS
export ZSH=${cfg.package}/share/oh-my-zsh
-
${optionalString (length(cfg.plugins) > 0)
-
"plugins=(${concatStringsSep " " cfg.plugins})"
}
-
${optionalString (custom != null)
"ZSH_CUSTOM=\"${custom}\""
}
-
${optionalString (stringLength(cfg.theme) > 0)
"ZSH_THEME=\"${cfg.theme}\""
}
-
${optionalString (cfg.cacheDir != null) ''
if [[ ! -d "${cfg.cacheDir}" ]]; then
mkdir -p "${cfg.cacheDir}"
fi
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.zsh.ohMyZsh;
···
custom =
if cfg.custom != null then cfg.custom
+
else if builtins.length cfg.customPkgs == 0 then null
else pkgs.linkFarm "oh-my-zsh-custom" [
(mkLinkFarmEntry' "themes")
(mkLinkFarmEntry "completions" "site-functions")
···
in
{
imports = [
+
(lib.mkRenamedOptionModule [ "programs" "zsh" "oh-my-zsh" "enable" ] [ "programs" "zsh" "ohMyZsh" "enable" ])
+
(lib.mkRenamedOptionModule [ "programs" "zsh" "oh-my-zsh" "theme" ] [ "programs" "zsh" "ohMyZsh" "theme" ])
+
(lib.mkRenamedOptionModule [ "programs" "zsh" "oh-my-zsh" "custom" ] [ "programs" "zsh" "ohMyZsh" "custom" ])
+
(lib.mkRenamedOptionModule [ "programs" "zsh" "oh-my-zsh" "plugins" ] [ "programs" "zsh" "ohMyZsh" "plugins" ])
];
options = {
programs.zsh.ohMyZsh = {
+
enable = lib.mkOption {
+
type = lib.types.bool;
default = false;
description = ''
Enable oh-my-zsh.
'';
};
+
package = lib.mkPackageOption pkgs "oh-my-zsh" { };
+
plugins = lib.mkOption {
default = [];
+
type = lib.types.listOf(lib.types.str);
description = ''
List of oh-my-zsh plugins
'';
};
+
custom = lib.mkOption {
default = null;
+
type = with lib.types; nullOr str;
description = ''
Path to a custom oh-my-zsh package to override config of oh-my-zsh.
(Can't be used along with `customPkgs`).
'';
};
+
customPkgs = lib.mkOption {
default = [];
+
type = lib.types.listOf lib.types.package;
description = ''
List of custom packages that should be loaded into `oh-my-zsh`.
'';
};
+
theme = lib.mkOption {
default = "";
+
type = lib.types.str;
description = ''
Name of the theme to be used by oh-my-zsh.
'';
};
+
cacheDir = lib.mkOption {
default = "$HOME/.cache/oh-my-zsh";
+
type = lib.types.str;
description = ''
Cache directory to be used by `oh-my-zsh`.
Without this option it would default to the read-only nix store.
···
};
};
+
config = lib.mkIf cfg.enable {
# Prevent zsh from overwriting oh-my-zsh's prompt
+
programs.zsh.promptInit = lib.mkDefault "";
environment.systemPackages = [ cfg.package ];
···
# oh-my-zsh configuration generated by NixOS
export ZSH=${cfg.package}/share/oh-my-zsh
+
${lib.optionalString (builtins.length(cfg.plugins) > 0)
+
"plugins=(${builtins.concatStringsSep " " cfg.plugins})"
}
+
${lib.optionalString (custom != null)
"ZSH_CUSTOM=\"${custom}\""
}
+
${lib.optionalString (builtins.stringLength(cfg.theme) > 0)
"ZSH_THEME=\"${cfg.theme}\""
}
+
${lib.optionalString (cfg.cacheDir != null) ''
if [[ ! -d "${cfg.cacheDir}" ]]; then
mkdir -p "${cfg.cacheDir}"
fi
+3 -5
nixos/modules/programs/zsh/zsh-autoenv.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.zsh.zsh-autoenv;
in {
options = {
programs.zsh.zsh-autoenv = {
-
enable = mkEnableOption "zsh-autoenv";
-
package = mkPackageOption pkgs "zsh-autoenv" { };
};
};
-
config = mkIf cfg.enable {
programs.zsh.interactiveShellInit = ''
source ${cfg.package}/share/zsh-autoenv/autoenv.zsh
'';
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.zsh.zsh-autoenv;
in {
options = {
programs.zsh.zsh-autoenv = {
+
enable = lib.mkEnableOption "zsh-autoenv";
+
package = lib.mkPackageOption pkgs "zsh-autoenv" { };
};
};
+
config = lib.mkIf cfg.enable {
programs.zsh.interactiveShellInit = ''
source ${cfg.package}/share/zsh-autoenv/autoenv.zsh
'';
+15 -17
nixos/modules/programs/zsh/zsh-autosuggestions.nix
···
{ config, pkgs, lib, ... }:
-
with lib;
-
let
cfg = config.programs.zsh.autosuggestions;
in
{
imports = [
-
(mkRenamedOptionModule [ "programs" "zsh" "enableAutosuggestions" ] [ "programs" "zsh" "autosuggestions" "enable" ])
];
options.programs.zsh.autosuggestions = {
-
enable = mkEnableOption "zsh-autosuggestions";
-
highlightStyle = mkOption {
-
type = types.str;
default = "fg=8"; # https://github.com/zsh-users/zsh-autosuggestions/tree/v0.4.3#suggestion-highlight-style
description = "Highlight style for suggestions ({fore,back}ground color)";
example = "fg=cyan";
};
-
strategy = mkOption {
-
type = types.listOf (types.enum [ "history" "completion" "match_prev_cmd" ]);
default = [ "history" ];
description = ''
`ZSH_AUTOSUGGEST_STRATEGY` is an array that specifies how suggestions should be generated.
···
'';
};
-
async = mkOption {
-
type = types.bool;
default = true;
description = "Whether to fetch suggestions asynchronously";
example = false;
};
-
extraConfig = mkOption {
-
type = with types; attrsOf str;
default = {};
description = "Attribute set with additional configuration values";
-
example = literalExpression ''
{
"ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE" = "20";
}
···
};
-
config = mkIf cfg.enable {
programs.zsh.interactiveShellInit = ''
source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh
export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="${cfg.highlightStyle}"
-
export ZSH_AUTOSUGGEST_STRATEGY=(${concatStringsSep " " cfg.strategy})
-
${optionalString (!cfg.async) "unset ZSH_AUTOSUGGEST_USE_ASYNC"}
-
${concatStringsSep "\n" (mapAttrsToList (key: value: ''export ${key}="${value}"'') cfg.extraConfig)}
'';
};
···
{ config, pkgs, lib, ... }:
let
cfg = config.programs.zsh.autosuggestions;
in
{
imports = [
+
(lib.mkRenamedOptionModule [ "programs" "zsh" "enableAutosuggestions" ] [ "programs" "zsh" "autosuggestions" "enable" ])
];
options.programs.zsh.autosuggestions = {
+
enable = lib.mkEnableOption "zsh-autosuggestions";
+
highlightStyle = lib.mkOption {
+
type = lib.types.str;
default = "fg=8"; # https://github.com/zsh-users/zsh-autosuggestions/tree/v0.4.3#suggestion-highlight-style
description = "Highlight style for suggestions ({fore,back}ground color)";
example = "fg=cyan";
};
+
strategy = lib.mkOption {
+
type = lib.types.listOf (lib.types.enum [ "history" "completion" "match_prev_cmd" ]);
default = [ "history" ];
description = ''
`ZSH_AUTOSUGGEST_STRATEGY` is an array that specifies how suggestions should be generated.
···
'';
};
+
async = lib.mkOption {
+
type = lib.types.bool;
default = true;
description = "Whether to fetch suggestions asynchronously";
example = false;
};
+
extraConfig = lib.mkOption {
+
type = lib.types.attrsOf lib.types.str;
default = {};
description = "Attribute set with additional configuration values";
+
example = lib.literalExpression ''
{
"ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE" = "20";
}
···
};
+
config = lib.mkIf cfg.enable {
programs.zsh.interactiveShellInit = ''
source ${pkgs.zsh-autosuggestions}/share/zsh-autosuggestions/zsh-autosuggestions.zsh
export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="${cfg.highlightStyle}"
+
export ZSH_AUTOSUGGEST_STRATEGY=(${builtins.concatStringsSep " " cfg.strategy})
+
${lib.optionalString (!cfg.async) "unset ZSH_AUTOSUGGEST_USE_ASYNC"}
+
${builtins.concatStringsSep "\n" (lib.mapAttrsToList (key: value: ''export ${key}="${value}"'') cfg.extraConfig)}
'';
};
+25 -27
nixos/modules/programs/zsh/zsh-syntax-highlighting.nix
···
{ config, lib, pkgs, ... }:
-
with lib;
-
let
cfg = config.programs.zsh.syntaxHighlighting;
in
{
imports = [
-
(mkRenamedOptionModule [ "programs" "zsh" "enableSyntaxHighlighting" ] [ "programs" "zsh" "syntaxHighlighting" "enable" ])
-
(mkRenamedOptionModule [ "programs" "zsh" "syntax-highlighting" "enable" ] [ "programs" "zsh" "syntaxHighlighting" "enable" ])
-
(mkRenamedOptionModule [ "programs" "zsh" "syntax-highlighting" "highlighters" ] [ "programs" "zsh" "syntaxHighlighting" "highlighters" ])
-
(mkRenamedOptionModule [ "programs" "zsh" "syntax-highlighting" "patterns" ] [ "programs" "zsh" "syntaxHighlighting" "patterns" ])
];
options = {
programs.zsh.syntaxHighlighting = {
-
enable = mkEnableOption "zsh-syntax-highlighting";
-
highlighters = mkOption {
default = [ "main" ];
# https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
-
type = types.listOf(types.enum([
"main"
"brackets"
"pattern"
···
'';
};
-
patterns = mkOption {
default = {};
-
type = types.attrsOf types.str;
-
example = literalExpression ''
{
"rm -rf *" = "fg=white,bold,bg=red";
}
···
https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/pattern.md
'';
};
-
styles = mkOption {
default = {};
-
type = types.attrsOf types.str;
-
example = literalExpression ''
{
"alias" = "fg=magenta,bold";
}
···
};
};
-
config = mkIf cfg.enable {
-
environment.systemPackages = with pkgs; [ zsh-syntax-highlighting ];
assertions = [
{
-
assertion = length(attrNames cfg.patterns) > 0 -> elem "pattern" cfg.highlighters;
message = ''
When highlighting patterns, "pattern" needs to be included in the list of highlighters.
'';
}
];
-
programs.zsh.interactiveShellInit = with pkgs;
-
lib.mkAfter (lib.concatStringsSep "\n" ([
-
"source ${zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
-
] ++ optional (length(cfg.highlighters) > 0)
-
"ZSH_HIGHLIGHT_HIGHLIGHTERS=(${concatStringsSep " " cfg.highlighters})"
-
++ optionals (length(attrNames cfg.patterns) > 0)
-
(mapAttrsToList (
pattern: design:
"ZSH_HIGHLIGHT_PATTERNS+=('${pattern}' '${design}')"
) cfg.patterns)
-
++ optionals (length(attrNames cfg.styles) > 0)
-
(mapAttrsToList (
styles: design:
"ZSH_HIGHLIGHT_STYLES[${styles}]='${design}'"
) cfg.styles)
···
{ config, lib, pkgs, ... }:
let
cfg = config.programs.zsh.syntaxHighlighting;
in
{
imports = [
+
(lib.mkRenamedOptionModule [ "programs" "zsh" "enableSyntaxHighlighting" ] [ "programs" "zsh" "syntaxHighlighting" "enable" ])
+
(lib.mkRenamedOptionModule [ "programs" "zsh" "syntax-highlighting" "enable" ] [ "programs" "zsh" "syntaxHighlighting" "enable" ])
+
(lib.mkRenamedOptionModule [ "programs" "zsh" "syntax-highlighting" "highlighters" ] [ "programs" "zsh" "syntaxHighlighting" "highlighters" ])
+
(lib.mkRenamedOptionModule [ "programs" "zsh" "syntax-highlighting" "patterns" ] [ "programs" "zsh" "syntaxHighlighting" "patterns" ])
];
options = {
programs.zsh.syntaxHighlighting = {
+
enable = lib.mkEnableOption "zsh-syntax-highlighting";
+
highlighters = lib.mkOption {
default = [ "main" ];
# https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
+
type = lib.types.listOf(lib.types.enum([
"main"
"brackets"
"pattern"
···
'';
};
+
patterns = lib.mkOption {
default = {};
+
type = lib.types.attrsOf lib.types.str;
+
example = lib.literalExpression ''
{
"rm -rf *" = "fg=white,bold,bg=red";
}
···
https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/pattern.md
'';
};
+
styles = lib.mkOption {
default = {};
+
type = lib.types.attrsOf lib.types.str;
+
example = lib.literalExpression ''
{
"alias" = "fg=magenta,bold";
}
···
};
};
+
config = lib.mkIf cfg.enable {
+
environment.systemPackages = [ pkgs.zsh-syntax-highlighting ];
assertions = [
{
+
assertion = builtins.length(builtins.attrNames cfg.patterns) > 0 -> builtins.elem "pattern" cfg.highlighters;
message = ''
When highlighting patterns, "pattern" needs to be included in the list of highlighters.
'';
}
];
+
programs.zsh.interactiveShellInit =
+
lib.lib.mkAfter (lib.concatStringsSep "\n" ([
+
"source ${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
+
] ++ lib.optional (builtins.length(cfg.highlighters) > 0)
+
"ZSH_HIGHLIGHT_HIGHLIGHTERS=(${builtins.concatStringsSep " " cfg.highlighters})"
+
++ lib.optionals (builtins.length(builtins.attrNames cfg.patterns) > 0)
+
(lib.mapAttrsToList (
pattern: design:
"ZSH_HIGHLIGHT_PATTERNS+=('${pattern}' '${design}')"
) cfg.patterns)
+
++ lib.optionals (builtins.length(builtins.attrNames cfg.styles) > 0)
+
(lib.mapAttrsToList (
styles: design:
"ZSH_HIGHLIGHT_STYLES[${styles}]='${design}'"
) cfg.styles)
+42 -44
nixos/modules/programs/zsh/zsh.nix
···
{ config, lib, options, pkgs, ... }:
-
with lib;
-
let
cfge = config.environment;
···
cfg = config.programs.zsh;
opt = options.programs.zsh;
-
zshAliases = concatStringsSep "\n" (
-
mapAttrsFlatten (k: v: "alias -- ${k}=${escapeShellArg v}")
-
(filterAttrs (k: v: v != null) cfg.shellAliases)
);
zshStartupNotes = ''
···
programs.zsh = {
-
enable = mkOption {
default = false;
description = ''
Whether to configure zsh as an interactive shell. To enable zsh for
···
option for that user. To enable zsh system-wide use the
{option}`users.defaultUserShell` option.
'';
-
type = types.bool;
};
-
shellAliases = mkOption {
default = { };
description = ''
Set of aliases for zsh shell, which overrides {option}`environment.shellAliases`.
See {option}`environment.shellAliases` for an option format description.
'';
-
type = with types; attrsOf (nullOr (either str path));
};
-
shellInit = mkOption {
default = "";
description = ''
Shell script code called during zsh shell initialisation.
'';
-
type = types.lines;
};
-
loginShellInit = mkOption {
default = "";
description = ''
Shell script code called during zsh login shell initialisation.
'';
-
type = types.lines;
};
-
interactiveShellInit = mkOption {
default = "";
description = ''
Shell script code called during interactive zsh shell initialisation.
'';
-
type = types.lines;
};
-
promptInit = mkOption {
default = ''
# Note that to manually override this in ~/.zshrc you should run `prompt off`
# before setting your PS1 and etc. Otherwise this will likely to interact with
···
description = ''
Shell script code used to initialise the zsh prompt.
'';
-
type = types.lines;
};
-
histSize = mkOption {
default = 2000;
description = ''
Change history size.
'';
-
type = types.int;
};
-
histFile = mkOption {
default = "$HOME/.zsh_history";
description = ''
Change history file.
'';
-
type = types.str;
};
-
setOptions = mkOption {
-
type = types.listOf types.str;
default = [
"HIST_IGNORE_DUPS"
"SHARE_HISTORY"
···
'';
};
-
enableCompletion = mkOption {
default = true;
description = ''
Enable zsh completion for all interactive zsh shells.
'';
-
type = types.bool;
};
-
enableBashCompletion = mkOption {
default = false;
description = ''
Enable compatibility with bash's programmable completion system.
'';
-
type = types.bool;
};
-
enableGlobalCompInit = mkOption {
default = cfg.enableCompletion;
-
defaultText = literalExpression "config.${opt.enableCompletion}";
description = ''
Enable execution of compinit call for all interactive zsh shells.
···
`fpath` and a custom `compinit`
call in the local config is required.
'';
-
type = types.bool;
};
-
enableLsColors = mkOption {
default = true;
description = ''
Enable extra colors in directory listings (used by `ls` and `tree`).
'';
-
type = types.bool;
};
};
};
-
config = mkIf cfg.enable {
-
programs.zsh.shellAliases = mapAttrs (name: mkDefault) cfge.shellAliases;
environment.etc.zshenv.text =
''
···
if [ -n "$__ETC_ZSHRC_SOURCED" -o -n "$NOSYSZSHRC" ]; then return; fi
__ETC_ZSHRC_SOURCED=1
-
${optionalString (cfg.setOptions != []) ''
# Set zsh options.
-
setopt ${concatStringsSep " " cfg.setOptions}
''}
# Alternative method of determining short and full hostname.
···
# Setup command line history.
# Don't export these, otherwise other shells (bash) will try to use same HISTFILE.
-
SAVEHIST=${toString cfg.histSize}
-
HISTSIZE=${toString cfg.histSize}
HISTFILE=${cfg.histFile}
# Configure sane keyboard defaults.
. /etc/zinputrc
-
${optionalString cfg.enableGlobalCompInit ''
# Enable autocompletion.
autoload -U compinit && compinit
''}
-
${optionalString cfg.enableBashCompletion ''
# Enable compatibility with bash's completion system.
autoload -U bashcompinit && bashcompinit
''}
···
${cfg.interactiveShellInit}
-
${optionalString cfg.enableLsColors ''
# Extra colors for directory listings.
eval "$(${pkgs.coreutils}/bin/dircolors -b)"
''}
···
environment.etc.zinputrc.text = builtins.readFile ./zinputrc;
environment.systemPackages = [ pkgs.zsh ]
-
++ optional cfg.enableCompletion pkgs.nix-zsh-completions;
-
environment.pathsToLink = optional cfg.enableCompletion "/share/zsh";
-
#users.defaultUserShell = mkDefault "/run/current-system/sw/bin/zsh";
environment.shells =
[
···
{ config, lib, options, pkgs, ... }:
let
cfge = config.environment;
···
cfg = config.programs.zsh;
opt = options.programs.zsh;
+
zshAliases = builtins.concatStringsSep "\n" (
+
lib.mapAttrsFlatten (k: v: "alias -- ${k}=${lib.escapeShellArg v}")
+
(lib.filterAttrs (k: v: v != null) cfg.shellAliases)
);
zshStartupNotes = ''
···
programs.zsh = {
+
enable = lib.mkOption {
default = false;
description = ''
Whether to configure zsh as an interactive shell. To enable zsh for
···
option for that user. To enable zsh system-wide use the
{option}`users.defaultUserShell` option.
'';
+
type = lib.types.bool;
};
+
shellAliases = lib.mkOption {
default = { };
description = ''
Set of aliases for zsh shell, which overrides {option}`environment.shellAliases`.
See {option}`environment.shellAliases` for an option format description.
'';
+
type = with lib.types; attrsOf (nullOr (either str path));
};
+
shellInit = lib.mkOption {
default = "";
description = ''
Shell script code called during zsh shell initialisation.
'';
+
type = lib.types.lines;
};
+
loginShellInit = lib.mkOption {
default = "";
description = ''
Shell script code called during zsh login shell initialisation.
'';
+
type = lib.types.lines;
};
+
interactiveShellInit = lib.mkOption {
default = "";
description = ''
Shell script code called during interactive zsh shell initialisation.
'';
+
type = lib.types.lines;
};
+
promptInit = lib.mkOption {
default = ''
# Note that to manually override this in ~/.zshrc you should run `prompt off`
# before setting your PS1 and etc. Otherwise this will likely to interact with
···
description = ''
Shell script code used to initialise the zsh prompt.
'';
+
type = lib.types.lines;
};
+
histSize = lib.mkOption {
default = 2000;
description = ''
Change history size.
'';
+
type = lib.types.int;
};
+
histFile = lib.mkOption {
default = "$HOME/.zsh_history";
description = ''
Change history file.
'';
+
type = lib.types.str;
};
+
setOptions = lib.mkOption {
+
type = lib.types.listOf lib.types.str;
default = [
"HIST_IGNORE_DUPS"
"SHARE_HISTORY"
···
'';
};
+
enableCompletion = lib.mkOption {
default = true;
description = ''
Enable zsh completion for all interactive zsh shells.
'';
+
type = lib.types.bool;
};
+
enableBashCompletion = lib.mkOption {
default = false;
description = ''
Enable compatibility with bash's programmable completion system.
'';
+
type = lib.types.bool;
};
+
enableGlobalCompInit = lib.mkOption {
default = cfg.enableCompletion;
+
defaultText = lib.literalExpression "config.${opt.enableCompletion}";
description = ''
Enable execution of compinit call for all interactive zsh shells.
···
`fpath` and a custom `compinit`
call in the local config is required.
'';
+
type = lib.types.bool;
};
+
enableLsColors = lib.mkOption {
default = true;
description = ''
Enable extra colors in directory listings (used by `ls` and `tree`).
'';
+
type = lib.types.bool;
};
};
};
+
config = lib.mkIf cfg.enable {
+
programs.zsh.shellAliases = builtins.mapAttrs (name: lib.mkDefault) cfge.shellAliases;
environment.etc.zshenv.text =
''
···
if [ -n "$__ETC_ZSHRC_SOURCED" -o -n "$NOSYSZSHRC" ]; then return; fi
__ETC_ZSHRC_SOURCED=1
+
${lib.optionalString (cfg.setOptions != []) ''
# Set zsh options.
+
setopt ${builtins.concatStringsSep " " cfg.setOptions}
''}
# Alternative method of determining short and full hostname.
···
# Setup command line history.
# Don't export these, otherwise other shells (bash) will try to use same HISTFILE.
+
SAVEHIST=${builtins.toString cfg.histSize}
+
HISTSIZE=${builtins.toString cfg.histSize}
HISTFILE=${cfg.histFile}
# Configure sane keyboard defaults.
. /etc/zinputrc
+
${lib.optionalString cfg.enableGlobalCompInit ''
# Enable autocompletion.
autoload -U compinit && compinit
''}
+
${lib.optionalString cfg.enableBashCompletion ''
# Enable compatibility with bash's completion system.
autoload -U bashcompinit && bashcompinit
''}
···
${cfg.interactiveShellInit}
+
${lib.optionalString cfg.enableLsColors ''
# Extra colors for directory listings.
eval "$(${pkgs.coreutils}/bin/dircolors -b)"
''}
···
environment.etc.zinputrc.text = builtins.readFile ./zinputrc;
environment.systemPackages = [ pkgs.zsh ]
+
++ lib.optional cfg.enableCompletion pkgs.nix-zsh-completions;
+
environment.pathsToLink = lib.optional cfg.enableCompletion "/share/zsh";
+
#users.defaultUserShell = lib.mkDefault "/run/current-system/sw/bin/zsh";
environment.shells =
[