nixos/gnome: Remove global with expressions

The can potentially mask evaluation errors due to laziness of variable access within.
This commit is contained in:
Jan Tojnar 2024-04-30 18:57:01 +02:00
parent f77c3bf760
commit 5b2b3b8558
22 changed files with 102 additions and 145 deletions

View File

@ -2,8 +2,6 @@
{ config, pkgs, lib, ... }:
with lib;
let cfg = config.programs.evince;
in {
@ -14,9 +12,9 @@ in {
programs.evince = {
enable = mkEnableOption "Evince, the GNOME document viewer";
enable = lib.mkEnableOption "Evince, the GNOME document viewer";
package = mkPackageOption pkgs "evince" { };
package = lib.mkPackageOption pkgs "evince" { };
};
@ -25,7 +23,7 @@ in {
###### implementation
config = mkIf config.programs.evince.enable {
config = lib.mkIf config.programs.evince.enable {
environment.systemPackages = [ cfg.package ];

View File

@ -2,8 +2,6 @@
{ config, pkgs, lib, ... }:
with lib;
let cfg = config.programs.file-roller;
in {
@ -14,9 +12,9 @@ in {
programs.file-roller = {
enable = mkEnableOption "File Roller, an archive manager for GNOME";
enable = lib.mkEnableOption "File Roller, an archive manager for GNOME";
package = mkPackageOption pkgs [ "gnome" "file-roller" ] { };
package = lib.mkPackageOption pkgs [ "gnome" "file-roller" ] { };
};
@ -25,7 +23,7 @@ in {
###### implementation
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];

View File

@ -2,12 +2,10 @@
{ config, pkgs, lib, ... }:
with lib;
{
meta = {
maintainers = teams.gnome.members;
maintainers = lib.teams.gnome.members;
};
###### interface
@ -16,8 +14,8 @@ with lib;
programs.gnome-disks = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable GNOME Disks daemon, a program designed to
@ -32,7 +30,7 @@ with lib;
###### implementation
config = mkIf config.programs.gnome-disks.enable {
config = lib.mkIf config.programs.gnome-disks.enable {
environment.systemPackages = [ pkgs.gnome.gnome-disk-utility ];

View File

@ -2,8 +2,6 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.programs.gnome-terminal;
@ -13,14 +11,14 @@ in
{
meta = {
maintainers = teams.gnome.members;
maintainers = lib.teams.gnome.members;
};
options = {
programs.gnome-terminal.enable = mkEnableOption "GNOME Terminal";
programs.gnome-terminal.enable = lib.mkEnableOption "GNOME Terminal";
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.gnome.gnome-terminal ];
services.dbus.packages = [ pkgs.gnome.gnome-terminal ];
systemd.packages = [ pkgs.gnome.gnome-terminal ];

View File

@ -1,15 +1,13 @@
# GPaste.
{ config, lib, pkgs, ... }:
with lib;
{
###### interface
options = {
programs.gpaste = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable GPaste, a clipboard manager.
@ -19,7 +17,7 @@ with lib;
};
###### implementation
config = mkIf config.programs.gpaste.enable {
config = lib.mkIf config.programs.gpaste.enable {
environment.systemPackages = [ pkgs.gnome.gpaste ];
services.dbus.packages = [ pkgs.gnome.gpaste ];
systemd.packages = [ pkgs.gnome.gpaste ];

View File

@ -2,8 +2,6 @@
{ config, pkgs, lib, ... }:
with lib;
{
###### interface
@ -12,7 +10,7 @@ with lib;
programs.seahorse = {
enable = mkEnableOption "Seahorse, a GNOME application for managing encryption keys and passwords in the GNOME Keyring";
enable = lib.mkEnableOption "Seahorse, a GNOME application for managing encryption keys and passwords in the GNOME Keyring";
};
@ -21,9 +19,9 @@ with lib;
###### implementation
config = mkIf config.programs.seahorse.enable {
config = lib.mkIf config.programs.seahorse.enable {
programs.ssh.askPassword = mkDefault "${pkgs.gnome.seahorse}/libexec/seahorse/ssh-askpass";
programs.ssh.askPassword = lib.mkDefault "${pkgs.gnome.seahorse}/libexec/seahorse/ssh-askpass";
environment.systemPackages = [
pkgs.gnome.seahorse

View File

@ -2,12 +2,10 @@
{ config, lib, pkgs, ... }:
with lib;
{
meta = {
maintainers = teams.gnome.members;
maintainers = lib.teams.gnome.members;
};
###### interface
@ -15,8 +13,8 @@ with lib;
services.gnome.at-spi2-core = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable at-spi2-core, a service for the Assistive Technologies
@ -34,14 +32,14 @@ with lib;
###### implementation
config = mkMerge [
(mkIf config.services.gnome.at-spi2-core.enable {
config = lib.mkMerge [
(lib.mkIf config.services.gnome.at-spi2-core.enable {
environment.systemPackages = [ pkgs.at-spi2-core ];
services.dbus.packages = [ pkgs.at-spi2-core ];
systemd.packages = [ pkgs.at-spi2-core ];
})
(mkIf (!config.services.gnome.at-spi2-core.enable) {
(lib.mkIf (!config.services.gnome.at-spi2-core.enable) {
environment.sessionVariables = {
NO_AT_BRIDGE = "1";
GTK_A11Y = "none";

View File

@ -2,12 +2,10 @@
{ config, lib, pkgs, ... }:
with lib;
{
meta = {
maintainers = teams.gnome.members;
maintainers = lib.teams.gnome.members;
};
###### interface
@ -15,19 +13,19 @@ with lib;
options = {
services.gnome.evolution-data-server = {
enable = mkEnableOption "Evolution Data Server, a collection of services for storing addressbooks and calendars";
plugins = mkOption {
type = types.listOf types.package;
enable = lib.mkEnableOption "Evolution Data Server, a collection of services for storing addressbooks and calendars";
plugins = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [ ];
description = "Plugins for Evolution Data Server.";
};
};
programs.evolution = {
enable = mkEnableOption "Evolution, a Personal information management application that provides integrated mail, calendaring and address book functionality";
plugins = mkOption {
type = types.listOf types.package;
enable = lib.mkEnableOption "Evolution, a Personal information management application that provides integrated mail, calendaring and address book functionality";
plugins = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [ ];
example = literalExpression "[ pkgs.evolution-ews ]";
example = lib.literalExpression "[ pkgs.evolution-ews ]";
description = "Plugins for Evolution.";
};
@ -40,15 +38,15 @@ with lib;
let
bundle = pkgs.evolutionWithPlugins.override { inherit (config.services.gnome.evolution-data-server) plugins; };
in
mkMerge [
(mkIf config.services.gnome.evolution-data-server.enable {
lib.mkMerge [
(lib.mkIf config.services.gnome.evolution-data-server.enable {
environment.systemPackages = [ bundle ];
services.dbus.packages = [ bundle ];
systemd.packages = [ bundle ];
})
(mkIf config.programs.evolution.enable {
(lib.mkIf config.programs.evolution.enable {
services.gnome.evolution-data-server = {
enable = true;
plugins = [ pkgs.evolution ] ++ config.programs.evolution.plugins;

View File

@ -2,12 +2,10 @@
{ config, pkgs, lib, ... }:
with lib;
{
meta = {
maintainers = teams.gnome.members;
maintainers = lib.teams.gnome.members;
};
###### interface
@ -16,7 +14,7 @@ with lib;
services.gnome.glib-networking = {
enable = mkEnableOption "network extensions for GLib";
enable = lib.mkEnableOption "network extensions for GLib";
};
@ -24,7 +22,7 @@ with lib;
###### implementation
config = mkIf config.services.gnome.glib-networking.enable {
config = lib.mkIf config.services.gnome.glib-networking.enable {
services.dbus.packages = [ pkgs.glib-networking ];

View File

@ -2,8 +2,6 @@
{ config, pkgs, lib, ... }:
with lib;
let
# GNOME initial setup's run is conditioned on whether
@ -45,7 +43,7 @@ in
{
meta = {
maintainers = teams.gnome.members;
maintainers = lib.teams.gnome.members;
};
###### interface
@ -54,7 +52,7 @@ in
services.gnome.gnome-initial-setup = {
enable = mkEnableOption "GNOME Initial Setup, a Simple, easy, and safe way to prepare a new system";
enable = lib.mkEnableOption "GNOME Initial Setup, a Simple, easy, and safe way to prepare a new system";
};
@ -63,12 +61,12 @@ in
###### implementation
config = mkIf config.services.gnome.gnome-initial-setup.enable {
config = lib.mkIf config.services.gnome.gnome-initial-setup.enable {
environment.systemPackages = [
pkgs.gnome.gnome-initial-setup
]
++ optional (versionOlder config.system.stateVersion "20.03") createGisStampFilesAutostart
++ lib.optional (lib.versionOlder config.system.stateVersion "20.03") createGisStampFilesAutostart
;
systemd.packages = [

View File

@ -2,12 +2,10 @@
{ config, pkgs, lib, ... }:
with lib;
{
meta = {
maintainers = teams.gnome.members;
maintainers = lib.teams.gnome.members;
};
###### interface
@ -16,8 +14,8 @@ with lib;
services.gnome.gnome-keyring = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable GNOME Keyring daemon, a service designed to
@ -33,7 +31,7 @@ with lib;
###### implementation
config = mkIf config.services.gnome.gnome-keyring.enable {
config = lib.mkIf config.services.gnome.gnome-keyring.enable {
environment.systemPackages = [ pkgs.gnome.gnome-keyring ];

View File

@ -2,12 +2,10 @@
{ config, pkgs, lib, ... }:
with lib;
{
meta = {
maintainers = teams.gnome.members;
maintainers = lib.teams.gnome.members;
};
###### interface
@ -16,8 +14,8 @@ with lib;
services.gnome.gnome-online-accounts = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable GNOME Online Accounts daemon, a service that provides
@ -32,7 +30,7 @@ with lib;
###### implementation
config = mkIf config.services.gnome.gnome-online-accounts.enable {
config = lib.mkIf config.services.gnome.gnome-online-accounts.enable {
environment.systemPackages = [ pkgs.gnome-online-accounts ];

View File

@ -2,12 +2,10 @@
{ config, pkgs, lib, ... }:
with lib;
{
meta = {
maintainers = teams.gnome.members;
maintainers = lib.teams.gnome.members;
};
###### interface
@ -16,8 +14,8 @@ with lib;
services.gnome.gnome-online-miners = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable GNOME Online Miners, a service that
@ -32,7 +30,7 @@ with lib;
###### implementation
config = mkIf config.services.gnome.gnome-online-miners.enable {
config = lib.mkIf config.services.gnome.gnome-online-miners.enable {
environment.systemPackages = [ pkgs.gnome.gnome-online-miners ];

View File

@ -1,22 +1,20 @@
# Remote desktop daemon using Pipewire.
{ config, lib, pkgs, ... }:
with lib;
{
meta = {
maintainers = teams.gnome.members;
maintainers = lib.teams.gnome.members;
};
###### interface
options = {
services.gnome.gnome-remote-desktop = {
enable = mkEnableOption "Remote Desktop support using Pipewire";
enable = lib.mkEnableOption "Remote Desktop support using Pipewire";
};
};
###### implementation
config = mkIf config.services.gnome.gnome-remote-desktop.enable {
config = lib.mkIf config.services.gnome.gnome-remote-desktop.enable {
services.pipewire.enable = true;
systemd.packages = [ pkgs.gnome.gnome-remote-desktop ];

View File

@ -2,8 +2,6 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.gnome.gnome-settings-daemon;
@ -13,7 +11,7 @@ in
{
meta = {
maintainers = teams.gnome.members;
maintainers = lib.teams.gnome.members;
};
###### interface
@ -22,7 +20,7 @@ in
services.gnome.gnome-settings-daemon = {
enable = mkEnableOption "GNOME Settings Daemon";
enable = lib.mkEnableOption "GNOME Settings Daemon";
};
@ -31,7 +29,7 @@ in
###### implementation
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
environment.systemPackages = [
pkgs.gnome.gnome-settings-daemon

View File

@ -2,12 +2,10 @@
{ config, pkgs, lib, ... }:
with lib;
{
meta = {
maintainers = teams.gnome.members;
maintainers = lib.teams.gnome.members;
};
###### interface
@ -16,7 +14,7 @@ with lib;
services.gnome.gnome-user-share = {
enable = mkEnableOption "GNOME User Share, a user-level file sharing service for GNOME";
enable = lib.mkEnableOption "GNOME User Share, a user-level file sharing service for GNOME";
};
@ -25,7 +23,7 @@ with lib;
###### implementation
config = mkIf config.services.gnome.gnome-user-share.enable {
config = lib.mkIf config.services.gnome.gnome-user-share.enable {
environment.systemPackages = [
pkgs.gnome.gnome-user-share

View File

@ -1,30 +1,28 @@
# rygel service.
{ config, lib, pkgs, ... }:
with lib;
{
meta = {
maintainers = teams.gnome.members;
maintainers = lib.teams.gnome.members;
};
###### interface
options = {
services.gnome.rygel = {
enable = mkOption {
enable = lib.mkOption {
default = false;
description = ''
Whether to enable Rygel UPnP Mediaserver.
You will need to also allow UPnP connections in firewall, see the following [comment](https://github.com/NixOS/nixpkgs/pull/45045#issuecomment-416030795).
'';
type = types.bool;
type = lib.types.bool;
};
};
};
###### implementation
config = mkIf config.services.gnome.rygel.enable {
config = lib.mkIf config.services.gnome.rygel.enable {
environment.systemPackages = [ pkgs.gnome.rygel ];
services.dbus.packages = [ pkgs.gnome.rygel ];

View File

@ -2,12 +2,10 @@
{ config, lib, pkgs, ... }:
with lib;
{
meta = {
maintainers = teams.gnome.members;
maintainers = lib.teams.gnome.members;
};
###### interface
@ -16,8 +14,8 @@ with lib;
services.gnome.sushi = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable Sushi, a quick previewer for nautilus.
@ -31,7 +29,7 @@ with lib;
###### implementation
config = mkIf config.services.gnome.sushi.enable {
config = lib.mkIf config.services.gnome.sushi.enable {
environment.systemPackages = [ pkgs.gnome.sushi ];

View File

@ -2,12 +2,10 @@
{ config, pkgs, lib, ... }:
with lib;
{
meta = {
maintainers = teams.gnome.members;
maintainers = lib.teams.gnome.members;
};
###### interface
@ -16,8 +14,8 @@ with lib;
services.gnome.tracker-miners = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable Tracker miners, indexing services for Tracker
@ -31,7 +29,7 @@ with lib;
###### implementation
config = mkIf config.services.gnome.tracker-miners.enable {
config = lib.mkIf config.services.gnome.tracker-miners.enable {
environment.systemPackages = [ pkgs.tracker-miners ];

View File

@ -2,15 +2,13 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.services.gnome.tracker;
in
{
meta = {
maintainers = teams.gnome.members;
maintainers = lib.teams.gnome.members;
};
###### interface
@ -19,8 +17,8 @@ in
services.gnome.tracker = {
enable = mkOption {
type = types.bool;
enable = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Whether to enable Tracker services, a search engine,
@ -28,8 +26,8 @@ in
'';
};
subcommandPackages = mkOption {
type = types.listOf types.package;
subcommandPackages = lib.mkOption {
type = lib.types.listOf lib.types.package;
default = [ ];
internal = true;
description = ''
@ -44,7 +42,7 @@ in
###### implementation
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
environment.systemPackages = [ pkgs.tracker ];

View File

@ -2,8 +2,6 @@
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.services.gvfs;
@ -13,7 +11,7 @@ in
{
meta = {
maintainers = teams.gnome.members;
maintainers = lib.teams.gnome.members;
};
###### interface
@ -22,10 +20,10 @@ in
services.gvfs = {
enable = mkEnableOption "GVfs, a userspace virtual filesystem";
enable = lib.mkEnableOption "GVfs, a userspace virtual filesystem";
# gvfs can be built with multiple configurations
package = mkPackageOption pkgs [ "gnome" "gvfs" ] { };
package = lib.mkPackageOption pkgs [ "gnome" "gvfs" ] { };
};
@ -34,7 +32,7 @@ in
###### implementation
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];

View File

@ -1,8 +1,7 @@
{ config, lib, pkgs, utils, ... }:
with lib;
let
inherit (lib) mkOption types mkDefault mkEnableOption literalExpression;
cfg = config.services.xserver.desktopManager.gnome;
serviceCfg = config.services.gnome;
@ -51,8 +50,8 @@ let
destination = "/share/gnome-background-properties/nixos.xml";
};
flashbackEnabled = cfg.flashback.enableMetacity || length cfg.flashback.customSessions > 0;
flashbackWms = optional cfg.flashback.enableMetacity {
flashbackEnabled = cfg.flashback.enableMetacity || lib.length cfg.flashback.customSessions > 0;
flashbackWms = lib.optional cfg.flashback.enableMetacity {
wmName = "metacity";
wmLabel = "Metacity";
wmCommand = "${pkgs.gnome.metacity}/bin/metacity";
@ -67,7 +66,7 @@ in
meta = {
doc = ./gnome.md;
maintainers = teams.gnome.members;
maintainers = lib.teams.gnome.members;
};
options = {
@ -184,8 +183,8 @@ in
};
config = mkMerge [
(mkIf (cfg.enable || flashbackEnabled) {
config = lib.mkMerge [
(lib.mkIf (cfg.enable || flashbackEnabled) {
# Seed our configuration into nixos-generate-config
system.nixos-generate-config.desktopConfiguration = [''
# Enable the GNOME Desktop Environment.
@ -200,7 +199,7 @@ in
services.displayManager.sessionPackages = [ pkgs.gnome.gnome-session.sessions ];
environment.extraInit = ''
${concatMapStrings (p: ''
${lib.concatMapStrings (p: ''
if [ -d "${p}/share/gsettings-schemas/${p.name}" ]; then
export XDG_DATA_DIRS=$XDG_DATA_DIRS''${XDG_DATA_DIRS:+:}${p}/share/gsettings-schemas/${p.name}
fi
@ -214,19 +213,19 @@ in
environment.systemPackages = cfg.sessionPath;
environment.sessionVariables.GNOME_SESSION_DEBUG = mkIf cfg.debug "1";
environment.sessionVariables.GNOME_SESSION_DEBUG = lib.mkIf cfg.debug "1";
# Override GSettings schemas
environment.sessionVariables.NIX_GSETTINGS_OVERRIDES_DIR = "${nixos-gsettings-desktop-schemas}/share/gsettings-schemas/nixos-gsettings-overrides/glib-2.0/schemas";
})
(mkIf flashbackEnabled {
(lib.mkIf flashbackEnabled {
services.displayManager.sessionPackages =
let
wmNames = map (wm: wm.wmName) flashbackWms;
namesAreUnique = lib.unique wmNames == wmNames;
in
assert (assertMsg namesAreUnique "Flashback WM names must be unique.");
assert (lib.assertMsg namesAreUnique "Flashback WM names must be unique.");
map
(wm:
pkgs.gnome.gnome-flashback.mkSessionForWm {
@ -254,7 +253,7 @@ in
++ (map (wm: gnome-flashback.mkGnomeSession { inherit (wm) wmName wmLabel enableGnomePanel; }) flashbackWms);
})
(mkIf serviceCfg.core-os-services.enable {
(lib.mkIf serviceCfg.core-os-services.enable {
hardware.bluetooth.enable = mkDefault true;
hardware.pulseaudio.enable = mkDefault true;
programs.dconf.enable = true;
@ -307,7 +306,7 @@ in
];
})
(mkIf serviceCfg.core-shell.enable {
(lib.mkIf serviceCfg.core-shell.enable {
services.xserver.desktopManager.gnome.sessionPath =
let
mandatoryPackages = [
@ -329,7 +328,7 @@ in
services.gnome.gnome-user-share.enable = mkDefault true;
services.gnome.rygel.enable = mkDefault true;
services.gvfs.enable = true;
services.system-config-printer.enable = (mkIf config.services.printing.enable (mkDefault true));
services.system-config-printer.enable = (lib.mkIf config.services.printing.enable (mkDefault true));
systemd.packages = with pkgs.gnome; [
gnome-session
@ -399,7 +398,7 @@ in
})
# Adapt from https://gitlab.gnome.org/GNOME/gnome-build-meta/-/blob/gnome-45/elements/core/meta-gnome-core-utilities.bst
(mkIf serviceCfg.core-utilities.enable {
(lib.mkIf serviceCfg.core-utilities.enable {
environment.systemPackages =
with pkgs.gnome;
utils.removePackagesByName
@ -460,7 +459,7 @@ in
];
})
(mkIf serviceCfg.games.enable {
(lib.mkIf serviceCfg.games.enable {
environment.systemPackages = with pkgs.gnome; utils.removePackagesByName [
aisleriot
atomix
@ -486,7 +485,7 @@ in
})
# Adapt from https://gitlab.gnome.org/GNOME/gnome-build-meta/-/blob/3.38.0/elements/core/meta-gnome-core-developer-tools.bst
(mkIf serviceCfg.core-developer-tools.enable {
(lib.mkIf serviceCfg.core-developer-tools.enable {
environment.systemPackages = with pkgs.gnome; utils.removePackagesByName [
dconf-editor
devhelp