-
-
Notifications
You must be signed in to change notification settings - Fork 13.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos/modules/programs/dconf: redesign profiles #189099
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ lib }: | ||
|
||
# This module contains helpers for the `programs.dconf` NixOS module | ||
|
||
rec { | ||
types = { | ||
tuple = "_tuple"; | ||
}; | ||
|
||
mkTuple = _elements: { | ||
inherit _elements; | ||
|
||
_type = types.tuple; | ||
}; | ||
} | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,6 +125,18 @@ | |
would in NixOS 22.05 and earlier. | ||
</para> | ||
</listitem> | ||
<listitem> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We no longer do xml files in nixos/* . Also please carry over the other changelog to 23.05 |
||
<para> | ||
The <literal>programs.dconf</literal> module now supports | ||
configuration using the Nix language. This allows you to | ||
configure settings of apps and DEs (if they use | ||
<literal>dconf</literal>) declaratively without having to use | ||
<literal>extraGSettingsOverrides</literal> which has some | ||
problems noted in | ||
<link xlink:href="https://github.com/NixOS/nixpkgs/issues/54150">this | ||
issue</link>. | ||
</para> | ||
</listitem> | ||
<listitem> | ||
<para> | ||
PHP now defaults to PHP 8.1, updated from 8.0. | ||
|
@@ -651,6 +663,14 @@ | |
<literal>emacs-gtk</literal>. | ||
</para> | ||
</listitem> | ||
<listitem> | ||
<para> | ||
The option <literal>programs.dconf.packages</literal> has been | ||
removed, use | ||
<literal>programs.dconf.profiles.user.databases</literal> | ||
instead. | ||
</para> | ||
</listitem> | ||
<listitem> | ||
<para> | ||
riak package removed along with | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,6 +51,11 @@ In addition to numerous new and upgraded packages, this release has the followin | |
Alternatively, you can remove the `hostPlatform` line and use NixOS like you | ||
would in NixOS 22.05 and earlier. | ||
|
||
- The `programs.dconf` module now supports configuration using the Nix language. | ||
This allows you to configure settings of apps and DEs (if they use `dconf`) | ||
declaratively without having to use `extraGSettingsOverrides` which has some | ||
problems noted in [this issue](https://github.com/NixOS/nixpkgs/issues/54150). | ||
|
||
- PHP now defaults to PHP 8.1, updated from 8.0. | ||
|
||
- `protonup` has been aliased to and replaced by `protonup-ng` due to upstream not maintaining it. | ||
|
@@ -212,6 +217,8 @@ Available as [services.patroni](options.html#opt-services.patroni.enable). | |
- Emacs now uses the Lucid toolkit by default instead of GTK because of stability and compatibility issues. | ||
Users who still wish to remain using GTK can do so by using `emacs-gtk`. | ||
|
||
- The option `programs.dconf.packages` has been removed, use `programs.dconf.profiles.user.databases` instead. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can definitely be a mkRenamedOption |
||
|
||
- riak package removed along with `services.riak` module, due to lack of maintainer to update the package. | ||
|
||
- ppd files in `pkgs.cups-drv-rastertosag-gdi` are now gzipped. If you refer to such a ppd file with its path (e.g. via [hardware.printers.ensurePrinters](options.html#opt-hardware.printers.ensurePrinters)) you will need to append `.gz` to the path. | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,56 +1,55 @@ | ||||||
{ config, lib, pkgs, ... }: | ||||||
|
||||||
with lib; | ||||||
|
||||||
let | ||||||
cfg = config.programs.dconf; | ||||||
cfgDir = pkgs.symlinkJoin { | ||||||
name = "dconf-system-config"; | ||||||
paths = map (x: "${x}/etc/dconf") cfg.packages; | ||||||
postBuild = '' | ||||||
mkdir -p $out/profile | ||||||
mkdir -p $out/db | ||||||
'' + ( | ||||||
concatStringsSep "\n" ( | ||||||
mapAttrsToList ( | ||||||
name: path: '' | ||||||
ln -s ${path} $out/profile/${name} | ||||||
'' | ||||||
) cfg.profiles | ||||||
) | ||||||
) + '' | ||||||
${pkgs.dconf}/bin/dconf update $out/db | ||||||
''; | ||||||
}; | ||||||
|
||||||
asFileDb = val: | ||||||
let db = | ||||||
if lib.isAttrs val && !lib.isDerivation val then | ||||||
pkgs.dconf-utils.mkDconfDb "${pkgs.writeTextDir "dconf/db" (lib.generators.toDconfINI val)}/dconf" | ||||||
else val; | ||||||
in "file-db:${db}"; | ||||||
in | ||||||
{ | ||||||
###### interface | ||||||
imports = [ | ||||||
(lib.mkRemovedOptionModule [ "programs" "dconf" "packages" ] "This option is not supported anymore, you should use `programs.dconf.profiles.<profile>.databases` instead.") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We canno use mkRenamedOption here? |
||||||
]; | ||||||
|
||||||
options = { | ||||||
programs.dconf = { | ||||||
enable = mkEnableOption (lib.mdDoc "dconf"); | ||||||
enable = lib.mkEnableOption (lib.mdDoc "dconf"); | ||||||
|
||||||
profiles = lib.mkOption { | ||||||
type = with lib.types; attrsOf (submodule { | ||||||
options = { | ||||||
enableUserDb = lib.mkOption { | ||||||
type = bool; | ||||||
default = true; | ||||||
description = lib.mdDoc "Add `user-db:user` at the beginning of the profile."; | ||||||
}; | ||||||
|
||||||
profiles = mkOption { | ||||||
type = types.attrsOf types.path; | ||||||
default = {}; | ||||||
description = lib.mdDoc "Set of dconf profile files, installed at {file}`/etc/dconf/profiles/«name»`."; | ||||||
internal = true; | ||||||
databases = lib.mkOption { | ||||||
type = with lib.types; listOf (oneOf [ attrs str path package ]); | ||||||
default = []; | ||||||
description = lib.mdDoc "List of data sources for the profile. An element can be an attrset, or the path of an already compiled database."; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing explanation of string argument. |
||||||
}; | ||||||
}; | ||||||
}); | ||||||
description = lib.mdDoc "Attrset of dconf profiles."; | ||||||
}; | ||||||
|
||||||
packages = mkOption { | ||||||
type = types.listOf types.package; | ||||||
default = []; | ||||||
description = lib.mdDoc "A list of packages which provide dconf profiles and databases in {file}`/etc/dconf`."; | ||||||
defaultProfile = lib.mkOption { | ||||||
type = with lib.types; nullOr str; | ||||||
default = null; | ||||||
description = lib.mdDoc "The default dconf profile."; | ||||||
}; | ||||||
}; | ||||||
}; | ||||||
|
||||||
###### implementation | ||||||
|
||||||
config = mkIf (cfg.profiles != {} || cfg.enable) { | ||||||
environment.etc.dconf = mkIf (cfg.profiles != {} || cfg.packages != []) { | ||||||
source = cfgDir; | ||||||
}; | ||||||
config = lib.mkIf cfg.enable { | ||||||
environment.etc = lib.attrsets.mapAttrs' (name: value: lib.nameValuePair "dconf/profile/${name}" { | ||||||
text = lib.concatMapStrings (x: "${x}\n") ((lib.optional value.enableUserDb "user-db:user") ++ (map asFileDb value.databases)); | ||||||
}) cfg.profiles; | ||||||
|
||||||
services.dbus.packages = [ pkgs.dconf ]; | ||||||
|
||||||
|
@@ -59,8 +58,9 @@ in | |||||
# For dconf executable | ||||||
environment.systemPackages = [ pkgs.dconf ]; | ||||||
|
||||||
# Needed for unwrapped applications | ||||||
environment.sessionVariables.GIO_EXTRA_MODULES = mkIf cfg.enable [ "${pkgs.dconf.lib}/lib/gio/modules" ]; | ||||||
environment.sessionVariables = { | ||||||
# Needed for unwrapped applications | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't we rather fix those or is the overhead so big, that we rather not wrap this at all? |
||||||
GIO_EXTRA_MODULES = [ "${pkgs.dconf.lib}/lib/gio/modules" ]; | ||||||
} // (if cfg.defaultProfile != null then { DCONF_PROFILE = cfg.defaultProfile; } else {}); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
}; | ||||||
|
||||||
} |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -229,39 +229,13 @@ in | |||||||
|
||||||||
systemd.user.services.dbus.wantedBy = [ "default.target" ]; | ||||||||
|
||||||||
programs.dconf.profiles.gdm = | ||||||||
let | ||||||||
customDconf = pkgs.writeTextFile { | ||||||||
name = "gdm-dconf"; | ||||||||
destination = "/dconf/gdm-custom"; | ||||||||
text = '' | ||||||||
${optionalString (!cfg.gdm.autoSuspend) '' | ||||||||
[org/gnome/settings-daemon/plugins/power] | ||||||||
sleep-inactive-ac-type='nothing' | ||||||||
sleep-inactive-battery-type='nothing' | ||||||||
sleep-inactive-ac-timeout=0 | ||||||||
sleep-inactive-battery-timeout=0 | ||||||||
''} | ||||||||
''; | ||||||||
programs.dconf.profiles.gdm.databases = [ "${gdm}/share/gdm/greeter-dconf-defaults" ] ++ lib.lists.optional cfg.gdm.autoSuspend { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
org.gnome.settings-daemon.plugins.power = { | ||||||||
sleep-inactive-ac-type = "nothing"; | ||||||||
sleep-inactive-battery-type = "nothing"; | ||||||||
sleep-inactive-ac-timeout = 0; | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we should require an explicit integer type (eg. Alternative would be making the dconf module internal and creating a separate GSettings module that would also perform validation against schema. |
||||||||
sleep-inactive-battery-timeout = 0; | ||||||||
}; | ||||||||
|
||||||||
customDconfDb = pkgs.stdenv.mkDerivation { | ||||||||
name = "gdm-dconf-db"; | ||||||||
buildCommand = '' | ||||||||
${pkgs.dconf}/bin/dconf compile $out ${customDconf}/dconf | ||||||||
''; | ||||||||
}; | ||||||||
in pkgs.stdenv.mkDerivation { | ||||||||
name = "dconf-gdm-profile"; | ||||||||
buildCommand = '' | ||||||||
# Check that the GDM profile starts with what we expect. | ||||||||
if [ $(head -n 1 ${gdm}/share/dconf/profile/gdm) != "user-db:user" ]; then | ||||||||
echo "GDM dconf profile changed, please update gdm.nix" | ||||||||
exit 1 | ||||||||
fi | ||||||||
# Insert our custom DB behind it. | ||||||||
sed '2ifile-db:${customDconfDb}' ${gdm}/share/dconf/profile/gdm > $out | ||||||||
''; | ||||||||
}; | ||||||||
|
||||||||
# Use AutomaticLogin if delay is zero, because it's immediate. | ||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ runCommand, dconf }: | ||
|
||
{ | ||
# Builds a dconf database from a keyfile directory | ||
mkDconfDb = dir: runCommand "dconf-db" { | ||
nativeBuildInputs = [ dconf ]; | ||
} '' | ||
dconf compile $out ${dir} | ||
''; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3703,6 +3703,8 @@ with pkgs; | |
|
||
dconf = callPackage ../development/libraries/dconf { }; | ||
|
||
dconf-utils = callPackage ../development/libraries/dconf/utils.nix { }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is very tiny, please move it into dconf itself. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
ddate = callPackage ../tools/misc/ddate { }; | ||
|
||
ddosify = callPackage ../development/tools/ddosify { }; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we even need this here? Why not put it into the module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This incomplete implementation of GVariant type system. Ideally, we would have a full implementation like home-manager has and having it separately is nicer for using it in different context, including tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If that is the full one, we should keep it separate. Maybe add a comment, that it isn't complete and maybe with a ref to hm.