mirror of
https://github.com/nix-community/home-manager.git
synced 2026-09-18 12:49:19 +00:00
Noctalia is a native Wayland desktop shell for people who want a polished, configurable Linux desktop without stitching together a separate bar, launcher, notification daemon, lock screen, wallpaper tool, and settings UI.
154 lines
4.2 KiB
Nix
154 lines
4.2 KiB
Nix
{
|
|
config,
|
|
pkgs,
|
|
lib,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.programs.noctalia;
|
|
jsonFormat = pkgs.formats.json { };
|
|
tomlFormat = pkgs.formats.toml { };
|
|
|
|
generateConfig =
|
|
format: name: value:
|
|
if lib.isString value then
|
|
pkgs.writeText name value
|
|
else if builtins.isPath value || lib.isStorePath value then
|
|
value
|
|
else
|
|
format.generate name value;
|
|
|
|
generateToml = generateConfig tomlFormat;
|
|
generateJson = generateConfig jsonFormat;
|
|
in
|
|
{
|
|
meta.maintainers = with lib.maintainers; [
|
|
rachitvrma
|
|
];
|
|
|
|
options.programs.noctalia = {
|
|
enable = lib.mkEnableOption "noctalia, a lightweight Wayland shell and bar";
|
|
|
|
systemd.enable = lib.mkEnableOption "a systemd user service for noctalia";
|
|
|
|
package = lib.mkPackageOption pkgs "noctalia" { nullable = true; };
|
|
|
|
checkConfig = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = true;
|
|
description = "Validate the configuration file at build time.";
|
|
};
|
|
|
|
settings = lib.mkOption {
|
|
type =
|
|
with lib.types;
|
|
oneOf [
|
|
tomlFormat.type
|
|
str
|
|
path
|
|
];
|
|
default = { };
|
|
description = ''
|
|
Default settings for noctalia, can be written as:
|
|
- A Nix attrset (converted to TOML via nixpkgs' tomlFormat)
|
|
- A raw TOML string
|
|
- A path to a `.toml` file
|
|
|
|
See <https://docs.noctalia.dev/v5> for more information and examples.
|
|
|
|
Note: these settings can still be overwritten at runtime via the settings menu.
|
|
'';
|
|
example = lib.literalExpression ''
|
|
{
|
|
shell = {
|
|
font = "JetBrainsMono Nerd Font";
|
|
settings_show_advanced = true;
|
|
};
|
|
|
|
theme = {
|
|
mode = "dark";
|
|
source = "builtin";
|
|
builtin = "Catppuccin";
|
|
};
|
|
}
|
|
'';
|
|
};
|
|
|
|
customPalettes = lib.mkOption {
|
|
type =
|
|
with lib.types;
|
|
attrsOf (oneOf [
|
|
jsonFormat.type
|
|
str
|
|
path
|
|
]);
|
|
default = { };
|
|
description = ''
|
|
Custom color palettes, keyed by name. Each value can be:
|
|
- A Nix attrset (converted to JSON)
|
|
- A raw JSON string
|
|
- A path to a {file}`.json` file
|
|
|
|
See <https://docs.noctalia.dev/v5/theming/#custom_palette>.
|
|
'';
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
assertions = [
|
|
(lib.hm.assertions.assertPlatform "programs.noctalia" pkgs lib.platforms.linux)
|
|
|
|
{
|
|
assertion = !cfg.systemd.enable || cfg.package != null;
|
|
message = "programs.noctalia.package cannot be null when programs.noctalia.systemd.enable is true";
|
|
}
|
|
];
|
|
systemd.user.services.noctalia = lib.mkIf cfg.systemd.enable {
|
|
Unit = {
|
|
Description = "Noctalia - A lightweight Wayland shell and bar";
|
|
Documentation = "https://docs.noctalia.dev/v5/";
|
|
PartOf = [ config.wayland.systemd.target ];
|
|
After = [ config.wayland.systemd.target ];
|
|
X-Restart-Triggers =
|
|
lib.optional (cfg.settings != { }) "${config.xdg.configFile."noctalia/config.toml".source}"
|
|
++ lib.mapAttrsToList (
|
|
name: _: "${config.xdg.configFile."noctalia/palettes/${name}.json".source}"
|
|
) cfg.customPalettes;
|
|
};
|
|
|
|
Service = {
|
|
ExecStart = lib.getExe cfg.package;
|
|
Restart = "on-failure";
|
|
};
|
|
|
|
Install.WantedBy = [ config.wayland.systemd.target ];
|
|
};
|
|
|
|
home.packages = lib.optional (cfg.package != null) cfg.package;
|
|
|
|
xdg = {
|
|
configFile = lib.mkMerge [
|
|
(lib.mkIf (cfg.settings != { }) {
|
|
"noctalia/config.toml".source =
|
|
let
|
|
rawConfig = generateToml "config.toml" cfg.settings;
|
|
in
|
|
if cfg.checkConfig && cfg.package != null then
|
|
pkgs.runCommand "noctalia-config.toml" { } ''
|
|
${lib.getExe cfg.package} config validate ${rawConfig}
|
|
cp ${rawConfig} $out
|
|
''
|
|
else
|
|
rawConfig;
|
|
})
|
|
(lib.mapAttrs' (
|
|
name: palette:
|
|
lib.nameValuePair "noctalia/palettes/${name}.json" {
|
|
source = generateJson "${name}-palette.json" palette;
|
|
}
|
|
) cfg.customPalettes)
|
|
];
|
|
};
|
|
};
|
|
}
|