mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-04-19 19:34:24 +02:00
fix(nix): home manager module, and features
This commit is contained in:
parent
0f5ec1fe34
commit
d0b7bdbafc
3 changed files with 88 additions and 60 deletions
|
@ -70,7 +70,8 @@ Here is an example nix flake that uses Ironbar.
|
||||||
enable = true;
|
enable = true;
|
||||||
config = {};
|
config = {};
|
||||||
style = "";
|
style = "";
|
||||||
package = inputs.ironbar.packageBuilder ["feature" "another_feature"];
|
package = inputs.ironbar;
|
||||||
|
features = ["feature" "another_feature"];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
109
flake.nix
109
flake.nix
|
@ -6,9 +6,6 @@
|
||||||
url = "github:oxalica/rust-overlay";
|
url = "github:oxalica/rust-overlay";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
#nci.url = "github:yusdacra/nix-cargo-integration";
|
|
||||||
#nci.inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
#nci.inputs.rust-overlay.follows = "rust-overlay";
|
|
||||||
};
|
};
|
||||||
outputs = {
|
outputs = {
|
||||||
self,
|
self,
|
||||||
|
@ -31,15 +28,6 @@
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
mkRustToolchain = pkgs: pkgs.rust-bin.stable.latest.default;
|
mkRustToolchain = pkgs: pkgs.rust-bin.stable.latest.default;
|
||||||
# defaultFeatures = [
|
|
||||||
# "http"
|
|
||||||
# "config+all"
|
|
||||||
# "clock"
|
|
||||||
# "music+all"
|
|
||||||
# "sys_info"
|
|
||||||
# "tray"
|
|
||||||
# "workspaces+all"
|
|
||||||
# ];
|
|
||||||
in {
|
in {
|
||||||
overlays.default = final: prev: let
|
overlays.default = final: prev: let
|
||||||
rust = mkRustToolchain final;
|
rust = mkRustToolchain final;
|
||||||
|
@ -48,34 +36,25 @@
|
||||||
cargo = rust;
|
cargo = rust;
|
||||||
rustc = rust;
|
rustc = rust;
|
||||||
};
|
};
|
||||||
|
props = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
||||||
|
mkDate = longDate: (lib.concatStringsSep "-" [
|
||||||
|
(builtins.substring 0 4 longDate)
|
||||||
|
(builtins.substring 4 2 longDate)
|
||||||
|
(builtins.substring 6 2 longDate)
|
||||||
|
]);
|
||||||
in {
|
in {
|
||||||
ironbar = features:
|
ironbar = prev.callPackage ./nix/default.nix {
|
||||||
rustPlatform.buildRustPackage {
|
version = props.package.version + "+date=" + (mkDate (self.lastModifiedDate or "19700101")) + "_" + (self.shortRev or "dirty");
|
||||||
pname = "ironbar";
|
inherit rustPlatform;
|
||||||
version = self.rev or "dirty";
|
};
|
||||||
src = builtins.path {
|
|
||||||
name = "ironbar";
|
|
||||||
path = prev.lib.cleanSource ./.;
|
|
||||||
};
|
|
||||||
buildNoDefaultFeatures =
|
|
||||||
if features == []
|
|
||||||
then false
|
|
||||||
else true;
|
|
||||||
buildFeatures = features;
|
|
||||||
cargoDeps = rustPlatform.importCargoLock {lockFile = ./Cargo.lock;};
|
|
||||||
cargoLock.lockFile = ./Cargo.lock;
|
|
||||||
nativeBuildInputs = with prev; [pkg-config];
|
|
||||||
buildInputs = with prev; [gtk3 gdk-pixbuf gtk-layer-shell libxkbcommon openssl];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
packageBuilder = genSystems (system: self.packages.${system}.ironbar);
|
|
||||||
packages = genSystems (
|
packages = genSystems (
|
||||||
system: let
|
system: let
|
||||||
pkgs = pkgsFor system;
|
pkgs = pkgsFor system;
|
||||||
in
|
in
|
||||||
(self.overlays.default pkgs pkgs)
|
(self.overlays.default pkgs pkgs)
|
||||||
// {
|
// {
|
||||||
default = self.packages.${system}.ironbar [];
|
default = self.packages.${system}.ironbar;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
devShells = genSystems (system: let
|
devShells = genSystems (system: let
|
||||||
|
@ -103,7 +82,7 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
cfg = config.programs.ironbar;
|
cfg = config.programs.ironbar;
|
||||||
defaultIronbarPackage = self.packages.${pkgs.hostPlatform.system}.default [];
|
defaultIronbarPackage = self.packages.${pkgs.hostPlatform.system}.default;
|
||||||
jsonFormat = pkgs.formats.json {};
|
jsonFormat = pkgs.formats.json {};
|
||||||
in {
|
in {
|
||||||
options.programs.ironbar = {
|
options.programs.ironbar = {
|
||||||
|
@ -111,49 +90,61 @@
|
||||||
package = lib.mkOption {
|
package = lib.mkOption {
|
||||||
type = with lib.types; package;
|
type = with lib.types; package;
|
||||||
default = defaultIronbarPackage;
|
default = defaultIronbarPackage;
|
||||||
description = "The package for ironbar to use";
|
description = "The package for ironbar to use.";
|
||||||
};
|
};
|
||||||
systemd = lib.mkOption {
|
systemd = lib.mkOption {
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
default = pkgs.stdenv.isLinux;
|
default = pkgs.stdenv.isLinux;
|
||||||
description = "Whether to enable to systemd service for ironbar";
|
description = "Whether to enable to systemd service for ironbar.";
|
||||||
};
|
};
|
||||||
style = lib.mkOption {
|
style = lib.mkOption {
|
||||||
type = lib.types.lines;
|
type = lib.types.lines;
|
||||||
default = "";
|
default = "";
|
||||||
description = "The stylesheet to apply to ironbar";
|
description = "The stylesheet to apply to ironbar.";
|
||||||
};
|
};
|
||||||
config = lib.mkOption {
|
config = lib.mkOption {
|
||||||
type = jsonFormat.type;
|
type = jsonFormat.type;
|
||||||
default = {};
|
default = {};
|
||||||
description = "The config to pass to ironbar";
|
description = "The config to pass to ironbar.";
|
||||||
|
};
|
||||||
|
features = lib.mkOption {
|
||||||
|
type = lib.types.listOf lib.types.nonEmptyStr;
|
||||||
|
default = [];
|
||||||
|
description = "The features to be used.";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = lib.mkIf cfg.enable {
|
config = let
|
||||||
home.packages = [cfg.package];
|
pkg = cfg.package.override {features = cfg.features;};
|
||||||
xdg.configFile = {
|
in
|
||||||
"ironbar/config.json" = lib.mkIf (cfg.config != "") {
|
lib.mkIf cfg.enable {
|
||||||
source = jsonFormat.generate "ironbar-config" cfg.config;
|
home.packages = [pkg];
|
||||||
|
xdg.configFile = {
|
||||||
|
"ironbar/config.json" = lib.mkIf (cfg.config != "") {
|
||||||
|
source = jsonFormat.generate "ironbar-config" cfg.config;
|
||||||
|
};
|
||||||
|
"ironbar/style.css" = lib.mkIf (cfg.style != "") {
|
||||||
|
text = cfg.style;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
"ironbar/style.css" = lib.mkIf (cfg.style != "") {
|
systemd.user.services.ironbar = lib.mkIf cfg.systemd {
|
||||||
text = cfg.style;
|
Unit = {
|
||||||
|
Description = "Systemd service for Ironbar";
|
||||||
|
Requires = ["graphical-session.target"];
|
||||||
|
};
|
||||||
|
Service = {
|
||||||
|
Type = "simple";
|
||||||
|
ExecStart = "${pkg}/bin/ironbar";
|
||||||
|
};
|
||||||
|
Install.WantedBy = [
|
||||||
|
(lib.mkIf config.wayland.windowManager.hyprland.systemdIntegration "hyprland-session.target")
|
||||||
|
(lib.mkIf config.wayland.windowManager.sway.systemdIntegration "sway-session.target")
|
||||||
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
systemd.user.services.ironbar = lib.mkIf cfg.systemd {
|
|
||||||
Unit = {
|
|
||||||
Description = "Systemd service for Ironbar";
|
|
||||||
Requires = ["graphical-session.target"];
|
|
||||||
};
|
|
||||||
Service = {
|
|
||||||
Type = "simple";
|
|
||||||
ExecStart = "${cfg.package}/bin/ironbar";
|
|
||||||
};
|
|
||||||
Install.WantedBy = [
|
|
||||||
(lib.mkIf config.wayland.windowManager.hyprland.systemdIntegration "hyprland-session.target")
|
|
||||||
(lib.mkIf config.wayland.windowManager.sway.systemdIntegration "sway-session.target")
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
nixConfig = {
|
||||||
|
extra-substituters = ["https://jakestanger.cachix.org"];
|
||||||
|
extra-trusted-public-keys = ["jakestanger.cachix.org-1:VWJE7AWNe5/KOEvCQRxoE8UsI2Xs2nHULJ7TEjYm7mM="];
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
36
nix/default.nix
Normal file
36
nix/default.nix
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
{
|
||||||
|
gtk3,
|
||||||
|
gdk-pixbuf,
|
||||||
|
gtk-layer-shell,
|
||||||
|
libxkbcommon,
|
||||||
|
openssl,
|
||||||
|
pkg-config,
|
||||||
|
rustPlatform,
|
||||||
|
lib,
|
||||||
|
version ? "git",
|
||||||
|
features ? [],
|
||||||
|
}:
|
||||||
|
rustPlatform.buildRustPackage {
|
||||||
|
inherit version;
|
||||||
|
pname = "ironbar";
|
||||||
|
src = builtins.path {
|
||||||
|
name = "ironbar";
|
||||||
|
path = lib.cleanSource ../.;
|
||||||
|
};
|
||||||
|
buildNoDefaultFeatures =
|
||||||
|
if features == []
|
||||||
|
then false
|
||||||
|
else true;
|
||||||
|
buildFeatures = features;
|
||||||
|
cargoDeps = rustPlatform.importCargoLock {lockFile = ../Cargo.lock;};
|
||||||
|
cargoLock.lockFile = ../Cargo.lock;
|
||||||
|
nativeBuildInputs = [pkg-config];
|
||||||
|
buildInputs = [gtk3 gdk-pixbuf gtk-layer-shell libxkbcommon openssl];
|
||||||
|
meta = with lib; {
|
||||||
|
homepage = "https://github.com/JakeStanger/ironbar";
|
||||||
|
description = "Customisable gtk-layer-shell wlroots/sway bar written in rust.";
|
||||||
|
license = licenses.mit;
|
||||||
|
platforms = platforms.linux;
|
||||||
|
mainProgram = "Hyprland";
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue