0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 21:50:33 +03:00

Merge pull request #113064 from worldofpeace/fix-108124

nixos/tools: make desktopConfiguation types.listOf types.lines
This commit is contained in:
WORLDofPEACE 2021-02-16 15:16:53 -05:00 committed by GitHub
commit 8a2bd1342e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 31 additions and 13 deletions

View file

@ -585,6 +585,22 @@ EOF
return $config; return $config;
} }
sub generateXserverConfig {
my $xserverEnabled = "@xserverEnabled@";
my $config = "";
if ($xserverEnabled eq "1") {
$config = <<EOF;
# Enable the X11 windowing system.
services.xserver.enable = true;
EOF
} else {
$config = <<EOF;
# Enable the X11 windowing system.
# services.xserver.enable = true;
EOF
}
}
if ($showHardwareConfig) { if ($showHardwareConfig) {
print STDOUT $hwConfig; print STDOUT $hwConfig;
@ -630,6 +646,8 @@ EOF
my $networkingDhcpConfig = generateNetworkingDhcpConfig(); my $networkingDhcpConfig = generateNetworkingDhcpConfig();
my $xserverConfig = generateXserverConfig();
(my $desktopConfiguration = <<EOF)=~s/^/ /gm; (my $desktopConfiguration = <<EOF)=~s/^/ /gm;
@desktopConfiguration@ @desktopConfiguration@
EOF EOF

View file

@ -36,6 +36,7 @@ let
path = lib.optionals (lib.elem "btrfs" config.boot.supportedFilesystems) [ pkgs.btrfs-progs ]; path = lib.optionals (lib.elem "btrfs" config.boot.supportedFilesystems) [ pkgs.btrfs-progs ];
perl = "${pkgs.perl}/bin/perl -I${pkgs.perlPackages.FileSlurp}/${pkgs.perl.libPrefix}"; perl = "${pkgs.perl}/bin/perl -I${pkgs.perlPackages.FileSlurp}/${pkgs.perl.libPrefix}";
inherit (config.system.nixos-generate-config) configuration desktopConfiguration; inherit (config.system.nixos-generate-config) configuration desktopConfiguration;
xserverEnabled = config.services.xserver.enable;
}; };
nixos-option = nixos-option =
@ -87,8 +88,8 @@ in
desktopConfiguration = mkOption { desktopConfiguration = mkOption {
internal = true; internal = true;
type = types.str; type = types.listOf types.lines;
default = ""; default = [];
description = '' description = ''
Text to preseed the desktop configuration that <literal>nixos-generate-config</literal> Text to preseed the desktop configuration that <literal>nixos-generate-config</literal>
saves to <literal>/etc/nixos/configuration.nix</literal>. saves to <literal>/etc/nixos/configuration.nix</literal>.
@ -136,6 +137,8 @@ in
# keyMap = "us"; # keyMap = "us";
# }; # };
$xserverConfig
$desktopConfiguration $desktopConfiguration
# Configure keymap in X11 # Configure keymap in X11
# services.xserver.layout = "us"; # services.xserver.layout = "us";

View file

@ -197,12 +197,11 @@ in
config = mkMerge [ config = mkMerge [
(mkIf (cfg.enable || flashbackEnabled) { (mkIf (cfg.enable || flashbackEnabled) {
# Seed our configuration into nixos-generate-config # Seed our configuration into nixos-generate-config
system.nixos-generate-config.desktopConfiguration = '' system.nixos-generate-config.desktopConfiguration = [''
# Enable the GNOME 3 Desktop Environment. # Enable the GNOME 3 Desktop Environment.
services.xserver.enable = true;
services.xserver.displayManager.gdm.enable = true; services.xserver.displayManager.gdm.enable = true;
services.xserver.desktopManager.gnome3.enable = true; services.xserver.desktopManager.gnome3.enable = true;
''; ''];
services.gnome3.core-os-services.enable = true; services.gnome3.core-os-services.enable = true;
services.gnome3.core-shell.enable = true; services.gnome3.core-shell.enable = true;

View file

@ -184,12 +184,11 @@ in
config = mkMerge [ config = mkMerge [
(mkIf cfg.enable { (mkIf cfg.enable {
# Seed our configuration into nixos-generate-config # Seed our configuration into nixos-generate-config
system.nixos-generate-config.desktopConfiguration = '' system.nixos-generate-config.desktopConfiguration = [''
# Enable the Plasma 5 Desktop Environment. # Enable the Plasma 5 Desktop Environment.
services.xserver.enable = true;
services.xserver.displayManager.sddm.enable = true; services.xserver.displayManager.sddm.enable = true;
services.xserver.desktopManager.plasma5.enable = true; services.xserver.desktopManager.plasma5.enable = true;
''; ''];
services.xserver.desktopManager.session = singleton { services.xserver.desktopManager.session = singleton {
name = "plasma5"; name = "plasma5";

View file

@ -11,12 +11,11 @@ import ./make-test-python.nix ({ lib, ... } : {
} }
''; '';
system.nixos-generate-config.desktopConfiguration = '' system.nixos-generate-config.desktopConfiguration = [''
# DESKTOP # DESKTOP
# services.xserver.enable = true; services.xserver.displayManager.gdm.enable = true;
# services.xserver.displayManager.gdm.enable = true; services.xserver.desktopManager.gnome3.enable = true;
# services.xserver.desktopManager.gnome3.enable = true; ''];
'';
}; };
testScript = '' testScript = ''
start_all() start_all()