Skip to content

Commit

Permalink
Wrap alacritty with nixGL to make it render on RHEL8
Browse files Browse the repository at this point in the history
  • Loading branch information
rake5k committed Jan 6, 2023
1 parent b7694a4 commit 3137658
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 82 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ jobs:
uses: christianharke/flake-commons/.github/workflows/nix-ci.yml@main
with:
branch: master
nix-command: build .#homeConfigurations."christian@non-nixos-vm".activationPackage
nix-command: build --impure .#homeConfigurations."christian@non-nixos-vm".activationPackage
nix-ci-non-nixos-vm-demo:
uses: christianharke/flake-commons/.github/workflows/nix-ci.yml@main
with:
branch: master
nix-command: build .#homeConfigurations."demo@non-nixos-vm".activationPackage
nix-command: build --impure .#homeConfigurations."demo@non-nixos-vm".activationPackage
30 changes: 27 additions & 3 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@
pre-commit-hooks.follows = "pre-commit-hooks";
};
};

nixgl = {
url = "github:guibou/nixGL";
inputs = {
nixpkgs.follows = "nixpkgs-unstable";
flake-utils.follows = "flake-utils";
};
};
};

outputs = { self, nixpkgs, ... } @ inputs:
Expand Down
7 changes: 6 additions & 1 deletion flake/per-system.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ let
inherit config system;
};

nixgl = import inputs.nixpkgs-unstable {
inherit system;
overlays = [ inputs.nixgl.overlays.default ];
};

nur = import inputs.nur {
nurpkgs = inputs.nixpkgs.legacyPackages.x86_64-linux;
pkgs = import inputs.nixpkgs {
Expand All @@ -27,7 +32,7 @@ let

overlays = [
(final: prev: {
inherit unstable nur;
inherit unstable nixgl nur;
inherit (inputs.agenix-cli.packages."${system}") agenix-cli;
inherit (inputs.kmonad.packages."${system}") kmonad;

Expand Down
2 changes: 1 addition & 1 deletion home/base/non-nixos/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ in
];

shellAliases = {
hm-switch = "home-manager switch -b hm-bak --flake '${flakeBaseDir}'";
hm-switch = "home-manager switch -b hm-bak --impure --flake '${flakeBaseDir}'";
};
};

Expand Down
5 changes: 5 additions & 0 deletions home/programs/xmonad/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ in
};
};

terminalCmd = mkOption {
type = types.str;
description = "Command to spawn the default terminal emulator";
};

xmobar = {
enable = mkEnableOption "Xmobar";
mobile = mkEnableOption "Enable additional mobile monitors";
Expand Down
2 changes: 1 addition & 1 deletion home/programs/xmonad/xmonad.hs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ pkgs.writeText "xmonad.hs" ''
myModMask = ${cfg.modKey}Mask
myTerminal :: String
myTerminal = "alacritty"
myTerminal = "${cfg.terminalCmd}"
myScratchpads :: [NamedScratchpad]
myScratchpads =
Expand Down
153 changes: 84 additions & 69 deletions home/roles/desktop/alacritty/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,84 +13,99 @@ in
options = {
custom.roles.desktop.alacritty = {
enable = mkEnableOption "Alacritty terminal emulator";

spawnCmd = mkOption {
type = types.str;
default = "alacritty";
description = "Command to spawn the default terminal emulator";
};
};
};

config = mkIf cfg.enable {
home = {
packages = with pkgs; [
desktopCfg.font.package
];

sessionVariables =
let
terminal = "alacritty";
in
{
TERMINAL = terminal;
TERMCMD = terminal;
};
};
config = mkIf cfg.enable
{
home = {
packages = with pkgs; [
desktopCfg.font.package
];

programs.alacritty = {
enable = true;
settings = {
env.TERM = "xterm-256color";
window = {
dynamic_padding = true;
opacity = 0.95;
};
font =
sessionVariables =
let
fontFamily = "${desktopCfg.font.family}";
terminal = "alacritty";
in
{
normal = {
family = fontFamily;
style = "SemiBold";
};
bold = {
family = fontFamily;
style = "Bold";
};
italic = {
family = fontFamily;
style = "Italic";
};
bold_italic = {
family = fontFamily;
style = "Bold Italic";
};
size = 11.5;
TERMINAL = terminal;
TERMCMD = terminal;
};
key_bindings = [
{
key = "Key0";
mods = "Control";
action = "ResetFontSize";
}
{
key = "Numpad0";
mods = "Control";
action = "ResetFontSize";
}
{
key = "NumpadAdd";
mods = "Control";
action = "IncreaseFontSize";
}
{
key = "Plus";
mods = "Control|Shift";
action = "IncreaseFontSize";
}
{
key = "NumpadSubtract";
mods = "Control";
action = "DecreaseFontSize";
}
];
};

programs.alacritty = {
enable = true;
settings = {
env.TERM = "xterm-256color";
window = {
dynamic_padding = true;
opacity = 0.95;
};
font =
let
fontFamily = "${desktopCfg.font.family}";
in
{
normal = {
family = fontFamily;
style = "SemiBold";
};
bold = {
family = fontFamily;
style = "Bold";
};
italic = {
family = fontFamily;
style = "Italic";
};
bold_italic = {
family = fontFamily;
style = "Bold Italic";
};
size = 11.5;
};
key_bindings = [
{
key = "Key0";
mods = "Control";
action = "ResetFontSize";
}
{
key = "Numpad0";
mods = "Control";
action = "ResetFontSize";
}
{
key = "NumpadAdd";
mods = "Control";
action = "IncreaseFontSize";
}
{
key = "Plus";
mods = "Control|Shift";
action = "IncreaseFontSize";
}
{
key = "NumpadSubtract";
mods = "Control";
action = "DecreaseFontSize";
}
];
};
};
} // mkIf config.custom.base.non-nixos.enable {
custom.roles.desktop.alacritty.spawnCmd = "nixGL alacritty";

home = {
packages = with pkgs; [
nixgl.nixgl.auto.nixGLDefault
];
};
};
}
6 changes: 6 additions & 0 deletions home/roles/desktop/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ in
description = "Font config";
};
};

terminalCmd = mkOption {
type = types.str;
default = "${cfg.alacritty.spawnCmd}";
description = "Command to spawn the default terminal emulator";
};
};
};

Expand Down
10 changes: 5 additions & 5 deletions home/roles/desktop/xmonad/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ in
custom.programs.xmonad = {
enable = true;

inherit (desktopCfg) locker;
inherit (desktopCfg) locker terminalCmd;

autoruns = {
"alacritty" = 1;
};
font = {
inherit (desktopCfg.font) package pango;
"${desktopCfg.terminalCmd}" = 1;
};
dmenu = {
package = dmenuPatched;
runCmd = "dmenu_run -fn \"${desktopCfg.font.xft}\" -h 22";
};
font = {
inherit (desktopCfg.font) package pango;
};
xmobar = {
enable = true;
mobile = desktopCfg.mobile.enable;
Expand Down

0 comments on commit 3137658

Please sign in to comment.