feat: add isGraphical target option

This commit is contained in:
winston 2023-11-28 12:21:17 +01:00
parent 4ac4130f5e
commit d9cbfc07dc
Signed by: winston
GPG key ID: 3786770EDBC2B481
18 changed files with 546 additions and 498 deletions

View file

@ -31,16 +31,19 @@
system = "aarch64-darwin"; system = "aarch64-darwin";
username = "winston"; username = "winston";
extraModules = [inputs.nekowinston-nur.darwinModules.default]; extraModules = [inputs.nekowinston-nur.darwinModules.default];
isGraphical = true;
} }
{ {
host = "futomaki"; host = "futomaki";
system = "x86_64-linux"; system = "x86_64-linux";
username = "winston"; username = "winston";
isGraphical = true;
} }
{ {
host = "bento"; host = "bento";
system = "x86_64-linux"; system = "x86_64-linux";
username = "w"; username = "w";
isGraphical = true;
} }
]; ];
imports = [inputs.pre-commit-hooks.flakeModule]; imports = [inputs.pre-commit-hooks.flakeModule];

View file

@ -1,12 +1,14 @@
{ {
config,
lib, lib,
pkgs, pkgs,
... ...
}: let }: let
inherit (pkgs.stdenv.hostPlatform) isLinux; inherit (pkgs.stdenv) isLinux;
in { in {
config = lib.mkIf config.isGraphical {
programs.chromium = { programs.chromium = {
enable = true; enable = isLinux;
package = pkgs.ungoogled-chromium; package = pkgs.ungoogled-chromium;
}; };
@ -152,9 +154,11 @@ in {
}; };
}; };
}; };
home.packages = lib.mkIf isLinux [ home.packages = lib.mkIf isLinux [
pkgs.nekowinston-nur.sizzy pkgs.nekowinston-nur.sizzy
]; ];
xdg.mimeApps.defaultApplications = { xdg.mimeApps.defaultApplications = {
"text/html" = "chromium.desktop"; "text/html" = "chromium.desktop";
"x-scheme-handler/http" = "chromium.desktop"; "x-scheme-handler/http" = "chromium.desktop";
@ -162,4 +166,5 @@ in {
"x-scheme-handler/about" = "chromium.desktop"; "x-scheme-handler/about" = "chromium.desktop";
"x-scheme-handler/unknown" = "chromium.desktop"; "x-scheme-handler/unknown" = "chromium.desktop";
}; };
};
} }

View file

