mirror of
https://github.com/scorpion-26/gBar.git
synced 2024-11-22 03:02:49 +00:00
Add a home-manager nix module (#11)
Add a home-manager module to simplify installation and config management on nix systems. This greatly reduces the setup time and makes it integrate better with other programs on nix, mainly Hyprland which this module is based on.
This commit is contained in:
parent
00caccc459
commit
3b6bafe91a
3 changed files with 60 additions and 10 deletions
|
@ -32,7 +32,10 @@ You can install it e.g.: with yay
|
|||
```yay -S gbar-git```
|
||||
|
||||
## Building and installation (Nix)
|
||||
You can install the nix flake in a number of ways, either through your system/home flake or simply running nix build to get the binary directly.
|
||||
If you choose the Nix/NixOS installation there are a couple of ways to do it but they all require you to have flakes enabled.
|
||||
- Building it seperately and just running the binary, run nix build in the directory and use the binary from ./result/bin
|
||||
- Import the flake to inputs and then add `gBar.defaultPackage.x86_64-linux` to either environment.systemPackages or home.packages.
|
||||
- Use the home manager module. This is done by, as in the previous way, importing the flake and then adding `gBar.homeManagerModules.x86_64-linux.default` into your home-manager imorts section. This exposes the option programs.gBar to home manager and you can look at the module file to see available options.
|
||||
|
||||
## Running gBar
|
||||
*Open bar on monitor 0*
|
||||
|
|
11
flake.nix
11
flake.nix
|
@ -13,7 +13,6 @@
|
|||
gbar = (with pkgs; stdenv.mkDerivation {
|
||||
|
||||
name = "gbar";
|
||||
|
||||
src = ./.;
|
||||
|
||||
nativeBuildInputs = [
|
||||
|
@ -31,21 +30,15 @@
|
|||
gtk-layer-shell
|
||||
libpulseaudio
|
||||
];
|
||||
|
||||
|
||||
});
|
||||
in rec {
|
||||
defaultApp = flake-utils.lib.mkApp {
|
||||
drv = defaultPackage;
|
||||
};
|
||||
in {
|
||||
defaultPackage = gbar;
|
||||
devShell = pkgs.mkShell {
|
||||
buildInputs = [
|
||||
gbar
|
||||
];
|
||||
};
|
||||
homeManagerModules.default = import ./module.nix self;
|
||||
}
|
||||
|
||||
);
|
||||
}
|
||||
|
||||
|
|
54
module.nix
Normal file
54
module.nix
Normal file
|
@ -0,0 +1,54 @@
|
|||
# Based on Hyprland's home-manager and NixOS module
|
||||
|
||||
self:
|
||||
{ config
|
||||
, lib
|
||||
, pkgs
|
||||
, ...
|
||||
}: let
|
||||
cfg = config.programs.gBar;
|
||||
|
||||
defaultGBarPackage = self.defaultPackage.x86_64-linux;
|
||||
|
||||
in {
|
||||
options.programs.gBar = {
|
||||
enable = lib.mkEnableOption "Wether to enable gBar, a blazingly fast statusbar written in c++";
|
||||
|
||||
package = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.package;
|
||||
default = defaultGBarPackage;
|
||||
defaultText = lib.literalExpression "<gBar flake>.packages.<system>.default";
|
||||
example = lib.literalExpression "<gBar flake>.packages.<system>.default.override { }";
|
||||
description = ''
|
||||
gBar package to use.
|
||||
'';
|
||||
};
|
||||
|
||||
extraConfig = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.lines;
|
||||
default = null;
|
||||
description = ''
|
||||
Configuration to write to ~/.config/gBar/config, if none nothing happens
|
||||
'';
|
||||
};
|
||||
|
||||
extraCSS = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.lines;
|
||||
default = null;
|
||||
description = ''
|
||||
Configuration to write to ~/.config/gBar/config, if none nothing happens
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
home.packages = lib.optional (cfg.package != null) cfg.package;
|
||||
|
||||
xdg.configFile."gBar/config" = lib.mkIf (cfg.extraConfig != null) {
|
||||
text = cfg.extraConfig;
|
||||
};
|
||||
xdg.configFile."gBar/style.css" = lib.mkIf (cfg.extraCSS != null) {
|
||||
text = cfg.extraCSS;
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue