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

This commit is contained in:
Acid Bong 2024-04-17 14:37:58 +03:00
parent 861f29655c
commit 49f6869f71
No known key found for this signature in database
118 changed files with 1053 additions and 1269 deletions

View File

@ -1,7 +1,5 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib;
let let
cfg = config.programs._1password-gui; cfg = config.programs._1password-gui;
@ -9,25 +7,25 @@ let
in in
{ {
imports = [ imports = [
(mkRemovedOptionModule [ "programs" "_1password-gui" "gid" ] '' (lib.mkRemovedOptionModule [ "programs" "_1password-gui" "gid" ] ''
A preallocated GID will be used instead. A preallocated GID will be used instead.
'') '')
]; ];
options = { options = {
programs._1password-gui = { programs._1password-gui = {
enable = mkEnableOption "the 1Password GUI application"; enable = lib.mkEnableOption "the 1Password GUI application";
polkitPolicyOwners = mkOption { polkitPolicyOwners = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
default = [ ]; default = [ ];
example = literalExpression ''["user1" "user2" "user3"]''; example = lib.literalExpression ''["user1" "user2" "user3"]'';
description = '' description = ''
A list of users who should be able to integrate 1Password with polkit-based authentication mechanisms. A list of users who should be able to integrate 1Password with polkit-based authentication mechanisms.
''; '';
}; };
package = mkPackageOption pkgs "1Password GUI" { package = lib.mkPackageOption pkgs "1Password GUI" {
default = [ "_1password-gui" ]; default = [ "_1password-gui" ];
}; };
}; };
@ -39,7 +37,7 @@ in
polkitPolicyOwners = cfg.polkitPolicyOwners; polkitPolicyOwners = cfg.polkitPolicyOwners;
}; };
in in
mkIf cfg.enable { lib.mkIf cfg.enable {
environment.systemPackages = [ package ]; environment.systemPackages = [ package ];
users.groups.onepassword.gid = config.ids.gids.onepassword; users.groups.onepassword.gid = config.ids.gids.onepassword;

View File

@ -1,7 +1,5 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib;
let let
cfg = config.programs._1password; cfg = config.programs._1password;
@ -9,22 +7,22 @@ let
in in
{ {
imports = [ imports = [
(mkRemovedOptionModule [ "programs" "_1password" "gid" ] '' (lib.mkRemovedOptionModule [ "programs" "_1password" "gid" ] ''
A preallocated GID will be used instead. A preallocated GID will be used instead.
'') '')
]; ];
options = { options = {
programs._1password = { programs._1password = {
enable = mkEnableOption "the 1Password CLI tool"; enable = lib.mkEnableOption "the 1Password CLI tool";
package = mkPackageOption pkgs "1Password CLI" { package = lib.mkPackageOption pkgs "1Password CLI" {
default = [ "_1password" ]; default = [ "_1password" ];
}; };
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ]; environment.systemPackages = [ cfg.package ];
users.groups.onepassword-cli.gid = config.ids.gids.onepassword-cli; users.groups.onepassword-cli.gid = config.ids.gids.onepassword-cli;

View File

@ -1,16 +1,14 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
{ {
meta.maintainers = [ maintainers.mic92 ]; meta.maintainers = [ lib.maintainers.mic92 ];
###### interface ###### interface
options = { options = {
programs.adb = { programs.adb = {
enable = mkOption { enable = lib.mkOption {
default = false; default = false;
type = types.bool; type = lib.types.bool;
description = '' description = ''
Whether to configure system to use Android Debug Bridge (adb). Whether to configure system to use Android Debug Bridge (adb).
To grant access to a user, it must be part of adbusers group: To grant access to a user, it must be part of adbusers group:
@ -21,7 +19,7 @@ with lib;
}; };
###### implementation ###### implementation
config = mkIf config.programs.adb.enable { config = lib.mkIf config.programs.adb.enable {
services.udev.packages = [ pkgs.android-udev-rules ]; services.udev.packages = [ pkgs.android-udev-rules ];
environment.systemPackages = [ pkgs.android-tools ]; environment.systemPackages = [ pkgs.android-tools ];
users.groups.adbusers = {}; users.groups.adbusers = {};

View File

@ -1,19 +1,17 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib;
let let
cfg = config.programs.alvr; cfg = config.programs.alvr;
in in
{ {
options = { options = {
programs.alvr = { programs.alvr = {
enable = mkEnableOption "ALVR, the VR desktop streamer"; enable = lib.mkEnableOption "ALVR, the VR desktop streamer";
package = mkPackageOption pkgs "alvr" { }; package = lib.mkPackageOption pkgs "alvr" { };
openFirewall = mkOption { openFirewall = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to open the default ports in the firewall for the ALVR server. Whether to open the default ports in the firewall for the ALVR server.
@ -22,14 +20,14 @@ in
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ]; environment.systemPackages = [ cfg.package ];
networking.firewall = mkIf cfg.openFirewall { networking.firewall = lib.mkIf cfg.openFirewall {
allowedTCPPorts = [ 9943 9944 ]; allowedTCPPorts = [ 9943 9944 ];
allowedUDPPorts = [ 9943 9944 ]; allowedUDPPorts = [ 9943 9944 ];
}; };
}; };
meta.maintainers = with maintainers; [ passivelemon ]; meta.maintainers = with lib.maintainers; [ passivelemon ];
} }

View File

@ -1,15 +1,13 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib;
{ {
options = { options = {
programs.appgate-sdp = { programs.appgate-sdp = {
enable = mkEnableOption "the AppGate SDP VPN client"; enable = lib.mkEnableOption "the AppGate SDP VPN client";
}; };
}; };
config = mkIf config.programs.appgate-sdp.enable { config = lib.mkIf config.programs.appgate-sdp.enable {
boot.kernelModules = [ "tun" ]; boot.kernelModules = [ "tun" ];
environment.systemPackages = [ pkgs.appgate-sdp ]; environment.systemPackages = [ pkgs.appgate-sdp ];
services.dbus.packages = [ pkgs.appgate-sdp ]; services.dbus.packages = [ pkgs.appgate-sdp ];

View File

@ -2,8 +2,6 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let cfg = config.programs.atop; let cfg = config.programs.atop;
in in
@ -14,31 +12,31 @@ in
programs.atop = rec { programs.atop = rec {
enable = mkEnableOption "Atop, a tool for monitoring system resources"; enable = lib.mkEnableOption "Atop, a tool for monitoring system resources";
package = mkPackageOption pkgs "atop" { }; package = lib.mkPackageOption pkgs "atop" { };
netatop = { netatop = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to install and enable the netatop kernel module. Whether to install and enable the netatop kernel module.
Note: this sets the kernel taint flag "O" for loading out-of-tree modules. Note: this sets the kernel taint flag "O" for loading out-of-tree modules.
''; '';
}; };
package = mkOption { package = lib.mkOption {
type = types.package; type = lib.types.package;
default = config.boot.kernelPackages.netatop; default = config.boot.kernelPackages.netatop;
defaultText = literalExpression "config.boot.kernelPackages.netatop"; defaultText = lib.literalExpression "config.boot.kernelPackages.netatop";
description = '' description = ''
Which package to use for netatop. Which package to use for netatop.
''; '';
}; };
}; };
atopgpu.enable = mkOption { atopgpu.enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to install and enable the atopgpud daemon to get information about Whether to install and enable the atopgpud daemon to get information about
@ -46,8 +44,8 @@ in
''; '';
}; };
setuidWrapper.enable = mkOption { setuidWrapper.enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to install a setuid wrapper for Atop. This is required to use some of Whether to install a setuid wrapper for Atop. This is required to use some of
@ -56,24 +54,24 @@ in
''; '';
}; };
atopService.enable = mkOption { atopService.enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = '' description = ''
Whether to enable the atop service responsible for storing statistics for Whether to enable the atop service responsible for storing statistics for
long-term analysis. long-term analysis.
''; '';
}; };
atopRotateTimer.enable = mkOption { atopRotateTimer.enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = '' description = ''
Whether to enable the atop-rotate timer, which restarts the atop service Whether to enable the atop-rotate timer, which restarts the atop service
daily to make sure the data files are rotate. daily to make sure the data files are rotate.
''; '';
}; };
atopacctService.enable = mkOption { atopacctService.enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = '' description = ''
Whether to enable the atopacct service which manages process accounting. Whether to enable the atopacct service which manages process accounting.
@ -81,8 +79,8 @@ in
two refresh intervals. two refresh intervals.
''; '';
}; };
settings = mkOption { settings = lib.mkOption {
type = types.attrs; type = lib.types.attrs;
default = { }; default = { };
example = { example = {
flags = "a1f"; flags = "a1f";
@ -95,7 +93,7 @@ in
}; };
}; };
config = mkIf cfg.enable ( config = lib.mkIf cfg.enable (
let let
atop = atop =
if cfg.atopgpu.enable then if cfg.atopgpu.enable then
@ -104,11 +102,11 @@ in
cfg.package; cfg.package;
in in
{ {
environment.etc = mkIf (cfg.settings != { }) { environment.etc = lib.mkIf (cfg.settings != { }) {
atoprc.text = concatStrings atoprc.text = lib.concatStrings
(mapAttrsToList (lib.mapAttrsToList
(n: v: '' (n: v: ''
${n} ${toString v} ${n} ${builtins.toString v}
'') '')
cfg.settings); cfg.settings);
}; };
@ -122,8 +120,8 @@ in
wantedBy = [ (if type == "services" then "multi-user.target" else if type == "timers" then "timers.target" else null) ]; wantedBy = [ (if type == "services" then "multi-user.target" else if type == "timers" then "timers.target" else null) ];
}; };
}; };
mkService = mkSystemd "services"; mkService = lib.mkSystemd "services";
mkTimer = mkSystemd "timers"; mkTimer = lib.mkSystemd "timers";
in in
{ {
packages = [ atop (lib.mkIf cfg.netatop.enable cfg.netatop.package) ]; packages = [ atop (lib.mkIf cfg.netatop.enable cfg.netatop.package) ];

View File

@ -1,15 +1,13 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.ausweisapp; cfg = config.programs.ausweisapp;
in in
{ {
options.programs.ausweisapp = { options.programs.ausweisapp = {
enable = mkEnableOption "AusweisApp"; enable = lib.mkEnableOption "AusweisApp";
openFirewall = mkOption { openFirewall = lib.mkOption {
description = '' description = ''
Whether to open the required firewall ports for the Smartphone as Card Reader (SaC) functionality of AusweisApp. Whether to open the required firewall ports for the Smartphone as Card Reader (SaC) functionality of AusweisApp.
''; '';
@ -18,7 +16,7 @@ in
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ ausweisapp ]; environment.systemPackages = with pkgs; [ ausweisapp ];
networking.firewall.allowedUDPPorts = lib.optionals cfg.openFirewall [ 24727 ]; networking.firewall.allowedUDPPorts = lib.optionals cfg.openFirewall [ 24727 ];
}; };

View File

@ -1,7 +1,5 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.autojump; cfg = config.programs.autojump;
prg = config.programs; prg = config.programs;
@ -10,8 +8,8 @@ in
options = { options = {
programs.autojump = { programs.autojump = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to enable autojump. Whether to enable autojump.
@ -22,12 +20,12 @@ in
###### implementation ###### implementation
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.pathsToLink = [ "/share/autojump" ]; environment.pathsToLink = [ "/share/autojump" ];
environment.systemPackages = [ pkgs.autojump ]; environment.systemPackages = [ pkgs.autojump ];
programs.bash.interactiveShellInit = "source ${pkgs.autojump}/share/autojump/autojump.bash"; 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.zsh.interactiveShellInit = lib.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"; programs.fish.interactiveShellInit = lib.mkIf prg.fish.enable "source ${pkgs.autojump}/share/autojump/autojump.fish";
}; };
} }

View File

@ -1,15 +1,13 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let cfg = config.programs.bandwhich; let cfg = config.programs.bandwhich;
in { in {
meta.maintainers = with maintainers; [ Br1ght0ne ]; meta.maintainers = with lib.maintainers; [ Br1ght0ne ];
options = { options = {
programs.bandwhich = { programs.bandwhich = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to add bandwhich to the global environment and configure a Whether to add bandwhich to the global environment and configure a
@ -19,7 +17,7 @@ in {
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ bandwhich ]; environment.systemPackages = with pkgs; [ bandwhich ];
security.wrappers.bandwhich = { security.wrappers.bandwhich = {
owner = "root"; owner = "root";

View File

@ -1,7 +1,5 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib;
let let
prg = config.programs; prg = config.programs;
cfg = prg.bash-my-aws; cfg = prg.bash-my-aws;
@ -13,11 +11,11 @@ in
{ {
options = { options = {
programs.bash-my-aws = { programs.bash-my-aws = {
enable = mkEnableOption "bash-my-aws"; enable = lib.mkEnableOption "bash-my-aws";
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ bash-my-aws ]; environment.systemPackages = with pkgs; [ bash-my-aws ];
programs.bash.interactiveShellInit = initScript; programs.bash.interactiveShellInit = initScript;

View File

@ -1,18 +1,16 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
enable = config.programs.bash.enableCompletion; enable = config.programs.bash.enableCompletion;
in in
{ {
options = { options = {
programs.bash.enableCompletion = mkEnableOption "Bash completion for all interactive bash shells" // { programs.bash.enableCompletion = lib.mkEnableOption "Bash completion for all interactive bash shells" // {
default = true; default = true;
}; };
}; };
config = mkIf enable { config = lib.mkIf enable {
programs.bash.promptPluginInit = '' programs.bash.promptPluginInit = ''
# Check whether we're running a version of Bash that has support for # Check whether we're running a version of Bash that has support for
# programmable completion. If we do, enable all modules installed in # programmable completion. If we do, enable all modules installed in

View File

@ -3,24 +3,22 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfge = config.environment; cfge = config.environment;
cfg = config.programs.bash; cfg = config.programs.bash;
bashAliases = concatStringsSep "\n" ( bashAliases = builtins.concatStringsSep "\n" (
mapAttrsFlatten (k: v: "alias -- ${k}=${escapeShellArg v}") lib.mapAttrsFlatten (k: v: "alias -- ${k}=${lib.escapeShellArg v}")
(filterAttrs (k: v: v != null) cfg.shellAliases) (lib.filterAttrs (k: v: v != null) cfg.shellAliases)
); );
in in
{ {
imports = [ imports = [
(mkRemovedOptionModule [ "programs" "bash" "enable" ] "") (lib.mkRemovedOptionModule [ "programs" "bash" "enable" ] "")
]; ];
options = { options = {
@ -28,7 +26,7 @@ in
programs.bash = { programs.bash = {
/* /*
enable = mkOption { enable = lib.mkOption {
default = true; default = true;
description = '' description = ''
Whenever to configure Bash as an interactive shell. Whenever to configure Bash as an interactive shell.
@ -38,44 +36,44 @@ in
set this variable if you have another shell configured set this variable if you have another shell configured
with NixOS. with NixOS.
''; '';
type = types.bool; type = lib.types.bool;
}; };
*/ */
shellAliases = mkOption { shellAliases = lib.mkOption {
default = {}; default = {};
description = '' description = ''
Set of aliases for bash shell, which overrides {option}`environment.shellAliases`. Set of aliases for bash shell, which overrides {option}`environment.shellAliases`.
See {option}`environment.shellAliases` for an option format description. See {option}`environment.shellAliases` for an option format description.
''; '';
type = with types; attrsOf (nullOr (either str path)); type = with lib.types; attrsOf (nullOr (either str path));
}; };
shellInit = mkOption { shellInit = lib.mkOption {
default = ""; default = "";
description = '' description = ''
Shell script code called during bash shell initialisation. Shell script code called during bash shell initialisation.
''; '';
type = types.lines; type = lib.types.lines;
}; };
loginShellInit = mkOption { loginShellInit = lib.mkOption {
default = ""; default = "";
description = '' description = ''
Shell script code called during login bash shell initialisation. Shell script code called during login bash shell initialisation.
''; '';
type = types.lines; type = lib.types.lines;
}; };
interactiveShellInit = mkOption { interactiveShellInit = lib.mkOption {
default = ""; default = "";
description = '' description = ''
Shell script code called during interactive bash shell initialisation. Shell script code called during interactive bash shell initialisation.
''; '';
type = types.lines; type = lib.types.lines;
}; };
promptInit = mkOption { promptInit = lib.mkOption {
default = '' default = ''
# Provide a nice prompt if the terminal supports it. # Provide a nice prompt if the terminal supports it.
if [ "$TERM" != "dumb" ] || [ -n "$INSIDE_EMACS" ]; then if [ "$TERM" != "dumb" ] || [ -n "$INSIDE_EMACS" ]; then
@ -95,15 +93,15 @@ in
description = '' description = ''
Shell script code used to initialise the bash prompt. Shell script code used to initialise the bash prompt.
''; '';
type = types.lines; type = lib.types.lines;
}; };
promptPluginInit = mkOption { promptPluginInit = lib.mkOption {
default = ""; default = "";
description = '' description = ''
Shell script code used to initialise bash prompt plugins. Shell script code used to initialise bash prompt plugins.
''; '';
type = types.lines; type = lib.types.lines;
internal = true; internal = true;
}; };
@ -111,11 +109,11 @@ in
}; };
config = /* mkIf cfg.enable */ { config = /* lib.mkIf cfg.enable */ {
programs.bash = { programs.bash = {
shellAliases = mapAttrs (name: mkDefault) cfge.shellAliases; shellAliases = builtins.mapAttrs (name: lib.mkDefault) cfge.shellAliases;
shellInit = '' shellInit = ''
if [ -z "$__NIXOS_SET_ENVIRONMENT_DONE" ]; then if [ -z "$__NIXOS_SET_ENVIRONMENT_DONE" ]; then
@ -196,11 +194,11 @@ in
# Configuration for readline in bash. We use "option default" # Configuration for readline in bash. We use "option default"
# priority to allow user override using both .text and .source. # priority to allow user override using both .text and .source.
environment.etc.inputrc.source = mkOptionDefault ./inputrc; environment.etc.inputrc.source = lib.mkOptionDefault ./inputrc;
users.defaultUserShell = mkDefault pkgs.bashInteractive; users.defaultUserShell = lib.mkDefault pkgs.bashInteractive;
environment.pathsToLink = optionals cfg.enableCompletion [ environment.pathsToLink = lib.optionals cfg.enableCompletion [
"/etc/bash_completion.d" "/etc/bash_completion.d"
"/share/bash-completion" "/share/bash-completion"
]; ];

View File

@ -1,16 +1,15 @@
{ lib, config, pkgs, ... }: { lib, config, pkgs, ... }:
with lib;
let let
cfg = config.programs.bash.blesh; cfg = config.programs.bash.blesh;
in { in {
options = { options = {
programs.bash.blesh.enable = mkEnableOption "blesh, a full-featured line editor written in pure Bash"; programs.bash.blesh.enable = lib.mkEnableOption "blesh, a full-featured line editor written in pure Bash";
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
programs.bash.interactiveShellInit = mkBefore '' programs.bash.interactiveShellInit = lib.mkBefore ''
source ${pkgs.blesh}/share/blesh/ble.sh source ${pkgs.blesh}/share/blesh/ble.sh
''; '';
}; };
meta.maintainers = with maintainers; [ laalsaas ]; meta.maintainers = with lib.maintainers; [ laalsaas ];
} }

View File

@ -1,18 +1,16 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
enable = config.programs.bash.enableLsColors; enable = config.programs.bash.enableLsColors;
in in
{ {
options = { options = {
programs.bash.enableLsColors = mkEnableOption "extra colors in directory listings" // { programs.bash.enableLsColors = lib.mkEnableOption "extra colors in directory listings" // {
default = true; default = true;
}; };
}; };
config = mkIf enable { config = lib.mkIf enable {
programs.bash.promptPluginInit = '' programs.bash.promptPluginInit = ''
eval "$(${pkgs.coreutils}/bin/dircolors -b)" eval "$(${pkgs.coreutils}/bin/dircolors -b)"
''; '';

View File

@ -1,36 +1,34 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.bash.undistractMe; cfg = config.programs.bash.undistractMe;
in in
{ {
options = { options = {
programs.bash.undistractMe = { programs.bash.undistractMe = {
enable = mkEnableOption "notifications when long-running terminal commands complete"; enable = lib.mkEnableOption "notifications when long-running terminal commands complete";
playSound = mkEnableOption "notification sounds when long-running terminal commands complete"; playSound = lib.mkEnableOption "notification sounds when long-running terminal commands complete";
timeout = mkOption { timeout = lib.mkOption {
default = 10; default = 10;
description = '' description = ''
Number of seconds it would take for a command to be considered long-running. Number of seconds it would take for a command to be considered long-running.
''; '';
type = types.int; type = lib.types.int;
}; };
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
programs.bash.promptPluginInit = '' programs.bash.promptPluginInit = ''
export LONG_RUNNING_COMMAND_TIMEOUT=${toString cfg.timeout} export LONG_RUNNING_COMMAND_TIMEOUT=${builtins.toString cfg.timeout}
export UDM_PLAY_SOUND=${if cfg.playSound then "1" else "0"} export UDM_PLAY_SOUND=${if cfg.playSound then "1" else "0"}
. "${pkgs.undistract-me}/etc/profile.d/undistract-me.sh" . "${pkgs.undistract-me}/etc/profile.d/undistract-me.sh"
''; '';
}; };
meta = { meta = {
maintainers = with maintainers; [ kira-bruneau ]; maintainers = with lib.maintainers; [ kira-bruneau ];
}; };
} }

View File

@ -1,12 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
{ {
options.programs.browserpass.enable = mkEnableOption "Browserpass native messaging host"; options.programs.browserpass.enable = lib.mkEnableOption "Browserpass native messaging host";
config = mkIf config.programs.browserpass.enable { config = lib.mkIf config.programs.browserpass.enable {
environment.etc = let environment.etc = let
appId = "com.github.browserpass.native.json"; appId = "com.github.browserpass.native.json";
source = part: "${pkgs.browserpass}/lib/browserpass/${part}/${appId}"; source = part: "${pkgs.browserpass}/lib/browserpass/${part}/${appId}";

View File

@ -1,19 +1,17 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.calls; cfg = config.programs.calls;
in { in {
options = { options = {
programs.calls = { programs.calls = {
enable = mkEnableOption '' enable = lib.mkEnableOption ''
GNOME calls: a phone dialer and call handler GNOME calls: a phone dialer and call handler
''; '';
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
programs.dconf.enable = true; programs.dconf.enable = true;
environment.systemPackages = [ environment.systemPackages = [

View File

@ -1,36 +1,34 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let cfg = config.programs.cdemu; let cfg = config.programs.cdemu;
in { in {
options = { options = {
programs.cdemu = { programs.cdemu = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
{command}`cdemu` for members of {command}`cdemu` for members of
{option}`programs.cdemu.group`. {option}`programs.cdemu.group`.
''; '';
}; };
group = mkOption { group = lib.mkOption {
type = types.str; type = lib.types.str;
default = "cdrom"; default = "cdrom";
description = '' description = ''
Group that users must be in to use {command}`cdemu`. Group that users must be in to use {command}`cdemu`.
''; '';
}; };
gui = mkOption { gui = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = '' description = ''
Whether to install the {command}`cdemu` GUI (gCDEmu). Whether to install the {command}`cdemu` GUI (gCDEmu).
''; '';
}; };
image-analyzer = mkOption { image-analyzer = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = '' description = ''
Whether to install the image analyzer. Whether to install the image analyzer.
@ -39,7 +37,7 @@ in {
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
boot = { boot = {
extraModulePackages = [ config.boot.kernelPackages.vhba ]; extraModulePackages = [ config.boot.kernelPackages.vhba ];
@ -68,8 +66,8 @@ in {
environment.systemPackages = environment.systemPackages =
[ pkgs.cdemu-daemon pkgs.cdemu-client ] [ pkgs.cdemu-daemon pkgs.cdemu-client ]
++ optional cfg.gui pkgs.gcdemu ++ lib.optional cfg.gui pkgs.gcdemu
++ optional cfg.image-analyzer pkgs.image-analyzer; ++ lib.optional cfg.image-analyzer pkgs.image-analyzer;
}; };
} }

View File

@ -2,8 +2,6 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib;
let let
cfg = config.programs.cfs-zen-tweaks; cfg = config.programs.cfs-zen-tweaks;
@ -13,14 +11,14 @@ in
{ {
meta = { meta = {
maintainers = with maintainers; [ mkg20001 ]; maintainers = with lib.maintainers; [ mkg20001 ];
}; };
options = { options = {
programs.cfs-zen-tweaks.enable = mkEnableOption "CFS Zen Tweaks"; programs.cfs-zen-tweaks.enable = lib.mkEnableOption "CFS Zen Tweaks";
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
systemd.packages = [ pkgs.cfs-zen-tweaks ]; systemd.packages = [ pkgs.cfs-zen-tweaks ];
systemd.services.set-cfs-tweaks.wantedBy = [ systemd.services.set-cfs-tweaks.wantedBy = [

View File

@ -1,11 +1,9 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.chromium; cfg = config.programs.chromium;
defaultProfile = filterAttrs (k: v: v != null) { defaultProfile = lib.filterAttrs (k: v: v != null) {
HomepageLocation = cfg.homepageLocation; HomepageLocation = cfg.homepageLocation;
DefaultSearchProviderEnabled = cfg.defaultSearchProviderEnabled; DefaultSearchProviderEnabled = cfg.defaultSearchProviderEnabled;
DefaultSearchProviderSearchURL = cfg.defaultSearchProviderSearchURL; DefaultSearchProviderSearchURL = cfg.defaultSearchProviderSearchURL;
@ -19,14 +17,14 @@ in
options = { options = {
programs.chromium = { programs.chromium = {
enable = mkEnableOption "{command}`chromium` policies"; enable = lib.mkEnableOption "{command}`chromium` policies";
enablePlasmaBrowserIntegration = mkEnableOption "Native Messaging Host for Plasma Browser Integration"; enablePlasmaBrowserIntegration = lib.mkEnableOption "Native Messaging Host for Plasma Browser Integration";
plasmaBrowserIntegrationPackage = mkPackageOption pkgs [ "plasma5Packages" "plasma-browser-integration" ] { }; plasmaBrowserIntegrationPackage = lib.mkPackageOption pkgs [ "plasma5Packages" "plasma-browser-integration" ] { };
extensions = mkOption { extensions = lib.mkOption {
type = with types; nullOr (listOf str); type = with lib.types; nullOr (listOf str);
description = '' description = ''
List of chromium extensions to install. List of chromium extensions to install.
For list of plugins ids see id in url of extensions on For list of plugins ids see id in url of extensions on
@ -38,7 +36,7 @@ in
for additional details. for additional details.
''; '';
default = null; default = null;
example = literalExpression '' example = lib.literalExpression ''
[ [
"chlffgpmiacpedhhbkiomidkjlcfhogd" # pushbullet "chlffgpmiacpedhhbkiomidkjlcfhogd" # pushbullet
"mbniclmhobmnbdlbpiphghaielnnpgdp" # lightshot "mbniclmhobmnbdlbpiphghaielnnpgdp" # lightshot
@ -48,36 +46,36 @@ in
''; '';
}; };
homepageLocation = mkOption { homepageLocation = lib.mkOption {
type = types.nullOr types.str; type = lib.types.nullOr lib.types.str;
description = "Chromium default homepage"; description = "Chromium default homepage";
default = null; default = null;
example = "https://nixos.org"; example = "https://nixos.org";
}; };
defaultSearchProviderEnabled = mkOption { defaultSearchProviderEnabled = lib.mkOption {
type = types.nullOr types.bool; type = lib.types.nullOr lib.types.bool;
description = "Enable the default search provider."; description = "Enable the default search provider.";
default = null; default = null;
example = true; example = true;
}; };
defaultSearchProviderSearchURL = mkOption { defaultSearchProviderSearchURL = lib.mkOption {
type = types.nullOr types.str; type = lib.types.nullOr lib.types.str;
description = "Chromium default search provider url."; description = "Chromium default search provider url.";
default = null; 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}"; 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 { defaultSearchProviderSuggestURL = lib.mkOption {
type = types.nullOr types.str; type = lib.types.nullOr lib.types.str;
description = "Chromium default search provider url for suggestions."; description = "Chromium default search provider url for suggestions.";
default = null; default = null;
example = "https://encrypted.google.com/complete/search?output=chrome&q={searchTerms}"; example = "https://encrypted.google.com/complete/search?output=chrome&q={searchTerms}";
}; };
extraOpts = mkOption { extraOpts = lib.mkOption {
type = types.attrs; type = lib.types.attrs;
description = '' description = ''
Extra chromium policy options. A list of available policies Extra chromium policy options. A list of available policies
can be found in the Chrome Enterprise documentation: can be found in the Chrome Enterprise documentation:
@ -85,7 +83,7 @@ in
Make sure the selected policy is supported on Linux and your browser version. Make sure the selected policy is supported on Linux and your browser version.
''; '';
default = {}; default = {};
example = literalExpression '' example = lib.literalExpression ''
{ {
"BrowserSignin" = 0; "BrowserSignin" = 0;
"SyncDisabled" = true; "SyncDisabled" = true;
@ -99,8 +97,8 @@ in
''; '';
}; };
initialPrefs = mkOption { initialPrefs = lib.mkOption {
type = types.attrs; type = lib.types.attrs;
description = '' description = ''
Initial preferences are used to configure the browser for the first run. 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. Unlike {option}`programs.chromium.extraOpts`, initialPrefs can be changed by users in the browser settings.
@ -108,7 +106,7 @@ in
<https://www.chromium.org/administrators/configuring-other-preferences/> <https://www.chromium.org/administrators/configuring-other-preferences/>
''; '';
default = {}; default = {};
example = literalExpression '' example = lib.literalExpression ''
{ {
"first_run_tabs" = [ "first_run_tabs" = [
"https://nixos.org/" "https://nixos.org/"

View File

@ -1,18 +1,16 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.cnping; cfg = config.programs.cnping;
in in
{ {
options = { options = {
programs.cnping = { programs.cnping = {
enable = mkEnableOption "a setcap wrapper for cnping"; enable = lib.mkEnableOption "a setcap wrapper for cnping";
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
security.wrappers.cnping = { security.wrappers.cnping = {
source = "${pkgs.cnping}/bin/cnping"; source = "${pkgs.cnping}/bin/cnping";
capabilities = "cap_net_raw+ep"; capabilities = "cap_net_raw+ep";

View File

@ -5,8 +5,6 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.command-not-found; cfg = config.programs.command-not-found;
commandNotFound = pkgs.substituteAll { commandNotFound = pkgs.substituteAll {
@ -23,8 +21,8 @@ in
{ {
options.programs.command-not-found = { options.programs.command-not-found = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = '' description = ''
Whether interactive shells should show which Nix package (if Whether interactive shells should show which Nix package (if
@ -32,7 +30,7 @@ in
''; '';
}; };
dbPath = mkOption { dbPath = lib.mkOption {
default = "/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite" ; default = "/nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite" ;
description = '' description = ''
Absolute path to programs.sqlite. Absolute path to programs.sqlite.
@ -40,11 +38,11 @@ in
By default this file will be provided by your channel By default this file will be provided by your channel
(nixexprs.tar.xz). (nixexprs.tar.xz).
''; '';
type = types.path; type = lib.types.path;
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
programs.bash.interactiveShellInit = programs.bash.interactiveShellInit =
'' ''
# This function is called whenever a command is not found. # This function is called whenever a command is not found.

View File

@ -1,14 +1,12 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let cfg = config.programs.criu; let cfg = config.programs.criu;
in { in {
options = { options = {
programs.criu = { programs.criu = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Install {command}`criu` along with necessary kernel options. Install {command}`criu` along with necessary kernel options.
@ -16,7 +14,7 @@ in {
}; };
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
system.requiredKernelConfig = with config.lib.kernelConfig; [ system.requiredKernelConfig = with config.lib.kernelConfig; [
(isYes "CHECKPOINT_RESTORE") (isYes "CHECKPOINT_RESTORE")
]; ];

View File

@ -1,29 +1,27 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.digitalbitbox; cfg = config.programs.digitalbitbox;
in in
{ {
options.programs.digitalbitbox = { options.programs.digitalbitbox = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Installs the Digital Bitbox application and enables the complementary hardware module. Installs the Digital Bitbox application and enables the complementary hardware module.
''; '';
}; };
package = mkPackageOption pkgs "digitalbitbox" { package = lib.mkPackageOption pkgs "digitalbitbox" {
extraDescription = '' extraDescription = ''
This can be used to install a package with udev rules that differ from the defaults. This can be used to install a package with udev rules that differ from the defaults.
''; '';
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ]; environment.systemPackages = [ cfg.package ];
hardware.digitalbitbox = { hardware.digitalbitbox = {
enable = true; enable = true;

View File

@ -1,19 +1,17 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.dmrconfig; cfg = config.programs.dmrconfig;
in { in {
meta.maintainers = with maintainers; [ ]; meta.maintainers = with lib.maintainers; [ ];
###### interface ###### interface
options = { options = {
programs.dmrconfig = { programs.dmrconfig = {
enable = mkOption { enable = lib.mkOption {
default = false; default = false;
type = types.bool; type = lib.types.bool;
description = '' description = ''
Whether to configure system to enable use of dmrconfig. This Whether to configure system to enable use of dmrconfig. This
enables the required udev rules and installs the program. enables the required udev rules and installs the program.
@ -21,12 +19,12 @@ in {
relatedPackages = [ "dmrconfig" ]; relatedPackages = [ "dmrconfig" ];
}; };
package = mkPackageOption pkgs "dmrconfig" { }; package = lib.mkPackageOption pkgs "dmrconfig" { };
}; };
}; };
###### implementation ###### implementation
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ]; environment.systemPackages = [ cfg.package ];
services.udev.packages = [ cfg.package ]; services.udev.packages = [ cfg.package ];
}; };

View File

@ -1,10 +1,8 @@
{ lib, pkgs, config, ... }: { lib, pkgs, config, ... }:
with lib;
{ {
options.programs.droidcam = { options.programs.droidcam = {
enable = mkEnableOption "DroidCam client"; enable = lib.mkEnableOption "DroidCam client";
}; };
config = lib.mkIf config.programs.droidcam.enable { config = lib.mkIf config.programs.droidcam.enable {

View File

@ -1,7 +1,5 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.dublin-traceroute; cfg = config.programs.dublin-traceroute;
@ -10,22 +8,22 @@ in {
options = { options = {
programs.dublin-traceroute = { programs.dublin-traceroute = {
enable = mkEnableOption '' enable = lib.mkEnableOption ''
dublin-traceroute, add it to the global environment and configure a setcap wrapper for it. dublin-traceroute, add it to the global environment and configure a setcap wrapper for it.
''; '';
package = mkPackageOption pkgs "dublin-traceroute" { }; package = lib.mkPackageOption pkgs "dublin-traceroute" { };
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ]; environment.systemPackages = [ cfg.package ];
security.wrappers.dublin-traceroute = { security.wrappers.dublin-traceroute = {
owner = "root"; owner = "root";
group = "root"; group = "root";
capabilities = "cap_net_raw+p"; capabilities = "cap_net_raw+p";
source = getExe cfg.package; source = lib.getExe cfg.package;
}; };
}; };
} }

View File

@ -1,16 +1,14 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.ecryptfs; cfg = config.programs.ecryptfs;
in { in {
options.programs.ecryptfs = { options.programs.ecryptfs = {
enable = mkEnableOption "ecryptfs setuid mount wrappers"; enable = lib.mkEnableOption "ecryptfs setuid mount wrappers";
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
security.wrappers = { security.wrappers = {
"mount.ecryptfs_private" = { "mount.ecryptfs_private" = {

View File

@ -4,8 +4,6 @@
{ config, lib, ... }: { config, lib, ... }:
with lib;
let let
cfg = config.environment; cfg = config.environment;
@ -20,14 +18,14 @@ in
{ NIXPKGS_CONFIG = "/etc/nix/nixpkgs-config.nix"; { NIXPKGS_CONFIG = "/etc/nix/nixpkgs-config.nix";
# note: many programs exec() this directly, so default options for less must not # 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 # be specified here; do so in the default value of programs.less.envVariables instead
PAGER = mkDefault "less"; PAGER = lib.mkDefault "less";
EDITOR = mkDefault "nano"; EDITOR = lib.mkDefault "nano";
}; };
# since we set PAGER to this above, make sure it's installed # since we set PAGER to this above, make sure it's installed
programs.less.enable = true; programs.less.enable = true;
environment.profiles = mkAfter environment.profiles = lib.mkAfter
[ "/nix/var/nix/profiles/default" [ "/nix/var/nix/profiles/default"
"/run/current-system/sw" "/run/current-system/sw"
]; ];
@ -53,7 +51,7 @@ in
environment.extraInit = environment.extraInit =
'' ''
export NIX_USER_PROFILE_DIR="/nix/var/nix/profiles/per-user/$USER" export NIX_USER_PROFILE_DIR="/nix/var/nix/profiles/per-user/$USER"
export NIX_PROFILES="${concatStringsSep " " (reverseList cfg.profiles)}" export NIX_PROFILES="${builtins.concatStringsSep " " (lib.reverseList cfg.profiles)}"
''; '';
}; };

View File

@ -1,16 +1,15 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib;
let let
cfg = config.programs.extra-container; cfg = config.programs.extra-container;
in { in {
options = { options = {
programs.extra-container.enable = mkEnableOption '' programs.extra-container.enable = lib.mkEnableOption ''
extra-container, a tool for running declarative NixOS containers extra-container, a tool for running declarative NixOS containers
without host system rebuilds without host system rebuilds
''; '';
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.extra-container ]; environment.systemPackages = [ pkgs.extra-container ];
boot.extraSystemdUnitPaths = [ "/etc/systemd-mutable/system" ]; boot.extraSystemdUnitPaths = [ "/etc/systemd-mutable/system" ];
}; };

View File

@ -1,21 +1,19 @@
{ pkgs, lib, config, ... }: { pkgs, lib, config, ... }:
with lib;
let let
cfg = config.programs.feedbackd; cfg = config.programs.feedbackd;
in { in {
options = { options = {
programs.feedbackd = { programs.feedbackd = {
enable = mkEnableOption '' enable = lib.mkEnableOption ''
the feedbackd D-BUS service and udev rules. the feedbackd D-BUS service and udev rules.
Your user needs to be in the `feedbackd` group to trigger effects Your user needs to be in the `feedbackd` group to trigger effects
''; '';
package = mkPackageOption pkgs "feedbackd" { }; package = lib.mkPackageOption pkgs "feedbackd" { };
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ]; environment.systemPackages = [ cfg.package ];
services.dbus.packages = [ cfg.package ]; services.dbus.packages = [ cfg.package ];

View File

@ -1,7 +1,5 @@
{ pkgs, config, lib, ... }: { pkgs, config, lib, ... }:
with lib;
let let
cfg = config.programs.firefox; cfg = config.programs.firefox;
@ -62,13 +60,13 @@ let
in in
{ {
options.programs.firefox = { options.programs.firefox = {
enable = mkEnableOption "the Firefox web browser"; enable = lib.mkEnableOption "the Firefox web browser";
package = mkOption { package = lib.mkOption {
type = types.package; type = lib.types.package;
default = pkgs.firefox; default = pkgs.firefox;
description = "Firefox package to use."; description = "Firefox package to use.";
defaultText = literalExpression "pkgs.firefox"; defaultText = lib.literalExpression "pkgs.firefox";
relatedPackages = [ relatedPackages = [
"firefox" "firefox"
"firefox-beta-bin" "firefox-beta-bin"
@ -78,13 +76,13 @@ in
]; ];
}; };
wrapperConfig = mkOption { wrapperConfig = lib.mkOption {
type = types.attrs; type = lib.types.attrs;
default = {}; default = {};
description = "Arguments to pass to Firefox wrapper"; description = "Arguments to pass to Firefox wrapper";
}; };
policies = mkOption { policies = lib.mkOption {
type = policyFormat.type; type = policyFormat.type;
default = { }; default = { };
description = '' description = ''
@ -100,8 +98,8 @@ in
''; '';
}; };
preferences = mkOption { preferences = lib.mkOption {
type = with types; attrsOf (oneOf [ bool int str ]); type = with lib.types; attrsOf (oneOf [ bool int str ]);
default = { }; default = { };
description = '' description = ''
Preferences to set from `about:config`. Preferences to set from `about:config`.
@ -113,8 +111,8 @@ in
''; '';
}; };
preferencesStatus = mkOption { preferencesStatus = lib.mkOption {
type = types.enum [ "default" "locked" "user" "clear" ]; type = lib.types.enum [ "default" "locked" "user" "clear" ];
default = "locked"; default = "locked";
description = '' description = ''
The status of `firefox.preferences`. The status of `firefox.preferences`.
@ -127,9 +125,9 @@ in
''; '';
}; };
languagePacks = mkOption { languagePacks = lib.mkOption {
# Available languages can be found in https://releases.mozilla.org/pub/firefox/releases/${cfg.package.version}/linux-x86_64/xpi/ # 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 ([ type = lib.types.listOf (lib.types.enum ([
"ach" "ach"
"af" "af"
"an" "an"
@ -235,8 +233,8 @@ in
''; '';
}; };
autoConfig = mkOption { autoConfig = lib.mkOption {
type = types.lines; type = lib.types.lines;
default = ""; default = "";
description = '' description = ''
AutoConfig files can be used to set and lock preferences that are not covered AutoConfig files can be used to set and lock preferences that are not covered
@ -247,19 +245,19 @@ in
}; };
nativeMessagingHosts = ({ nativeMessagingHosts = ({
packages = mkOption { packages = lib.mkOption {
type = types.listOf types.package; type = lib.types.listOf lib.types.package;
default = []; default = [];
description = '' description = ''
Additional packages containing native messaging hosts that should be made available to Firefox extensions. Additional packages containing native messaging hosts that should be made available to Firefox extensions.
''; '';
}; };
}) // (mapAttrs (k: v: mkEnableOption "${v.name} support") nmhOptions); }) // (builtins.mapAttrs (k: v: lib.mkEnableOption "${v.name} support") nmhOptions);
}; };
config = let config = let
forEachEnabledNmh = fn: flatten (mapAttrsToList (k: v: lib.optional cfg.nativeMessagingHosts.${k} (fn k v)) nmhOptions); forEachEnabledNmh = fn: lib.flatten (lib.mapAttrsToList (k: v: lib.optional cfg.nativeMessagingHosts.${k} (fn k v)) nmhOptions);
in mkIf cfg.enable { in lib.mkIf cfg.enable {
warnings = forEachEnabledNmh (k: v: warnings = forEachEnabledNmh (k: v:
"The `programs.firefox.nativeMessagingHosts.${k}` option is deprecated, " + "The `programs.firefox.nativeMessagingHosts.${k}` option is deprecated, " +
"please add `${v.package.pname}` to `programs.firefox.nativeMessagingHosts.packages` instead." "please add `${v.package.pname}` to `programs.firefox.nativeMessagingHosts.packages` instead."
@ -278,18 +276,18 @@ in
let let
policiesJSON = policyFormat.generate "firefox-policies.json" { inherit (cfg) policies; }; policiesJSON = policyFormat.generate "firefox-policies.json" { inherit (cfg) policies; };
in in
mkIf (cfg.policies != { }) { lib.mkIf (cfg.policies != { }) {
"firefox/policies/policies.json".source = "${policiesJSON}"; "firefox/policies/policies.json".source = "${policiesJSON}";
}; };
# Preferences are converted into a policy # Preferences are converted into a policy
programs.firefox.policies = { programs.firefox.policies = {
DisableAppUpdate = true; DisableAppUpdate = true;
Preferences = (mapAttrs Preferences = (builtins.mapAttrs
(_: value: { Value = value; Status = cfg.preferencesStatus; }) (_: value: { Value = value; Status = cfg.preferencesStatus; })
cfg.preferences); cfg.preferences);
ExtensionSettings = listToAttrs (map ExtensionSettings = builtins.listToAttrs (builtins.map
(lang: nameValuePair (lang: builtins.nameValuePair
"langpack-${lang}@firefox.mozilla.org" "langpack-${lang}@firefox.mozilla.org"
{ {
installation_mode = "normal_installed"; installation_mode = "normal_installed";
@ -300,5 +298,5 @@ in
}; };
}; };
meta.maintainers = with maintainers; [ danth ]; meta.maintainers = with lib.maintainers; [ danth ];
} }

View File

@ -1,7 +1,5 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.firejail; cfg = config.programs.firejail;
@ -21,13 +19,13 @@ let
else { executable = value; desktop = null; profile = null; extraArgs = []; }; else { executable = value; desktop = null; profile = null; extraArgs = []; };
args = lib.escapeShellArgs ( args = lib.escapeShellArgs (
opts.extraArgs opts.extraArgs
++ (optional (opts.profile != null) "--profile=${toString opts.profile}") ++ (lib.optional (opts.profile != null) "--profile=${builtins.toString opts.profile}")
); );
in in
'' ''
cat <<_EOF >$out/bin/${command} cat <<_EOF >$out/bin/${command}
#! ${pkgs.runtimeShell} -e #! ${pkgs.runtimeShell} -e
exec /run/wrappers/bin/firejail ${args} -- ${toString opts.executable} "\$@" exec /run/wrappers/bin/firejail ${args} -- ${builtins.toString opts.executable} "\$@"
_EOF _EOF
chmod 0755 $out/bin/${command} chmod 0755 $out/bin/${command}
@ -40,30 +38,30 @@ let
in { in {
options.programs.firejail = { options.programs.firejail = {
enable = mkEnableOption "firejail, a sandboxing tool for Linux"; enable = lib.mkEnableOption "firejail, a sandboxing tool for Linux";
wrappedBinaries = mkOption { wrappedBinaries = lib.mkOption {
type = types.attrsOf (types.either types.path (types.submodule { type = lib.types.attrsOf (lib.types.either lib.types.path (lib.types.submodule {
options = { options = {
executable = mkOption { executable = lib.mkOption {
type = types.path; type = lib.types.path;
description = "Executable to run sandboxed"; description = "Executable to run sandboxed";
example = literalExpression ''"''${lib.getBin pkgs.firefox}/bin/firefox"''; example = lib.literalExpression ''"''${lib.getBin pkgs.firefox}/bin/firefox"'';
}; };
desktop = mkOption { desktop = lib.mkOption {
type = types.nullOr types.path; type = lib.types.nullOr lib.types.path;
default = null; default = null;
description = ".desktop file to modify. Only necessary if it uses the absolute path to the executable."; description = ".desktop file to modify. Only necessary if it uses the absolute path to the executable.";
example = literalExpression ''"''${pkgs.firefox}/share/applications/firefox.desktop"''; example = lib.literalExpression ''"''${pkgs.firefox}/share/applications/firefox.desktop"'';
}; };
profile = mkOption { profile = lib.mkOption {
type = types.nullOr types.path; type = lib.types.nullOr lib.types.path;
default = null; default = null;
description = "Profile to use"; description = "Profile to use";
example = literalExpression ''"''${pkgs.firejail}/etc/firejail/firefox.profile"''; example = lib.literalExpression ''"''${pkgs.firejail}/etc/firejail/firefox.profile"'';
}; };
extraArgs = mkOption { extraArgs = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
default = []; default = [];
description = "Extra arguments to pass to firejail"; description = "Extra arguments to pass to firejail";
example = [ "--private=~/.firejail_home" ]; example = [ "--private=~/.firejail_home" ];
@ -71,7 +69,7 @@ in {
}; };
})); }));
default = {}; default = {};
example = literalExpression '' example = lib.literalExpression ''
{ {
firefox = { firefox = {
executable = "''${lib.getBin pkgs.firefox}/bin/firefox"; executable = "''${lib.getBin pkgs.firefox}/bin/firefox";
@ -89,7 +87,7 @@ in {
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
security.wrappers.firejail = security.wrappers.firejail =
{ setuid = true; { setuid = true;
owner = "root"; owner = "root";
@ -100,5 +98,5 @@ in {
environment.systemPackages = [ pkgs.firejail ] ++ [ wrappedBins ]; environment.systemPackages = [ pkgs.firejail ] ++ [ wrappedBins ];
}; };
meta.maintainers = with maintainers; [ peterhoeg ]; meta.maintainers = with lib.maintainers; [ peterhoeg ];
} }

View File

@ -1,21 +1,19 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfge = config.environment; cfge = config.environment;
cfg = config.programs.fish; cfg = config.programs.fish;
fishAbbrs = concatStringsSep "\n" ( fishAbbrs = builtins.concatStringsSep "\n" (
mapAttrsFlatten (k: v: "abbr -ag ${k} ${escapeShellArg v}") lib.mapAttrsFlatten (k: v: "abbr -ag ${k} ${builtins.escapeShellArg v}")
cfg.shellAbbrs cfg.shellAbbrs
); );
fishAliases = concatStringsSep "\n" ( fishAliases = builtins.concatStringsSep "\n" (
mapAttrsFlatten (k: v: "alias ${k} ${escapeShellArg v}") builtins.mapAttrsFlatten (k: v: "alias ${k} ${builtins.escapeShellArg v}")
(filterAttrs (k: v: v != null) cfg.shellAliases) (builtins.filterAttrs (k: v: v != null) cfg.shellAliases)
); );
envShellInit = pkgs.writeText "shellInit" cfge.shellInit; envShellInit = pkgs.writeText "shellInit" cfge.shellInit;
@ -47,18 +45,18 @@ in
programs.fish = { programs.fish = {
enable = mkOption { enable = lib.mkOption {
default = false; default = false;
description = '' description = ''
Whether to configure fish as an interactive shell. Whether to configure fish as an interactive shell.
''; '';
type = types.bool; type = lib.types.bool;
}; };
package = mkPackageOption pkgs "fish" { }; package = lib.mkPackageOption pkgs "fish" { };
useBabelfish = mkOption { useBabelfish = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
If enabled, the configured environment will be translated to native fish using [babelfish](https://github.com/bouk/babelfish). If enabled, the configured environment will be translated to native fish using [babelfish](https://github.com/bouk/babelfish).
@ -66,31 +64,31 @@ in
''; '';
}; };
vendor.config.enable = mkOption { vendor.config.enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = '' description = ''
Whether fish should source configuration snippets provided by other packages. Whether fish should source configuration snippets provided by other packages.
''; '';
}; };
vendor.completions.enable = mkOption { vendor.completions.enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = '' description = ''
Whether fish should use completion files provided by other packages. Whether fish should use completion files provided by other packages.
''; '';
}; };
vendor.functions.enable = mkOption { vendor.functions.enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = '' description = ''
Whether fish should autoload fish functions provided by other packages. Whether fish should autoload fish functions provided by other packages.
''; '';
}; };
shellAbbrs = mkOption { shellAbbrs = lib.mkOption {
default = {}; default = {};
example = { example = {
gco = "git checkout"; gco = "git checkout";
@ -99,63 +97,63 @@ in
description = '' description = ''
Set of fish abbreviations. Set of fish abbreviations.
''; '';
type = with types; attrsOf str; type = with lib.types; attrsOf str;
}; };
shellAliases = mkOption { shellAliases = lib.mkOption {
default = {}; default = {};
description = '' description = ''
Set of aliases for fish shell, which overrides {option}`environment.shellAliases`. Set of aliases for fish shell, which overrides {option}`environment.shellAliases`.
See {option}`environment.shellAliases` for an option format description. See {option}`environment.shellAliases` for an option format description.
''; '';
type = with types; attrsOf (nullOr (either str path)); type = with lib.types; attrsOf (nullOr (either str path));
}; };
shellInit = mkOption { shellInit = lib.mkOption {
default = ""; default = "";
description = '' description = ''
Shell script code called during fish shell initialisation. Shell script code called during fish shell initialisation.
''; '';
type = types.lines; type = lib.types.lines;
}; };
loginShellInit = mkOption { loginShellInit = lib.mkOption {
default = ""; default = "";
description = '' description = ''
Shell script code called during fish login shell initialisation. Shell script code called during fish login shell initialisation.
''; '';
type = types.lines; type = lib.types.lines;
}; };
interactiveShellInit = mkOption { interactiveShellInit = lib.mkOption {
default = ""; default = "";
description = '' description = ''
Shell script code called during interactive fish shell initialisation. Shell script code called during interactive fish shell initialisation.
''; '';
type = types.lines; type = lib.types.lines;
}; };
promptInit = mkOption { promptInit = lib.mkOption {
default = ""; default = "";
description = '' description = ''
Shell script code used to initialise fish prompt. Shell script code used to initialise fish prompt.
''; '';
type = types.lines; type = lib.types.lines;
}; };
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
programs.fish.shellAliases = mapAttrs (name: mkDefault) cfge.shellAliases; programs.fish.shellAliases = builtins.mapAttrs (name: lib.mkDefault) cfge.shellAliases;
# Required for man completions # Required for man completions
documentation.man.generateCaches = lib.mkDefault true; documentation.man.generateCaches = lib.mkDefault true;
environment = mkMerge [ environment = lib.mkMerge [
(mkIf cfg.useBabelfish (lib.mkIf cfg.useBabelfish
{ {
etc."fish/setEnvironment.fish".source = babelfishTranslate config.system.build.setEnvironment "setEnvironment"; etc."fish/setEnvironment.fish".source = babelfishTranslate config.system.build.setEnvironment "setEnvironment";
etc."fish/shellInit.fish".source = babelfishTranslate envShellInit "shellInit"; etc."fish/shellInit.fish".source = babelfishTranslate envShellInit "shellInit";
@ -163,7 +161,7 @@ in
etc."fish/interactiveShellInit.fish".source = babelfishTranslate envInteractiveShellInit "interactiveShellInit"; etc."fish/interactiveShellInit.fish".source = babelfishTranslate envInteractiveShellInit "interactiveShellInit";
}) })
(mkIf (!cfg.useBabelfish) (lib.mkIf (!cfg.useBabelfish)
{ {
etc."fish/foreign-env/shellInit".source = envShellInit; etc."fish/foreign-env/shellInit".source = envShellInit;
etc."fish/foreign-env/loginShellInit".source = envLoginShellInit; etc."fish/foreign-env/loginShellInit".source = envLoginShellInit;
@ -266,7 +264,7 @@ in
pathName = substring storeLength (stringLength package - storeLength) package; pathName = substring storeLength (stringLength package - storeLength) package;
in (package.name or pathName) + "_fish-completions") in (package.name or pathName) + "_fish-completions")
( { inherit package; } // ( { inherit package; } //
optionalAttrs (package ? meta.priority) { meta.priority = package.meta.priority; }) lib.optionalAttrs (package ? meta.priority) { meta.priority = package.meta.priority; })
'' ''
mkdir -p $out mkdir -p $out
if [ -d $package/share/man ]; then if [ -d $package/share/man ]; then
@ -277,16 +275,16 @@ in
pkgs.buildEnv { pkgs.buildEnv {
name = "system_fish-completions"; name = "system_fish-completions";
ignoreCollisions = true; ignoreCollisions = true;
paths = map generateCompletions config.environment.systemPackages; paths = builtins.map generateCompletions config.environment.systemPackages;
}; };
} }
# include programs that bring their own completions # include programs that bring their own completions
{ {
pathsToLink = [] pathsToLink = []
++ optional cfg.vendor.config.enable "/share/fish/vendor_conf.d" ++ lib.optional cfg.vendor.config.enable "/share/fish/vendor_conf.d"
++ optional cfg.vendor.completions.enable "/share/fish/vendor_completions.d" ++ lib.optional cfg.vendor.completions.enable "/share/fish/vendor_completions.d"
++ optional cfg.vendor.functions.enable "/share/fish/vendor_functions.d"; ++ lib.optional cfg.vendor.functions.enable "/share/fish/vendor_functions.d";
} }
{ systemPackages = [ cfg.package ]; } { systemPackages = [ cfg.package ]; }

View File

@ -1,14 +1,12 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.flashrom; cfg = config.programs.flashrom;
in in
{ {
options.programs.flashrom = { options.programs.flashrom = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Installs flashrom and configures udev rules for programmers Installs flashrom and configures udev rules for programmers
@ -16,10 +14,10 @@ in
group. group.
''; '';
}; };
package = mkPackageOption pkgs "flashrom" { }; package = lib.mkPackageOption pkgs "flashrom" { };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.udev.packages = [ cfg.package ]; services.udev.packages = [ cfg.package ];
environment.systemPackages = [ cfg.package ]; environment.systemPackages = [ cfg.package ];
}; };

View File

@ -1,19 +1,17 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib;
let let
cfg = config.programs.flexoptix-app; cfg = config.programs.flexoptix-app;
in { in {
options = { options = {
programs.flexoptix-app = { programs.flexoptix-app = {
enable = mkEnableOption "FLEXOPTIX app + udev rules"; enable = lib.mkEnableOption "FLEXOPTIX app + udev rules";
package = mkPackageOption pkgs "flexoptix-app" { }; package = lib.mkPackageOption pkgs "flexoptix-app" { };
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ]; environment.systemPackages = [ cfg.package ];
services.udev.packages = [ cfg.package ]; services.udev.packages = [ cfg.package ];
}; };

View File

@ -2,8 +2,6 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.environment.freetds; cfg = config.environment.freetds;
@ -14,10 +12,10 @@ in
options = { options = {
environment.freetds = mkOption { environment.freetds = lib.mkOption {
type = types.attrsOf types.str; type = lib.types.attrsOf lib.types.str;
default = {}; default = {};
example = literalExpression '' example = lib.literalExpression ''
{ MYDATABASE = ''' { MYDATABASE = '''
host = 10.0.2.100 host = 10.0.2.100
port = 1433 port = 1433
@ -40,14 +38,14 @@ in
###### implementation ###### implementation
config = mkIf (length (attrNames cfg) > 0) { config = lib.mkIf (builtins.length (builtins.attrNames cfg) > 0) {
environment.variables.FREETDSCONF = "/etc/freetds.conf"; environment.variables.FREETDSCONF = "/etc/freetds.conf";
environment.variables.FREETDS = "/etc/freetds.conf"; environment.variables.FREETDS = "/etc/freetds.conf";
environment.variables.SYBASE = "${pkgs.freetds}"; environment.variables.SYBASE = "${pkgs.freetds}";
environment.etc."freetds.conf" = { text = environment.etc."freetds.conf" = { text =
(concatStrings (mapAttrsToList (name: value: (lib.concatStrings (lib.mapAttrsToList (name: value:
'' ''
[${name}] [${name}]
${value} ${value}

View File

@ -1,25 +1,23 @@
{ config, lib, ... }: { config, lib, ... }:
with lib;
let let
cfg = config.programs.fuse; cfg = config.programs.fuse;
in { in {
meta.maintainers = with maintainers; [ primeos ]; meta.maintainers = with lib.maintainers; [ primeos ];
options.programs.fuse = { options.programs.fuse = {
mountMax = mkOption { mountMax = lib.mkOption {
# In the C code it's an "int" (i.e. signed and at least 16 bit), but # In the C code it's an "int" (i.e. signed and at least 16 bit), but
# negative numbers obviously make no sense: # negative numbers obviously make no sense:
type = types.ints.between 0 32767; # 2^15 - 1 type = lib.types.ints.between 0 32767; # 2^15 - 1
default = 1000; default = 1000;
description = '' description = ''
Set the maximum number of FUSE mounts allowed to non-root users. Set the maximum number of FUSE mounts allowed to non-root users.
''; '';
}; };
userAllowOther = mkOption { userAllowOther = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Allow non-root users to specify the allow_other or allow_root mount Allow non-root users to specify the allow_other or allow_root mount
@ -30,8 +28,8 @@ in {
config = { config = {
environment.etc."fuse.conf".text = '' environment.etc."fuse.conf".text = ''
${optionalString (!cfg.userAllowOther) "#"}user_allow_other ${lib.optionalString (!cfg.userAllowOther) "#"}user_allow_other
mount_max = ${toString cfg.mountMax} mount_max = ${builtins.toString cfg.mountMax}
''; '';
}; };
} }

View File

@ -1,7 +1,5 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.gamemode; cfg = config.programs.gamemode;
settingsFormat = pkgs.formats.ini { }; settingsFormat = pkgs.formats.ini { };
@ -10,20 +8,20 @@ in
{ {
options = { options = {
programs.gamemode = { programs.gamemode = {
enable = mkEnableOption "GameMode to optimise system performance on demand"; enable = lib.mkEnableOption "GameMode to optimise system performance on demand";
enableRenice = mkEnableOption "CAP_SYS_NICE on gamemoded to support lowering process niceness" // { enableRenice = lib.mkEnableOption "CAP_SYS_NICE on gamemoded to support lowering process niceness" // {
default = true; default = true;
}; };
settings = mkOption { settings = lib.mkOption {
type = settingsFormat.type; type = settingsFormat.type;
default = { }; default = { };
description = '' description = ''
System-wide configuration for GameMode (/etc/gamemode.ini). System-wide configuration for GameMode (/etc/gamemode.ini).
See gamemoded(8) man page for available settings. See gamemoded(8) man page for available settings.
''; '';
example = literalExpression '' example = lib.literalExpression ''
{ {
general = { general = {
renice = 10; renice = 10;
@ -46,7 +44,7 @@ in
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment = { environment = {
systemPackages = [ pkgs.gamemode ]; systemPackages = [ pkgs.gamemode ];
etc."gamemode.ini".source = configFile; etc."gamemode.ini".source = configFile;
@ -54,7 +52,7 @@ in
security = { security = {
polkit.enable = true; polkit.enable = true;
wrappers = mkIf cfg.enableRenice { wrappers = lib.mkIf cfg.enableRenice {
gamemoded = { gamemoded = {
owner = "root"; owner = "root";
group = "root"; group = "root";
@ -77,14 +75,14 @@ in
# #
# This uses a link farm to make sure other wrapped executables # This uses a link farm to make sure other wrapped executables
# aren't included in PATH. # aren't included in PATH.
environment.PATH = mkForce (pkgs.linkFarm "pkexec" [ environment.PATH = lib.mkForce (pkgs.linkFarm "pkexec" [
{ {
name = "pkexec"; name = "pkexec";
path = "${config.security.wrapperDir}/pkexec"; path = "${config.security.wrapperDir}/pkexec";
} }
]); ]);
serviceConfig.ExecStart = mkIf cfg.enableRenice [ serviceConfig.ExecStart = lib.mkIf cfg.enableRenice [
"" # Tell systemd to clear the existing ExecStart list, to prevent appending to it. "" # Tell systemd to clear the existing ExecStart list, to prevent appending to it.
"${config.security.wrapperDir}/gamemoded" "${config.security.wrapperDir}/gamemoded"
]; ];
@ -95,6 +93,6 @@ in
}; };
meta = { meta = {
maintainers = with maintainers; [ kira-bruneau ]; maintainers = with lib.maintainers; [ kira-bruneau ];
}; };
} }

View File

@ -3,30 +3,30 @@
, pkgs , pkgs
, ... , ...
}: }:
with lib; let let
cfg = config.programs.gamescope; cfg = config.programs.gamescope;
gamescope = gamescope =
let let
wrapperArgs = wrapperArgs =
optional (cfg.args != [ ]) lib.optional (cfg.args != [ ])
''--add-flags "${toString cfg.args}"'' ''--add-flags "${builtins.toString cfg.args}"''
++ builtins.attrValues (mapAttrs (var: val: "--set-default ${var} ${val}") cfg.env); ++ builtins.attrValues (builtins.mapAttrs (var: val: "--set-default ${var} ${val}") cfg.env);
in in
pkgs.runCommand "gamescope" { nativeBuildInputs = [ pkgs.makeBinaryWrapper ]; } '' pkgs.runCommand "gamescope" { nativeBuildInputs = [ pkgs.makeBinaryWrapper ]; } ''
mkdir -p $out/bin mkdir -p $out/bin
makeWrapper ${cfg.package}/bin/gamescope $out/bin/gamescope --inherit-argv0 \ makeWrapper ${cfg.package}/bin/gamescope $out/bin/gamescope --inherit-argv0 \
${toString wrapperArgs} ${builtins.toString wrapperArgs}
''; '';
in in
{ {
options.programs.gamescope = { options.programs.gamescope = {
enable = mkEnableOption "gamescope, the SteamOS session compositing window manager"; enable = lib.mkEnableOption "gamescope, the SteamOS session compositing window manager";
package = mkPackageOption pkgs "gamescope" { }; package = lib.mkPackageOption pkgs "gamescope" { };
capSysNice = mkOption { capSysNice = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Add cap_sys_nice capability to the GameScope Add cap_sys_nice capability to the GameScope
@ -34,8 +34,8 @@ in
''; '';
}; };
args = mkOption { args = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
default = [ ]; default = [ ];
example = [ "--rt" "--prefer-vk-device 8086:9bc4" ]; example = [ "--rt" "--prefer-vk-device 8086:9bc4" ];
description = '' description = ''
@ -43,10 +43,10 @@ in
''; '';
}; };
env = mkOption { env = lib.mkOption {
type = types.attrsOf types.str; type = lib.types.attrsOf lib.types.str;
default = { }; default = { };
example = literalExpression '' example = lib.literalExpression ''
# for Prime render offload on Nvidia laptops. # for Prime render offload on Nvidia laptops.
# Also requires `hardware.nvidia.prime.offload.enable`. # Also requires `hardware.nvidia.prime.offload.enable`.
{ {
@ -61,8 +61,8 @@ in
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
security.wrappers = mkIf cfg.capSysNice { security.wrappers = lib.mkIf cfg.capSysNice {
gamescope = { gamescope = {
owner = "root"; owner = "root";
group = "root"; group = "root";
@ -71,8 +71,8 @@ in
}; };
}; };
environment.systemPackages = mkIf (!cfg.capSysNice) [ gamescope ]; environment.systemPackages = lib.mkIf (!cfg.capSysNice) [ gamescope ];
}; };
meta.maintainers = with maintainers; [ nrdxp ]; meta.maintainers = with lib.maintainers; [ nrdxp ];
} }

View File

@ -1,20 +1,18 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib;
let let
cfg = config.programs.geary; cfg = config.programs.geary;
in { in {
meta = { meta = {
maintainers = teams.gnome.members; maintainers = lib.teams.gnome.members;
}; };
options = { options = {
programs.geary.enable = mkEnableOption "Geary, a Mail client for GNOME"; programs.geary.enable = lib.mkEnableOption "Geary, a Mail client for GNOME";
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.gnome.geary ]; environment.systemPackages = [ pkgs.gnome.geary ];
programs.dconf.enable = true; programs.dconf.enable = true;
services.gnome.gnome-keyring.enable = true; services.gnome.gnome-keyring.enable = true;

View File

@ -1,7 +1,5 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.git; cfg = config.programs.git;
in in
@ -9,23 +7,23 @@ in
{ {
options = { options = {
programs.git = { programs.git = {
enable = mkEnableOption "git, a distributed version control system"; enable = lib.mkEnableOption "git, a distributed version control system";
package = mkPackageOption pkgs "git" { package = lib.mkPackageOption pkgs "git" {
example = "gitFull"; example = "gitFull";
}; };
config = mkOption { config = lib.mkOption {
type = type =
with types; with lib.types;
let let
gitini = attrsOf (attrsOf anything); gitini = attrsOf (attrsOf anything);
in in
either gitini (listOf gitini) // { either gitini (listOf gitini) // {
merge = loc: defs: merge = loc: defs:
let let
config = foldl' config = builtins.foldl'
(acc: { value, ... }@x: acc // (if isList value then { (acc: { value, ... }@x: acc // (if builtins.isList value then {
ordered = acc.ordered ++ value; ordered = acc.ordered ++ value;
} else { } else {
unordered = acc.unordered ++ [ x ]; unordered = acc.unordered ++ [ x ];
@ -55,25 +53,25 @@ in
}; };
prompt = { prompt = {
enable = mkEnableOption "automatically sourcing git-prompt.sh. This does not change $PS1; it simply provides relevant utility functions"; enable = lib.mkEnableOption "automatically sourcing git-prompt.sh. This does not change $PS1; it simply provides relevant utility functions";
}; };
lfs = { lfs = {
enable = mkEnableOption "git-lfs (Large File Storage)"; enable = lib.mkEnableOption "git-lfs (Large File Storage)";
package = mkPackageOption pkgs "git-lfs" { }; package = lib.mkPackageOption pkgs "git-lfs" { };
}; };
}; };
}; };
config = mkMerge [ config = lib.mkMerge [
(mkIf cfg.enable { (lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ]; environment.systemPackages = [ cfg.package ];
environment.etc.gitconfig = mkIf (cfg.config != [ ]) { environment.etc.gitconfig = lib.mkIf (cfg.config != [ ]) {
text = concatMapStringsSep "\n" generators.toGitINI cfg.config; text = lib.concatMapStringsSep "\n" lib.generators.toGitINI cfg.config;
}; };
}) })
(mkIf (cfg.enable && cfg.lfs.enable) { (lib.mkIf (cfg.enable && cfg.lfs.enable) {
environment.systemPackages = [ cfg.lfs.package ]; environment.systemPackages = [ cfg.lfs.package ];
programs.git.config = { programs.git.config = {
filter.lfs = { filter.lfs = {
@ -84,12 +82,12 @@ in
}; };
}; };
}) })
(mkIf (cfg.enable && cfg.prompt.enable) { (lib.mkIf (cfg.enable && cfg.prompt.enable) {
environment.interactiveShellInit = '' environment.interactiveShellInit = ''
source ${cfg.package}/share/bash-completion/completions/git-prompt.sh source ${cfg.package}/share/bash-completion/completions/git-prompt.sh
''; '';
}) })
]; ];
meta.maintainers = with maintainers; [ figsoda ]; meta.maintainers = with lib.maintainers; [ figsoda ];
} }

View File

@ -1,16 +1,14 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
{ {
meta.maintainers = [ maintainers.league ]; meta.maintainers = [ lib.maintainers.league ];
###### interface ###### interface
options = { options = {
programs.gphoto2 = { programs.gphoto2 = {
enable = mkOption { enable = lib.mkOption {
default = false; default = false;
type = types.bool; type = lib.types.bool;
description = '' description = ''
Whether to configure system to use gphoto2. Whether to configure system to use gphoto2.
To grant digital camera access to a user, the user must To grant digital camera access to a user, the user must
@ -22,7 +20,7 @@ with lib;
}; };
###### implementation ###### implementation
config = mkIf config.programs.gphoto2.enable { config = lib.mkIf config.programs.gphoto2.enable {
services.udev.packages = [ pkgs.libgphoto2 ]; services.udev.packages = [ pkgs.libgphoto2 ];
environment.systemPackages = [ pkgs.gphoto2 ]; environment.systemPackages = [ pkgs.gphoto2 ];
users.groups.camera = {}; users.groups.camera = {};

View File

@ -1,13 +1,11 @@
{ lib, pkgs, config, ... }: { lib, pkgs, config, ... }:
with lib;
{ {
options.programs.haguichi = { options.programs.haguichi = {
enable = mkEnableOption "Haguichi, a Linux GUI frontend to the proprietary LogMeIn Hamachi"; enable = lib.mkEnableOption "Haguichi, a Linux GUI frontend to the proprietary LogMeIn Hamachi";
}; };
config = mkIf config.programs.haguichi.enable { config = lib.mkIf config.programs.haguichi.enable {
environment.systemPackages = with pkgs; [ haguichi ]; environment.systemPackages = with pkgs; [ haguichi ];
services.logmein-hamachi.enable = true; services.logmein-hamachi.enable = true;

View File

@ -1,12 +1,10 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
{ {
meta.maintainers = pkgs.hamster.meta.maintainers; meta.maintainers = pkgs.hamster.meta.maintainers;
options.programs.hamster.enable = options.programs.hamster.enable =
mkEnableOption "hamster, a time tracking program"; lib.mkEnableOption "hamster, a time tracking program";
config = lib.mkIf config.programs.hamster.enable { config = lib.mkIf config.programs.hamster.enable {
environment.systemPackages = [ pkgs.hamster ]; environment.systemPackages = [ pkgs.hamster ];

View File

@ -1,29 +1,27 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.htop; cfg = config.programs.htop;
fmt = value: fmt = value:
if isList value then concatStringsSep " " (map fmt value) else if builtins.isList value then builtins.concatStringsSep " " (builtins.map fmt value) else
if isString value then value else if builtins.isString value then value else
if isBool value then if value then "1" else "0" else if builtins.isBool value then if value then "1" else "0" else
if isInt value then toString value else if builtins.isInt value then builtins.toString value else
throw "Unrecognized type ${typeOf value} in htop settings"; throw "Unrecognized type ${builtins.typeOf value} in htop settings";
in in
{ {
options.programs.htop = { options.programs.htop = {
package = mkPackageOption pkgs "htop" { }; package = lib.mkPackageOption pkgs "htop" { };
enable = mkEnableOption "htop process monitor"; enable = lib.mkEnableOption "htop process monitor";
settings = mkOption { settings = lib.mkOption {
type = with types; attrsOf (oneOf [ str int bool (listOf (oneOf [ str int bool ])) ]); type = with lib.types; attrsOf (oneOf [ str int bool (listOf (oneOf [ str int bool ])) ]);
default = {}; default = {};
example = { example = {
hide_kernel_threads = true; hide_kernel_threads = true;
@ -38,7 +36,7 @@ in
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [ environment.systemPackages = [
cfg.package cfg.package
]; ];
@ -46,7 +44,7 @@ in
environment.etc."htoprc".text = '' environment.etc."htoprc".text = ''
# Global htop configuration # Global htop configuration
# To change set: programs.htop.settings.KEY = VALUE; # To change set: programs.htop.settings.KEY = VALUE;
'' + concatStringsSep "\n" (mapAttrsToList (key: value: "${key}=${fmt value}") cfg.settings); '' + builtins.concatStringsSep "\n" (lib.mapAttrsToList (key: value: "${key}=${fmt value}") cfg.settings);
}; };
} }

View File

@ -1,7 +1,5 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.i3lock; cfg = config.programs.i3lock;
@ -12,8 +10,8 @@ in {
options = { options = {
programs.i3lock = { programs.i3lock = {
enable = mkEnableOption "i3lock"; enable = lib.mkEnableOption "i3lock";
package = mkPackageOption pkgs "i3lock" { package = lib.mkPackageOption pkgs "i3lock" {
example = "i3lock-color"; example = "i3lock-color";
extraDescription = '' extraDescription = ''
::: {.note} ::: {.note}
@ -21,8 +19,8 @@ in {
::: :::
''; '';
}; };
u2fSupport = mkOption { u2fSupport = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
example = true; example = true;
description = '' description = ''
@ -36,11 +34,11 @@ in {
###### implementation ###### implementation
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ]; environment.systemPackages = [ cfg.package ];
security.wrappers.i3lock = mkIf cfg.u2fSupport { security.wrappers.i3lock = lib.mkIf cfg.u2fSupport {
setuid = true; setuid = true;
owner = "root"; owner = "root";
group = "root"; group = "root";

View File

@ -1,14 +1,12 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib;
let let
cfg = config.programs.iftop; cfg = config.programs.iftop;
in { in {
options = { options = {
programs.iftop.enable = mkEnableOption "iftop + setcap wrapper"; programs.iftop.enable = lib.mkEnableOption "iftop + setcap wrapper";
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.iftop ]; environment.systemPackages = [ pkgs.iftop ];
security.wrappers.iftop = { security.wrappers.iftop = {
owner = "root"; owner = "root";

View File

@ -1,14 +1,12 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib;
let let
cfg = config.programs.iotop; cfg = config.programs.iotop;
in { in {
options = { options = {
programs.iotop.enable = mkEnableOption "iotop + setcap wrapper"; programs.iotop.enable = lib.mkEnableOption "iotop + setcap wrapper";
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
security.wrappers.iotop = { security.wrappers.iotop = {
owner = "root"; owner = "root";
group = "root"; group = "root";

View File

@ -3,8 +3,6 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.java; cfg = config.programs.java;
in in
@ -14,7 +12,7 @@ in
programs.java = { programs.java = {
enable = mkEnableOption "java" // { enable = lib.mkEnableOption "java" // {
description = '' description = ''
Install and setup the Java development kit. Install and setup the Java development kit.
@ -30,19 +28,19 @@ in
''; '';
}; };
package = mkPackageOption pkgs "jdk" { package = lib.mkPackageOption pkgs "jdk" {
example = "jre"; example = "jre";
}; };
binfmt = mkEnableOption "binfmt to execute java jar's and classes"; binfmt = lib.mkEnableOption "binfmt to execute java jar's and classes";
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
boot.binfmt.registrations = mkIf cfg.binfmt { boot.binfmt.registrations = lib.mkIf cfg.binfmt {
java-class = { java-class = {
recognitionType = "extension"; recognitionType = "extension";
magicOrExtension = "class"; magicOrExtension = "class";

View File

@ -1,8 +1,7 @@
{ lib, pkgs, config, ... }: { lib, pkgs, config, ... }:
with lib;
{ {
options.programs.joycond-cemuhook = { options.programs.joycond-cemuhook = {
enable = mkEnableOption "joycond-cemuhook, a program to enable support for cemuhook's UDP protocol for joycond devices."; 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 { config = lib.mkIf config.programs.joycond-cemuhook.enable {

View File

@ -1,12 +1,10 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib;
{ {
# interface # interface
options.programs.k3b = { options.programs.k3b = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to enable k3b, the KDE disk burning application. Whether to enable k3b, the KDE disk burning application.
@ -22,7 +20,7 @@ with lib;
}; };
# implementation # implementation
config = mkIf config.programs.k3b.enable { config = lib.mkIf config.programs.k3b.enable {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
k3b k3b

View File

@ -1,7 +1,5 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.k40-whisperer; cfg = config.programs.k40-whisperer;
pkg = cfg.package.override { pkg = cfg.package.override {
@ -10,20 +8,20 @@ let
in in
{ {
options.programs.k40-whisperer = { options.programs.k40-whisperer = {
enable = mkEnableOption "K40-Whisperer"; enable = lib.mkEnableOption "K40-Whisperer";
group = mkOption { group = lib.mkOption {
type = types.str; type = lib.types.str;
description = '' description = ''
Group assigned to the device when connected. Group assigned to the device when connected.
''; '';
default = "k40"; default = "k40";
}; };
package = mkPackageOption pkgs "k40-whisperer" { }; package = lib.mkPackageOption pkgs "k40-whisperer" { };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
users.groups.${cfg.group} = {}; users.groups.${cfg.group} = {};
environment.systemPackages = [ pkg ]; environment.systemPackages = [ pkg ];

View File

@ -1,15 +1,13 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.kbdlight; cfg = config.programs.kbdlight;
in in
{ {
options.programs.kbdlight.enable = mkEnableOption "kbdlight"; options.programs.kbdlight.enable = lib.mkEnableOption "kbdlight";
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.kbdlight ]; environment.systemPackages = [ pkgs.kbdlight ];
security.wrappers.kbdlight = security.wrappers.kbdlight =
{ setuid = true; { setuid = true;

View File

@ -1,12 +1,11 @@
{ lib, pkgs, config, ... }: { lib, pkgs, config, ... }:
with lib;
let let
cfg = config.programs.kclock; cfg = config.programs.kclock;
kclockPkg = pkgs.libsForQt5.kclock; kclockPkg = pkgs.libsForQt5.kclock;
in { in {
options.programs.kclock = { enable = mkEnableOption "KClock"; }; options.programs.kclock = { enable = lib.mkEnableOption "KClock"; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.dbus.packages = [ kclockPkg ]; services.dbus.packages = [ kclockPkg ];
environment.systemPackages = [ kclockPkg ]; environment.systemPackages = [ kclockPkg ];
}; };

View File

@ -1,8 +1,7 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib;
{ {
options.programs.kdeconnect = { options.programs.kdeconnect = {
enable = mkEnableOption '' enable = lib.mkEnableOption ''
kdeconnect. kdeconnect.
Note that it will open the TCP and UDP port from Note that it will open the TCP and UDP port from
@ -11,7 +10,7 @@ with lib;
`gnomeExtensions.gsconnect` as an alternative `gnomeExtensions.gsconnect` as an alternative
implementation if you use Gnome implementation if you use Gnome
''; '';
package = mkPackageOption pkgs [ "plasma5Packages" "kdeconnect-kde" ] { package = lib.mkPackageOption pkgs [ "plasma5Packages" "kdeconnect-kde" ] {
example = "gnomeExtensions.gsconnect"; example = "gnomeExtensions.gsconnect";
}; };
}; };
@ -19,7 +18,7 @@ with lib;
let let
cfg = config.programs.kdeconnect; cfg = config.programs.kdeconnect;
in in
mkIf cfg.enable { lib.mkIf cfg.enable {
environment.systemPackages = [ environment.systemPackages = [
cfg.package cfg.package
pkgs.sshfs pkgs.sshfs

View File

@ -1,26 +1,24 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.less; cfg = config.programs.less;
configText = if (cfg.configFile != null) then (builtins.readFile cfg.configFile) else '' configText = if (cfg.configFile != null) then (builtins.readFile cfg.configFile) else ''
#command #command
${concatStringsSep "\n" ${builtins.concatStringsSep "\n"
(mapAttrsToList (command: action: "${command} ${action}") cfg.commands) (lib.mapAttrsToList (command: action: "${command} ${action}") cfg.commands)
} }
${optionalString cfg.clearDefaultCommands "#stop"} ${lib.optionalString cfg.clearDefaultCommands "#stop"}
#line-edit #line-edit
${concatStringsSep "\n" ${builtins.concatStringsSep "\n"
(mapAttrsToList (command: action: "${command} ${action}") cfg.lineEditingKeys) (lib.mapAttrsToList (command: action: "${command} ${action}") cfg.lineEditingKeys)
} }
#env #env
${concatStringsSep "\n" ${builtins.concatStringsSep "\n"
(mapAttrsToList (variable: values: "${variable}=${values}") cfg.envVariables) (lib.mapAttrsToList (variable: values: "${variable}=${values}") cfg.envVariables)
} }
''; '';
@ -35,12 +33,12 @@ in
# note that environment.nix sets PAGER=less, and # note that environment.nix sets PAGER=less, and
# therefore also enables this module # therefore also enables this module
enable = mkEnableOption "less, a file pager"; enable = lib.mkEnableOption "less, a file pager";
configFile = mkOption { configFile = lib.mkOption {
type = types.nullOr types.path; type = lib.types.nullOr lib.types.path;
default = null; default = null;
example = literalExpression ''"''${pkgs.my-configs}/lesskey"''; example = lib.literalExpression ''"''${pkgs.my-configs}/lesskey"'';
description = '' description = ''
Path to lesskey configuration file. Path to lesskey configuration file.
@ -50,8 +48,8 @@ in
''; '';
}; };
commands = mkOption { commands = lib.mkOption {
type = types.attrsOf types.str; type = lib.types.attrsOf lib.types.str;
default = {}; default = {};
example = { example = {
h = "noaction 5\\e("; h = "noaction 5\\e(";
@ -60,8 +58,8 @@ in
description = "Defines new command keys."; description = "Defines new command keys.";
}; };
clearDefaultCommands = mkOption { clearDefaultCommands = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Clear all default commands. Clear all default commands.
@ -70,8 +68,8 @@ in
''; '';
}; };
lineEditingKeys = mkOption { lineEditingKeys = lib.mkOption {
type = types.attrsOf types.str; type = lib.types.attrsOf lib.types.str;
default = {}; default = {};
example = { example = {
e = "abort"; e = "abort";
@ -79,8 +77,8 @@ in
description = "Defines new line-editing keys."; description = "Defines new line-editing keys.";
}; };
envVariables = mkOption { envVariables = lib.mkOption {
type = types.attrsOf types.str; type = lib.types.attrsOf lib.types.str;
default = { default = {
LESS = "-R"; LESS = "-R";
}; };
@ -90,17 +88,17 @@ in
description = "Defines environment variables."; description = "Defines environment variables.";
}; };
lessopen = mkOption { lessopen = lib.mkOption {
type = types.nullOr types.str; type = lib.types.nullOr lib.types.str;
default = "|${pkgs.lesspipe}/bin/lesspipe.sh %s"; default = "|${pkgs.lesspipe}/bin/lesspipe.sh %s";
defaultText = literalExpression ''"|''${pkgs.lesspipe}/bin/lesspipe.sh %s"''; defaultText = lib.literalExpression ''"|''${pkgs.lesspipe}/bin/lesspipe.sh %s"'';
description = '' 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. 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 { lessclose = lib.mkOption {
type = types.nullOr types.str; type = lib.types.nullOr lib.types.str;
default = null; default = null;
description = '' description = ''
When less closes a file opened in such a way, it will call another program, called the input postprocessor, When less closes a file opened in such a way, it will call another program, called the input postprocessor,
@ -110,26 +108,26 @@ in
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.less ]; environment.systemPackages = [ pkgs.less ];
environment.variables = { environment.variables = {
LESSKEYIN_SYSTEM = toString lessKey; LESSKEYIN_SYSTEM = builtins.toString lessKey;
} // optionalAttrs (cfg.lessopen != null) { } // lib.optionalAttrs (cfg.lessopen != null) {
LESSOPEN = cfg.lessopen; LESSOPEN = cfg.lessopen;
} // optionalAttrs (cfg.lessclose != null) { } // lib.optionalAttrs (cfg.lessclose != null) {
LESSCLOSE = cfg.lessclose; LESSCLOSE = cfg.lessclose;
}; };
warnings = optional ( warnings = lib.optional (
cfg.clearDefaultCommands && (all (x: x != "quit") (attrValues cfg.commands)) 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. config.programs.less.clearDefaultCommands clears all default commands of less but there is no alternative binding for exiting.
Consider adding a binding for 'quit'. Consider adding a binding for 'quit'.
''; '';
}; };
meta.maintainers = with maintainers; [ johnazoidberg ]; meta.maintainers = with lib.maintainers; [ johnazoidberg ];
} }

View File

@ -1,16 +1,14 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.liboping; cfg = config.programs.liboping;
in { in {
options.programs.liboping = { options.programs.liboping = {
enable = mkEnableOption "liboping"; enable = lib.mkEnableOption "liboping";
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ liboping ]; environment.systemPackages = with pkgs; [ liboping ];
security.wrappers = mkMerge (map ( security.wrappers = lib.mkMerge (builtins.map (
exec: { exec: {
"${exec}" = { "${exec}" = {
owner = "root"; owner = "root";

View File

@ -1,7 +1,5 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.light; cfg = config.programs.light;
@ -10,9 +8,9 @@ in
options = { options = {
programs.light = { programs.light = {
enable = mkOption { enable = lib.mkOption {
default = false; default = false;
type = types.bool; type = lib.types.bool;
description = '' description = ''
Whether to install Light backlight control command Whether to install Light backlight control command
and udev rules granting access to members of the "video" group. and udev rules granting access to members of the "video" group.
@ -20,8 +18,8 @@ in
}; };
brightnessKeys = { brightnessKeys = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to enable brightness control with keyboard keys. Whether to enable brightness control with keyboard keys.
@ -38,8 +36,8 @@ in
''; '';
}; };
step = mkOption { step = lib.mkOption {
type = types.int; type = lib.types.int;
default = 10; default = 10;
description = '' description = ''
The percentage value by which to increase/decrease brightness. The percentage value by which to increase/decrease brightness.
@ -51,14 +49,14 @@ in
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.light ]; environment.systemPackages = [ pkgs.light ];
services.udev.packages = [ pkgs.light ]; services.udev.packages = [ pkgs.light ];
services.actkbd = mkIf cfg.brightnessKeys.enable { services.actkbd = lib.mkIf cfg.brightnessKeys.enable {
enable = true; enable = true;
bindings = let bindings = let
light = "${pkgs.light}/bin/light"; light = "${pkgs.light}/bin/light";
step = toString cfg.brightnessKeys.step; step = builtins.toString cfg.brightnessKeys.step;
in [ in [
{ {
keys = [ 224 ]; keys = [ 224 ];

View File

@ -1,14 +1,13 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib;
let let
cfg = config.programs.mdevctl; cfg = config.programs.mdevctl;
in { in {
options.programs.mdevctl = { options.programs.mdevctl = {
enable = mkEnableOption "Mediated Device Management"; enable = lib.mkEnableOption "Mediated Device Management";
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ mdevctl ]; environment.systemPackages = with pkgs; [ mdevctl ];
environment.etc."mdevctl.d/scripts.d/notifiers/.keep".text = ""; environment.etc."mdevctl.d/scripts.d/notifiers/.keep".text = "";

View File

@ -1,15 +1,14 @@
{ pkgs, config, lib, ...}: { pkgs, config, lib, ...}:
with lib;
let let
cfg = config.programs.mepo; cfg = config.programs.mepo;
in in
{ {
options.programs.mepo = { options.programs.mepo = {
enable = mkEnableOption "Mepo, a fast, simple and hackable OSM map viewer"; enable = lib.mkEnableOption "Mepo, a fast, simple and hackable OSM map viewer";
locationBackends = { locationBackends = {
gpsd = mkOption { gpsd = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to enable location detection via gpsd. Whether to enable location detection via gpsd.
@ -17,21 +16,21 @@ in
''; '';
}; };
geoclue = mkOption { geoclue = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = "Whether to enable location detection via geoclue"; description = "Whether to enable location detection via geoclue";
}; };
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
mepo mepo
] ++ lib.optional cfg.locationBackends.geoclue geoclue2-with-demo-agent ] ++ lib.optional cfg.locationBackends.geoclue geoclue2-with-demo-agent
++ lib.optional cfg.locationBackends.gpsd gpsd; ++ lib.optional cfg.locationBackends.gpsd gpsd;
services.geoclue2 = mkIf cfg.locationBackends.geoclue { services.geoclue2 = lib.mkIf cfg.locationBackends.geoclue {
enable = true; enable = true;
appConfig.where-am-i = { appConfig.where-am-i = {
isAllowed = true; isAllowed = true;
@ -42,5 +41,5 @@ in
services.gpsd.enable = cfg.locationBackends.gpsd; services.gpsd.enable = cfg.locationBackends.gpsd;
}; };
meta.maintainers = with maintainers; [ laalsaas ]; meta.maintainers = with lib.maintainers; [ laalsaas ];
} }

View File

@ -2,15 +2,13 @@
# kernel must have NETNS/VETH/SCHED # kernel must have NETNS/VETH/SCHED
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.mininet; cfg = config.programs.mininet;
in in
{ {
options.programs.mininet.enable = mkEnableOption "Mininet, an emulator for rapid prototyping of Software Defined Networks"; options.programs.mininet.enable = lib.mkEnableOption "Mininet, an emulator for rapid prototyping of Software Defined Networks";
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
virtualisation.vswitch.enable = true; virtualisation.vswitch.enable = true;

View File

@ -1,27 +1,25 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.msmtp; cfg = config.programs.msmtp;
in { in {
meta.maintainers = with maintainers; [ pacien ]; meta.maintainers = with lib.maintainers; [ pacien ];
options = { options = {
programs.msmtp = { programs.msmtp = {
enable = mkEnableOption "msmtp - an SMTP client"; enable = lib.mkEnableOption "msmtp - an SMTP client";
setSendmail = mkOption { setSendmail = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = '' description = ''
Whether to set the system sendmail to msmtp's. Whether to set the system sendmail to msmtp's.
''; '';
}; };
defaults = mkOption { defaults = lib.mkOption {
type = types.attrs; type = lib.types.attrs;
default = {}; default = {};
example = { example = {
aliases = "/etc/aliases"; aliases = "/etc/aliases";
@ -34,8 +32,8 @@ in {
''; '';
}; };
accounts = mkOption { accounts = lib.mkOption {
type = with types; attrsOf attrs; type = with lib.types; attrsOf attrs;
default = {}; default = {};
example = { example = {
"default" = { "default" = {
@ -59,8 +57,8 @@ in {
''; '';
}; };
extraConfig = mkOption { extraConfig = lib.mkOption {
type = types.lines; type = lib.types.lines;
default = ""; default = "";
description = '' description = ''
Extra lines to add to the msmtp configuration verbatim. Extra lines to add to the msmtp configuration verbatim.
@ -70,10 +68,10 @@ in {
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.msmtp ]; environment.systemPackages = [ pkgs.msmtp ];
services.mail.sendmailSetuidWrapper = mkIf cfg.setSendmail { services.mail.sendmailSetuidWrapper = lib.mkIf cfg.setSendmail {
program = "sendmail"; program = "sendmail";
source = "${pkgs.msmtp}/bin/sendmail"; source = "${pkgs.msmtp}/bin/sendmail";
setuid = false; setuid = false;
@ -86,10 +84,10 @@ in {
mkValueString = v: mkValueString = v:
if v == true then "on" if v == true then "on"
else if v == false then "off" else if v == false then "off"
else generators.mkValueStringDefault {} v; else lib.generators.mkValueStringDefault {} v;
mkKeyValueString = k: v: "${k} ${mkValueString v}"; mkKeyValueString = k: v: "${k} ${mkValueString v}";
mkInnerSectionString = mkInnerSectionString =
attrs: concatStringsSep "\n" (mapAttrsToList mkKeyValueString attrs); attrs: builtins.concatStringsSep "\n" (lib.mapAttrsToList mkKeyValueString attrs);
mkAccountString = name: attrs: '' mkAccountString = name: attrs: ''
account ${name} account ${name}
${mkInnerSectionString attrs} ${mkInnerSectionString attrs}
@ -98,7 +96,7 @@ in {
defaults defaults
${mkInnerSectionString cfg.defaults} ${mkInnerSectionString cfg.defaults}
${concatStringsSep "\n" (mapAttrsToList mkAccountString cfg.accounts)} ${builtins.concatStringsSep "\n" (lib.mapAttrsToList mkAccountString cfg.accounts)}
${cfg.extraConfig} ${cfg.extraConfig}
''; '';

View File

@ -1,15 +1,13 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.mtr; cfg = config.programs.mtr;
in { in {
options = { options = {
programs.mtr = { programs.mtr = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to add mtr to the global environment and configure a Whether to add mtr to the global environment and configure a
@ -17,12 +15,12 @@ in {
''; '';
}; };
package = mkPackageOption pkgs "mtr" { }; package = lib.mkPackageOption pkgs "mtr" { };
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ cfg.package ]; environment.systemPackages = [ cfg.package ];
security.wrappers.mtr-packet = { security.wrappers.mtr-packet = {
owner = "root"; owner = "root";

View File

@ -1,18 +1,16 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.nbd; cfg = config.programs.nbd;
in in
{ {
options = { options = {
programs.nbd = { programs.nbd = {
enable = mkEnableOption "Network Block Device (nbd) support"; enable = lib.mkEnableOption "Network Block Device (nbd) support";
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ nbd ]; environment.systemPackages = with pkgs; [ nbd ];
boot.kernelModules = [ "nbd" ]; boot.kernelModules = [ "nbd" ];
}; };

View File

@ -1,14 +1,12 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.neovim; cfg = config.programs.neovim;
in in
{ {
options.programs.neovim = { options.programs.neovim = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
example = true; example = true;
description = '' description = ''
@ -21,8 +19,8 @@ in
''; '';
}; };
defaultEditor = mkOption { defaultEditor = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
When enabled, installs neovim and configures neovim to be the default editor When enabled, installs neovim and configures neovim to be the default editor
@ -30,44 +28,44 @@ in
''; '';
}; };
viAlias = mkOption { viAlias = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Symlink {command}`vi` to {command}`nvim` binary. Symlink {command}`vi` to {command}`nvim` binary.
''; '';
}; };
vimAlias = mkOption { vimAlias = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Symlink {command}`vim` to {command}`nvim` binary. Symlink {command}`vim` to {command}`nvim` binary.
''; '';
}; };
withRuby = mkOption { withRuby = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = "Enable Ruby provider."; description = "Enable Ruby provider.";
}; };
withPython3 = mkOption { withPython3 = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = "Enable Python 3 provider."; description = "Enable Python 3 provider.";
}; };
withNodeJs = mkOption { withNodeJs = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = "Enable Node provider."; description = "Enable Node provider.";
}; };
configure = mkOption { configure = lib.mkOption {
type = types.attrs; type = lib.types.attrs;
default = { }; default = { };
example = literalExpression '' example = lib.literalExpression ''
{ {
customRC = ''' customRC = '''
" here your custom configuration goes! " here your custom configuration goes!
@ -86,31 +84,31 @@ in
''; '';
}; };
package = mkPackageOption pkgs "neovim-unwrapped" { }; package = lib.mkPackageOption pkgs "neovim-unwrapped" { };
finalPackage = mkOption { finalPackage = lib.mkOption {
type = types.package; type = lib.types.package;
visible = false; visible = false;
readOnly = true; readOnly = true;
description = "Resulting customized neovim package."; description = "Resulting customized neovim package.";
}; };
runtime = mkOption { runtime = lib.mkOption {
default = { }; default = { };
example = literalExpression '' example = lib.literalExpression ''
{ "ftplugin/c.vim".text = "setlocal omnifunc=v:lua.vim.lsp.omnifunc"; } { "ftplugin/c.vim".text = "setlocal omnifunc=v:lua.vim.lsp.omnifunc"; }
''; '';
description = '' description = ''
Set of files that have to be linked in {file}`runtime`. Set of files that have to be linked in {file}`runtime`.
''; '';
type = with types; attrsOf (submodule ( type = with lib.types; attrsOf (submodule (
{ name, config, ... }: { name, config, ... }:
{ {
options = { options = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = '' description = ''
Whether this runtime directory should be generated. This Whether this runtime directory should be generated. This
@ -118,49 +116,49 @@ in
''; '';
}; };
target = mkOption { target = lib.mkOption {
type = types.str; type = lib.types.str;
description = '' description = ''
Name of symlink. Defaults to the attribute Name of symlink. Defaults to the attribute
name. name.
''; '';
}; };
text = mkOption { text = lib.mkOption {
default = null; default = null;
type = types.nullOr types.lines; type = lib.types.nullOr lib.types.lines;
description = "Text of the file."; description = "Text of the file.";
}; };
source = mkOption { source = lib.mkOption {
default = null; default = null;
type = types.nullOr types.path; type = lib.types.nullOr lib.types.path;
description = "Path of the source file."; description = "Path of the source file.";
}; };
}; };
config.target = mkDefault name; config.target = lib.mkDefault name;
} }
)); ));
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [ environment.systemPackages = [
cfg.finalPackage cfg.finalPackage
]; ];
environment.variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "nvim"); environment.variables.EDITOR = lib.mkIf cfg.defaultEditor (lib.mkOverride 900 "nvim");
environment.etc = listToAttrs (attrValues (mapAttrs environment.etc = builtins.listToAttrs (builtins.attrValues (builtins.mapAttrs
(name: value: { (name: value: {
name = "xdg/nvim/${name}"; name = "xdg/nvim/${name}";
value = removeAttrs value = builtins.removeAttrs
(value // { (value // {
target = "xdg/nvim/${value.target}"; target = "xdg/nvim/${value.target}";
}) })
(optionals (isNull value.source) [ "source" ]); (lib.optionals (builtins.isNull value.source) [ "source" ]);
}) })
cfg.runtime)); cfg.runtime));

View File

@ -1,16 +1,14 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let cfg = config.programs.nethoscope; let cfg = config.programs.nethoscope;
in in
{ {
meta.maintainers = with maintainers; [ _0x4A6F ]; meta.maintainers = with lib.maintainers; [ _0x4A6F ];
options = { options = {
programs.nethoscope = { programs.nethoscope = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to add nethoscope to the global environment and configure a Whether to add nethoscope to the global environment and configure a
@ -20,7 +18,7 @@ in
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ nethoscope ]; environment.systemPackages = with pkgs; [ nethoscope ];
security.wrappers.nethoscope = { security.wrappers.nethoscope = {
source = "${pkgs.nethoscope}/bin/nethoscope"; source = "${pkgs.nethoscope}/bin/nethoscope";

View File

@ -1,6 +1,5 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
nncpCfgFile = "/run/nncp.hjson"; nncpCfgFile = "/run/nncp.hjson";
programCfg = config.programs.nncp; programCfg = config.programs.nncp;
@ -11,10 +10,10 @@ in {
options.programs.nncp = { options.programs.nncp = {
enable = enable =
mkEnableOption "NNCP (Node to Node copy) utilities and configuration"; lib.mkEnableOption "NNCP (Node to Node copy) utilities and configuration";
group = mkOption { group = lib.mkOption {
type = types.str; type = lib.types.str;
default = "uucp"; default = "uucp";
description = '' description = ''
The group under which NNCP files shall be owned. The group under which NNCP files shall be owned.
@ -23,10 +22,10 @@ in {
''; '';
}; };
package = mkPackageOption pkgs "nncp" { }; package = lib.mkPackageOption pkgs "nncp" { };
secrets = mkOption { secrets = lib.mkOption {
type = with types; listOf str; type = with lib.types; listOf str;
example = [ "/run/keys/nncp.hjson" ]; example = [ "/run/keys/nncp.hjson" ];
description = '' description = ''
A list of paths to NNCP configuration files that should not be A list of paths to NNCP configuration files that should not be
@ -35,7 +34,7 @@ in {
''; '';
}; };
settings = mkOption { settings = lib.mkOption {
type = settingsFormat.type; type = settingsFormat.type;
description = '' description = ''
NNCP configuration, see NNCP configuration, see
@ -52,7 +51,7 @@ in {
}; };
config = mkIf programCfg.enable { config = lib.mkIf programCfg.enable {
environment = { environment = {
systemPackages = [ pkg ]; systemPackages = [ pkg ];
@ -60,8 +59,8 @@ in {
}; };
programs.nncp.settings = { programs.nncp.settings = {
spool = mkDefault "/var/spool/nncp"; spool = lib.mkDefault "/var/spool/nncp";
log = mkDefault "/var/spool/nncp/log"; log = lib.mkDefault "/var/spool/nncp/log";
}; };
systemd.tmpfiles.rules = [ systemd.tmpfiles.rules = [
@ -77,7 +76,7 @@ in {
script = '' script = ''
umask u=rw umask u=rw
nncpCfgDir=$(mktemp --directory nncp.XXX) nncpCfgDir=$(mktemp --directory nncp.XXX)
for f in ${jsonCfgFile} ${toString config.programs.nncp.secrets}; do for f in ${jsonCfgFile} ${builtins.toString config.programs.nncp.secrets}; do
tmpdir=$(mktemp --directory nncp.XXX) tmpdir=$(mktemp --directory nncp.XXX)
nncp-cfgdir -cfg $f -dump $tmpdir nncp-cfgdir -cfg $f -dump $tmpdir
find $tmpdir -size 1c -delete find $tmpdir -size 1c -delete

View File

@ -1,17 +1,15 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib;
let cfg = config.programs.noisetorch; let cfg = config.programs.noisetorch;
in in
{ {
options.programs.noisetorch = { options.programs.noisetorch = {
enable = mkEnableOption "noisetorch (+ setcap wrapper), a virtual microphone device with noise suppression"; enable = lib.mkEnableOption "noisetorch (+ setcap wrapper), a virtual microphone device with noise suppression";
package = mkPackageOption pkgs "noisetorch" { }; package = lib.mkPackageOption pkgs "noisetorch" { };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
security.wrappers.noisetorch = { security.wrappers.noisetorch = {
owner = "root"; owner = "root";
group = "root"; group = "root";

View File

@ -1,7 +1,5 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.npm; cfg = config.programs.npm;
in in
@ -11,13 +9,13 @@ in
options = { options = {
programs.npm = { programs.npm = {
enable = mkEnableOption "{command}`npm` global config"; enable = lib.mkEnableOption "{command}`npm` global config";
package = mkPackageOption pkgs [ "nodePackages" "npm" ] { package = lib.mkPackageOption pkgs [ "nodePackages" "npm" ] {
example = "nodePackages_13_x.npm"; example = "nodePackages_13_x.npm";
}; };
npmrc = mkOption { npmrc = lib.mkOption {
type = lib.types.lines; type = lib.types.lines;
description = '' description = ''
The system-wide npm configuration. The system-wide npm configuration.

View File

@ -1,11 +1,9 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
{ {
imports = [ imports = [
(mkRemovedOptionModule [ "programs" "oblogout" ] "programs.oblogout has been removed from NixOS. This is because the oblogout repository has been archived upstream.") (lib.mkRemovedOptionModule [ "programs" "oblogout" ] "programs.oblogout has been removed from NixOS. This is because the oblogout repository has been archived upstream.")
]; ];
} }

View File

@ -1,19 +1,17 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.openvpn3; cfg = config.programs.openvpn3;
in in
{ {
options.programs.openvpn3 = { options.programs.openvpn3 = {
enable = mkEnableOption "the openvpn3 client"; enable = lib.mkEnableOption "the openvpn3 client";
package = mkOption { package = lib.mkOption {
type = types.package; type = lib.types.package;
default = pkgs.openvpn3.override { default = pkgs.openvpn3.override {
enableSystemdResolved = config.services.resolved.enable; enableSystemdResolved = config.services.resolved.enable;
}; };
defaultText = literalExpression ''pkgs.openvpn3.override { defaultText = lib.literalExpression ''pkgs.openvpn3.override {
enableSystemdResolved = config.services.resolved.enable; enableSystemdResolved = config.services.resolved.enable;
}''; }'';
description = '' description = ''
@ -22,7 +20,7 @@ in
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
services.dbus.packages = [ services.dbus.packages = [
cfg.package cfg.package
]; ];

View File

@ -1,19 +1,17 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
{ {
meta = { meta = {
maintainers = teams.pantheon.members; maintainers = lib.teams.pantheon.members;
}; };
###### interface ###### interface
options = { options = {
programs.pantheon-tweaks.enable = mkEnableOption "Pantheon Tweaks, an unofficial system settings panel for Pantheon"; programs.pantheon-tweaks.enable = lib.mkEnableOption "Pantheon Tweaks, an unofficial system settings panel for Pantheon";
}; };
###### implementation ###### implementation
config = mkIf config.programs.pantheon-tweaks.enable { config = lib.mkIf config.programs.pantheon-tweaks.enable {
services.xserver.desktopManager.pantheon.extraSwitchboardPlugs = [ pkgs.pantheon-tweaks ]; services.xserver.desktopManager.pantheon.extraSwitchboardPlugs = [ pkgs.pantheon-tweaks ];
}; };
} }

View File

@ -1,7 +1,5 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.plotinus; cfg = config.programs.plotinus;
in in
@ -15,21 +13,21 @@ in
options = { options = {
programs.plotinus = { programs.plotinus = {
enable = mkOption { enable = lib.mkOption {
default = false; default = false;
description = '' description = ''
Whether to enable the Plotinus GTK 3 plugin. Plotinus provides a Whether to enable the Plotinus GTK 3 plugin. Plotinus provides a
popup (triggered by Ctrl-Shift-P) to search the menus of a popup (triggered by Ctrl-Shift-P) to search the menus of a
compatible application. compatible application.
''; '';
type = types.bool; type = lib.types.bool;
}; };
}; };
}; };
###### implementation ###### implementation
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.sessionVariables.XDG_DATA_DIRS = [ "${pkgs.plotinus}/share/gsettings-schemas/${pkgs.plotinus.name}" ]; environment.sessionVariables.XDG_DATA_DIRS = [ "${pkgs.plotinus}/share/gsettings-schemas/${pkgs.plotinus.name}" ];
environment.variables.GTK3_MODULES = [ "${pkgs.plotinus}/lib/libplotinus.so" ]; environment.variables.GTK3_MODULES = [ "${pkgs.plotinus}/lib/libplotinus.so" ];
}; };

View File

@ -1,15 +1,14 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.proxychains; cfg = config.programs.proxychains;
configFile = '' configFile = ''
${cfg.chain.type}_chain ${cfg.chain.type}_chain
${optionalString (cfg.chain.type == "random") ${lib.optionalString (cfg.chain.type == "random")
"chain_len = ${builtins.toString cfg.chain.length}"} "chain_len = ${builtins.toString cfg.chain.length}"}
${optionalString cfg.proxyDNS "proxy_dns"} ${lib.optionalString cfg.proxyDNS "proxy_dns"}
${optionalString cfg.quietMode "quiet_mode"} ${lib.optionalString cfg.quietMode "quiet_mode"}
remote_dns_subnet ${builtins.toString cfg.remoteDNSSubnet} remote_dns_subnet ${builtins.toString cfg.remoteDNSSubnet}
tcp_read_time_out ${builtins.toString cfg.tcpReadTimeOut} tcp_read_time_out ${builtins.toString cfg.tcpReadTimeOut}
tcp_connect_time_out ${builtins.toString cfg.tcpConnectTimeOut} tcp_connect_time_out ${builtins.toString cfg.tcpConnectTimeOut}
@ -22,20 +21,20 @@ let
proxyOptions = { proxyOptions = {
options = { options = {
enable = mkEnableOption "this proxy"; enable = lib.mkEnableOption "this proxy";
type = mkOption { type = lib.mkOption {
type = types.enum [ "http" "socks4" "socks5" ]; type = lib.types.enum [ "http" "socks4" "socks5" ];
description = "Proxy type."; description = "Proxy type.";
}; };
host = mkOption { host = lib.mkOption {
type = types.str; type = lib.types.str;
description = "Proxy host or IP address."; description = "Proxy host or IP address.";
}; };
port = mkOption { port = lib.mkOption {
type = types.port; type = lib.types.port;
description = "Proxy port"; description = "Proxy port";
}; };
}; };
@ -49,15 +48,15 @@ in {
programs.proxychains = { programs.proxychains = {
enable = mkEnableOption "proxychains configuration"; enable = lib.mkEnableOption "proxychains configuration";
package = mkPackageOption pkgs "proxychains" { package = lib.mkPackageOption pkgs "proxychains" {
example = "proxychains-ng"; example = "proxychains-ng";
}; };
chain = { chain = {
type = mkOption { type = lib.mkOption {
type = types.enum [ "dynamic" "strict" "random" ]; type = lib.types.enum [ "dynamic" "strict" "random" ];
default = "strict"; default = "strict";
description = '' description = ''
`dynamic` - Each connection will be done via chained proxies `dynamic` - Each connection will be done via chained proxies
@ -75,8 +74,8 @@ in {
(or proxy chain, see {option}`programs.proxychains.chain.length`) from the list. (or proxy chain, see {option}`programs.proxychains.chain.length`) from the list.
''; '';
}; };
length = mkOption { length = lib.mkOption {
type = types.nullOr types.int; type = lib.types.nullOr lib.types.int;
default = null; default = null;
description = '' description = ''
Chain length for random chain. Chain length for random chain.
@ -84,47 +83,47 @@ in {
}; };
}; };
proxyDNS = mkOption { proxyDNS = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
description = "Proxy DNS requests - no leak for DNS data."; description = "Proxy DNS requests - no leak for DNS data.";
}; };
quietMode = mkEnableOption "Quiet mode (no output from the library)"; quietMode = lib.mkEnableOption "Quiet mode (no output from the library)";
remoteDNSSubnet = mkOption { remoteDNSSubnet = lib.mkOption {
type = types.enum [ 10 127 224 ]; type = lib.types.enum [ 10 127 224 ];
default = 224; default = 224;
description = '' 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. 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 { tcpReadTimeOut = lib.mkOption {
type = types.int; type = lib.types.int;
default = 15000; default = 15000;
description = "Connection read time-out in milliseconds."; description = "Connection read time-out in milliseconds.";
}; };
tcpConnectTimeOut = mkOption { tcpConnectTimeOut = lib.mkOption {
type = types.int; type = lib.types.int;
default = 8000; default = 8000;
description = "Connection time-out in milliseconds."; description = "Connection time-out in milliseconds.";
}; };
localnet = mkOption { localnet = lib.mkOption {
type = types.str; type = lib.types.str;
default = "127.0.0.0/255.0.0.0"; default = "127.0.0.0/255.0.0.0";
description = "By default enable localnet for loopback address ranges."; description = "By default enable localnet for loopback address ranges.";
}; };
proxies = mkOption { proxies = lib.mkOption {
type = types.attrsOf (types.submodule proxyOptions); type = lib.types.attrsOf (lib.types.submodule proxyOptions);
description = '' description = ''
Proxies to be used by proxychains. Proxies to be used by proxychains.
''; '';
example = literalExpression '' example = lib.literalExpression ''
{ myproxy = { myproxy =
{ type = "socks4"; { type = "socks4";
host = "127.0.0.1"; host = "127.0.0.1";
@ -140,11 +139,11 @@ in {
###### implementation ###### implementation
meta.maintainers = with maintainers; [ sorki ]; meta.maintainers = with lib.maintainers; [ sorki ];
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
assertions = singleton { assertions = lib.singleton {
assertion = cfg.chain.type != "random" && cfg.chain.length == null; assertion = cfg.chain.type != "random" && cfg.chain.length == null;
message = '' message = ''
Option `programs.proxychains.chain.length` Option `programs.proxychains.chain.length`
@ -152,9 +151,9 @@ in {
''; '';
}; };
programs.proxychains.proxies = mkIf config.services.tor.client.enable programs.proxychains.proxies = lib.mkIf config.services.tor.client.enable
{ {
torproxy = mkDefault { torproxy = lib.mkDefault {
enable = true; enable = true;
type = "socks4"; type = "socks4";
host = "127.0.0.1"; host = "127.0.0.1";

View File

@ -1,9 +1,7 @@
{ lib, ... }: { lib, ... }:
with lib;
{ {
imports = [ imports = [
(mkRemovedOptionModule [ "programs" "qt5ct" "enable" ] "Use qt5.platformTheme = \"qt5ct\" instead.") (lib.mkRemovedOptionModule [ "programs" "qt5ct" "enable" ] "Use qt5.platformTheme = \"qt5ct\" instead.")
]; ];
} }

View File

@ -1,7 +1,5 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.rust-motd; cfg = config.programs.rust-motd;
format = pkgs.formats.toml { }; format = pkgs.formats.toml { };
@ -24,10 +22,10 @@ let
''; '';
in { in {
options.programs.rust-motd = { options.programs.rust-motd = {
enable = mkEnableOption "rust-motd, a Message Of The Day (MOTD) generator"; enable = lib.mkEnableOption "rust-motd, a Message Of The Day (MOTD) generator";
enableMotdInSSHD = mkOption { enableMotdInSSHD = lib.mkOption {
default = true; default = true;
type = types.bool; type = lib.types.bool;
description = '' description = ''
Whether to let `openssh` print the Whether to let `openssh` print the
result when entering a new `ssh`-session. result when entering a new `ssh`-session.
@ -36,18 +34,18 @@ in {
the latter option is incompatible with this module. the latter option is incompatible with this module.
''; '';
}; };
refreshInterval = mkOption { refreshInterval = lib.mkOption {
default = "*:0/5"; default = "*:0/5";
type = types.str; type = lib.types.str;
description = '' description = ''
Interval in which the {manpage}`motd(5)` file is refreshed. Interval in which the {manpage}`motd(5)` file is refreshed.
For possible formats, please refer to {manpage}`systemd.time(7)`. For possible formats, please refer to {manpage}`systemd.time(7)`.
''; '';
}; };
order = mkOption { order = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
default = attrNames cfg.settings; default = builtins.attrNames cfg.settings;
defaultText = literalExpression "attrNames cfg.settings"; defaultText = lib.literalExpression "attrNames cfg.settings";
description = '' description = ''
The order of the sections in [](#opt-programs.rust-motd.settings). The order of the sections in [](#opt-programs.rust-motd.settings).
By default they are ordered alphabetically. By default they are ordered alphabetically.
@ -79,8 +77,8 @@ in {
makes sure that `uptime` is placed before `banner` in the motd. makes sure that `uptime` is placed before `banner` in the motd.
''; '';
}; };
settings = mkOption { settings = lib.mkOption {
type = types.attrsOf format.type; type = lib.types.attrsOf format.type;
description = '' description = ''
Settings on what to generate. Please read the Settings on what to generate. Please read the
[upstream documentation](https://github.com/rust-motd/rust-motd/blob/main/README.md#configuration) [upstream documentation](https://github.com/rust-motd/rust-motd/blob/main/README.md#configuration)
@ -88,14 +86,14 @@ in {
''; '';
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
assertions = [ assertions = [
{ assertion = config.users.motd == null; { assertion = config.users.motd == null;
message = '' message = ''
`programs.rust-motd` is incompatible with `users.motd`! `programs.rust-motd` is incompatible with `users.motd`!
''; '';
} }
{ assertion = sort (a: b: a < b) cfg.order == attrNames cfg.settings; { assertion = builtins.sort (a: b: a < b) cfg.order == builtins.attrNames cfg.settings;
message = '' message = ''
Please ensure that every section from `programs.rust-motd.settings` is present in Please ensure that every section from `programs.rust-motd.settings` is present in
`programs.rust-motd.order`. `programs.rust-motd.order`.
@ -138,12 +136,12 @@ in {
wantedBy = [ "timers.target" ]; wantedBy = [ "timers.target" ];
timerConfig.OnCalendar = cfg.refreshInterval; timerConfig.OnCalendar = cfg.refreshInterval;
}; };
security.pam.services.sshd.text = mkIf cfg.enableMotdInSSHD (mkDefault (mkAfter '' 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 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 != {}) '' services.openssh.extraConfig = lib.mkIf (cfg.settings ? last_login && cfg.settings.last_login != {}) ''
PrintLastLog no PrintLastLog no
''; '';
}; };
meta.maintainers = with maintainers; [ ma27 ]; meta.maintainers = with lib.maintainers; [ ma27 ];
} }

View File

@ -1,14 +1,12 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.sedutil; cfg = config.programs.sedutil;
in { in {
options.programs.sedutil.enable = mkEnableOption "sedutil, to manage self encrypting drives that conform to the Trusted Computing Group OPAL 2.0 SSC specification"; 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 = mkIf cfg.enable { config = lib.mkIf cfg.enable {
boot.kernelParams = [ boot.kernelParams = [
"libata.allow_tpm=1" "libata.allow_tpm=1"
]; ];

View File

@ -1,15 +1,14 @@
# Configuration for the pwdutils suite of tools: passwd, useradd, etc. # Configuration for the pwdutils suite of tools: passwd, useradd, etc.
{ config, lib, utils, pkgs, ... }: { config, lib, utils, pkgs, ... }:
with lib;
let let
cfg = config.security.loginDefs; cfg = config.security.loginDefs;
in in
{ {
options = with types; { options = with lib.types; {
security.loginDefs = { security.loginDefs = {
package = mkPackageOption pkgs "shadow" { }; package = lib.mkPackageOption pkgs "shadow" { };
chfnRestrict = mkOption { chfnRestrict = lib.mkOption {
description = '' description = ''
Use chfn SUID to allow non-root users to change their account GECOS information. Use chfn SUID to allow non-root users to change their account GECOS information.
''; '';
@ -17,7 +16,7 @@ in
default = null; default = null;
}; };
settings = mkOption { settings = lib.mkOption {
description = '' description = ''
Config options for the /etc/login.defs file, that defines Config options for the /etc/login.defs file, that defines
the site-specific configuration for the shadow password suite. the site-specific configuration for the shadow password suite.
@ -35,68 +34,68 @@ in
by systemd for features like ConditionUser=@system and systemd-sysusers by systemd for features like ConditionUser=@system and systemd-sysusers
*/ */
options = { options = {
DEFAULT_HOME = mkOption { DEFAULT_HOME = lib.mkOption {
description = "Indicate if login is allowed if we can't cd to the home directory."; description = "Indicate if login is allowed if we can't cd to the home directory.";
default = "yes"; default = "yes";
type = enum [ "yes" "no" ]; type = enum [ "yes" "no" ];
}; };
ENCRYPT_METHOD = mkOption { ENCRYPT_METHOD = lib.mkOption {
description = "This defines the system default encryption algorithm for encrypting passwords."; description = "This defines the system default encryption algorithm for encrypting passwords.";
# The default crypt() method, keep in sync with the PAM default # The default crypt() method, keep in sync with the PAM default
default = "YESCRYPT"; default = "YESCRYPT";
type = enum [ "YESCRYPT" "SHA512" "SHA256" "MD5" "DES"]; type = enum [ "YESCRYPT" "SHA512" "SHA256" "MD5" "DES"];
}; };
SYS_UID_MIN = mkOption { SYS_UID_MIN = lib.mkOption {
description = "Range of user IDs used for the creation of system users by useradd or newusers."; description = "Range of user IDs used for the creation of system users by useradd or newusers.";
default = 400; default = 400;
type = int; type = int;
}; };
SYS_UID_MAX = mkOption { SYS_UID_MAX = lib.mkOption {
description = "Range of user IDs used for the creation of system users by useradd or newusers."; description = "Range of user IDs used for the creation of system users by useradd or newusers.";
default = 999; default = 999;
type = int; type = int;
}; };
UID_MIN = mkOption { UID_MIN = lib.mkOption {
description = "Range of user IDs used for the creation of regular users by useradd or newusers."; description = "Range of user IDs used for the creation of regular users by useradd or newusers.";
default = 1000; default = 1000;
type = int; type = int;
}; };
UID_MAX = mkOption { UID_MAX = lib.mkOption {
description = "Range of user IDs used for the creation of regular users by useradd or newusers."; description = "Range of user IDs used for the creation of regular users by useradd or newusers.";
default = 29999; default = 29999;
type = int; type = int;
}; };
SYS_GID_MIN = mkOption { SYS_GID_MIN = lib.mkOption {
description = "Range of group IDs used for the creation of system groups by useradd, groupadd, or newusers"; description = "Range of group IDs used for the creation of system groups by useradd, groupadd, or newusers";
default = 400; default = 400;
type = int; type = int;
}; };
SYS_GID_MAX = mkOption { SYS_GID_MAX = lib.mkOption {
description = "Range of group IDs used for the creation of system groups by useradd, groupadd, or newusers"; description = "Range of group IDs used for the creation of system groups by useradd, groupadd, or newusers";
default = 999; default = 999;
type = int; type = int;
}; };
GID_MIN = mkOption { GID_MIN = lib.mkOption {
description = "Range of group IDs used for the creation of regular groups by useradd, groupadd, or newusers."; description = "Range of group IDs used for the creation of regular groups by useradd, groupadd, or newusers.";
default = 1000; default = 1000;
type = int; type = int;
}; };
GID_MAX = mkOption { GID_MAX = lib.mkOption {
description = "Range of group IDs used for the creation of regular groups by useradd, groupadd, or newusers."; description = "Range of group IDs used for the creation of regular groups by useradd, groupadd, or newusers.";
default = 29999; default = 29999;
type = int; type = int;
}; };
TTYGROUP = mkOption { TTYGROUP = lib.mkOption {
description = '' description = ''
The terminal permissions: the login tty will be owned by the TTYGROUP group, The terminal permissions: the login tty will be owned by the TTYGROUP group,
and the permissions will be set to TTYPERM''; and the permissions will be set to TTYPERM'';
@ -104,7 +103,7 @@ in
type = str; type = str;
}; };
TTYPERM = mkOption { TTYPERM = lib.mkOption {
description = '' description = ''
The terminal permissions: the login tty will be owned by the TTYGROUP group, The terminal permissions: the login tty will be owned by the TTYGROUP group,
and the permissions will be set to TTYPERM''; and the permissions will be set to TTYPERM'';
@ -113,7 +112,7 @@ in
}; };
# Ensure privacy for newly created home directories. # Ensure privacy for newly created home directories.
UMASK = mkOption { UMASK = lib.mkOption {
description = "The file mode creation mask is initialized to this value."; description = "The file mode creation mask is initialized to this value.";
default = "077"; default = "077";
type = str; type = str;
@ -124,7 +123,7 @@ in
}; };
}; };
users.defaultUserShell = mkOption { users.defaultUserShell = lib.mkOption {
description = '' description = ''
This option defines the default shell assigned to user This option defines the default shell assigned to user
accounts. This can be either a full system path or a shell package. accounts. This can be either a full system path or a shell package.
@ -132,7 +131,7 @@ in
This must not be a store path, since the path is This must not be a store path, since the path is
used outside the store (in particular in /etc/passwd). used outside the store (in particular in /etc/passwd).
''; '';
example = literalExpression "pkgs.zsh"; example = lib.literalExpression "pkgs.zsh";
type = either path shellPackage; type = either path shellPackage;
}; };
}; };
@ -160,18 +159,18 @@ in
]; ];
security.loginDefs.settings.CHFN_RESTRICT = security.loginDefs.settings.CHFN_RESTRICT =
mkIf (cfg.chfnRestrict != null) cfg.chfnRestrict; lib.mkIf (cfg.chfnRestrict != null) cfg.chfnRestrict;
environment.systemPackages = optional config.users.mutableUsers cfg.package environment.systemPackages = lib.optional config.users.mutableUsers cfg.package
++ optional (types.shellPackage.check config.users.defaultUserShell) config.users.defaultUserShell ++ lib.optional (lib.types.shellPackage.check config.users.defaultUserShell) config.users.defaultUserShell
++ optional (cfg.chfnRestrict != null) pkgs.util-linux; ++ lib.optional (cfg.chfnRestrict != null) pkgs.util-linux;
environment.etc = environment.etc =
# Create custom toKeyValue generator # Create custom toKeyValue generator
# see https://man7.org/linux/man-pages/man5/login.defs.5.html for config specification # see https://man7.org/linux/man-pages/man5/login.defs.5.html for config specification
let let
toKeyValue = generators.toKeyValue { toKeyValue = lib.generators.toKeyValue {
mkKeyValue = generators.mkKeyValueDefault { } " "; mkKeyValue = lib.generators.mkKeyValueDefault { } " ";
}; };
in in
{ {
@ -231,7 +230,7 @@ in
newuidmap = mkSetuidRoot "${cfg.package.out}/bin/newuidmap"; newuidmap = mkSetuidRoot "${cfg.package.out}/bin/newuidmap";
newgidmap = mkSetuidRoot "${cfg.package.out}/bin/newgidmap"; newgidmap = mkSetuidRoot "${cfg.package.out}/bin/newgidmap";
} }
// optionalAttrs config.users.mutableUsers { // lib.optionalAttrs config.users.mutableUsers {
chsh = mkSetuidRoot "${cfg.package.out}/bin/chsh"; chsh = mkSetuidRoot "${cfg.package.out}/bin/chsh";
passwd = mkSetuidRoot "${cfg.package.out}/bin/passwd"; passwd = mkSetuidRoot "${cfg.package.out}/bin/passwd";
}; };

View File

@ -1,8 +1,7 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib;
{ {
options.programs.sharing = { options.programs.sharing = {
enable = mkEnableOption '' enable = lib.mkEnableOption ''
sharing, a CLI tool for sharing files. 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 Note that it will opens the 7478 port for TCP in the firewall, which is needed for it to function properly
@ -12,7 +11,7 @@ with lib;
let let
cfg = config.programs.sharing; cfg = config.programs.sharing;
in in
mkIf cfg.enable { lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.sharing ]; environment.systemPackages = [ pkgs.sharing ];
networking.firewall.allowedTCPPorts = [ 7478 ]; networking.firewall.allowedTCPPorts = [ 7478 ];
}; };

View File

@ -5,21 +5,20 @@
... ...
}: }:
with lib;
let let
cfg = config.programs.singularity; cfg = config.programs.singularity;
in in
{ {
options.programs.singularity = { options.programs.singularity = {
enable = mkEnableOption "singularity" // { enable = lib.mkEnableOption "singularity" // {
description = '' description = ''
Whether to install Singularity/Apptainer with system-level overriding such as SUID support. Whether to install Singularity/Apptainer with system-level overriding such as SUID support.
''; '';
}; };
package = mkPackageOption pkgs "singularity" { example = "apptainer"; }; package = lib.mkPackageOption pkgs "singularity" { example = "apptainer"; };
packageOverriden = mkOption { packageOverriden = lib.mkOption {
type = types.nullOr types.package; type = lib.types.nullOr lib.types.package;
default = null; default = null;
description = '' description = ''
This option provides access to the overridden result of `programs.singularity.package`. This option provides access to the overridden result of `programs.singularity.package`.
@ -42,8 +41,8 @@ in
Use `lib.mkForce` to forcefully specify the overridden package. Use `lib.mkForce` to forcefully specify the overridden package.
''; '';
}; };
enableExternalLocalStateDir = mkOption { enableExternalLocalStateDir = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
example = false; example = false;
description = '' description = ''
@ -54,22 +53,22 @@ in
`/var/lib/''${projectName}/mnt/session`. `/var/lib/''${projectName}/mnt/session`.
''; '';
}; };
enableFakeroot = mkOption { enableFakeroot = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = true; default = true;
example = false; example = false;
description = '' description = ''
Whether to enable the `--fakeroot` support of Singularity/Apptainer. Whether to enable the `--fakeroot` support of Singularity/Apptainer.
''; '';
}; };
enableSuid = mkOption { enableSuid = lib.mkOption {
type = types.bool; type = lib.types.bool;
# SingularityCE requires SETUID for most things. Apptainer prefers user # SingularityCE requires SETUID for most things. Apptainer prefers user
# namespaces, e.g. `apptainer exec --nv` would fail if built # namespaces, e.g. `apptainer exec --nv` would fail if built
# `--with-suid`: # `--with-suid`:
# > `FATAL: nvidia-container-cli not allowed in setuid mode` # > `FATAL: nvidia-container-cli not allowed in setuid mode`
default = cfg.package.projectName != "apptainer"; default = cfg.package.projectName != "apptainer";
defaultText = literalExpression ''config.services.singularity.package.projectName != "apptainer"''; defaultText = lib.literalExpression ''config.services.singularity.package.projectName != "apptainer"'';
example = false; example = false;
description = '' description = ''
Whether to enable the SUID support of Singularity/Apptainer. Whether to enable the SUID support of Singularity/Apptainer.
@ -77,28 +76,28 @@ in
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
programs.singularity.packageOverriden = ( programs.singularity.packageOverriden = (
cfg.package.override ( cfg.package.override (
optionalAttrs cfg.enableExternalLocalStateDir { externalLocalStateDir = "/var/lib"; } lib.optionalAttrs cfg.enableExternalLocalStateDir { externalLocalStateDir = "/var/lib"; }
// optionalAttrs cfg.enableFakeroot { // lib.optionalAttrs cfg.enableFakeroot {
newuidmapPath = "/run/wrappers/bin/newuidmap"; newuidmapPath = "/run/wrappers/bin/newuidmap";
newgidmapPath = "/run/wrappers/bin/newgidmap"; newgidmapPath = "/run/wrappers/bin/newgidmap";
} }
// optionalAttrs cfg.enableSuid { // lib.optionalAttrs cfg.enableSuid {
enableSuid = true; enableSuid = true;
starterSuidPath = "/run/wrappers/bin/${cfg.package.projectName}-suid"; starterSuidPath = "/run/wrappers/bin/${cfg.package.projectName}-suid";
} }
) )
); );
environment.systemPackages = [ cfg.packageOverriden ]; environment.systemPackages = [ cfg.packageOverriden ];
security.wrappers."${cfg.packageOverriden.projectName}-suid" = mkIf cfg.enableSuid { security.wrappers."${cfg.packageOverriden.projectName}-suid" = lib.mkIf cfg.enableSuid {
setuid = true; setuid = true;
owner = "root"; owner = "root";
group = "root"; group = "root";
source = "${cfg.packageOverriden}/libexec/${cfg.packageOverriden.projectName}/bin/starter-suid.orig"; source = "${cfg.packageOverriden}/libexec/${cfg.packageOverriden.projectName}/bin/starter-suid.orig";
}; };
systemd.tmpfiles.rules = mkIf cfg.enableExternalLocalStateDir [ systemd.tmpfiles.rules = lib.mkIf cfg.enableExternalLocalStateDir [
"d /var/lib/${cfg.packageOverriden.projectName}/mnt/session 0770 root root -" "d /var/lib/${cfg.packageOverriden.projectName}/mnt/session 0770 root root -"
]; ];
}; };

View File

@ -1,7 +1,5 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.slock; cfg = config.programs.slock;
@ -9,18 +7,18 @@ in
{ {
options = { options = {
programs.slock = { programs.slock = {
enable = mkOption { enable = lib.mkOption {
default = false; default = false;
type = types.bool; type = lib.types.bool;
description = '' description = ''
Whether to install slock screen locker with setuid wrapper. Whether to install slock screen locker with setuid wrapper.
''; '';
}; };
package = mkPackageOption pkgs "slock" {}; package = lib.mkPackageOption pkgs "slock" {};
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ]; environment.systemPackages = [ cfg.package ];
security.wrappers.slock = security.wrappers.slock =
{ setuid = true; { setuid = true;

View File

@ -1,26 +1,24 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.soundmodem; cfg = config.programs.soundmodem;
in in
{ {
options = { options = {
programs.soundmodem = { programs.soundmodem = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to add Soundmodem to the global environment and configure a Whether to add Soundmodem to the global environment and configure a
wrapper for 'soundmodemconfig' for users in the 'soundmodem' group. wrapper for 'soundmodemconfig' for users in the 'soundmodem' group.
''; '';
}; };
package = mkPackageOption pkgs "soundmodem" { }; package = lib.mkPackageOption pkgs "soundmodem" { };
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ]; environment.systemPackages = [ cfg.package ];
users.groups.soundmodem = { }; users.groups.soundmodem = { };

View File

@ -2,8 +2,6 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let cfg = config.programs.spacefm; let cfg = config.programs.spacefm;
in in
@ -14,21 +12,21 @@ in
programs.spacefm = { programs.spacefm = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to install SpaceFM and create {file}`/etc/spacefm/spacefm.conf`. Whether to install SpaceFM and create {file}`/etc/spacefm/spacefm.conf`.
''; '';
}; };
settings = mkOption { settings = lib.mkOption {
type = types.attrs; type = lib.types.attrs;
default = { default = {
tmp_dir = "/tmp"; tmp_dir = "/tmp";
terminal_su = "${pkgs.sudo}/bin/sudo"; terminal_su = "${pkgs.sudo}/bin/sudo";
}; };
defaultText = literalExpression '' defaultText = lib.literalExpression ''
{ {
tmp_dir = "/tmp"; tmp_dir = "/tmp";
terminal_su = "''${pkgs.sudo}/bin/sudo"; terminal_su = "''${pkgs.sudo}/bin/sudo";
@ -46,10 +44,10 @@ in
###### implementation ###### implementation
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.spaceFM ]; environment.systemPackages = [ pkgs.spaceFM ];
environment.etc."spacefm/spacefm.conf".text = environment.etc."spacefm/spacefm.conf".text =
concatStrings (mapAttrsToList (n: v: "${n}=${toString v}\n") cfg.settings); lib.concatStrings (lib.mapAttrsToList (n: v: "${n}=${builtins.toString v}\n") cfg.settings);
}; };
} }

View File

@ -2,8 +2,6 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.ssh; cfg = config.programs.ssh;
@ -17,16 +15,16 @@ let
exec ${cfg.askPassword} "$@" exec ${cfg.askPassword} "$@"
''; '';
knownHosts = attrValues cfg.knownHosts; knownHosts = builtins.attrValues cfg.knownHosts;
knownHostsText = (flip (concatMapStringsSep "\n") knownHosts knownHostsText = (lib.flip (lib.concatMapStringsSep "\n") knownHosts
(h: assert h.hostNames != []; (h: assert h.hostNames != [];
optionalString h.certAuthority "@cert-authority " + concatStringsSep "," h.hostNames + " " lib.optionalString h.certAuthority "@cert-authority " + builtins.concatStringsSep "," h.hostNames + " "
+ (if h.publicKey != null then h.publicKey else readFile h.publicKeyFile) + (if h.publicKey != null then h.publicKey else builtins.readFile h.publicKeyFile)
)) + "\n"; )) + "\n";
knownHostsFiles = [ "/etc/ssh/ssh_known_hosts" ] knownHostsFiles = [ "/etc/ssh/ssh_known_hosts" ]
++ map pkgs.copyPathToStore cfg.knownHostsFiles; ++ builtins.map pkgs.copyPathToStore cfg.knownHostsFiles;
in in
{ {
@ -36,21 +34,21 @@ in
programs.ssh = { programs.ssh = {
enableAskPassword = mkOption { enableAskPassword = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = config.services.xserver.enable; default = config.services.xserver.enable;
defaultText = literalExpression "config.services.xserver.enable"; defaultText = lib.literalExpression "config.services.xserver.enable";
description = "Whether to configure SSH_ASKPASS in the environment."; description = "Whether to configure SSH_ASKPASS in the environment.";
}; };
askPassword = mkOption { askPassword = lib.mkOption {
type = types.str; type = lib.types.str;
default = "${pkgs.x11_ssh_askpass}/libexec/x11-ssh-askpass"; default = "${pkgs.x11_ssh_askpass}/libexec/x11-ssh-askpass";
defaultText = literalExpression ''"''${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."; description = "Program used by SSH to ask for passwords.";
}; };
forwardX11 = mkOption { forwardX11 = lib.mkOption {
type = with lib.types; nullOr bool; type = with lib.types; nullOr bool;
default = false; default = false;
description = '' description = ''
@ -65,25 +63,25 @@ in
''; '';
}; };
setXAuthLocation = mkOption { setXAuthLocation = lib.mkOption {
type = types.bool; type = lib.types.bool;
description = '' description = ''
Whether to set the path to {command}`xauth` for X11-forwarded connections. Whether to set the path to {command}`xauth` for X11-forwarded connections.
This causes a dependency on X11 packages. This causes a dependency on X11 packages.
''; '';
}; };
pubkeyAcceptedKeyTypes = mkOption { pubkeyAcceptedKeyTypes = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
default = []; default = [];
example = [ "ssh-ed25519" "ssh-rsa" ]; example = [ "ssh-ed25519" "ssh-rsa" ];
description = '' description = ''
Specifies the key types that will be used for public key authentication. Specifies the key lib.types that will be used for public key authentication.
''; '';
}; };
hostKeyAlgorithms = mkOption { hostKeyAlgorithms = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
default = []; default = [];
example = [ "ssh-ed25519" "ssh-rsa" ]; example = [ "ssh-ed25519" "ssh-rsa" ];
description = '' description = ''
@ -91,8 +89,8 @@ in
''; '';
}; };
extraConfig = mkOption { extraConfig = lib.mkOption {
type = types.lines; type = lib.types.lines;
default = ""; default = "";
description = '' description = ''
Extra configuration text prepended to {file}`ssh_config`. Other generated Extra configuration text prepended to {file}`ssh_config`. Other generated
@ -102,8 +100,8 @@ in
''; '';
}; };
startAgent = mkOption { startAgent = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to start the OpenSSH agent when you log in. The OpenSSH agent Whether to start the OpenSSH agent when you log in. The OpenSSH agent
@ -113,8 +111,8 @@ in
''; '';
}; };
agentTimeout = mkOption { agentTimeout = lib.mkOption {
type = types.nullOr types.str; type = lib.types.nullOr lib.types.str;
default = null; default = null;
example = "1h"; example = "1h";
description = '' description = ''
@ -122,34 +120,34 @@ in
''; '';
}; };
agentPKCS11Whitelist = mkOption { agentPKCS11Whitelist = lib.mkOption {
type = types.nullOr types.str; type = lib.types.nullOr lib.types.str;
default = null; default = null;
example = literalExpression ''"''${pkgs.opensc}/lib/opensc-pkcs11.so"''; example = lib.literalExpression ''"''${pkgs.opensc}/lib/opensc-pkcs11.so"'';
description = '' description = ''
A pattern-list of acceptable paths for PKCS#11 shared libraries A pattern-list of acceptable paths for PKCS#11 shared libraries
that may be used with the -s option to ssh-add. that may be used with the -s option to ssh-add.
''; '';
}; };
package = mkPackageOption pkgs "openssh" { }; package = lib.mkPackageOption pkgs "openssh" { };
knownHosts = mkOption { knownHosts = lib.mkOption {
default = {}; default = {};
type = types.attrsOf (types.submodule ({ name, config, options, ... }: { type = lib.types.attrsOf (lib.types.submodule ({ name, config, options, ... }: {
options = { options = {
certAuthority = mkOption { certAuthority = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
This public key is an SSH certificate authority, rather than an This public key is an SSH certificate authority, rather than an
individual host's key. individual host's key.
''; '';
}; };
hostNames = mkOption { hostNames = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
default = [ name ] ++ config.extraHostNames; default = [ name ] ++ config.extraHostNames;
defaultText = literalExpression "[ ${name} ] ++ config.${options.extraHostNames}"; defaultText = lib.literalExpression "[ ${name} ] ++ config.${options.extraHostNames}";
description = '' description = ''
A list of host names and/or IP numbers used for accessing A list of host names and/or IP numbers used for accessing
the host's ssh service. This list includes the name of the the host's ssh service. This list includes the name of the
@ -160,8 +158,8 @@ in
`hostNames` list. `hostNames` list.
''; '';
}; };
extraHostNames = mkOption { extraHostNames = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
default = []; default = [];
description = '' description = ''
A list of additional host names and/or IP numbers used for A list of additional host names and/or IP numbers used for
@ -169,9 +167,9 @@ in
`hostNames` is set explicitly. `hostNames` is set explicitly.
''; '';
}; };
publicKey = mkOption { publicKey = lib.mkOption {
default = null; default = null;
type = types.nullOr types.str; type = lib.types.nullOr lib.types.str;
example = "ecdsa-sha2-nistp521 AAAAE2VjZHN...UEPg=="; example = "ecdsa-sha2-nistp521 AAAAE2VjZHN...UEPg==";
description = '' description = ''
The public key data for the host. You can fetch a public key The public key data for the host. You can fetch a public key
@ -180,9 +178,9 @@ in
the key type and the key itself. the key type and the key itself.
''; '';
}; };
publicKeyFile = mkOption { publicKeyFile = lib.mkOption {
default = null; default = null;
type = types.nullOr types.path; type = lib.types.nullOr lib.types.path;
description = '' description = ''
The path to the public key file for the host. The public 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. key file is read at build time and saved in the Nix store.
@ -204,7 +202,7 @@ in
`extraHostNames` to add additional host names without `extraHostNames` to add additional host names without
disabling this default. disabling this default.
''; '';
example = literalExpression '' example = lib.literalExpression ''
{ {
myhost = { myhost = {
extraHostNames = [ "myhost.mydomain.com" "10.10.1.4" ]; extraHostNames = [ "myhost.mydomain.com" "10.10.1.4" ];
@ -219,16 +217,16 @@ in
''; '';
}; };
knownHostsFiles = mkOption { knownHostsFiles = lib.mkOption {
default = []; default = [];
type = with types; listOf path; type = with lib.types; listOf path;
description = '' description = ''
Files containing SSH host keys to set as global known hosts. Files containing SSH host keys to set as global known hosts.
`/etc/ssh/ssh_known_hosts` (which is `/etc/ssh/ssh_known_hosts` (which is
generated by {option}`programs.ssh.knownHosts`) is generated by {option}`programs.ssh.knownHosts`) is
always included. always included.
''; '';
example = literalExpression '' example = lib.literalExpression ''
[ [
./known_hosts ./known_hosts
(writeText "github.keys" ''' (writeText "github.keys" '''
@ -240,8 +238,8 @@ in
''; '';
}; };
kexAlgorithms = mkOption { kexAlgorithms = lib.mkOption {
type = types.nullOr (types.listOf types.str); type = lib.types.nullOr (lib.types.listOf lib.types.str);
default = null; default = null;
example = [ "curve25519-sha256@libssh.org" "diffie-hellman-group-exchange-sha256" ]; example = [ "curve25519-sha256@libssh.org" "diffie-hellman-group-exchange-sha256" ];
description = '' description = ''
@ -249,8 +247,8 @@ in
''; '';
}; };
ciphers = mkOption { ciphers = lib.mkOption {
type = types.nullOr (types.listOf types.str); type = lib.types.nullOr (lib.types.listOf lib.types.str);
default = null; default = null;
example = [ "chacha20-poly1305@openssh.com" "aes256-gcm@openssh.com" ]; example = [ "chacha20-poly1305@openssh.com" "aes256-gcm@openssh.com" ];
description = '' description = ''
@ -258,8 +256,8 @@ in
''; '';
}; };
macs = mkOption { macs = lib.mkOption {
type = types.nullOr (types.listOf types.str); type = lib.types.nullOr (lib.types.listOf lib.types.str);
default = null; default = null;
example = [ "hmac-sha2-512-etm@openssh.com" "hmac-sha1" ]; example = [ "hmac-sha2-512-etm@openssh.com" "hmac-sha1" ];
description = '' description = ''
@ -274,13 +272,13 @@ in
config = { config = {
programs.ssh.setXAuthLocation = programs.ssh.setXAuthLocation =
mkDefault (config.services.xserver.enable || config.programs.ssh.forwardX11 == true || config.services.openssh.settings.X11Forwarding); lib.mkDefault (config.services.xserver.enable || config.programs.ssh.forwardX11 == true || config.services.openssh.settings.X11Forwarding);
assertions = assertions =
[ { assertion = cfg.forwardX11 == true -> cfg.setXAuthLocation; [ { assertion = cfg.forwardX11 == true -> cfg.setXAuthLocation;
message = "cannot enable X11 forwarding without setting XAuth location"; message = "cannot enable X11 forwarding without setting XAuth location";
} }
] ++ flip mapAttrsToList cfg.knownHosts (name: data: { ] ++ lib.flip lib.mapAttrsToList cfg.knownHosts (name: data: {
assertion = (data.publicKey == null && data.publicKeyFile != null) || assertion = (data.publicKey == null && data.publicKeyFile != null) ||
(data.publicKey != null && data.publicKeyFile == null); (data.publicKey != null && data.publicKeyFile == null);
message = "knownHost ${name} must contain either a publicKey or publicKeyFile"; message = "knownHost ${name} must contain either a publicKey or publicKeyFile";
@ -296,22 +294,22 @@ in
# Generated options from other settings # Generated options from other settings
Host * Host *
AddressFamily ${if config.networking.enableIPv6 then "any" else "inet"} AddressFamily ${if config.networking.enableIPv6 then "any" else "inet"}
GlobalKnownHostsFile ${concatStringsSep " " knownHostsFiles} GlobalKnownHostsFile ${builtins.concatStringsSep " " knownHostsFiles}
${optionalString cfg.setXAuthLocation "XAuthLocation ${pkgs.xorg.xauth}/bin/xauth"} ${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.forwardX11 != null) "ForwardX11 ${if cfg.forwardX11 then "yes" else "no"}"}
${optionalString (cfg.pubkeyAcceptedKeyTypes != []) "PubkeyAcceptedKeyTypes ${concatStringsSep "," cfg.pubkeyAcceptedKeyTypes}"} ${lib.optionalString (cfg.pubkeyAcceptedKeyTypes != []) "PubkeyAcceptedKeyTypes ${builtins.concatStringsSep "," cfg.pubkeyAcceptedKeyTypes}"}
${optionalString (cfg.hostKeyAlgorithms != []) "HostKeyAlgorithms ${concatStringsSep "," cfg.hostKeyAlgorithms}"} ${lib.optionalString (cfg.hostKeyAlgorithms != []) "HostKeyAlgorithms ${builtins.concatStringsSep "," cfg.hostKeyAlgorithms}"}
${optionalString (cfg.kexAlgorithms != null) "KexAlgorithms ${concatStringsSep "," cfg.kexAlgorithms}"} ${lib.optionalString (cfg.kexAlgorithms != null) "KexAlgorithms ${builtins.concatStringsSep "," cfg.kexAlgorithms}"}
${optionalString (cfg.ciphers != null) "Ciphers ${concatStringsSep "," cfg.ciphers}"} ${lib.optionalString (cfg.ciphers != null) "Ciphers ${builtins.concatStringsSep "," cfg.ciphers}"}
${optionalString (cfg.macs != null) "MACs ${concatStringsSep "," cfg.macs}"} ${lib.optionalString (cfg.macs != null) "MACs ${builtins.concatStringsSep "," cfg.macs}"}
''; '';
environment.etc."ssh/ssh_known_hosts".text = knownHostsText; environment.etc."ssh/ssh_known_hosts".text = knownHostsText;
# FIXME: this should really be socket-activated for über-awesomeness. # FIXME: this should really be socket-activated for über-awesomeness.
systemd.user.services.ssh-agent = mkIf cfg.startAgent systemd.user.services.ssh-agent = lib.mkIf cfg.startAgent
{ description = "SSH Agent"; { description = "SSH Agent";
wantedBy = [ "default.target" ]; wantedBy = [ "default.target" ];
unitConfig.ConditionUser = "!@system"; unitConfig.ConditionUser = "!@system";
@ -319,8 +317,8 @@ in
{ ExecStartPre = "${pkgs.coreutils}/bin/rm -f %t/ssh-agent"; { ExecStartPre = "${pkgs.coreutils}/bin/rm -f %t/ssh-agent";
ExecStart = ExecStart =
"${cfg.package}/bin/ssh-agent " + "${cfg.package}/bin/ssh-agent " +
optionalString (cfg.agentTimeout != null) ("-t ${cfg.agentTimeout} ") + lib.optionalString (cfg.agentTimeout != null) ("-t ${cfg.agentTimeout} ") +
optionalString (cfg.agentPKCS11Whitelist != null) ("-P ${cfg.agentPKCS11Whitelist} ") + lib.optionalString (cfg.agentPKCS11Whitelist != null) ("-P ${cfg.agentPKCS11Whitelist} ") +
"-a %t/ssh-agent"; "-a %t/ssh-agent";
StandardOutput = "null"; StandardOutput = "null";
Type = "forking"; Type = "forking";
@ -330,18 +328,18 @@ in
# Allow ssh-agent to ask for confirmation. This requires the # Allow ssh-agent to ask for confirmation. This requires the
# unit to know about the user's $DISPLAY (via systemctl # unit to know about the user's $DISPLAY (via systemctl
# import-environment). # import-environment).
environment.SSH_ASKPASS = optionalString cfg.enableAskPassword askPasswordWrapper; environment.SSH_ASKPASS = lib.optionalString cfg.enableAskPassword askPasswordWrapper;
environment.DISPLAY = "fake"; # required to make ssh-agent start $SSH_ASKPASS environment.DISPLAY = "fake"; # required to make ssh-agent start $SSH_ASKPASS
}; };
environment.extraInit = optionalString cfg.startAgent environment.extraInit = lib.optionalString cfg.startAgent
'' ''
if [ -z "$SSH_AUTH_SOCK" -a -n "$XDG_RUNTIME_DIR" ]; then if [ -z "$SSH_AUTH_SOCK" -a -n "$XDG_RUNTIME_DIR" ]; then
export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent" export SSH_AUTH_SOCK="$XDG_RUNTIME_DIR/ssh-agent"
fi fi
''; '';
environment.variables.SSH_ASKPASS = optionalString cfg.enableAskPassword cfg.askPassword; environment.variables.SSH_ASKPASS = lib.optionalString cfg.enableAskPassword cfg.askPassword;
}; };
} }

View File

@ -1,7 +1,5 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.steam; cfg = config.programs.steam;
gamescopeCfg = config.programs.gamescope; gamescopeCfg = config.programs.gamescope;
@ -11,7 +9,7 @@ let
in in
pkgs.writeShellScriptBin "steam-gamescope" '' pkgs.writeShellScriptBin "steam-gamescope" ''
${builtins.concatStringsSep "\n" exports} ${builtins.concatStringsSep "\n" exports}
gamescope --steam ${toString cfg.gamescopeSession.args} -- steam -tenfoot -pipewire-dmabuf gamescope --steam ${builtins.toString cfg.gamescopeSession.args} -- steam -tenfoot -pipewire-dmabuf
''; '';
gamescopeSessionFile = gamescopeSessionFile =
@ -24,13 +22,13 @@ let
'').overrideAttrs (_: { passthru.providedSessions = [ "steam" ]; }); '').overrideAttrs (_: { passthru.providedSessions = [ "steam" ]; });
in { in {
options.programs.steam = { options.programs.steam = {
enable = mkEnableOption "steam"; enable = lib.mkEnableOption "steam";
package = mkOption { package = lib.mkOption {
type = types.package; type = lib.types.package;
default = pkgs.steam; default = pkgs.steam;
defaultText = literalExpression "pkgs.steam"; defaultText = lib.literalExpression "pkgs.steam";
example = literalExpression '' example = lib.literalExpression ''
pkgs.steam-small.override { pkgs.steam-small.override {
extraEnv = { extraEnv = {
MANGOHUD = true; MANGOHUD = true;
@ -44,8 +42,8 @@ in {
''; '';
apply = steam: steam.override (prev: { apply = steam: steam.override (prev: {
extraEnv = (lib.optionalAttrs (cfg.extraCompatPackages != [ ]) { extraEnv = (lib.optionalAttrs (cfg.extraCompatPackages != [ ]) {
STEAM_EXTRA_COMPAT_TOOLS_PATHS = makeSearchPathOutput "steamcompattool" "" cfg.extraCompatPackages; STEAM_EXTRA_COMPAT_TOOLS_PATHS = lib.makeSearchPathOutput "steamcompattool" "" cfg.extraCompatPackages;
}) // (optionalAttrs cfg.extest.enable { }) // (lib.optionalAttrs cfg.extest.enable {
LD_PRELOAD = "${pkgs.pkgsi686Linux.extest}/lib/libextest.so"; LD_PRELOAD = "${pkgs.pkgsi686Linux.extest}/lib/libextest.so";
}) // (prev.extraEnv or {}); }) // (prev.extraEnv or {});
extraLibraries = pkgs: let extraLibraries = pkgs: let
@ -55,7 +53,7 @@ in {
then [ package ] ++ extraPackages then [ package ] ++ extraPackages
else [ package32 ] ++ extraPackages32; else [ package32 ] ++ extraPackages32;
in prevLibs ++ additionalLibs; in prevLibs ++ additionalLibs;
} // optionalAttrs (cfg.gamescopeSession.enable && gamescopeCfg.capSysNice) } // lib.optionalAttrs (cfg.gamescopeSession.enable && gamescopeCfg.capSysNice)
{ {
buildFHSEnv = pkgs.buildFHSEnv.override { buildFHSEnv = pkgs.buildFHSEnv.override {
# use the setuid wrapped bubblewrap # use the setuid wrapped bubblewrap
@ -71,10 +69,10 @@ in {
''; '';
}; };
extraCompatPackages = mkOption { extraCompatPackages = lib.mkOption {
type = types.listOf types.package; type = lib.types.listOf lib.types.package;
default = [ ]; default = [ ];
example = literalExpression '' example = lib.literalExpression ''
with pkgs; [ with pkgs; [
proton-ge-bin proton-ge-bin
] ]
@ -88,46 +86,46 @@ in {
''; '';
}; };
remotePlay.openFirewall = mkOption { remotePlay.openFirewall = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Open ports in the firewall for Steam Remote Play. Open ports in the firewall for Steam Remote Play.
''; '';
}; };
dedicatedServer.openFirewall = mkOption { dedicatedServer.openFirewall = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Open ports in the firewall for Source Dedicated Server. Open ports in the firewall for Source Dedicated Server.
''; '';
}; };
localNetworkGameTransfers.openFirewall = mkOption { localNetworkGameTransfers.openFirewall = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Open ports in the firewall for Steam Local Network Game Transfers. Open ports in the firewall for Steam Local Network Game Transfers.
''; '';
}; };
gamescopeSession = mkOption { gamescopeSession = lib.mkOption {
description = "Run a GameScope driven Steam session from your display-manager"; description = "Run a GameScope driven Steam session from your display-manager";
default = {}; default = {};
type = types.submodule { type = lib.types.submodule {
options = { options = {
enable = mkEnableOption "GameScope Session"; enable = lib.mkEnableOption "GameScope Session";
args = mkOption { args = lib.mkOption {
type = types.listOf types.str; type = lib.types.listOf lib.types.str;
default = [ ]; default = [ ];
description = '' description = ''
Arguments to be passed to GameScope for the session. Arguments to be passed to GameScope for the session.
''; '';
}; };
env = mkOption { env = lib.mkOption {
type = types.attrsOf types.str; type = lib.types.attrsOf lib.types.str;
default = { }; default = { };
description = '' description = ''
Environmental variables to be passed to GameScope for the session. Environmental variables to be passed to GameScope for the session.
@ -137,20 +135,20 @@ in {
}; };
}; };
extest.enable = mkEnableOption '' extest.enable = lib.mkEnableOption ''
Load the extest library into Steam, to translate X11 input events to Load the extest library into Steam, to translate X11 input events to
uinput events (e.g. for using Steam Input on Wayland) uinput events (e.g. for using Steam Input on Wayland)
''; '';
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
hardware.opengl = { # this fixes the "glXChooseVisual failed" bug, context: https://github.com/NixOS/nixpkgs/issues/47932 hardware.opengl = { # this fixes the "glXChooseVisual failed" bug, context: https://github.com/NixOS/nixpkgs/issues/47932
enable = true; enable = true;
driSupport = true; driSupport = true;
driSupport32Bit = true; driSupport32Bit = true;
}; };
security.wrappers = mkIf (cfg.gamescopeSession.enable && gamescopeCfg.capSysNice) { security.wrappers = lib.mkIf (cfg.gamescopeSession.enable && gamescopeCfg.capSysNice) {
# needed or steam fails # needed or steam fails
bwrap = { bwrap = {
owner = "root"; owner = "root";
@ -160,8 +158,8 @@ in {
}; };
}; };
programs.gamescope.enable = mkDefault cfg.gamescopeSession.enable; programs.gamescope.enable = lib.mkDefault cfg.gamescopeSession.enable;
services.displayManager.sessionPackages = mkIf cfg.gamescopeSession.enable [ gamescopeSessionFile ]; services.displayManager.sessionPackages = lib.mkIf cfg.gamescopeSession.enable [ gamescopeSessionFile ];
# optionally enable 32bit pulseaudio support if pulseaudio is enabled # optionally enable 32bit pulseaudio support if pulseaudio is enabled
hardware.pulseaudio.support32Bit = config.hardware.pulseaudio.enable; hardware.pulseaudio.support32Bit = config.hardware.pulseaudio.enable;
@ -174,25 +172,25 @@ in {
] ++ lib.optional cfg.gamescopeSession.enable steam-gamescope; ] ++ lib.optional cfg.gamescopeSession.enable steam-gamescope;
networking.firewall = lib.mkMerge [ networking.firewall = lib.mkMerge [
(mkIf (cfg.remotePlay.openFirewall || cfg.localNetworkGameTransfers.openFirewall) { (lib.mkIf (cfg.remotePlay.openFirewall || cfg.localNetworkGameTransfers.openFirewall) {
allowedUDPPorts = [ 27036 ]; # Peer discovery allowedUDPPorts = [ 27036 ]; # Peer discovery
}) })
(mkIf cfg.remotePlay.openFirewall { (lib.mkIf cfg.remotePlay.openFirewall {
allowedTCPPorts = [ 27036 ]; allowedTCPPorts = [ 27036 ];
allowedUDPPortRanges = [ { from = 27031; to = 27035; } ]; allowedUDPPortRanges = [ { from = 27031; to = 27035; } ];
}) })
(mkIf cfg.dedicatedServer.openFirewall { (lib.mkIf cfg.dedicatedServer.openFirewall {
allowedTCPPorts = [ 27015 ]; # SRCDS Rcon port allowedTCPPorts = [ 27015 ]; # SRCDS Rcon port
allowedUDPPorts = [ 27015 ]; # Gameplay traffic allowedUDPPorts = [ 27015 ]; # Gameplay traffic
}) })
(mkIf cfg.localNetworkGameTransfers.openFirewall { (lib.mkIf cfg.localNetworkGameTransfers.openFirewall {
allowedTCPPorts = [ 27040 ]; # Data transfers allowedTCPPorts = [ 27040 ]; # Data transfers
}) })
]; ];
}; };
meta.maintainers = teams.steam; meta.maintainers = lib.teams.steam;
} }

View File

@ -1,34 +1,32 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.streamdeck-ui; cfg = config.programs.streamdeck-ui;
in in
{ {
options.programs.streamdeck-ui = { options.programs.streamdeck-ui = {
enable = mkEnableOption "streamdeck-ui"; enable = lib.mkEnableOption "streamdeck-ui";
autoStart = mkOption { autoStart = lib.mkOption {
default = true; default = true;
type = types.bool; type = lib.types.bool;
description = "Whether streamdeck-ui should be started automatically."; description = "Whether streamdeck-ui should be started automatically.";
}; };
package = mkPackageOption pkgs "streamdeck-ui" { package = lib.mkPackageOption pkgs "streamdeck-ui" {
default = [ "streamdeck-ui" ]; default = [ "streamdeck-ui" ];
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ environment.systemPackages = [
cfg.package cfg.package
(mkIf cfg.autoStart (makeAutostartItem { name = "streamdeck-ui-noui"; package = cfg.package; })) (lib.mkIf cfg.autoStart (pkgs.makeAutostartItem { name = "streamdeck-ui-noui"; package = cfg.package; }))
]; ];
services.udev.packages = [ cfg.package ]; services.udev.packages = [ cfg.package ];
}; };
meta.maintainers = with maintainers; [ majiir ]; meta.maintainers = with lib.maintainers; [ majiir ];
} }

View File

@ -1,13 +1,11 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.sysdig; cfg = config.programs.sysdig;
in { in {
options.programs.sysdig.enable = mkEnableOption "sysdig, a tracing tool"; options.programs.sysdig.enable = lib.mkEnableOption "sysdig, a tracing tool";
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.sysdig ]; environment.systemPackages = [ pkgs.sysdig ];
boot.extraModulePackages = [ config.boot.kernelPackages.sysdig ]; boot.extraModulePackages = [ config.boot.kernelPackages.sysdig ];
}; };

View File

@ -1,7 +1,5 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib;
{ {
###### interface ###### interface
@ -10,7 +8,7 @@ with lib;
programs.system-config-printer = { programs.system-config-printer = {
enable = mkEnableOption "system-config-printer, a Graphical user interface for CUPS administration"; enable = lib.mkEnableOption "system-config-printer, a Graphical user interface for CUPS administration";
}; };
@ -19,7 +17,7 @@ with lib;
###### implementation ###### implementation
config = mkIf config.programs.system-config-printer.enable { config = lib.mkIf config.programs.system-config-printer.enable {
environment.systemPackages = [ environment.systemPackages = [
pkgs.system-config-printer pkgs.system-config-printer

View File

@ -1,14 +1,12 @@
{ config, lib, ... }: { config, lib, ... }:
with lib;
let cfg = config.programs.systemtap; let cfg = config.programs.systemtap;
in { in {
options = { options = {
programs.systemtap = { programs.systemtap = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Install {command}`systemtap` along with necessary kernel options. Install {command}`systemtap` along with necessary kernel options.
@ -16,7 +14,7 @@ in {
}; };
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
system.requiredKernelConfig = with config.lib.kernelConfig; [ system.requiredKernelConfig = with config.lib.kernelConfig; [
(isYes "DEBUG") (isYes "DEBUG")
]; ];

View File

@ -1,7 +1,5 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib;
let let
prg = config.programs; prg = config.programs;
cfg = prg.thefuck; cfg = prg.thefuck;
@ -16,11 +14,11 @@ in
{ {
options = { options = {
programs.thefuck = { programs.thefuck = {
enable = mkEnableOption "thefuck, an app which corrects your previous console command"; enable = lib.mkEnableOption "thefuck, an app which corrects your previous console command";
alias = mkOption { alias = lib.mkOption {
default = "fuck"; default = "fuck";
type = types.str; type = lib.types.str;
description = '' description = ''
`thefuck` needs an alias to be configured. `thefuck` needs an alias to be configured.
@ -30,11 +28,11 @@ in
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ thefuck ]; environment.systemPackages = with pkgs; [ thefuck ];
programs.bash.interactiveShellInit = bashAndZshInitScript; programs.bash.interactiveShellInit = bashAndZshInitScript;
programs.zsh.interactiveShellInit = mkIf prg.zsh.enable bashAndZshInitScript; programs.zsh.interactiveShellInit = lib.mkIf prg.zsh.enable bashAndZshInitScript;
programs.fish.interactiveShellInit = mkIf prg.fish.enable fishInitScript; programs.fish.interactiveShellInit = lib.mkIf prg.fish.enable fishInitScript;
}; };
} }

View File

@ -1,29 +1,27 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let cfg = config.programs.thunar; let cfg = config.programs.thunar;
in { in {
meta = { meta = {
maintainers = teams.xfce.members; maintainers = lib.teams.xfce.members;
}; };
options = { options = {
programs.thunar = { programs.thunar = {
enable = mkEnableOption "Thunar, the Xfce file manager"; enable = lib.mkEnableOption "Thunar, the Xfce file manager";
plugins = mkOption { plugins = lib.mkOption {
default = []; default = [];
type = types.listOf types.package; type = lib.types.listOf lib.types.package;
description = "List of thunar plugins to install."; description = "List of thunar plugins to install.";
example = literalExpression "with pkgs.xfce; [ thunar-archive-plugin thunar-volman ]"; example = lib.literalExpression "with pkgs.xfce; [ thunar-archive-plugin thunar-volman ]";
}; };
}; };
}; };
config = mkIf cfg.enable ( config = lib.mkIf cfg.enable (
let package = pkgs.xfce.thunar.override { thunarPlugins = cfg.plugins; }; let package = pkgs.xfce.thunar.override { thunarPlugins = cfg.plugins; };
in { in {

View File

@ -1,14 +1,12 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.traceroute; cfg = config.programs.traceroute;
in { in {
options = { options = {
programs.traceroute = { programs.traceroute = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to configure a setcap wrapper for traceroute. Whether to configure a setcap wrapper for traceroute.
@ -17,7 +15,7 @@ in {
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
security.wrappers.traceroute = { security.wrappers.traceroute = {
owner = "root"; owner = "root";
group = "root"; group = "root";

View File

@ -2,8 +2,6 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.turbovnc; cfg = config.programs.turbovnc;
in in
@ -12,8 +10,8 @@ in
programs.turbovnc = { programs.turbovnc = {
ensureHeadlessSoftwareOpenGL = mkOption { ensureHeadlessSoftwareOpenGL = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to set up NixOS such that TurboVNC's built-in software OpenGL Whether to set up NixOS such that TurboVNC's built-in software OpenGL
@ -36,7 +34,7 @@ in
}; };
config = mkIf cfg.ensureHeadlessSoftwareOpenGL { config = lib.mkIf cfg.ensureHeadlessSoftwareOpenGL {
# TurboVNC has builtin support for Mesa llvmpipe's `swrast` # TurboVNC has builtin support for Mesa llvmpipe's `swrast`
# software rendering to implement GLX (OpenGL on Xorg). # software rendering to implement GLX (OpenGL on Xorg).

View File

@ -1,14 +1,12 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.udevil; cfg = config.programs.udevil;
in { in {
options.programs.udevil.enable = mkEnableOption "udevil, to mount filesystems without password"; options.programs.udevil.enable = lib.mkEnableOption "udevil, to mount filesystems without password";
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
security.wrappers.udevil = security.wrappers.udevil =
{ setuid = true; { setuid = true;
owner = "root"; owner = "root";

View File

@ -1,15 +1,13 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib;
let let
cfg = config.programs.usbtop; cfg = config.programs.usbtop;
in { in {
options = { options = {
programs.usbtop.enable = mkEnableOption "usbtop and required kernel module, to show estimated USB bandwidth"; programs.usbtop.enable = lib.mkEnableOption "usbtop and required kernel module, to show estimated USB bandwidth";
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
usbtop usbtop
]; ];

View File

@ -1,13 +1,11 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.vim; cfg = config.programs.vim;
in { in {
options.programs.vim = { options.programs.vim = {
defaultEditor = mkOption { defaultEditor = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
When enabled, installs vim and configures vim to be the default editor When enabled, installs vim and configures vim to be the default editor
@ -15,13 +13,13 @@ in {
''; '';
}; };
package = mkPackageOption pkgs "vim" { package = lib.mkPackageOption pkgs "vim" {
example = "vim-full"; example = "vim-full";
}; };
}; };
config = mkIf cfg.defaultEditor { config = lib.mkIf cfg.defaultEditor {
environment.systemPackages = [ cfg.package ]; environment.systemPackages = [ cfg.package ];
environment.variables = { EDITOR = mkOverride 900 "vim"; }; environment.variables = { EDITOR = lib.mkOverride 900 "vim"; };
}; };
} }

View File

@ -1,14 +1,12 @@
{ config, lib, pkgs, ... }: { config, lib, pkgs, ... }:
with lib;
let let
cfg = config.programs.wavemon; cfg = config.programs.wavemon;
in { in {
options = { options = {
programs.wavemon = { programs.wavemon = {
enable = mkOption { enable = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = '' description = ''
Whether to add wavemon to the global environment and configure a Whether to add wavemon to the global environment and configure a
@ -18,7 +16,7 @@ in {
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = with pkgs; [ wavemon ]; environment.systemPackages = with pkgs; [ wavemon ];
security.wrappers.wavemon = { security.wrappers.wavemon = {
owner = "root"; owner = "root";

View File

@ -3,7 +3,7 @@
, pkgs , pkgs
, ... , ...
}: }:
with lib; let let
cfg = config.programs.hyprland; cfg = config.programs.hyprland;
finalPortalPackage = cfg.portalPackage.override { finalPortalPackage = cfg.portalPackage.override {
@ -12,7 +12,7 @@ with lib; let
in in
{ {
options.programs.hyprland = { options.programs.hyprland = {
enable = mkEnableOption null // { enable = lib.mkEnableOption null // {
description = '' description = ''
Whether to enable Hyprland, the dynamic tiling Wayland compositor that doesn't sacrifice on its looks. Whether to enable Hyprland, the dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
@ -23,26 +23,26 @@ in
''; '';
}; };
package = mkPackageOption pkgs "hyprland" { }; package = lib.mkPackageOption pkgs "hyprland" { };
finalPackage = mkOption { finalPackage = lib.mkOption {
type = types.package; type = lib.types.package;
readOnly = true; readOnly = true;
default = cfg.package.override { default = cfg.package.override {
enableXWayland = cfg.xwayland.enable; enableXWayland = cfg.xwayland.enable;
}; };
defaultText = literalExpression defaultText = lib.literalExpression
"`programs.hyprland.package` with applied configuration"; "`programs.hyprland.package` with applied configuration";
description = '' description = ''
The Hyprland package after applying configuration. The Hyprland package after applying configuration.
''; '';
}; };
portalPackage = mkPackageOption pkgs "xdg-desktop-portal-hyprland" { }; portalPackage = lib.mkPackageOption pkgs "xdg-desktop-portal-hyprland" { };
xwayland.enable = mkEnableOption ("XWayland") // { default = true; }; xwayland.enable = lib.mkEnableOption ("XWayland") // { default = true; };
systemd.setPath.enable = mkEnableOption null // { systemd.setPath.enable = lib.mkEnableOption null // {
default = true; default = true;
example = false; example = false;
description = '' description = ''
@ -53,15 +53,15 @@ in
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.finalPackage ]; environment.systemPackages = [ cfg.finalPackage ];
fonts.enableDefaultPackages = mkDefault true; fonts.enableDefaultPackages = lib.mkDefault true;
hardware.opengl.enable = mkDefault true; hardware.opengl.enable = lib.mkDefault true;
programs = { programs = {
dconf.enable = mkDefault true; dconf.enable = lib.mkDefault true;
xwayland.enable = mkDefault cfg.xwayland.enable; xwayland.enable = lib.mkDefault cfg.xwayland.enable;
}; };
security.polkit.enable = true; security.polkit.enable = true;
@ -69,28 +69,28 @@ in
services.displayManager.sessionPackages = [ cfg.finalPackage ]; services.displayManager.sessionPackages = [ cfg.finalPackage ];
xdg.portal = { xdg.portal = {
enable = mkDefault true; enable = lib.mkDefault true;
extraPortals = [ finalPortalPackage ]; extraPortals = [ finalPortalPackage ];
configPackages = mkDefault [ cfg.finalPackage ]; configPackages = lib.mkDefault [ cfg.finalPackage ];
}; };
systemd = mkIf cfg.systemd.setPath.enable { systemd = lib.mkIf cfg.systemd.setPath.enable {
user.extraConfig = '' user.extraConfig = ''
DefaultEnvironment="PATH=$PATH:/run/current-system/sw/bin:/etc/profiles/per-user/%u/bin:/run/wrappers/bin" DefaultEnvironment="PATH=$PATH:/run/current-system/sw/bin:/etc/profiles/per-user/%u/bin:/run/wrappers/bin"
''; '';
}; };
}; };
imports = with lib; [ imports = [
(mkRemovedOptionModule (lib.mkRemovedOptionModule
[ "programs" "hyprland" "xwayland" "hidpi" ] [ "programs" "hyprland" "xwayland" "hidpi" ]
"XWayland patches are deprecated. Refer to https://wiki.hyprland.org/Configuring/XWayland" "XWayland patches are deprecated. Refer to https://wiki.hyprland.org/Configuring/XWayland"
) )
(mkRemovedOptionModule (lib.mkRemovedOptionModule
[ "programs" "hyprland" "enableNvidiaPatches" ] [ "programs" "hyprland" "enableNvidiaPatches" ]
"Nvidia patches are no longer needed" "Nvidia patches are no longer needed"
) )
(mkRemovedOptionModule (lib.mkRemovedOptionModule
[ "programs" "hyprland" "nvidiaPatches" ] [ "programs" "hyprland" "nvidiaPatches" ]
"Nvidia patches are no longer needed" "Nvidia patches are no longer needed"
) )

View File

@ -4,13 +4,13 @@
lib, lib,
... ...
}: }:
with lib; let let
cfg = config.programs.river; cfg = config.programs.river;
in { in {
options.programs.river = { options.programs.river = {
enable = mkEnableOption "river, a dynamic tiling Wayland compositor"; enable = lib.mkEnableOption "river, a dynamic tiling Wayland compositor";
package = mkPackageOption pkgs "river" { package = lib.mkPackageOption pkgs "river" {
nullable = true; nullable = true;
extraDescription = '' extraDescription = ''
Set to `null` to not add any River package to your path. Set to `null` to not add any River package to your path.
@ -18,17 +18,17 @@ in {
''; '';
}; };
extraPackages = mkOption { extraPackages = lib.mkOption {
type = with types; listOf package; type = with lib.types; listOf package;
default = with pkgs; [ default = with pkgs; [
swaylock swaylock
foot foot
dmenu dmenu
]; ];
defaultText = literalExpression '' defaultText = lib.literalExpression ''
with pkgs; [ swaylock foot dmenu ]; with pkgs; [ swaylock foot dmenu ];
''; '';
example = literalExpression '' example = lib.literalExpression ''
with pkgs; [ with pkgs; [
termite rofi light termite rofi light
] ]
@ -42,15 +42,15 @@ in {
}; };
config = config =
mkIf cfg.enable (mkMerge [ lib.mkIf cfg.enable (lib.mkMerge [
{ {
environment.systemPackages = optional (cfg.package != null) cfg.package ++ cfg.extraPackages; 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: # To make a river session available if a display manager like SDDM is enabled:
services.displayManager.sessionPackages = optionals (cfg.package != null) [ cfg.package ]; services.displayManager.sessionPackages = lib.optionals (cfg.package != null) [ cfg.package ];
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1050913 # https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1050913
xdg.portal.config.river.default = mkDefault [ "wlr" "gtk" ]; xdg.portal.config.river.default = lib.mkDefault [ "wlr" "gtk" ];
} }
(import ./wayland-session.nix { inherit lib pkgs; }) (import ./wayland-session.nix { inherit lib pkgs; })
]); ]);

Some files were not shown because too many files have changed in this diff Show More