1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-08-17 06:41:03 +02:00

chore(nix): simplify packaging and outputs

This commit is contained in:
atagen 2025-05-29 23:35:29 +10:00
parent 098df1ee26
commit 3b80b43582
7 changed files with 187 additions and 311 deletions

View file

@ -1,25 +0,0 @@
{
perSystem = { pkgs, ... }: {
devShells.default = pkgs.mkShell {
packages = with pkgs; [
cargo
clippy
rustfmt
gtk3
gtk-layer-shell
gcc
openssl
libdbusmenu-gtk3
libpulseaudio
libinput
libevdev
luajit
luajitPackages.lgi
];
nativeBuildInputs = with pkgs; [
pkg-config
];
};
};
}

View file

@ -7,57 +7,65 @@ self: {
cfg = config.programs.ironbar;
defaultIronbarPackage = self.packages.${pkgs.hostPlatform.system}.default;
jsonFormat = pkgs.formats.json {};
inherit
(lib)
types
mkOption
mkEnableOption
mkIf
getExe
;
in {
options.programs.ironbar = {
enable = lib.mkEnableOption "ironbar status bar";
enable = mkEnableOption "ironbar status bar";
package = lib.mkOption {
type = with lib.types; package;
package = mkOption {
type = types.package;
default = defaultIronbarPackage;
apply = pkg: pkg.override {features = cfg.features;};
description = "The package for ironbar to use.";
};
systemd = lib.mkEnableOption "systemd service for ironbar.";
systemd = mkEnableOption "systemd service for ironbar.";
style = lib.mkOption {
type = lib.types.either (lib.types.lines) (lib.types.path);
style = mkOption {
type = types.either (types.lines) (types.path);
default = "";
description = "The stylesheet to apply to ironbar.";
};
config = lib.mkOption {
config = mkOption {
type = jsonFormat.type;
default = {};
description = "The config to pass to ironbar.";
};
features = lib.mkOption {
type = lib.types.listOf lib.types.nonEmptyStr;
features = mkOption {
type = types.listOf types.nonEmptyStr;
default = [];
description = "The features to be used.";
};
};
config = lib.mkIf cfg.enable {
config = mkIf cfg.enable {
home.packages = [
cfg.package
];
xdg.configFile = {
"ironbar/config.json" = lib.mkIf (cfg.config != "") {
onChange = "${lib.getExe cfg.package} reload";
"ironbar/config.json" = mkIf (cfg.config != "") {
onChange = "${getExe cfg.package} reload";
source = jsonFormat.generate "ironbar-config" cfg.config;
};
"ironbar/style.css" = lib.mkIf (cfg.style != "") (
"ironbar/style.css" = mkIf (cfg.style != "") (
if builtins.isPath cfg.style || lib.isStorePath cfg.style
then {source = cfg.style;}
else {text = cfg.style;}
);
};
systemd.user.services.ironbar = lib.mkIf cfg.systemd {
systemd.user.services.ironbar = mkIf cfg.systemd {
Unit = {
Description = "Systemd service for Ironbar";
Documentation = "https://github.com/JakeStanger/ironbar";
@ -70,8 +78,8 @@ in {
};
Service = {
ExecReload = "${lib.getExe cfg.package} reload";
ExecStart = "${lib.getExe cfg.package}";
ExecReload = "${getExe cfg.package} reload";
ExecStart = "${getExe cfg.package}";
KillMode = "mixed";
Restart = "on-failure";
};
@ -79,9 +87,9 @@ in {
Install.WantedBy = [
config.wayland.systemd.target
"tray.target"
(lib.mkIf config.wayland.windowManager.hyprland.enable "hyprland-session.target")
(lib.mkIf config.wayland.windowManager.sway.enable "sway-session.target")
(lib.mkIf config.wayland.windowManager.river.enable "river-session.target")
(mkIf config.wayland.windowManager.hyprland.enable "hyprland-session.target")
(mkIf config.wayland.windowManager.sway.enable "sway-session.target")
(mkIf config.wayland.windowManager.river.enable "river-session.target")
];
};
};

View file

@ -23,16 +23,44 @@
installShellFiles,
adwaita-icon-theme,
hicolor-icon-theme,
rustPlatform,
lib,
version ? "git",
features ? [],
builderName ? "nix",
builder ? {},
naersk,
}: let
hasFeature = f: features == [] || builtins.elem f features;
flags = let
noDefault =
if features == []
then ""
else "--no-default-features";
basePkg = rec {
featuresStr =
if features == []
then ""
else ''-F "${builtins.concatStringsSep "," features}"'';
in [
noDefault
featuresStr
];
lgi = luajitPackages.lgi;
gappsWrapperArgs =
''
# Thumbnailers
--prefix XDG_DATA_DIRS : "${gdk-pixbuf}/share"
--prefix XDG_DATA_DIRS : "${librsvg}/share"
--prefix XDG_DATA_DIRS : "${webp-pixbuf-loader}/share"
--prefix XDG_DATA_DIRS : "${shared-mime-info}/share"
# gtk-launch
--suffix PATH : "${lib.makeBinPath [gtk3]}"
''
+ lib.optionalString (hasFeature "cairo") ''
--prefix LUA_PATH : "./?.lua;${lgi}/share/lua/5.1/?.lua;${lgi}/share/lua/5.1/?/init.lua;${luajit}/share/lua/5.1/\?.lua;${luajit}/share/lua/5.1/?/init.lua"
--prefix LUA_CPATH : "./?.so;${lgi}/lib/lua/5.1/?.so;${luajit}/lib/lua/5.1/?.so;${luajit}/lib/lua/5.1/loadall.so"
'';
in
naersk.buildPackage {
inherit version;
pname = "ironbar";
@ -48,15 +76,18 @@
ideRelated = fs.unions [
(lib.path.append root ".idea")
];
in fs.toSource {
inherit root;
# NOTE: can possibly filter out more
fileset = fs.difference root (fs.unions [
nixRelated
cicdRelated
ideRelated
]);
};
in
fs.toSource {
inherit root;
# NOTE: can possibly filter out more
fileset = fs.difference root (
fs.unions [
nixRelated
cicdRelated
ideRelated
]
);
};
nativeBuildInputs = [
pkg-config
@ -82,27 +113,14 @@
++ lib.optionals (hasFeature "tray") [libdbusmenu-gtk3]
++ lib.optionals (hasFeature "volume") [libpulseaudio]
++ lib.optionals (hasFeature "cairo") [luajit]
++ lib.optionals (hasFeature "keyboard") [libinput libevdev];
++ lib.optionals (hasFeature "keyboard") [
libinput
libevdev
];
propagatedBuildInputs = [gtk3];
lgi = luajitPackages.lgi;
gappsWrapperArgs =
''
# Thumbnailers
--prefix XDG_DATA_DIRS : "${gdk-pixbuf}/share"
--prefix XDG_DATA_DIRS : "${librsvg}/share"
--prefix XDG_DATA_DIRS : "${webp-pixbuf-loader}/share"
--prefix XDG_DATA_DIRS : "${shared-mime-info}/share"
# gtk-launch
--suffix PATH : "${lib.makeBinPath [gtk3]}"
''
+ lib.optionalString (hasFeature "cairo") ''
--prefix LUA_PATH : "./?.lua;${lgi}/share/lua/5.1/?.lua;${lgi}/share/lua/5.1/?/init.lua;${luajit}/share/lua/5.1/\?.lua;${luajit}/share/lua/5.1/?/init.lua"
--prefix LUA_CPATH : "./?.so;${lgi}/lib/lua/5.1/?.so;${luajit}/lib/lua/5.1/?.so;${luajit}/lib/lua/5.1/loadall.so"
'';
cargoBuildOptions = old: old ++ flags;
preFixup = ''
gappsWrapperArgs+=(
@ -119,48 +137,16 @@
passthru = {
updateScript = gnome.updateScript {
packageName = pname;
attrPath = "gnome.${pname}";
packageName = "ironbar";
attrPath = "gnome.ironbar";
};
};
meta = with lib; {
meta = {
homepage = "https://github.com/JakeStanger/ironbar";
description = "Customisable gtk-layer-shell wlroots/sway bar written in rust.";
license = licenses.mit;
platforms = platforms.linux;
license = lib.licenses.mit;
platforms = lib.platforms.linux;
mainProgram = "ironbar";
};
};
flags = let
noDefault =
if features == []
then ""
else "--no-default-features";
featuresStr =
if features == []
then ""
else ''-F "${builtins.concatStringsSep "," features}"'';
in [noDefault featuresStr];
in
if builderName == "naersk"
then builder.buildPackage (basePkg // {cargoBuildOptions = old: old ++ flags;})
else if builderName == "crane"
then
builder.buildPackage (basePkg
// {
cargoExtraArgs = builtins.concatStringsSep " " flags;
doCheck = false;
})
else
rustPlatform.buildRustPackage (basePkg
// {
buildNoDefaultFeatures = features != [];
buildFeatures = features;
cargoDeps = rustPlatform.importCargoLock {lockFile = ../Cargo.lock;};
cargoLock.lockFile = ../Cargo.lock;
cargoLock.outputHashes."stray-0.1.3" = "sha256-7mvsWZFmPWti9AiX67h6ZlWiVVRZRWIxq3pVaviOUtc=";
})
}