Parametrize the username a bit more
This commit is contained in:
parent
2d5b7e794a
commit
2caf4884db
32 changed files with 288 additions and 239 deletions
modules/home-manager
135
modules/home-manager/compat/hyprpaper.nix
Normal file
135
modules/home-manager/compat/hyprpaper.nix
Normal file
|
@ -0,0 +1,135 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.services.hyprpaper;
|
||||
toHyprconf = { attrs, indentLevel ? 0, importantPrefixes ? [ "$" ], }:
|
||||
let
|
||||
inherit (lib)
|
||||
all concatMapStringsSep concatStrings concatStringsSep filterAttrs foldl
|
||||
generators hasPrefix isAttrs isList mapAttrsToList replicate;
|
||||
|
||||
initialIndent = concatStrings (replicate indentLevel " ");
|
||||
|
||||
toHyprconf' = indent: attrs:
|
||||
let
|
||||
sections =
|
||||
filterAttrs (n: v: isAttrs v || (isList v && all isAttrs v)) attrs;
|
||||
|
||||
mkSection = n: attrs:
|
||||
if lib.isList attrs then
|
||||
(concatMapStringsSep "\n" (a: mkSection n a) attrs)
|
||||
else ''
|
||||
${indent}${n} {
|
||||
${toHyprconf' " ${indent}" attrs}${indent}}
|
||||
'';
|
||||
|
||||
mkFields = generators.toKeyValue {
|
||||
listsAsDuplicateKeys = true;
|
||||
inherit indent;
|
||||
};
|
||||
|
||||
allFields =
|
||||
filterAttrs (n: v: !(isAttrs v || (isList v && all isAttrs v)))
|
||||
attrs;
|
||||
|
||||
isImportantField = n: _:
|
||||
foldl (acc: prev: if hasPrefix prev n then true else acc) false
|
||||
importantPrefixes;
|
||||
|
||||
importantFields = filterAttrs isImportantField allFields;
|
||||
|
||||
fields = builtins.removeAttrs allFields
|
||||
(mapAttrsToList (n: _: n) importantFields);
|
||||
in
|
||||
mkFields importantFields
|
||||
+ concatStringsSep "\n" (mapAttrsToList mkSection sections)
|
||||
+ mkFields fields;
|
||||
in
|
||||
toHyprconf' initialIndent attrs;
|
||||
in
|
||||
{
|
||||
meta.maintainers = [ maintainers.khaneliman maintainers.fufexan ];
|
||||
|
||||
options.services.hyprpaper = {
|
||||
enable = mkEnableOption "Hyprpaper, Hyprland's wallpaper daemon";
|
||||
|
||||
package = mkPackageOption pkgs "hyprpaper" { };
|
||||
|
||||
settings = lib.mkOption {
|
||||
type = with lib.types;
|
||||
let
|
||||
valueType = nullOr
|
||||
(oneOf [
|
||||
bool
|
||||
int
|
||||
float
|
||||
str
|
||||
path
|
||||
(attrsOf valueType)
|
||||
(listOf valueType)
|
||||
]) // {
|
||||
description = "Hyprpaper configuration value";
|
||||
};
|
||||
in
|
||||
valueType;
|
||||
default = { };
|
||||
description = ''
|
||||
hyprpaper configuration written in Nix. Entries with the same key
|
||||
should be written as lists. Variables' and colors' names should be
|
||||
quoted. See <https://wiki.hyprland.org/Hypr-Ecosystem/hyprpaper/> for more examples.
|
||||
'';
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
ipc = "on";
|
||||
splash = false;
|
||||
splash_offset = 2.0;
|
||||
|
||||
preload =
|
||||
[ "/share/wallpapers/buttons.png" "/share/wallpapers/cat_pacman.png" ];
|
||||
|
||||
wallpaper = [
|
||||
"DP-3,/share/wallpapers/buttons.png"
|
||||
"DP-1,/share/wallpapers/cat_pacman.png"
|
||||
];
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
||||
importantPrefixes = lib.mkOption {
|
||||
type = with lib.types; listOf str;
|
||||
default = [ "$" ];
|
||||
example = [ "$" ];
|
||||
description = ''
|
||||
List of prefix of attributes to source at the top of the config.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
xdg.configFile."hypr/hyprpaper.conf" = mkIf (cfg.settings != { }) {
|
||||
text = toHyprconf {
|
||||
attrs = cfg.settings;
|
||||
inherit (cfg) importantPrefixes;
|
||||
};
|
||||
};
|
||||
|
||||
systemd.user.services.hyprpaper = {
|
||||
Install = { WantedBy = [ "graphical-session.target" ]; };
|
||||
|
||||
Unit = {
|
||||
ConditionEnvironment = "WAYLAND_DISPLAY";
|
||||
Description = "hyprpaper";
|
||||
After = [ "graphical-session-pre.target" ];
|
||||
PartOf = [ "graphical-session.target" ];
|
||||
X-Restart-Triggers =
|
||||
[ "${config.xdg.configFile."hypr/hyprpaper.conf".source}" ];
|
||||
};
|
||||
|
||||
Service = {
|
||||
ExecStart = "${getExe cfg.package}";
|
||||
Restart = "always";
|
||||
RestartSec = "10";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -3,16 +3,17 @@
|
|||
{
|
||||
# example = import ./example.nix;
|
||||
|
||||
# Modules not yet added to the stable branch
|
||||
bemenu = import ./compat/bemenu.nix;
|
||||
hyprpaper = import ./compat/hyprpaper.nix;
|
||||
k9s = import ./compat/k9s.nix;
|
||||
|
||||
# Personal things
|
||||
dev = import ./dev.nix;
|
||||
firefox = import ./firefox;
|
||||
monitors = import ./monitors.nix;
|
||||
satellite-dev = import ./satellite-dev.nix;
|
||||
satellite-persistence = import ./persistence.nix;
|
||||
|
||||
# Should upstream
|
||||
discord = import ./discord.nix;
|
||||
hyprpaper = import ./hyprpaper.nix;
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ in
|
|||
{
|
||||
options.programs.discord = {
|
||||
enable = lib.mkEnableOption "Discord";
|
||||
enableOpenASAR = lib.mkEnableOption "openASAR";
|
||||
disableUpdateCheck = lib.mkEnableOption "update skipping";
|
||||
enableDevtools = lib.mkEnableOption "devtools";
|
||||
|
||||
|
@ -16,19 +15,13 @@ in
|
|||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
home.packages =
|
||||
[
|
||||
(if cfg.enableOpenASAR
|
||||
then cfg.package.override { withOpenASAR = true; }
|
||||
else cfg.package)
|
||||
];
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
xdg.configFile."discord/settings.json".text =
|
||||
builtins.toJSON
|
||||
{
|
||||
SKIP_HOST_UPDATE = cfg.disableUpdateCheck;
|
||||
DANGEROUS_ENABLE_DEVTOOLS_ONLY_ENABLE_IF_YOU_KNOW_WHAT_YOURE_DOING = cfg.enableDevtools;
|
||||
};
|
||||
builtins.toJSON {
|
||||
SKIP_HOST_UPDATE = cfg.disableUpdateCheck;
|
||||
DANGEROUS_ENABLE_DEVTOOLS_ONLY_ENABLE_IF_YOU_KNOW_WHAT_YOURE_DOING = cfg.enableDevtools;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,113 +0,0 @@
|
|||
# TODO: add maintainers and upstream into home-manager
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.hyprpaper;
|
||||
mkWallpaper = { mode, image, monitor, ... }:
|
||||
let
|
||||
monitorString = lib.optionalString (monitor != null) monitor;
|
||||
modeString = lib.optionalString (mode == "contain") "contain:";
|
||||
in
|
||||
"wallpaper=${monitorString},${modeString}${image}";
|
||||
in
|
||||
{
|
||||
options.services.hyprpaper = {
|
||||
enable = mkEnableOption "hyprpaper";
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.hyprpaper;
|
||||
defaultText = "pkgs.hyprpaper";
|
||||
description = ''
|
||||
hyprpaper derivation to use.
|
||||
'';
|
||||
};
|
||||
|
||||
# TODO: what should the default value be for this?
|
||||
systemdTarget = mkOption {
|
||||
type = types.str;
|
||||
description = ''
|
||||
Systemd target to bind to.
|
||||
'';
|
||||
};
|
||||
|
||||
preload = mkOption {
|
||||
type = types.listOf (types.oneOf [ types.str types.path ]);
|
||||
default = [ ];
|
||||
example = [ "~/background.png" ];
|
||||
description = "List of images to preload";
|
||||
};
|
||||
|
||||
wallpapers = mkOption {
|
||||
type = types.listOf (types.submodule (_: {
|
||||
options = {
|
||||
monitor = mkOption {
|
||||
type = types.nullOr types.str;
|
||||
default = null;
|
||||
example = "eDP-1";
|
||||
description = ''
|
||||
Monitor to use for the wallpaper.
|
||||
Either leave empty as a wildcard,
|
||||
type the name of the monitor, or
|
||||
include the monitor's description
|
||||
prefixed with `desc:`.
|
||||
'';
|
||||
};
|
||||
|
||||
image = mkOption {
|
||||
type = types.oneOf [ types.str types.path ];
|
||||
default = null;
|
||||
example = "~/background.png";
|
||||
description = "Image to use as wallpaper";
|
||||
};
|
||||
|
||||
mode = mkOption {
|
||||
type = lib.types.enum [ "cover" "contain" ];
|
||||
default = "cover";
|
||||
example = "contain";
|
||||
description = "The way to display the wallpaper";
|
||||
};
|
||||
};
|
||||
}));
|
||||
|
||||
default = [ ];
|
||||
description = "List of wallpapers to set";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
assertions = [
|
||||
(lib.hm.assertions.assertPlatform "services.hyprpaper" pkgs
|
||||
lib.platforms.linux)
|
||||
];
|
||||
|
||||
xdg.configFile."hypr/hyprpaper.conf" = {
|
||||
text = ''
|
||||
${lib.concatStringsSep "\n" (lib.forEach cfg.preload (image: "preload=${image}"))}
|
||||
${lib.concatStringsSep "\n" (lib.forEach cfg.wallpapers mkWallpaper)}
|
||||
splash=true
|
||||
'';
|
||||
|
||||
onChange = (pkgs.writeShellScript "reload_hyprpaper" ''
|
||||
${pkgs.systemd}/bin/systemctl --user restart hyprpaper.service
|
||||
'').outPath;
|
||||
};
|
||||
|
||||
systemd.user.services.hyprpaper = {
|
||||
Unit = {
|
||||
Description = "Hyprland wallpaper daemon";
|
||||
Requires = [ "graphical-session.target" ];
|
||||
};
|
||||
|
||||
Service = {
|
||||
ExecStart = "${cfg.package}/bin/hyprpaper";
|
||||
};
|
||||
|
||||
Install = {
|
||||
WantedBy = [ cfg.systemdTarget ];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -1,35 +1,51 @@
|
|||
# My own module with nicer syntax for impernanence
|
||||
# My own module with nicer syntax for impernanence
|
||||
{ lib, config, ... }:
|
||||
let cfg = config.satellite.persistence;
|
||||
in
|
||||
{
|
||||
# {{{ Option definition
|
||||
options.satellite.persistence = {
|
||||
enable = lib.mkEnableOption "satellite persitence";
|
||||
enable = lib.mkEnableOption "satellite persistence";
|
||||
|
||||
at = lib.mkOption {
|
||||
default = { };
|
||||
description = "Record of persistent locations (eg: /persist)";
|
||||
type = lib.types.attrsOf (lib.types.submodule (_: {
|
||||
type = lib.types.attrsOf (lib.types.submodule (args: {
|
||||
config = {
|
||||
home = "${args.config.path}${config.home.homeDirectory}";
|
||||
};
|
||||
|
||||
options = {
|
||||
# {{{ Location options
|
||||
path = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
example = "/persist";
|
||||
default = null;
|
||||
description = "The location to store the files described in this record";
|
||||
description = "The root location to store the home directory for files in this record";
|
||||
};
|
||||
|
||||
home = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = "The path to the home directory for files in this record";
|
||||
};
|
||||
|
||||
prefixDirectories = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
example = false;
|
||||
description = "Whether to enable gnu/stow type prefix directories";
|
||||
};
|
||||
|
||||
# }}}
|
||||
# {{{ Apps
|
||||
apps = lib.mkOption {
|
||||
default = { };
|
||||
description = "The apps to be stores in this persistent location";
|
||||
type = lib.types.attrsOf (lib.types.submodule (_: {
|
||||
description = "Record of gnu/stow-style apps to be stored in this location";
|
||||
type = lib.types.attrsOf (lib.types.submodule ({ name, ... }: {
|
||||
options = {
|
||||
name = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = name;
|
||||
description = "The gnu/stow-style subdirectory name";
|
||||
};
|
||||
|
||||
files = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.str;
|
||||
default = [ ];
|
||||
|
@ -37,18 +53,21 @@ in
|
|||
description = ''
|
||||
A list of files in your home directory you want to
|
||||
link to persistent storage. Allows both absolute paths
|
||||
and paths relative to the home directory. .
|
||||
and paths relative to the home directory.
|
||||
'';
|
||||
};
|
||||
|
||||
directories = lib.mkOption {
|
||||
default = [ ];
|
||||
description = "Modified version of home.persistence.*.directories which takes in absolute paths";
|
||||
description = ''
|
||||
Modified version of `home.persistence.*.directories` which takes in absolute paths.
|
||||
'';
|
||||
|
||||
type = lib.types.listOf (lib.types.either lib.types.str (lib.types.submodule {
|
||||
options = {
|
||||
directory = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = null;
|
||||
example = "/home/username/.config/nvim";
|
||||
description = "The directory path to be linked.";
|
||||
};
|
||||
|
||||
|
@ -68,23 +87,27 @@ in
|
|||
};
|
||||
}));
|
||||
};
|
||||
# }}}
|
||||
};
|
||||
}));
|
||||
};
|
||||
};
|
||||
|
||||
# }}}
|
||||
# {{{ Config generation
|
||||
config =
|
||||
let
|
||||
makeLocation = location:
|
||||
let
|
||||
processPath = appName: value:
|
||||
# {{{ Path processing
|
||||
processPath = appName: path:
|
||||
let
|
||||
suffix = "${lib.strings.removePrefix "${config.home.homeDirectory}/" (builtins.toString value)}";
|
||||
suffix = "${lib.strings.removePrefix "${config.home.homeDirectory}/" (builtins.toString path)}";
|
||||
prefix = if location.prefixDirectories then "${appName}/" else "";
|
||||
in
|
||||
# lib.debug.traceSeq "\nProcessing path at location ${location.path} and app ${appName} from original path ${value} to ${prefix + suffix}"
|
||||
# lib.debug.traceSeq "\nProcessing path at location ${location.path} and app ${appName} from original path ${value} to ${prefix + suffix}"
|
||||
(prefix + suffix);
|
||||
|
||||
# }}}
|
||||
# {{{ Constructors
|
||||
mkDirectory = appName: directory:
|
||||
if builtins.isAttrs directory then {
|
||||
method = directory.method;
|
||||
|
@ -92,20 +115,24 @@ in
|
|||
}
|
||||
else processPath appName directory;
|
||||
|
||||
mkAppDirectory = appName: app: builtins.map (mkDirectory appName) app.directories;
|
||||
mkAppFiles = appName: app: builtins.map (processPath appName) app.files;
|
||||
mkAppDirectory = app: builtins.map (mkDirectory app.name) app.directories;
|
||||
mkAppFiles = app: builtins.map (processPath app.name) app.files;
|
||||
# }}}
|
||||
in
|
||||
lib.attrsets.nameValuePair (location.path + config.home.homeDirectory) {
|
||||
# {{{ Impermanence config generation
|
||||
lib.attrsets.nameValuePair location.home {
|
||||
removePrefixDirectory = location.prefixDirectories;
|
||||
allowOther = true;
|
||||
directories = lib.lists.flatten
|
||||
(lib.attrsets.mapAttrsToList mkAppDirectory location.apps);
|
||||
(lib.attrsets.mapAttrsToList (_: mkAppDirectory) location.apps);
|
||||
|
||||
files = lib.lists.flatten
|
||||
(lib.attrsets.mapAttrsToList mkAppFiles location.apps);
|
||||
(lib.attrsets.mapAttrsToList (_: mkAppFiles) location.apps);
|
||||
};
|
||||
# }}}
|
||||
in
|
||||
lib.mkIf cfg.enable {
|
||||
home.persistence = lib.attrsets.mapAttrs' (_: makeLocation) cfg.at;
|
||||
};
|
||||
# }}}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue