mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-04-19 19:34:24 +02:00
feat: add nix flake support
* Add nix flake * Fix readme syntax issue * Format nix flake * ci(build): add nix flake support * ci(build): fix workflow_dispatch casing * ci(build): fix nix flake lock update job * ci: add nix flake lock update timer job old method didn't work * improve example and add cachix info Co-authored-by: Jake Stanger <mail@jstanger.dev>
This commit is contained in:
parent
47420d83bf
commit
a3f90adaf1
5 changed files with 300 additions and 1 deletions
23
.github/workflows/build.yml
vendored
23
.github/workflows/build.yml
vendored
|
@ -1,6 +1,7 @@
|
||||||
name: Build
|
name: Build
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
branches: [ "master" ]
|
branches: [ "master" ]
|
||||||
pull_request:
|
pull_request:
|
||||||
|
@ -35,3 +36,25 @@ jobs:
|
||||||
|
|
||||||
- name: Check formatting
|
- name: Check formatting
|
||||||
run: cargo fmt --check
|
run: cargo fmt --check
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
build-nix:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- uses: cachix/install-nix-action@v17
|
||||||
|
with:
|
||||||
|
install_url: https://nixos.org/nix/install
|
||||||
|
extra_nix_config: |
|
||||||
|
auto-optimise-store = true
|
||||||
|
experimental-features = nix-command flakes
|
||||||
|
|
||||||
|
- uses: cachix/cachix-action@v11
|
||||||
|
with:
|
||||||
|
name: jakestanger
|
||||||
|
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
|
||||||
|
|
||||||
|
- run: nix build --print-build-logs
|
27
.github/workflows/update-nix-flake-lock.yml
vendored
Normal file
27
.github/workflows/update-nix-flake-lock.yml
vendored
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
name: update-nix-flake-lock
|
||||||
|
on:
|
||||||
|
workflow_dispatch: # allows manual triggering
|
||||||
|
schedule:
|
||||||
|
- cron: '0 0 1 * *' # first day of every month
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
update-nix-flake-lock:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install Nix
|
||||||
|
uses: cachix/install-nix-action@v16
|
||||||
|
with:
|
||||||
|
extra_nix_config: |
|
||||||
|
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Update flake.lock
|
||||||
|
uses: DeterminateSystems/update-flake-lock@vX
|
||||||
|
with:
|
||||||
|
pr-title: "Update flake.lock" # Title of PR to be created
|
||||||
|
pr-labels: | # Labels to be set on the PR
|
||||||
|
dependencies
|
||||||
|
automated
|
45
README.md
45
README.md
|
@ -27,6 +27,49 @@ yay -S ironbar-git
|
||||||
|
|
||||||
[aur package](https://aur.archlinux.org/packages/ironbar-git)
|
[aur package](https://aur.archlinux.org/packages/ironbar-git)
|
||||||
|
|
||||||
|
### Nix Flake
|
||||||
|
|
||||||
|
#### Example
|
||||||
|
Here is an example nix flake that uses ironbar, this is just a
|
||||||
|
proof of concept, please adapt it to your config
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
# Add the ironbar flake input
|
||||||
|
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
|
inputs.ironbar = {
|
||||||
|
url = "github:JakeStanger/ironbar";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
inputs.hm = {
|
||||||
|
url = "github:nix-community/home-manager";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = inputs: {
|
||||||
|
homeManagerConfigurations."USER@HOSTNAME" = inputs.hm.lib.homeManagerConfiguration {
|
||||||
|
pkgs = nixpkgs.legacyPackages.x86_64-linux;
|
||||||
|
modules = [
|
||||||
|
# And add the home-manager module
|
||||||
|
inputs.ironbar.homeManagerModules.default
|
||||||
|
{
|
||||||
|
# And configure
|
||||||
|
programs.ironbar = {
|
||||||
|
enable = true;
|
||||||
|
config = {};
|
||||||
|
style = "";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Binary Caching
|
||||||
|
There is also a cachix cache at `https://app.cachix.org/cache/jakestanger`
|
||||||
|
incase you don't want to compile ironbar!
|
||||||
|
|
||||||
### Source
|
### Source
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
@ -86,4 +129,4 @@ Please check [here](https://github.com/JakeStanger/ironbar/blob/master/CONTRIBUT
|
||||||
|
|
||||||
- [Waybar](https://github.com/Alexays/Waybar) - A lot of the initial inspiration, and a pretty great bar.
|
- [Waybar](https://github.com/Alexays/Waybar) - A lot of the initial inspiration, and a pretty great bar.
|
||||||
- [Rustbar](https://github.com/zeroeightysix/rustbar) - Served as a good demo for writing a basic GTK bar in Rust
|
- [Rustbar](https://github.com/zeroeightysix/rustbar) - Served as a good demo for writing a basic GTK bar in Rust
|
||||||
- [Smithay Client Toolkit](https://github.com/Smithay/client-toolkit) - Essential in being able to communicate to Wayland
|
- [Smithay Client Toolkit](https://github.com/Smithay/client-toolkit) - Essential in being able to communicate to Wayland
|
||||||
|
|
64
flake.lock
generated
Normal file
64
flake.lock
generated
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"flake-utils": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1659877975,
|
||||||
|
"narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1668994630,
|
||||||
|
"narHash": "sha256-1lqx6HLyw6fMNX/hXrrETG1vMvZRGm2XVC9O/Jt0T6c=",
|
||||||
|
"owner": "nixos",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "af50806f7c6ab40df3e6b239099e8f8385f6c78b",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "nixos",
|
||||||
|
"ref": "nixos-unstable",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"rust-overlay": "rust-overlay"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"rust-overlay": {
|
||||||
|
"inputs": {
|
||||||
|
"flake-utils": "flake-utils",
|
||||||
|
"nixpkgs": [
|
||||||
|
"nixpkgs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1669084742,
|
||||||
|
"narHash": "sha256-aLYwYVnrmEE1LVqd17v99CuqVmAZQrlgi2DVTAs4wFg=",
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"rev": "9652ef34c7439eca9f86cee11e94dbef5c9adb09",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "oxalica",
|
||||||
|
"repo": "rust-overlay",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
142
flake.nix
Normal file
142
flake.nix
Normal file
|
@ -0,0 +1,142 @@
|
||||||
|
{
|
||||||
|
description = "Nix Flake for ironbar";
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||||
|
rust-overlay = {
|
||||||
|
url = "github:oxalica/rust-overlay";
|
||||||
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
};
|
||||||
|
#nci.url = "github:yusdacra/nix-cargo-integration";
|
||||||
|
#nci.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
#nci.inputs.rust-overlay.follows = "rust-overlay";
|
||||||
|
};
|
||||||
|
outputs = {
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
rust-overlay,
|
||||||
|
...
|
||||||
|
}: 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
|
||||||
|
];
|
||||||
|
};
|
||||||
|
mkRustToolchain = pkgs: pkgs.rust-bin.stable.latest.default;
|
||||||
|
in {
|
||||||
|
overlays.default = final: prev: let
|
||||||
|
rust = mkRustToolchain final;
|
||||||
|
|
||||||
|
rustPlatform = prev.makeRustPlatform {
|
||||||
|
cargo = rust;
|
||||||
|
rustc = rust;
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
ironbar = rustPlatform.buildRustPackage {
|
||||||
|
pname = "ironbar";
|
||||||
|
version = self.rev or "dirty";
|
||||||
|
src = builtins.path {
|
||||||
|
name = "ironbar";
|
||||||
|
path = prev.lib.cleanSource ./.;
|
||||||
|
};
|
||||||
|
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];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
packages = genSystems (
|
||||||
|
system: let
|
||||||
|
pkgs = pkgsFor system;
|
||||||
|
in
|
||||||
|
(self.overlays.default pkgs pkgs)
|
||||||
|
// {
|
||||||
|
default = self.packages.${system}.ironbar;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
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
|
||||||
|
];
|
||||||
|
|
||||||
|
RUST_SRC_PATH = "${rust}/lib/rustlib/src/rust/library";
|
||||||
|
};
|
||||||
|
});
|
||||||
|
homeManagerModules.default = {
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
cfg = config.programs.ironbar;
|
||||||
|
defaultIronbarPackage = self.packages.${pkgs.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";
|
||||||
|
};
|
||||||
|
systemd = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = pkgs.stdenv.isLinux;
|
||||||
|
description = "Whether to enable to systemd service for ironbar";
|
||||||
|
};
|
||||||
|
style = lib.mkOption {
|
||||||
|
type = lib.types.lines;
|
||||||
|
default = "";
|
||||||
|
description = "The stylesheet to apply to ironbar";
|
||||||
|
};
|
||||||
|
config = lib.mkOption {
|
||||||
|
type = jsonFormat.type;
|
||||||
|
default = {};
|
||||||
|
description = "The config to pass to ironbar";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
home.packages = [cfg.package];
|
||||||
|
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;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
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")
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue