2022-04-10 11:54:58 +02:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
options,
|
|
|
|
...
|
|
|
|
}: let
|
|
|
|
inherit
|
|
|
|
(lib)
|
2022-01-11 16:08:21 +01:00
|
|
|
mkEnableOption
|
|
|
|
mkIf
|
|
|
|
optional
|
2022-04-10 11:54:58 +02:00
|
|
|
;
|
|
|
|
in {
|
2022-01-07 17:44:30 +01:00
|
|
|
options.my.gui = {
|
2022-01-11 16:08:21 +01:00
|
|
|
enable = mkEnableOption "System has some kind of screen attached";
|
|
|
|
isNvidia = mkEnableOption "System a NVIDIA GPU";
|
2022-01-07 17:44:30 +01:00
|
|
|
};
|
2021-06-01 14:28:20 +02:00
|
|
|
|
2022-01-11 16:08:21 +01:00
|
|
|
config = mkIf config.my.gui.enable {
|
2022-01-07 17:44:30 +01:00
|
|
|
my.displayManager.sddm.enable = true;
|
|
|
|
|
|
|
|
services = {
|
|
|
|
xserver = {
|
|
|
|
enable = true;
|
|
|
|
# NOTE: could use `mkOptionDefault` but this feels more explicit
|
2022-04-10 11:54:58 +02:00
|
|
|
videoDrivers =
|
|
|
|
if config.my.gui.isNvidia
|
|
|
|
then ["nvidia"]
|
|
|
|
else options.services.xserver.videoDrivers.default;
|
2022-01-07 17:44:30 +01:00
|
|
|
windowManager.i3.enable = true;
|
|
|
|
layout = "fr";
|
|
|
|
xkbVariant = "us";
|
|
|
|
libinput.enable = true;
|
|
|
|
};
|
2022-01-17 22:02:26 +01:00
|
|
|
|
|
|
|
logind.lidSwitch = "ignore";
|
2022-01-07 17:44:30 +01:00
|
|
|
};
|
|
|
|
|
2022-01-11 16:08:21 +01:00
|
|
|
environment.systemPackages = builtins.attrValues {
|
2022-04-10 11:54:58 +02:00
|
|
|
inherit
|
|
|
|
(pkgs)
|
2022-01-11 16:08:21 +01:00
|
|
|
element-desktop
|
|
|
|
feh
|
|
|
|
firefox
|
|
|
|
ffmpeg
|
|
|
|
gimp
|
|
|
|
imagemagick
|
|
|
|
mpv
|
|
|
|
obs-studio
|
|
|
|
pavucontrol
|
|
|
|
slack
|
|
|
|
spotify
|
|
|
|
tdesktop
|
|
|
|
teams
|
|
|
|
thunderbird
|
|
|
|
virt-manager
|
|
|
|
zathura
|
2022-04-10 11:54:58 +02:00
|
|
|
;
|
2021-04-18 14:46:12 +02:00
|
|
|
|
2022-01-11 16:08:21 +01:00
|
|
|
inherit (pkgs.gnome) nautilus;
|
|
|
|
|
2022-10-04 23:31:14 +02:00
|
|
|
discord = (pkgs.unstable.discord.override { nss = pkgs.nss_latest; });
|
2022-01-11 16:08:21 +01:00
|
|
|
};
|
2021-04-19 16:07:38 +02:00
|
|
|
|
2022-01-18 15:09:23 +01:00
|
|
|
networking.networkmanager = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
dispatcherScripts = [
|
|
|
|
{
|
2022-04-10 11:54:58 +02:00
|
|
|
source = let
|
|
|
|
grep = "${pkgs.gnugrep}/bin/grep";
|
|
|
|
nmcli = "${pkgs.networkmanager}/bin/nmcli";
|
|
|
|
in
|
|
|
|
pkgs.writeShellScript "disable_wifi_on_ethernet" ''
|
2022-01-18 15:09:23 +01:00
|
|
|
export LC_ALL=C
|
2022-06-13 16:42:22 +02:00
|
|
|
date >> /tmp/disable_wifi_on_ethernet.log
|
|
|
|
echo START "$@" >> /tmp/disable_wifi_on_ethernet.log
|
2022-01-18 15:09:23 +01:00
|
|
|
|
2022-06-13 16:42:22 +02:00
|
|
|
beginswith() { case $2 in "$1"*) true;; *) false;; esac; }
|
|
|
|
|
|
|
|
is_ethernet_interface ()
|
2022-01-18 15:09:23 +01:00
|
|
|
{
|
2022-06-13 16:42:22 +02:00
|
|
|
local type="$(${nmcli} dev show "$1" | grep 'GENERAL\.TYPE:' | awk '{ print $2 }')"
|
|
|
|
test "$type" = "ethernet" || beginswith enp "$1"
|
2022-01-18 15:09:23 +01:00
|
|
|
}
|
|
|
|
|
2022-06-13 16:42:22 +02:00
|
|
|
hotspot_enabled ()
|
|
|
|
{
|
|
|
|
${nmcli} dev | ${grep} -q "hotspot"
|
|
|
|
}
|
|
|
|
|
|
|
|
if is_ethernet_interface "$1" && ! hotspot_enabled; then
|
|
|
|
echo "change in ethernet and not in hotspot mode" >> /tmp/disable_wifi_on_ethernet.log
|
|
|
|
if [ "$2" = "up" ]; then
|
|
|
|
echo "turning wifi off" >> /tmp/disable_wifi_on_ethernet.log
|
|
|
|
nmcli radio wifi off
|
|
|
|
fi
|
2022-01-18 15:09:23 +01:00
|
|
|
|
2022-06-13 16:42:22 +02:00
|
|
|
if [ "$2" = "down" ]; then
|
|
|
|
echo "turning wifi on" >> /tmp/disable_wifi_on_ethernet.log
|
|
|
|
nmcli radio wifi on
|
|
|
|
fi
|
2022-01-18 15:09:23 +01:00
|
|
|
fi
|
2022-06-13 16:42:22 +02:00
|
|
|
echo END "$@" >> /tmp/disable_wifi_on_ethernet.log
|
2022-01-18 15:09:23 +01:00
|
|
|
'';
|
|
|
|
type = "basic";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2022-01-07 17:20:57 +01:00
|
|
|
programs.nm-applet.enable = true;
|
|
|
|
programs.steam.enable = true;
|
|
|
|
|
2022-04-20 11:57:50 +02:00
|
|
|
# this is necessary to set GTK stuff in home manager
|
|
|
|
# FIXME: better interdependency between this and the home part
|
|
|
|
programs.dconf.enable = true;
|
|
|
|
|
2022-01-07 17:20:57 +01:00
|
|
|
# NOTE: needed for home emacs configuration
|
|
|
|
nixpkgs.config.input-fonts.acceptLicense = true;
|
|
|
|
};
|
2021-04-16 21:33:48 +02:00
|
|
|
}
|