@ -1,22 +1,24 @@
{ {
config, config,
lib,
pkgs, pkgs,
... ...
}: let }: let
# TODO: de-duplicate across modules # TODO: de-duplicate across modules
lat = 48.210033; lat = 48.210033;
lng = 16.363449; lng = 16.363449;
inherit (pkgs.stdenv) isLinux; inherit (pkgs.stdenv) isDarwin isLinux;
in { in {
config = lib.mkIf config.isGraphical {
home.packages = [ home.packages = [
(pkgs.writeShellApplication { (pkgs.writeShellApplication {
name = "dark-mode-ternary"; name = "dark-mode-ternary";
runtimeInputs = [pkgs.gnugrep]; runtimeInputs = [pkgs.gnugrep];
text = let text = let
queryCommand = queryCommand =
if pkgs.stdenv.isLinux if isLinux
then "dbus-send --session --print-reply=literal --reply-timeout=5 --dest=org.freedesktop.portal.Desktop /org/freedesktop/portal/desktop org.freedesktop.portal.Settings.Read string:'org.freedesktop.appearance' string:'color-scheme' | grep -q 'uint32 1'" then "dbus-send --session --print-reply=literal --reply-timeout=5 --dest=org.freedesktop.portal.Desktop /org/freedesktop/portal/desktop org.freedesktop.portal.Settings.Read string:'org.freedesktop.appearance' string:'color-scheme' | grep -q 'uint32 1'"
else if pkgs.stdenv.isDarwin else if isDarwin
then "defaults read -g AppleInterfaceStyle &>/dev/null" then "defaults read -g AppleInterfaceStyle &>/dev/null"
else throw "Unsupported platform"; else throw "Unsupported platform";
in '' in ''
@ -55,4 +57,5 @@ in {
}; };
programs.zsh.shellAliases.cat = "bat --theme=$(dark-mode-ternary 'Catppuccin-mocha' 'Catppuccin-latte')"; programs.zsh.shellAliases.cat = "bat --theme=$(dark-mode-ternary 'Catppuccin-mocha' 'Catppuccin-latte')";
};
} }

View file

@ -1,4 +1,8 @@
{ {
lib,
osConfig,
...
}: {
imports = [ imports = [
./browsers.nix ./browsers.nix
./colorscheme-sync.nix ./colorscheme-sync.nix
@ -18,4 +22,10 @@
./wezterm.nix ./wezterm.nix
./zsh.nix ./zsh.nix
]; ];
options.isGraphical = lib.mkOption {
default = osConfig.isGraphical;
description = "Whether the system is a graphical target";
type = lib.types.bool;
};
} }

View file

@ -6,6 +6,7 @@
}: let }: let
inherit (pkgs.stdenv) isDarwin isLinux; inherit (pkgs.stdenv) isDarwin isLinux;
in { in {
config = lib.mkIf config.isGraphical {
home.packages = with pkgs; [ home.packages = with pkgs; [
(discord.override { (discord.override {
withOpenASAR = true; withOpenASAR = true;
@ -73,4 +74,5 @@ in {
mkdir -p "$(dirname "${path}")" mkdir -p "$(dirname "${path}")"
cp -f "${json}" "${path}" cp -f "${json}" "${path}"
''; '';
};
} }

View file

@ -4,6 +4,7 @@
pkgs, pkgs,
... ...
}: { }: {
config = lib.mkIf config.isGraphical {
home.activation = { home.activation = {
installCustomFonts = let installCustomFonts = let
fontDirectory = fontDirectory =
@ -24,4 +25,5 @@
ibm-plex ibm-plex
xkcd-font xkcd-font
]; ];
};
} }

View file

@ -1,4 +1,8 @@
{pkgs, ...}: let {
config,
pkgs,
...
}: let
inherit (pkgs.stdenv.hostPlatform) isLinux isDarwin; inherit (pkgs.stdenv.hostPlatform) isLinux isDarwin;
key = "0x0B89BC45007EE9CC"; key = "0x0B89BC45007EE9CC";
mailvelopeConfig = builtins.toJSON { mailvelopeConfig = builtins.toJSON {
@ -97,6 +101,9 @@ in {
enable = isLinux; enable = isLinux;
enableExtraSocket = true; enableExtraSocket = true;
enableSshSupport = true; enableSshSupport = true;
pinentryFlavor = "gnome3"; pinentryFlavor =
if config.isGraphical
then "gnome3"
else "curses";
}; };
} }

View file

@ -4,14 +4,16 @@
pkgs, pkgs,
... ...
}: let }: let
inherit (pkgs.stdenv) isLinux; themeDir = "${config.gtk.theme.package}/share/themes/${config.gtk.theme.name}";
in { in {
home.pointerCursor = lib.mkIf isLinux { config = lib.mkIf (config.isGraphical && pkgs.stdenv.isLinux) {
home.pointerCursor = {
name = "macOS-Monterey"; name = "macOS-Monterey";
package = pkgs.nur.repos.nekowinston.apple-cursor; package = pkgs.nur.repos.nekowinston.apple-cursor;
size = 24; size = 24;
}; };
gtk = lib.mkIf isLinux {
gtk = {
enable = true; enable = true;
iconTheme = { iconTheme = {
name = "Papirus-Dark"; name = "Papirus-Dark";
@ -43,10 +45,7 @@ in {
}; };
}; };
xdg = let xdg = {
themeDir = "${config.gtk.theme.package}/share/themes/${config.gtk.theme.name}";
in
lib.mkIf config.gtk.enable {
configFile."gtk-4.0/assets" = { configFile."gtk-4.0/assets" = {
source = "${themeDir}/gtk-4.0/assets"; source = "${themeDir}/gtk-4.0/assets";
recursive = true; recursive = true;
@ -54,4 +53,5 @@ in {
configFile."gtk-4.0/gtk.css".source = "${themeDir}/gtk-4.0/gtk.css"; configFile."gtk-4.0/gtk.css".source = "${themeDir}/gtk-4.0/gtk.css";
configFile."gtk-4.0/gtk-dark.css".source = "${themeDir}/gtk-4.0/gtk-dark.css"; configFile."gtk-4.0/gtk-dark.css".source = "${themeDir}/gtk-4.0/gtk-dark.css";
}; };
};
} }

View file

@ -1,13 +1,13 @@
{ {
config,
lib, lib,
pkgs, pkgs,
... ...
}: let }: let
inherit (pkgs.stdenv.hostPlatform) isDarwin isLinux; inherit (pkgs.stdenv.hostPlatform) isDarwin isLinux;
in { in {
programs.imv = { config = lib.mkIf config.isGraphical {
enable = isLinux; programs.imv.enable = isLinux;
};
programs.mpv.enable = isLinux; programs.mpv.enable = isLinux;
programs.zathura.enable = isLinux; programs.zathura.enable = isLinux;
@ -24,4 +24,5 @@ in {
"video/mp4" = "mpv.desktop"; "video/mp4" = "mpv.desktop";
"video/webm" = "mpv.desktop"; "video/webm" = "mpv.desktop";
}; };
};
} }

View file

@ -1,4 +1,5 @@
{ {
config,
lib, lib,
pkgs, pkgs,
... ...
@ -13,6 +14,7 @@
mauve = "#cba6f7"; mauve = "#cba6f7";
}; };
in { in {
config = lib.mkIf config.isGraphical {
programs.i3status-rust = lib.mkIf isLinux { programs.i3status-rust = lib.mkIf isLinux {
enable = true; enable = true;
bars.top = { bars.top = {
@ -124,4 +126,5 @@ in {
ring-wrong-color = "f38ba8"; ring-wrong-color = "f38ba8";
}; };
}; };
};
} }

View file

@ -5,7 +5,6 @@
pkgs, pkgs,
... ...
}: let }: let
inherit (pkgs.stdenv.hostPlatform) isLinux;
fonts = { fonts = {
names = ["IBM Plex Sans" "Symbols Nerd Font"]; names = ["IBM Plex Sans" "Symbols Nerd Font"];
size = 12.0; size = 12.0;
@ -21,9 +20,10 @@
lat = 48.210033; lat = 48.210033;
lng = 16.363449; lng = 16.363449;
in { in {
config = lib.mkIf (config.isGraphical && pkgs.stdenv.isLinux) {
fonts.fontconfig.enable = true; fonts.fontconfig.enable = true;
home = lib.mkIf isLinux { home = {
packages = with pkgs; [ packages = with pkgs; [
blueberry blueberry
kooha kooha
@ -35,7 +35,7 @@ in {
]; ];
}; };
services = lib.mkIf isLinux { services = {
clipman.enable = true; clipman.enable = true;
gnome-keyring = { gnome-keyring = {
enable = true; enable = true;
@ -51,8 +51,7 @@ in {
wayland.windowManager.sway = let wayland.windowManager.sway = let
modifier = "Mod4"; modifier = "Mod4";
in in {
lib.mkIf isLinux {
enable = true; enable = true;
package = null; package = null;
config = rec { config = rec {
@ -350,4 +349,5 @@ in {
xdgAutostart = true; xdgAutostart = true;
}; };
}; };
};
} }

View file

@ -11,7 +11,7 @@
keybindingsJSON = config.lib.file.mkOutOfStoreSymlink "${flakePath}/home/apps/vscode/keybindings.json"; keybindingsJSON = config.lib.file.mkOutOfStoreSymlink "${flakePath}/home/apps/vscode/keybindings.json";
in { in {
programs.vscode = { programs.vscode = {
enable = true; enable = config.isGraphical;
extensions = with pkgs.vscode-marketplace; [ extensions = with pkgs.vscode-marketplace; [
pkgs.vscode-extensions.valentjn.vscode-ltex pkgs.vscode-extensions.valentjn.vscode-ltex
adrianwilczynski.alpine-js-intellisense adrianwilczynski.alpine-js-intellisense

View file

@ -1,11 +1,19 @@
{ {
config, config,
flakePath, flakePath,
lib,
pkgs, pkgs,
... ...
}: let }: let
mkSymlink = path: config.lib.file.mkOutOfStoreSymlink "${flakePath}/home/apps/wezterm/${path}"; mkSymlink = path: config.lib.file.mkOutOfStoreSymlink "${flakePath}/home/apps/wezterm/${path}";
in { in {
# use the GUI version & config when we have a gui, else just get terminfo
config = lib.mkMerge [
(lib.mkIf (!config.isGraphical) {
home.packages = [pkgs.wezterm.terminfo];
})
(lib.mkIf config.isGraphical {
programs.wezterm.enable = true; programs.wezterm.enable = true;
xdg.configFile = { xdg.configFile = {
@ -34,4 +42,6 @@ in {
source ${config.programs.wezterm.package}/etc/profile.d/wezterm.sh source ${config.programs.wezterm.package}/etc/profile.d/wezterm.sh
fi fi
''; '';
})
];
} }

View file

@ -32,7 +32,7 @@ in {
wakatime wakatime
watchexec watchexec
] ]
++ lib.optionals isLinux [ ++ lib.optionals (config.isGraphical && isLinux) [
_1password-gui _1password-gui
nekowinston-nur.uhk-agent nekowinston-nur.uhk-agent
]); ]);

View file

@ -21,6 +21,7 @@
then "/Users/${username}" then "/Users/${username}"
else throw "Unsupported system"; else throw "Unsupported system";
home.username = username; home.username = username;
isGraphical = false;
targets.genericLinux.enable = isLinux; targets.genericLinux.enable = isLinux;
xdg.mime.enable = isLinux; xdg.mime.enable = isLinux;
}; };

View file

@ -11,9 +11,9 @@
then "/home" then "/home"
else throw "Unsupported OS"; else throw "Unsupported OS";
in { in {
users.users."${config.dotfiles.username}" = users.users."${config.lib.dotfiles.username}" =
{ {
home = "${homeRoot}/${config.dotfiles.username}"; home = "${homeRoot}/${config.lib.dotfiles.username}";
openssh.authorizedKeys.keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILm0O46zW/XfVOSwz0okRWYeOAg+wCVkCtCAoVTpZsOh"]; openssh.authorizedKeys.keys = ["ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILm0O46zW/XfVOSwz0okRWYeOAg+wCVkCtCAoVTpZsOh"];
shell = pkgs.zsh; shell = pkgs.zsh;
} }

View file

@ -25,7 +25,7 @@
virtualisation.podman.enable = true; virtualisation.podman.enable = true;
virtualisation.libvirtd.enable = true; virtualisation.libvirtd.enable = true;
users.users."${config.dotfiles.username}".extraGroups = ["libvirtd" "transmission"]; users.users."${config.lib.dotfiles.username}".extraGroups = ["libvirtd" "transmission"];
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
cabextract cabextract

View file

@ -26,6 +26,7 @@
host, host,
system, system,
username, username,
isGraphical ? false,
extraModules ? [], extraModules ? [],
}: let }: let
ldTernary = l: d: ldTernary = l: d:
@ -46,11 +47,11 @@
modules = with inputs; modules = with inputs;
[ [
{ {
options.dotfiles.username = with pkgs.lib; config.lib.dotfiles = {inherit username;};
mkOption { options.isGraphical = pkgs.lib.mkOption {
description = "Main user of this configuration."; type = pkgs.lib.types.bool;
type = types.str; default = isGraphical;
default = username; description = "Whether the system is a isGraphical target";
}; };
} }
./common/shared ./common/shared