2022-11-27 00:29:16 +03:00
|
|
|
{
|
|
|
|
description = "Nix Flake for ironbar";
|
2024-04-17 23:43:46 +03:00
|
|
|
|
2022-11-27 00:29:16 +03:00
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
2024-04-17 23:43:46 +03:00
|
|
|
|
2022-11-27 00:29:16 +03:00
|
|
|
rust-overlay = {
|
|
|
|
url = "github:oxalica/rust-overlay";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2024-04-17 23:43:46 +03:00
|
|
|
|
2023-07-27 00:22:52 +03:00
|
|
|
crane = {
|
|
|
|
url = "github:ipetkov/crane";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2024-04-17 23:43:46 +03:00
|
|
|
|
2023-07-27 00:22:52 +03:00
|
|
|
naersk.url = "github:nix-community/naersk";
|
2022-11-27 00:29:16 +03:00
|
|
|
};
|
2024-03-31 02:43:30 +03:00
|
|
|
|
2024-04-17 23:43:46 +03:00
|
|
|
outputs = { self, nixpkgs, rust-overlay, crane, naersk, ... }:
|
|
|
|
let
|
|
|
|
inherit (nixpkgs) lib;
|
|
|
|
|
|
|
|
genSystems = lib.genAttrs [ "aarch64-linux" "x86_64-linux" ];
|
|
|
|
|
|
|
|
pkgsFor = system:
|
|
|
|
import nixpkgs {
|
|
|
|
inherit system;
|
|
|
|
|
|
|
|
overlays = [ self.overlays.default rust-overlay.overlays.default ];
|
2022-11-27 00:29:16 +03:00
|
|
|
};
|
2024-04-17 23:43:46 +03:00
|
|
|
|
|
|
|
mkRustToolchain = pkgs:
|
|
|
|
pkgs.rust-bin.stable.latest.default.override {
|
|
|
|
extensions = [ "rust-src" ];
|
2022-11-27 00:29:16 +03:00
|
|
|
};
|
2024-04-17 23:43:46 +03:00
|
|
|
|
|
|
|
in {
|
|
|
|
overlays.default = final: prev:
|
|
|
|
let
|
|
|
|
rust = mkRustToolchain final;
|
|
|
|
|
|
|
|
craneLib = (crane.mkLib final).overrideToolchain rust;
|
|
|
|
|
|
|
|
naersk' = prev.callPackage naersk {
|
|
|
|
cargo = rust;
|
|
|
|
rustc = rust;
|
|
|
|
};
|
|
|
|
|
|
|
|
rustPlatform = prev.makeRustPlatform {
|
|
|
|
cargo = 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)
|
|
|
|
]);
|
|
|
|
|
|
|
|
builder = "naersk";
|
|
|
|
in {
|
|
|
|
ironbar = let
|
|
|
|
version = props.package.version + "+date="
|
|
|
|
+ (mkDate (self.lastModifiedDate or "19700101")) + "_"
|
|
|
|
+ (self.shortRev or "dirty");
|
|
|
|
in if builder == "crane" then
|
|
|
|
prev.callPackage ./nix/default.nix {
|
|
|
|
inherit version;
|
|
|
|
inherit rustPlatform;
|
|
|
|
builderName = builder;
|
|
|
|
builder = craneLib;
|
|
|
|
}
|
|
|
|
else if builder == "naersk" then
|
|
|
|
prev.callPackage ./nix/default.nix {
|
|
|
|
inherit version;
|
|
|
|
inherit rustPlatform;
|
|
|
|
builderName = builder;
|
|
|
|
builder = naersk';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
prev.callPackage ./nix/default.nix {
|
|
|
|
inherit version;
|
|
|
|
inherit rustPlatform;
|
|
|
|
builderName = builder;
|
|
|
|
};
|
2022-11-27 00:29:16 +03:00
|
|
|
};
|
2024-04-17 23:43:46 +03:00
|
|
|
|
|
|
|
packages = genSystems (system:
|
|
|
|
let pkgs = pkgsFor system;
|
|
|
|
in (self.overlays.default pkgs pkgs) // {
|
|
|
|
default = self.packages.${system}.ironbar;
|
|
|
|
});
|
|
|
|
|
|
|
|
apps = genSystems (system:
|
|
|
|
let pkgs = pkgsFor system;
|
2024-04-18 00:04:19 +03:00
|
|
|
in rec {
|
2024-04-17 23:43:46 +03:00
|
|
|
ironbar = {
|
|
|
|
type = "app";
|
|
|
|
program = "${pkgs.ironbar}/bin/ironbar";
|
|
|
|
};
|
2024-04-18 00:04:19 +03:00
|
|
|
|
|
|
|
default = ironbar;
|
2024-04-17 23:43:46 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
devShells = genSystems (system:
|
|
|
|
let
|
|
|
|
pkgs = pkgsFor system;
|
|
|
|
rust = mkRustToolchain pkgs;
|
|
|
|
|
|
|
|
in {
|
|
|
|
default = pkgs.mkShell {
|
|
|
|
packages = with pkgs; [
|
|
|
|
rust
|
|
|
|
rust-analyzer-unwrapped
|
|
|
|
gcc
|
|
|
|
gtk3
|
|
|
|
gtk-layer-shell
|
|
|
|
pkg-config
|
|
|
|
openssl
|
|
|
|
gdk-pixbuf
|
|
|
|
glib
|
|
|
|
glib-networking
|
|
|
|
shared-mime-info
|
2024-08-10 23:05:17 +03:00
|
|
|
adwaita-icon-theme
|
2024-04-17 23:43:46 +03:00
|
|
|
hicolor-icon-theme
|
|
|
|
gsettings-desktop-schemas
|
|
|
|
libxkbcommon
|
|
|
|
libpulseaudio
|
|
|
|
luajit
|
|
|
|
luajitPackages.lgi
|
|
|
|
];
|
|
|
|
|
|
|
|
RUST_SRC_PATH = "${rust}/lib/rustlib/src/rust/library";
|
|
|
|
};
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
homeManagerModules.default = { config, lib, pkgs, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.programs.ironbar;
|
|
|
|
defaultIronbarPackage =
|
|
|
|
self.packages.${pkgs.hostPlatform.system}.default;
|
|
|
|
jsonFormat = pkgs.formats.json { };
|
|
|
|
in {
|
|
|
|
options.programs.ironbar = {
|
|
|
|
enable = lib.mkEnableOption "ironbar status bar";
|
|
|
|
|
|
|
|
package = lib.mkOption {
|
|
|
|
type = with lib.types; package;
|
|
|
|
default = defaultIronbarPackage;
|
|
|
|
description = "The package for ironbar to use.";
|
2023-03-29 11:45:40 +03:00
|
|
|
};
|
2024-04-17 23:43:46 +03:00
|
|
|
|
|
|
|
systemd = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
|
|
|
default = pkgs.stdenv.isLinux;
|
|
|
|
description = "Whether to enable to systemd service for ironbar.";
|
2023-03-29 11:45:40 +03:00
|
|
|
};
|
2024-04-17 23:43:46 +03:00
|
|
|
|
|
|
|
style = lib.mkOption {
|
2024-07-02 16:38:35 +03:00
|
|
|
type = lib.types.either (lib.types.lines) (lib.types.path);
|
2024-04-17 23:43:46 +03:00
|
|
|
default = "";
|
|
|
|
description = "The stylesheet to apply to ironbar.";
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkOption {
|
|
|
|
type = jsonFormat.type;
|
|
|
|
default = { };
|
|
|
|
description = "The config to pass to ironbar.";
|
|
|
|
};
|
|
|
|
|
|
|
|
features = lib.mkOption {
|
|
|
|
type = lib.types.listOf lib.types.nonEmptyStr;
|
|
|
|
default = [ ];
|
|
|
|
description = "The features to be used.";
|
|
|
|
};
|
|
|
|
|
2022-11-27 00:29:16 +03:00
|
|
|
};
|
2024-04-17 23:43:46 +03:00
|
|
|
config = let pkg = cfg.package.override { features = cfg.features; };
|
|
|
|
in lib.mkIf cfg.enable {
|
|
|
|
home.packages = [ pkg ];
|
|
|
|
|
|
|
|
xdg.configFile = {
|
|
|
|
"ironbar/config.json" = lib.mkIf (cfg.config != "") {
|
|
|
|
source = jsonFormat.generate "ironbar-config" cfg.config;
|
|
|
|
};
|
|
|
|
|
2024-07-02 16:38:35 +03:00
|
|
|
"ironbar/style.css" = lib.mkIf (cfg.style != "") (
|
|
|
|
if builtins.isPath cfg.style || lib.isStorePath cfg.style then
|
|
|
|
{ source = cfg.style; }
|
|
|
|
else
|
|
|
|
{ text = cfg.style; }
|
|
|
|
);
|
2023-03-29 11:45:40 +03:00
|
|
|
};
|
2024-04-17 23:43:46 +03:00
|
|
|
|
|
|
|
systemd.user.services.ironbar = lib.mkIf cfg.systemd {
|
|
|
|
Unit = {
|
|
|
|
Description = "Systemd service for Ironbar";
|
|
|
|
Requires = [ "graphical-session.target" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
Service = {
|
|
|
|
Type = "simple";
|
|
|
|
ExecStart = "${pkg}/bin/ironbar";
|
|
|
|
};
|
|
|
|
|
|
|
|
Install.WantedBy = with config.wayland.windowManager; [
|
|
|
|
(lib.mkIf hyprland.systemd.enable "hyprland-session.target")
|
|
|
|
(lib.mkIf sway.systemd.enable "sway-session.target")
|
|
|
|
(lib.mkIf river.systemd.enable "river-session.target")
|
|
|
|
];
|
2023-03-29 11:45:40 +03:00
|
|
|
};
|
2022-11-27 00:29:16 +03:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-04-17 23:43:46 +03:00
|
|
|
|
2023-03-29 11:45:40 +03:00
|
|
|
nixConfig = {
|
2024-04-17 23:43:46 +03:00
|
|
|
extra-substituters = [ "https://cache.garnix.io" ];
|
|
|
|
extra-trusted-public-keys =
|
|
|
|
[ "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" ];
|
2023-03-29 11:45:40 +03:00
|
|
|
};
|
2022-11-27 00:29:16 +03:00
|
|
|
}
|