12
flake.nix
12
flake.nix
@@ -10,10 +10,16 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = inputs @ {flake-parts, ...}:
|
outputs = {
|
||||||
|
self,
|
||||||
|
flake-parts,
|
||||||
|
nixpkgs,
|
||||||
|
systems,
|
||||||
|
...
|
||||||
|
} @ inputs:
|
||||||
flake-parts.lib.mkFlake {inherit inputs;} {
|
flake-parts.lib.mkFlake {inherit inputs;} {
|
||||||
imports = [flake-parts.flakeModules.easyOverlay];
|
imports = [flake-parts.flakeModules.easyOverlay];
|
||||||
systems = import inputs.systems;
|
systems = import systems;
|
||||||
|
|
||||||
perSystem = {
|
perSystem = {
|
||||||
self',
|
self',
|
||||||
@@ -80,7 +86,7 @@
|
|||||||
overlayAttrs = config.packages;
|
overlayAttrs = config.packages;
|
||||||
};
|
};
|
||||||
|
|
||||||
flake = {self, ...}: {
|
flake = {
|
||||||
homeManagerModules = {
|
homeManagerModules = {
|
||||||
anyrun = import ./nix/hm-module.nix self;
|
anyrun = import ./nix/hm-module.nix self;
|
||||||
default = self.homeManagerModules.anyrun;
|
default = self.homeManagerModules.anyrun;
|
||||||
|
@@ -1,7 +1,9 @@
|
|||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
glib,
|
|
||||||
makeWrapper,
|
makeWrapper,
|
||||||
|
lockFile,
|
||||||
|
# Dependencies for Anyrun
|
||||||
|
glib,
|
||||||
rustPlatform,
|
rustPlatform,
|
||||||
atk,
|
atk,
|
||||||
gtk3,
|
gtk3,
|
||||||
@@ -11,16 +13,19 @@
|
|||||||
rustfmt,
|
rustfmt,
|
||||||
cargo,
|
cargo,
|
||||||
rustc,
|
rustc,
|
||||||
lockFile,
|
# Additional configuration arguments for the
|
||||||
|
# derivation. By default, we should not build
|
||||||
|
# any of the plugins.
|
||||||
dontBuildPlugins ? true,
|
dontBuildPlugins ? true,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
cargoToml = builtins.fromTOML (builtins.readFile ../anyrun/Cargo.toml);
|
inherit (builtins) fromTOML readFile;
|
||||||
|
cargoToml = fromTOML (readFile ../anyrun/Cargo.toml);
|
||||||
|
pname = cargoToml.package.name;
|
||||||
|
version = cargoToml.package.version;
|
||||||
in
|
in
|
||||||
rustPlatform.buildRustPackage rec {
|
rustPlatform.buildRustPackage {
|
||||||
pname = cargoToml.package.name;
|
inherit pname version;
|
||||||
version = cargoToml.package.version;
|
|
||||||
|
|
||||||
src = ../.;
|
src = ../.;
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
|
@@ -8,19 +8,28 @@ self: {
|
|||||||
cfg = config.programs.anyrun;
|
cfg = config.programs.anyrun;
|
||||||
|
|
||||||
defaultPackage = self.packages.${pkgs.stdenv.hostPlatform.system}.default;
|
defaultPackage = self.packages.${pkgs.stdenv.hostPlatform.system}.default;
|
||||||
|
|
||||||
|
inherit (builtins) map toJSON toString substring stringLength;
|
||||||
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
|
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
||||||
|
inherit (lib.lists) optional;
|
||||||
|
inherit (lib.attrsets) mapAttrs' nameValuePair;
|
||||||
|
inherit (lib.strings) toLower toUpper replaceStrings;
|
||||||
|
inherit (lib.trivial) boolToString;
|
||||||
|
inherit (lib.types) nullOr package submodule int float listOf either str enum lines bool attrs;
|
||||||
in {
|
in {
|
||||||
meta.maintainers = with lib.maintainers; [n3oney NotAShelf];
|
meta.maintainers = with lib.maintainers; [n3oney NotAShelf];
|
||||||
|
|
||||||
options.programs.anyrun = with lib; {
|
options.programs.anyrun = {
|
||||||
enable = mkEnableOption "anyrun";
|
enable = mkEnableOption "anyrun";
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
type = with types; nullOr package;
|
type = nullOr package;
|
||||||
default = defaultPackage;
|
default = defaultPackage;
|
||||||
defaultText = lib.literalExpression ''
|
defaultText = literalExpression ''
|
||||||
anyrun.packages.''${pkgs.stdenv.hostPlatform.system}.default
|
anyrun.packages.''${pkgs.stdenv.hostPlatform.system}.default
|
||||||
'';
|
'';
|
||||||
description = mdDoc ''
|
description = ''
|
||||||
Anyrun package to use. Defaults to the one provided by the flake.
|
Anyrun package to use. Defaults to the one provided by the flake.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
@@ -30,27 +39,26 @@ in {
|
|||||||
description,
|
description,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with types;
|
mkOption {
|
||||||
mkOption {
|
inherit default description;
|
||||||
inherit default description;
|
example = ''
|
||||||
example = ''
|
{ absolute = 200; };
|
||||||
{ absolute = 200; };
|
or
|
||||||
or
|
{ fraction = 0.4; };
|
||||||
{ fraction = 0.4; };
|
'';
|
||||||
'';
|
type = submodule {
|
||||||
type = submodule {
|
options = {
|
||||||
options = {
|
absolute = mkOption {
|
||||||
absolute = mkOption {
|
type = nullOr int;
|
||||||
type = nullOr int;
|
default = null;
|
||||||
default = null;
|
};
|
||||||
};
|
fraction = mkOption {
|
||||||
fraction = mkOption {
|
type = nullOr float;
|
||||||
type = nullOr float;
|
default = null;
|
||||||
default = null;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
numericInfo = ''
|
numericInfo = ''
|
||||||
This is a numeric option - pass either `{ absolute = int; };` or `{ fraction = float; };`.
|
This is a numeric option - pass either `{ absolute = int; };` or `{ fraction = float; };`.
|
||||||
@@ -59,16 +67,16 @@ in {
|
|||||||
'';
|
'';
|
||||||
in {
|
in {
|
||||||
plugins = mkOption {
|
plugins = mkOption {
|
||||||
type = with types; nullOr (listOf (either package str));
|
type = nullOr (listOf (either package str));
|
||||||
default = null;
|
default = null;
|
||||||
description = mdDoc ''
|
description = ''
|
||||||
List of anyrun plugins to use. Can either be packages, absolute plugin paths, or strings.
|
List of anyrun plugins to use. Can either be packages, absolute plugin paths, or strings.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
x = mkNumericOption {
|
x = mkNumericOption {
|
||||||
default.fraction = 0.5;
|
default.fraction = 0.5;
|
||||||
description = mdDoc ''
|
description = ''
|
||||||
The horizontal position, adjusted so that { relative = 0.5; } always centers the runner.
|
The horizontal position, adjusted so that { relative = 0.5; } always centers the runner.
|
||||||
|
|
||||||
${numericInfo}
|
${numericInfo}
|
||||||
@@ -77,7 +85,7 @@ in {
|
|||||||
|
|
||||||
y = mkNumericOption {
|
y = mkNumericOption {
|
||||||
default.fraction = 0.0;
|
default.fraction = 0.0;
|
||||||
description = mdDoc ''
|
description = ''
|
||||||
The vertical position, works the same as x.
|
The vertical position, works the same as x.
|
||||||
|
|
||||||
${numericInfo}
|
${numericInfo}
|
||||||
@@ -86,7 +94,7 @@ in {
|
|||||||
|
|
||||||
width = mkNumericOption {
|
width = mkNumericOption {
|
||||||
default.absolute = 800;
|
default.absolute = 800;
|
||||||
description = mdDoc ''
|
description = ''
|
||||||
The width of the runner.
|
The width of the runner.
|
||||||
|
|
||||||
${numericInfo}
|
${numericInfo}
|
||||||
@@ -95,7 +103,7 @@ in {
|
|||||||
|
|
||||||
height = mkNumericOption {
|
height = mkNumericOption {
|
||||||
default.absolute = 0;
|
default.absolute = 0;
|
||||||
description = mdDoc ''
|
description = ''
|
||||||
The minimum height of the runner, the runner will expand to fit all the entries.
|
The minimum height of the runner, the runner will expand to fit all the entries.
|
||||||
|
|
||||||
${numericInfo}
|
${numericInfo}
|
||||||
@@ -103,63 +111,63 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
hideIcons = mkOption {
|
hideIcons = mkOption {
|
||||||
type = types.bool;
|
type = bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = "Hide match and plugin info icons";
|
description = "Hide match and plugin info icons";
|
||||||
};
|
};
|
||||||
|
|
||||||
ignoreExclusiveZones = mkOption {
|
ignoreExclusiveZones = mkOption {
|
||||||
type = types.bool;
|
type = bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = "ignore exclusive zones, eg. Waybar";
|
description = "ignore exclusive zones, eg. Waybar";
|
||||||
};
|
};
|
||||||
|
|
||||||
layer = mkOption {
|
layer = mkOption {
|
||||||
type = with types; enum ["background" "bottom" "top" "overlay"];
|
type = enum ["background" "bottom" "top" "overlay"];
|
||||||
default = "overlay";
|
default = "overlay";
|
||||||
description = "Layer shell layer (background, bottom, top or overlay)";
|
description = "Layer shell layer (background, bottom, top or overlay)";
|
||||||
};
|
};
|
||||||
|
|
||||||
hidePluginInfo = mkOption {
|
hidePluginInfo = mkOption {
|
||||||
type = types.bool;
|
type = bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = "Hide the plugin info panel";
|
description = "Hide the plugin info panel";
|
||||||
};
|
};
|
||||||
|
|
||||||
closeOnClick = mkOption {
|
closeOnClick = mkOption {
|
||||||
type = types.bool;
|
type = bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = "Close window when a click outside the main box is received";
|
description = "Close window when a click outside the main box is received";
|
||||||
};
|
};
|
||||||
|
|
||||||
showResultsImmediately = mkOption {
|
showResultsImmediately = mkOption {
|
||||||
type = types.bool;
|
type = bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = "Show search results immediately when Anyrun starts";
|
description = "Show search results immediately when Anyrun starts";
|
||||||
};
|
};
|
||||||
|
|
||||||
maxEntries = mkOption {
|
maxEntries = mkOption {
|
||||||
type = with types; nullOr int;
|
type = nullOr int;
|
||||||
default = null;
|
default = null;
|
||||||
description = "Limit amount of entries shown in total";
|
description = "Limit amount of entries shown in total";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
extraCss = lib.mkOption {
|
extraCss = mkOption {
|
||||||
type = lib.types.nullOr lib.types.lines;
|
type = nullOr lines;
|
||||||
default = "";
|
default = "";
|
||||||
description = mdDoc ''
|
description = ''
|
||||||
Extra CSS lines to add to {file}`~/.config/anyrun/style.css`.
|
Extra CSS lines to add to {file}`~/.config/anyrun/style.css`.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
extraConfigFiles = lib.mkOption {
|
extraConfigFiles = mkOption {
|
||||||
# unfortunately HM doesn't really export the type for files, but hopefully
|
# unfortunately HM doesn't really export the type for files, but hopefully
|
||||||
# hm will throw errors if the options are wrong here, so I'm being *very* loose
|
# hm will throw errors if the options are wrong here, so I'm being *very* loose
|
||||||
type = lib.types.attrs;
|
type = attrs;
|
||||||
default = {};
|
default = {};
|
||||||
description = mdDoc ''
|
description = ''
|
||||||
Extra files to put in `~/.config/anyrun`, a wrapper over `xdg.configFile`.
|
Extra files to put in {file}`~/.config/anyrun`, a wrapper over {option}`xdg.configFile`.
|
||||||
'';
|
'';
|
||||||
example = ''
|
example = ''
|
||||||
programs.anyrun.extraConfigFiles."plugin-name.ron".text = '''
|
programs.anyrun.extraConfigFiles."plugin-name.ron".text = '''
|
||||||
@@ -171,7 +179,7 @@ in {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable (let
|
config = mkIf cfg.enable (let
|
||||||
assertNumeric = numeric: {
|
assertNumeric = numeric: {
|
||||||
assertion = !((numeric ? absolute && numeric.absolute != null) && (numeric ? fraction && numeric.fraction != null));
|
assertion = !((numeric ? absolute && numeric.absolute != null) && (numeric ? fraction && numeric.fraction != null));
|
||||||
message = "Invalid numeric definition, you can only specify one of absolute or fraction.";
|
message = "Invalid numeric definition, you can only specify one of absolute or fraction.";
|
||||||
@@ -179,19 +187,19 @@ in {
|
|||||||
|
|
||||||
stringifyNumeric = numeric:
|
stringifyNumeric = numeric:
|
||||||
if (numeric ? absolute && numeric.absolute != null)
|
if (numeric ? absolute && numeric.absolute != null)
|
||||||
then "Absolute(${builtins.toString numeric.absolute})"
|
then "Absolute(${toString numeric.absolute})"
|
||||||
else "Fraction(${builtins.toString numeric.fraction})";
|
else "Fraction(${toString numeric.fraction})";
|
||||||
|
|
||||||
capitalize = string:
|
capitalize = string:
|
||||||
lib.toUpper (builtins.substring 0 1 string) + lib.toLower (builtins.substring 1 ((builtins.stringLength string) - 1) string);
|
toUpper (substring 0 1 string) + toLower (substring 1 ((stringLength string) - 1) string);
|
||||||
|
|
||||||
parsedPlugins =
|
parsedPlugins =
|
||||||
if cfg.config.plugins == null
|
if cfg.config.plugins == null
|
||||||
then []
|
then []
|
||||||
else
|
else
|
||||||
builtins.map (entry:
|
map (entry:
|
||||||
if lib.types.package.check entry
|
if lib.types.package.check entry
|
||||||
then "${entry}/lib/lib${lib.replaceStrings ["-"] ["_"] entry.pname}.so"
|
then "${entry}/lib/lib${replaceStrings ["-"] ["_"] entry.pname}.so"
|
||||||
else entry)
|
else entry)
|
||||||
cfg.config.plugins;
|
cfg.config.plugins;
|
||||||
in {
|
in {
|
||||||
@@ -207,11 +215,11 @@ in {
|
|||||||
]
|
]
|
||||||
else [];
|
else [];
|
||||||
|
|
||||||
home.packages = lib.optional (cfg.package != null) cfg.package;
|
home.packages = optional (cfg.package != null) cfg.package;
|
||||||
|
|
||||||
xdg.configFile = lib.mkMerge [
|
xdg.configFile = mkMerge [
|
||||||
(lib.mapAttrs'
|
(mapAttrs'
|
||||||
(name: value: lib.nameValuePair ("anyrun/" + name) value)
|
(name: value: nameValuePair ("anyrun/" + name) value)
|
||||||
cfg.extraConfigFiles)
|
cfg.extraConfigFiles)
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -221,24 +229,24 @@ in {
|
|||||||
y: ${stringifyNumeric cfg.config.y},
|
y: ${stringifyNumeric cfg.config.y},
|
||||||
width: ${stringifyNumeric cfg.config.width},
|
width: ${stringifyNumeric cfg.config.width},
|
||||||
height: ${stringifyNumeric cfg.config.height},
|
height: ${stringifyNumeric cfg.config.height},
|
||||||
hide_icons: ${lib.boolToString cfg.config.hideIcons},
|
hide_icons: ${boolToString cfg.config.hideIcons},
|
||||||
ignore_exclusive_zones: ${lib.boolToString cfg.config.ignoreExclusiveZones},
|
ignore_exclusive_zones: ${boolToString cfg.config.ignoreExclusiveZones},
|
||||||
layer: ${capitalize cfg.config.layer},
|
layer: ${capitalize cfg.config.layer},
|
||||||
hide_plugin_info: ${lib.boolToString cfg.config.hidePluginInfo},
|
hide_plugin_info: ${boolToString cfg.config.hidePluginInfo},
|
||||||
close_on_click: ${lib.boolToString cfg.config.closeOnClick},
|
close_on_click: ${boolToString cfg.config.closeOnClick},
|
||||||
show_results_immediately: ${lib.boolToString cfg.config.showResultsImmediately},
|
show_results_immediately: ${boolToString cfg.config.showResultsImmediately},
|
||||||
max_entries: ${
|
max_entries: ${
|
||||||
if cfg.config.maxEntries == null
|
if cfg.config.maxEntries == null
|
||||||
then "None"
|
then "None"
|
||||||
else "Some(${builtins.toString cfg.config.maxEntries})"
|
else "Some(${toString cfg.config.maxEntries})"
|
||||||
},
|
},
|
||||||
plugins: ${builtins.toJSON parsedPlugins},
|
plugins: ${toJSON parsedPlugins},
|
||||||
)
|
)
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
"anyrun/style.css" = lib.mkIf (cfg.extraCss != null) {
|
"anyrun/style.css" = mkIf (cfg.extraCss != null) {
|
||||||
text = cfg.extraCss;
|
text = cfg.extraCss;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user