Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ff34fe762e | |||
| 7e4407a1f8 | |||
| 539fb26791 | |||
| 79b26ddfda | |||
| b8961fb47d | |||
| 4851f745d8 | |||
| 59b5cfb47c | |||
| a8364f21ca |
@@ -0,0 +1,61 @@
|
||||
# mibook: choose terminal-only vs desktop at boot
|
||||
|
||||
## Goal
|
||||
|
||||
Let mibook boot to a text console by default, with KDE fully installed and
|
||||
launchable on demand. The user decides after boot whether they need the
|
||||
graphical desktop, without rebuilding the system.
|
||||
|
||||
## Behavior
|
||||
|
||||
- mibook boots to a text console (`multi-user.target`). SDDM and Plasma do
|
||||
**not** start automatically.
|
||||
- KDE (SDDM + Plasma 6) remains fully installed.
|
||||
- Running `desktop` in the terminal starts the SDDM display manager, which
|
||||
presents the graphical login screen; logging in there enters a Plasma 6
|
||||
session.
|
||||
- No reverse command. To return to a text console, stop the display manager
|
||||
(`sudo systemctl stop display-manager`) or reboot.
|
||||
- Other machines that enable the `kde-desktop` profile are unaffected; their
|
||||
desktop still starts on boot.
|
||||
|
||||
## Implementation
|
||||
|
||||
### `modules/environments/kde-desktop/default.nix`
|
||||
|
||||
Add an opt-out option to the existing profile:
|
||||
|
||||
- New option `my.profiles.kde-desktop.startOnBoot`, a boolean defaulting to
|
||||
`true`. The default preserves the current behavior for every consumer.
|
||||
- The existing `config` block (SDDM, Plasma 6, user packages) stays enabled
|
||||
whenever the profile is enabled, regardless of `startOnBoot`.
|
||||
- When `startOnBoot = false`, additionally apply:
|
||||
- `systemd.services.display-manager.wantedBy = lib.mkForce [ ];` so SDDM is
|
||||
defined but not pulled in by any boot target.
|
||||
- `systemd.defaultUnit = "multi-user.target";` so the boot target is the
|
||||
text console.
|
||||
- A `desktop` command provided via
|
||||
`pkgs.writeShellScriptBin "desktop" "exec sudo systemctl start display-manager.service"`,
|
||||
added to `environment.systemPackages`.
|
||||
|
||||
### `machines/mibook/environments.nix`
|
||||
|
||||
Set `kde-desktop.startOnBoot = false;` alongside the existing
|
||||
`kde-desktop.enable = true;`.
|
||||
|
||||
## Testing / verification
|
||||
|
||||
- `nix build '.#nixosConfigurations.mibook.config.system.build.toplevel'`
|
||||
builds without error.
|
||||
- After `nixos-rebuild switch` on mibook: system boots to a TTY, no SDDM;
|
||||
running `desktop` brings up the SDDM login and a working Plasma session.
|
||||
- Confirm jupiter (or any non-mibook consumer) is unchanged: its evaluated
|
||||
`systemd.defaultUnit` / display-manager wantedBy are not altered.
|
||||
|
||||
## Trade-offs
|
||||
|
||||
- `desktop` relies on `sudo`; the user has sudo access, so no extra
|
||||
configuration is required.
|
||||
- Chose "boot to terminal, launch on demand" over a GRUB boot-menu entry
|
||||
because it is more robust across NixOS generations and needs no fragile
|
||||
static kernel entries.
|
||||
Generated
+30
-33
@@ -21,11 +21,11 @@
|
||||
"nixpkgs-lib": "nixpkgs-lib"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1778716662,
|
||||
"narHash": "sha256-m1Yf0wZ8j1OHjTc2UwHwyQRSnNeSgLJOd7q5Y45hzi4=",
|
||||
"lastModified": 1782949081,
|
||||
"narHash": "sha256-vp6Y/Grm98ESt6ceOkWiHWyZRDV3J1RID4w+6NWK9yA=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "f7c1a2d347e4c52d5fb8d10cb4d94b5884e546fb",
|
||||
"rev": "17c9d6cdfc60c64f4ee8d306f9bc0b4ccb51481e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -42,11 +42,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1778716662,
|
||||
"narHash": "sha256-m1Yf0wZ8j1OHjTc2UwHwyQRSnNeSgLJOd7q5Y45hzi4=",
|
||||
"lastModified": 1782949081,
|
||||
"narHash": "sha256-vp6Y/Grm98ESt6ceOkWiHWyZRDV3J1RID4w+6NWK9yA=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "f7c1a2d347e4c52d5fb8d10cb4d94b5884e546fb",
|
||||
"rev": "17c9d6cdfc60c64f4ee8d306f9bc0b4ccb51481e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -60,20 +60,17 @@
|
||||
"flake-compat": [
|
||||
"nix"
|
||||
],
|
||||
"gitignore": [
|
||||
"nix"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"nix",
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1781733627,
|
||||
"narHash": "sha256-U3yTuGBnmXvXoQI3qkpfEDsn9RovQPAjN7ndRco+3u0=",
|
||||
"lastModified": 1783008725,
|
||||
"narHash": "sha256-jGiy6+sxjNWXSjp25uoJuNfyH9zBK1PEDY0lVoL4ibQ=",
|
||||
"owner": "cachix",
|
||||
"repo": "git-hooks.nix",
|
||||
"rev": "3bbec39bc90eadfa031e6f3b77272f3f60803e39",
|
||||
"rev": "bca82caa46d5ec0f5d422c61fb1e30bc51313cbe",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -92,11 +89,11 @@
|
||||
"nixpkgs-regression": "nixpkgs-regression"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1782337899,
|
||||
"narHash": "sha256-Imevyelg3r2N5iDonnGdOKGRiB56m3HgVFAljTB3CLU=",
|
||||
"lastModified": 1784762557,
|
||||
"narHash": "sha256-R/r6jRnANV50c8F5Fz5+1Q1moab0IGWRk+cg5ME2nMY=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nix",
|
||||
"rev": "3887a906b178836818a62e8eba666ad652e8a388",
|
||||
"rev": "d10c84cd0cc0efdcb29cf2611caf5fbcd10fa071",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -146,11 +143,11 @@
|
||||
"nixpkgs": "nixpkgs_2"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1782379505,
|
||||
"narHash": "sha256-zPvPiU+a7pqtH47xrtZLNRABJKpOjfZQclDbcvNtH+I=",
|
||||
"lastModified": 1784723954,
|
||||
"narHash": "sha256-1CfD8ZUjCkTgjsneLZ/lxCHhgDfqxxE7/GX0MmsgiqA=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixos-hardware",
|
||||
"rev": "603d3afd1b6145bd66e97ae38a34d91c95df70cf",
|
||||
"rev": "a017f5b72210026af5b3ac5949f08d94380a6fbd",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -161,11 +158,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1780902259,
|
||||
"narHash": "sha256-YMnBf9lk/LYgvqfmSSJuOGigtRs5Lsy26pJHVlR9yMY=",
|
||||
"rev": "bd0ff2d3eac24699c3664d5966b9ef36f388e2ca",
|
||||
"lastModified": 1783148766,
|
||||
"narHash": "sha256-H9+N+GFtsbVC8ZniHliChM7ndizxtqVZs6bnGOLM3WQ=",
|
||||
"rev": "a50de1b7d8a586adc18d2395c19de7d6058e6030",
|
||||
"type": "tarball",
|
||||
"url": "https://releases.nixos.org/nixos/26.05/nixos-26.05.1550.bd0ff2d3eac2/nixexprs.tar.xz"
|
||||
"url": "https://releases.nixos.org/nixos/26.05/nixos-26.05.4193.a50de1b7d8a5/nixexprs.tar.xz"
|
||||
},
|
||||
"original": {
|
||||
"type": "tarball",
|
||||
@@ -190,11 +187,11 @@
|
||||
},
|
||||
"nixpkgs-lib": {
|
||||
"locked": {
|
||||
"lastModified": 1777168982,
|
||||
"narHash": "sha256-GOkGPcboWE9BmGCRMLX3worL4EMnsnG8MyKmXNeYuhQ=",
|
||||
"lastModified": 1782614948,
|
||||
"narHash": "sha256-ePjCwr1sNm9NYUqywL7QfK3JnlS015msC+eBu2zKlp8=",
|
||||
"owner": "nix-community",
|
||||
"repo": "nixpkgs.lib",
|
||||
"rev": "f5901329dade4a6ea039af1433fb087bd9c1fe14",
|
||||
"rev": "db3f255737b94216eb71cce308e2912cf6bc2d7c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -221,11 +218,11 @@
|
||||
},
|
||||
"nixpkgs-unstable": {
|
||||
"locked": {
|
||||
"lastModified": 1782467914,
|
||||
"narHash": "sha256-inDx/w70OSJoJPqtKh0BrzAsbZZhpya7YgS43jHnhwg=",
|
||||
"rev": "e73de5be04e0eff4190a1432b946d469c794e7b4",
|
||||
"lastModified": 1784796856,
|
||||
"narHash": "sha256-vwxWgF+Gj276WznzGb1LxGsK/39HaQwgQXiU3EkC844=",
|
||||
"rev": "e2587caef70cea85dd97d7daab492899902dbf5d",
|
||||
"type": "tarball",
|
||||
"url": "https://releases.nixos.org/nixos/unstable/nixos-26.11pre1022855.e73de5be04e0/nixexprs.tar.xz"
|
||||
"url": "https://releases.nixos.org/nixos/unstable/nixos-26.11pre1040357.e2587caef70c/nixexprs.tar.xz"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
@@ -248,11 +245,11 @@
|
||||
},
|
||||
"nixpkgs_3": {
|
||||
"locked": {
|
||||
"lastModified": 1782375420,
|
||||
"narHash": "sha256-f+/IH5ng5P91VHrhcNxqpW2RYDySD68V1fcX00COQy4=",
|
||||
"rev": "4062d36ebeae843c750011eef6b61ec9a9dbc9a9",
|
||||
"lastModified": 1784707089,
|
||||
"narHash": "sha256-DUedXhD2Rg8q4Xyd07Sb90eZGy4gg6W+Vl/WbLNwAZo=",
|
||||
"rev": "b3fe9581c9061c749abef42b6d4ee7b7c05c33fa",
|
||||
"type": "tarball",
|
||||
"url": "https://releases.nixos.org/nixos/26.05/nixos-26.05.3250.4062d36ebeae/nixexprs.tar.xz"
|
||||
"url": "https://releases.nixos.org/nixos/26.05/nixos-26.05.5845.b3fe9581c906/nixexprs.tar.xz"
|
||||
},
|
||||
"original": {
|
||||
"id": "nixpkgs",
|
||||
|
||||
@@ -44,6 +44,14 @@
|
||||
|
||||
services.openssh.enable = true;
|
||||
|
||||
# KDE (PowerDevil) power settings: do nothing on lid close while on AC power.
|
||||
# Shipped as a system-wide default; KConfig cascades so a user's own
|
||||
# ~/.config/powerdevilrc will override this if present.
|
||||
environment.etc."xdg/powerdevilrc".text = ''
|
||||
[AC][SuspendAndShutdown]
|
||||
LidAction=0
|
||||
'';
|
||||
|
||||
system = {
|
||||
stateVersion = "23.05";
|
||||
autoUpgrade.enable = true;
|
||||
|
||||
@@ -6,6 +6,7 @@ in
|
||||
{
|
||||
my.profiles = {
|
||||
kde-desktop.enable = true;
|
||||
kde-desktop.startOnBoot = false;
|
||||
zsh.enable = true;
|
||||
apps = {
|
||||
desktop_apps = true;
|
||||
|
||||
@@ -11,9 +11,19 @@ in
|
||||
{
|
||||
options.my.profiles.kde-desktop = with lib; {
|
||||
enable = mkEnableOption "KDE Desktop Environment";
|
||||
startOnBoot = mkOption {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
description = ''
|
||||
Whether the display manager (SDDM) starts automatically at boot.
|
||||
When false, the system boots to a text console and KDE can be
|
||||
launched on demand with the `desktop` command.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
config = lib.mkIf cfg.enable (lib.mkMerge [
|
||||
{
|
||||
services = {
|
||||
displayManager.sddm.enable = true;
|
||||
displayManager.sddm.wayland.enable = true;
|
||||
@@ -23,5 +33,15 @@ in
|
||||
# Programms can be added here...
|
||||
numix-icon-theme
|
||||
];
|
||||
};
|
||||
}
|
||||
(lib.mkIf (!cfg.startOnBoot) {
|
||||
# Boot to a text console; SDDM stays installed but is not pulled in
|
||||
# by any boot target. Launch KDE on demand with `desktop`.
|
||||
systemd.services.display-manager.wantedBy = lib.mkForce [ ];
|
||||
systemd.defaultUnit = lib.mkForce "multi-user.target";
|
||||
environment.systemPackages = [
|
||||
(pkgs.writeShellScriptBin "desktop" "exec sudo systemctl start display-manager.service")
|
||||
];
|
||||
})
|
||||
]);
|
||||
}
|
||||
Reference in New Issue
Block a user