Rework modules

This commit is contained in:
Victor Mignot 2024-08-01 21:40:51 +02:00
parent 3b37b97c76
commit 0f0409a489
Signed by: dala
GPG key ID: 5E7F2CE1BEAFED3D
36 changed files with 476 additions and 674 deletions

View file

@ -53,7 +53,7 @@
}; };
}; };
machineUsers = { my.users = {
dala = { dala = {
description = "Dala"; description = "Dala";
groups = [ "wheel" ]; groups = [ "wheel" ];

View file

@ -32,7 +32,7 @@
swapDevices = [ { device = "/dev/disk/by-uuid/a7c628ab-c5cb-4094-89d0-19b153fbead4"; } ]; swapDevices = [ { device = "/dev/disk/by-uuid/a7c628ab-c5cb-4094-89d0-19b153fbead4"; } ];
hwAccelerationGPU = "intel"; my.hardware.gpu = "intel";
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
} }

View file

@ -15,11 +15,7 @@
deployment.targetHost = null; deployment.targetHost = null;
boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
useLatestKernel = true; console.keyMap = "us";
isProfessional = false;
allowUnfreePackages = true;
keymap = "us";
sops = { sops = {
gnupg.sshKeyPaths = [ ]; gnupg.sshKeyPaths = [ ];
@ -31,7 +27,7 @@
secrets.wg0_private = { }; secrets.wg0_private = { };
}; };
machineUsers = { my.users = {
dala = { dala = {
description = "Dala"; description = "Dala";
groups = [ groups = [
@ -45,10 +41,10 @@
uid = 1000; uid = 1000;
shell = pkgs.fish; shell = pkgs.fish;
enableHomeManagerProfile = true; hmConfig = {
homeManagerConfig = {
programs.helix.enable = true; programs.helix.enable = true;
desktop.monitors = [ my.communications.matrix-client.enable = true;
my.desktop.sway.monitors = [
{ {
name = "Chimei Innolux Corporation 0x14C9 Unknown"; name = "Chimei Innolux Corporation 0x14C9 Unknown";
resolution = "1920x1080@60.008Hz"; resolution = "1920x1080@60.008Hz";
@ -57,7 +53,7 @@
} }
]; ];
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
development.embedded.enableTools = true; my.development.embedded-tools.enable = true;
}; };
}; };
}; };

View file

@ -13,7 +13,7 @@
boot.kernelModules = [ "kvm-intel" ]; boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
hwAccelerationGPU = "intel"; my.hardware.gpu = "intel";
boot.initrd.luks.devices = { boot.initrd.luks.devices = {
crypted-nixos = { crypted-nixos = {

View file

@ -9,15 +9,9 @@
imports = [ ./hardware.nix ]; imports = [ ./hardware.nix ];
# Meta
isProfessional = false;
deployment.targetHost = null; deployment.targetHost = null;
boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
# Linux kernel
useLatestKernel = true;
# Custom udev rules for Nucleo's stlink interface # Custom udev rules for Nucleo's stlink interface
services.udev.extraRules = '' services.udev.extraRules = ''
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b",MODE="660",GROUP="dialout",TAG+="uaccess" ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b",MODE="660",GROUP="dialout",TAG+="uaccess"
@ -25,15 +19,7 @@
''; '';
# Nix # Nix
allowUnfreePackages = true; nixpkgs.config.allowUnfree = true;
# Hardware acceleration
hwAccelerationGPU = "nvidia";
# Enable Docker
enableDocker = true;
keymap = "fr";
# System secrets # System secrets
sops = { sops = {
@ -66,7 +52,7 @@
}; };
# User config # User config
machineUsers = { my.users = {
dala = { dala = {
description = "Dala"; description = "Dala";
groups = [ groups = [
@ -82,10 +68,9 @@
]; ];
uid = 1000; uid = 1000;
shell = pkgs.fish; shell = pkgs.fish;
enableHomeManagerProfile = true; hmConfig = {
homeManagerConfig = {
programs.helix.enable = true; programs.helix.enable = true;
desktop.monitors = [ my.desktop.sway.monitors = [
{ {
name = "Iiyama North America PL2470H 0x0000047B"; name = "Iiyama North America PL2470H 0x0000047B";
resolution = "1920x1080@165.003Hz"; resolution = "1920x1080@165.003Hz";
@ -101,7 +86,7 @@
]; ];
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
development.embedded.enableTools = true; my.development.embedded-tools.enable = true;
}; };
}; };
}; };

View file

@ -41,5 +41,6 @@
swapDevices = [ { device = "/dev/disk/by-uuid/5fe5e76b-df3d-43ce-abf9-d2b63078df09"; } ]; swapDevices = [ { device = "/dev/disk/by-uuid/5fe5e76b-df3d-43ce-abf9-d2b63078df09"; } ];
my.hardware.gpu = "nvidia";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
} }

View file

@ -10,11 +10,11 @@
# Use the extlinux boot loader. (NixOS wants to enable GRUB by default) # Use the extlinux boot loader. (NixOS wants to enable GRUB by default)
boot.loader.grub.enable = false; boot.loader.grub.enable = false;
enableSystemdBoot = false; my.systemd-boot.enable = false;
# Enables the generation of /boot/extlinux/extlinux.conf # Enables the generation of /boot/extlinux/extlinux.conf
boot.loader.generic-extlinux-compatible.enable = true; boot.loader.generic-extlinux-compatible.enable = true;
machineUsers = { my.users = {
dala = { dala = {
description = "Dala"; description = "Dala";
groups = [ "wheel" ]; groups = [ "wheel" ];

View file

@ -51,6 +51,7 @@
}: }:
let let
machines = import ./machines.nix; machines = import ./machines.nix;
my = import ./modules;
lixModules = { lixModules = {
stable = lix-module-stable; stable = lix-module-stable;
unstable = lix-module-unstable; unstable = lix-module-unstable;
@ -66,13 +67,7 @@
imports = [ imports = [
lixModules.${config.nixpkgs}.nixosModules.default lixModules.${config.nixpkgs}.nixosModules.default
./configurations/${name} ./configurations/${name}
(if (config.type == "workstation") then ./modules/workstation else ./modules/server) (if config.enableHomeManager then home-manager.nixosModules.home-manager else { })
(
if (config.type == "workstation" && config.enableHomeManager) then
home-manager.nixosModules.home-manager
else
{ }
)
(if (config.system == "x86_64-linux") then lanzaboote.nixosModules.lanzaboote else { }) (if (config.system == "x86_64-linux") then lanzaboote.nixosModules.lanzaboote else { })
]; ];
@ -111,7 +106,10 @@
defaults = defaults =
{ ... }: { ... }:
{ {
imports = [ sops-nix.nixosModules.sops ]; imports = [
sops-nix.nixosModules.sops
my.modules
];
}; };
} // machinesNodes; } // machinesNodes;

View file

@ -1,6 +1,5 @@
{ {
london = { london = {
type = "workstation";
nixpkgs = "unstable"; nixpkgs = "unstable";
system = "x86_64-linux"; system = "x86_64-linux";
enableHomeManager = true; enableHomeManager = true;
@ -9,7 +8,6 @@
}; };
camelot = { camelot = {
type = "server";
nixpkgs = "stable"; nixpkgs = "stable";
system = "x86_64-linux"; system = "x86_64-linux";
enableHomeManager = false; enableHomeManager = false;
@ -18,7 +16,6 @@
}; };
fuyuki = { fuyuki = {
type = "workstation";
nixpkgs = "unstable"; nixpkgs = "unstable";
system = "x86_64-linux"; system = "x86_64-linux";
enableHomeManager = true; enableHomeManager = true;
@ -27,7 +24,6 @@
}; };
okeanos = { okeanos = {
type = "server";
nixpkgs = "stable"; nixpkgs = "stable";
system = "aarch64-linux"; system = "aarch64-linux";
enableHomeManager = false; enableHomeManager = false;

View file

@ -7,7 +7,7 @@
}: }:
with lib; with lib;
{ {
options.enableSystemdBoot = mkOption { options.my.systemd-boot.enable = mkOption {
type = types.bool; type = types.bool;
default = true; default = true;
example = false; example = false;
@ -17,13 +17,13 @@ with lib;
''; '';
}; };
config.environment.systemPackages = lib.mkIf config.enableSystemdBoot [ pkgs.sbctl ]; config.environment.systemPackages = lib.mkIf config.my.systemd-boot.enable [ pkgs.sbctl ];
config.boot = config.boot =
{ {
loader.systemd-boot.enable = false; loader.systemd-boot.enable = false;
} }
// ( // (
if config.enableSystemdBoot then if config.my.systemd-boot.enable then
{ {
lanzaboote = { lanzaboote = {
enable = true; enable = true;

View file

@ -17,34 +17,12 @@ with lib;
(modulesPath + "/installer/scan/not-detected.nix") (modulesPath + "/installer/scan/not-detected.nix")
]; ];
options.isProfessional = mkOption { # Only enable fish shell if there is at least one user using it.
type = types.bool; programs.fish.enable = builtins.any (user: user.shell == pkgs.fish) (
default = false; builtins.attrValues config.my.users
example = true; );
description = ''
Whether or not this machine is used for professionnal purposes.
'';
};
options.enableDocker = mkOption { # We always want to disable the X server as only workstation use windows manager
type = types.bool; # and they always use wayland.
default = false; services.xserver.enable = false;
example = true;
description = ''
Whether or not to enable the docker stack.
'';
};
config = {
virtualisation.docker.enable = config.enableDocker;
# Only enable fish shell if there is at least one user using it.
programs.fish.enable = builtins.any (user: user.shell == pkgs.fish) (
builtins.attrValues config.machineUsers
);
# We always want to disable the X server as only workstation use windows manager
# and they always use wayland.
services.xserver.enable = false;
};
} }

View file

@ -6,11 +6,12 @@
... ...
}: }:
let let
gpu = config.my.hardware.gpu;
hwAccelerationOptionPath = if (machineProps == "unstable") then "graphics" else "opengl"; hwAccelerationOptionPath = if (machineProps == "unstable") then "graphics" else "opengl";
in in
with lib; with lib;
{ {
options.hwAccelerationGPU = mkOption { options.my.hardware.gpu = mkOption {
type = types.nullOr ( type = types.nullOr (
types.enum [ types.enum [
"nvidia" "nvidia"
@ -26,14 +27,14 @@ with lib;
}; };
config = { config = {
boot.kernelParams = mkIf (config.hwAccelerationGPU == "intel") [ "i915.enable_guc=2" ]; boot.kernelParams = mkIf (gpu == "intel") [ "i915.enable_guc=2" ];
# Small hack as this option path changes between 24.05 and unstable # Small hack as this option path changes between 24.05 and unstable
hardware.${hwAccelerationOptionPath} = { hardware.${hwAccelerationOptionPath} = {
enable = config.hwAccelerationGPU != null; enable = gpu != null;
extraPackages = with pkgs; [ extraPackages = with pkgs; [
(mkIf (config.hwAccelerationGPU == "intel") intel-media-driver) (mkIf (gpu == "intel") intel-media-driver)
(mkIf (config.hwAccelerationGPU == "intel") intel-compute-runtime) (mkIf (gpu == "intel") intel-compute-runtime)
]; ];
}; };
}; };

View file

@ -1,58 +1,7 @@
{ lib, ... }:
{ {
lib, console.keyMap = lib.mkDefault "fr";
config, time.timeZone = lib.mkDefault "Europe/Paris";
pkgs, console.font = lib.mkDefault "Lat2-Terminus16";
... i18n.defaultLocale = lib.mkDefault "en_US.utf8";
}:
with lib;
{
options.useLatestKernel = mkOption {
type = types.bool;
default = false;
example = true;
description = ''
Whether or not to use the latest Linux kernel version.
'';
};
options.consoleFont = mkOption {
type = types.str;
default = "Lat2-Terminus16";
description = ''
The font to use in the Linux console.
'';
};
options.timeZone = mkOption {
type = types.str;
default = "Europe/Paris";
description = ''
The system time zone.
'';
};
options.locale = mkOption {
type = types.str;
default = "en_US.utf8";
description = ''
The system locale.
'';
};
options.keymap = mkOption {
type = types.str;
default = "fr";
example = "fr";
description = ''
The keyboard map used.
'';
};
config = {
boot.kernelPackages = mkIf config.useLatestKernel pkgs.linuxPackages_latest;
time.timeZone = config.timeZone;
console.font = config.consoleFont;
console.keyMap = config.keymap;
i18n.defaultLocale = config.locale;
};
} }

View file

@ -6,15 +6,6 @@
}: }:
with lib; with lib;
{ {
options.allowUnfreePackages = mkOption {
type = types.bool;
default = false;
example = true;
description = ''
Whether the system can use unfree derivations.
'';
};
config = { config = {
nix = { nix = {
settings.sandbox = true; settings.sandbox = true;
@ -25,7 +16,5 @@ with lib;
experimental-features = nix-command flakes experimental-features = nix-command flakes
''; '';
}; };
nixpkgs.config.allowUnfree = config.allowUnfreePackages;
}; };
} }

View file

@ -11,17 +11,12 @@ let
shell = mkOption { type = types.package; }; shell = mkOption { type = types.package; };
enableHomeManagerProfile = mkOption { hmConfig = mkOption { default = { }; };
type = types.bool;
default = false;
};
homeManagerConfig = mkOption { default = { }; };
}; };
}; };
in in
{ {
options.machineUsers = mkOption { type = types.attrsOf userModule; }; options.my.users = mkOption { type = types.attrsOf userModule; };
config = { config = {
users.users = builtins.mapAttrs (name: value: { users.users = builtins.mapAttrs (name: value: {
@ -31,6 +26,6 @@ in
extraGroups = value.groups; extraGroups = value.groups;
shell = value.shell; shell = value.shell;
uid = mkIf (value.uid != null) value.uid; uid = mkIf (value.uid != null) value.uid;
}) config.machineUsers; }) config.my.users;
}; };
} }

11
modules/default.nix Normal file
View file

@ -0,0 +1,11 @@
{
modules =
{ ... }:
{
imports = [
./common
./server
./workstation
];
};
}

View file

@ -1,34 +0,0 @@
{ lib, extraInfo, ... }:
with lib;
let
host = extraInfo.woodpeckerURI;
in
{
options.server.build.enable = mkOption {
type = types.bool;
default = false;
example = false;
description = ''
Enable the build server stack.
'';
};
config = lib.mkIf config.server.build.enable {
services.nginx.virtualHosts."${host}" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:3007";
};
};
woodpecker-server = {
enable = true;
environment = {
WOODPECKER_HOST = "https://${domain}";
WOODPECKER_SERVER_ADDR = ":3007";
WOODPECKER_OPEN = "true";
};
};
};
}

View file

@ -1,7 +1,7 @@
{ lib, config, ... }: { lib, config, ... }:
with lib; with lib;
{ {
options.enableBluetooth = mkOption { options.my.hardware.bluetooth.enable = mkOption {
type = types.bool; type = types.bool;
default = true; default = true;
example = false; example = false;
@ -10,7 +10,7 @@ with lib;
''; '';
}; };
config = mkIf config.enableBluetooth { config = mkIf config.my.hardware.bluetooth.enable {
hardware.bluetooth = { hardware.bluetooth = {
enable = true; enable = true;
}; };

View file

@ -16,49 +16,42 @@ with lib;
./bluetooth.nix ./bluetooth.nix
]; ];
options.enableHomeManager = mkOption { config =
type = types.bool; {
default = true; programs.dconf.enable = true;
example = false; security.polkit.enable = true;
description = '' services.dbus.enable = true;
Whether to install and use home-manager on this machine.
'';
};
config = { fonts.fontconfig.enable = true;
enableHomeManager = machineProps.enableHomeManager;
home-manager.useGlobalPkgs = mkIf config.enableHomeManager true; services.gnome.gnome-keyring.enable = true;
home-manager.useUserPackages = mkIf config.enableHomeManager true; }
home-manager.sharedModules = mkIf config.enableHomeManager [ // (
./home-manager if machineProps.enableHomeManager then
sopsHmModule
];
home-manager.extraSpecialArgs = {
keymap = config.keymap;
nvidiaGPU = (config.hwAccelerationGPU == "nvidia");
};
home-manager.users = builtins.mapAttrs (
name: value:
mkIf value.enableHomeManagerProfile (
{ {
home.username = name; home-manager.useGlobalPkgs = true;
home.homeDirectory = "/home/${name}"; home-manager.useUserPackages = true;
home.stateVersion = machineProps.stateVersion; home-manager.sharedModules = [
programs.home-manager.enable = true; ./home-manager
enableFishShell = value.shell == pkgs.fish; sopsHmModule
isProfessional = config.isProfessional; ];
home-manager.extraSpecialArgs = {
keymap = config.console.keyMap;
isNvidiaGpu = (config.my.hardware.gpu == "nvidia");
};
home-manager.users = builtins.mapAttrs (
name: value:
{
home.username = name;
home.homeDirectory = "/home/${name}";
home.stateVersion = machineProps.stateVersion;
programs.home-manager.enable = true;
programs.fish.enable = value.shell == pkgs.fish;
}
// value.hmConfig
) config.my.users;
} }
// value.homeManagerConfig else
) { }
) config.machineUsers; );
programs.dconf.enable = true;
security.polkit.enable = true;
services.dbus.enable = true;
fonts.fontconfig.enable = true;
services.gnome.gnome-keyring.enable = true;
};
} }

View file

@ -2,21 +2,26 @@
config, config,
lib, lib,
pkgs, pkgs,
machineProps,
... ...
}: }:
with lib; with lib;
let let
usersHasSway = builtins.any (user: config.home-manager.users.${user}.desktop.enableSwayStack) ( anySwayUser =
builtins.attrNames config.machineUsers if machineProps.enableHomeManager then
); builtins.any (user: config.home-manager.users.${user}.my.desktop.sway.enable) (
builtins.attrNames config.my.users
)
else
false;
in in
{ {
programs.sway = mkIf usersHasSway { programs.sway = mkIf anySwayUser {
enable = true; enable = true;
wrapperFeatures.gtk = true; wrapperFeatures.gtk = true;
}; };
xdg.portal = mkIf usersHasSway { xdg.portal = mkIf anySwayUser {
enable = true; enable = true;
xdgOpenUsePortal = true; xdgOpenUsePortal = true;
wlr.enable = true; wlr.enable = true;

View file

@ -4,38 +4,41 @@
config, config,
... ...
}: }:
let
commConfig = config.my.communications;
in
with lib; with lib;
{ {
options = { options.my.communications = {
communication.discord.enable = mkOption { discord.enable = mkOption {
type = types.bool; type = types.bool;
default = !config.isProfessional;
example = true; example = true;
default = false;
}; };
communication.slack.enable = mkOption { slack.enable = mkOption {
type = types.bool; type = types.bool;
default = config.isProfessional; default = false;
example = true;
};
communication.weechat.enable = mkOption {
type = types.bool;
default = true;
example = false; example = false;
}; };
communication.matrix.enable = mkOption { irc.enable = mkOption {
type = types.bool; type = types.bool;
default = !config.isProfessional; default = false;
example = false;
};
matrix-client.enable = mkOption {
type = types.bool;
default = false;
example = false; example = false;
}; };
}; };
config.home.packages = with pkgs; [ config.home.packages = with pkgs; [
(mkIf config.communication.discord.enable (discord.override { nss = nss_latest; })) (mkIf commConfig.discord.enable (discord.override { nss = nss_latest; }))
(mkIf config.communication.slack.enable slack) (mkIf commConfig.slack.enable slack)
(mkIf config.communication.weechat.enable weechat) (mkIf commConfig.irc.enable weechat)
(mkIf config.communication.matrix.enable element) (mkIf commConfig.matrix-client.enable element)
]; ];
} }

View file

@ -24,15 +24,12 @@ in
./desktop ./desktop
./development ./development
./fish.nix ./fish.nix
./termux.nix
./gpg.nix ./gpg.nix
./communication.nix ./communication.nix
./mail.nix ./mail.nix
./helix.nix ./helix.nix
]; ];
options.isProfessional = mkOption { type = types.bool; };
config = { config = {
fonts.fontconfig.enable = true; fonts.fontconfig.enable = true;

View file

@ -1,14 +1,7 @@
{ config, lib, ... }: { config, lib, ... }:
with lib; with lib;
let
tmuxFix = {
env = {
TERM = "xterm-256color";
};
};
in
{ {
programs.alacritty = mkIf config.desktop.enableSwayStack { programs.alacritty = {
enable = true; enable = true;
settings = { settings = {
font = { font = {
@ -83,6 +76,6 @@ in
window = { window = {
opacity = 1; opacity = 1;
}; };
} // tmuxFix; };
}; };
} }

View file

@ -1,77 +1,6 @@
{
lib,
config,
pkgs,
nvidiaGPU,
...
}:
with lib;
let
desktopPackages =
with pkgs;
[
grim
slurp
wl-clipboard
clipman
wf-recorder
(nerdfonts.override { fonts = [ "JetBrainsMono" ]; })
qt5ct
libsForQt5.qtstyleplugin-kvantum
font-awesome
nordzy-cursor-theme
jetbrains-mono
xdg-utils
libnotify
adwaita-icon-theme
]
++ (
if nvidiaGPU then
[
vulkan-validation-layers
vulkan-headers
vulkan-caps-viewer
vulkan-extension-layer
vulkan-tools
]
else
[ ]
);
in
{ {
imports = [ imports = [
./sway.nix ./sway
./alacritty.nix ./alacritty.nix
./swaylock.nix
./waybar.nix
./wofi.nix
./mako.nix
]; ];
options.desktop.enableSwayStack = mkOption {
type = types.bool;
default = true;
};
config = mkIf config.desktop.enableSwayStack {
home.packages = desktopPackages;
dconf = {
enable = true;
settings."org/gnome/desktop/interface".color-scheme = "prefer-dark";
};
# Theming GTK
gtk = {
enable = true;
theme = {
name = "Nordic-darker";
package = pkgs.nordic;
};
cursorTheme = {
name = "Nordzy-cursors";
package = pkgs.nordzy-cursor-theme;
};
};
};
} }

View file

@ -1,257 +0,0 @@
{
config,
pkgs,
lib,
keymap,
nvidiaGPU,
...
}:
with lib;
let
isQwerty = keymap == "us";
wlrRendererLine = if nvidiaGPU then "export WLR_RENDERER=vulkan" else "";
gnomeSchema = "org.gnome.desktop.interface";
monitorModule = types.submodule {
options = {
name = mkOption { type = types.str; };
resolution = mkOption { type = types.str; };
position = mkOption { type = types.str; };
defaultWorkspace = mkOption { type = types.int; };
};
};
in
{
options = {
desktop.monitors = mkOption { type = types.listOf monitorModule; };
};
config.wayland.windowManager.sway = mkIf config.desktop.enableSwayStack {
enable = true;
systemd.enable = false;
checkConfig = false;
config = rec {
modifier = "Mod4";
left = "left";
right = "right";
up = "up";
down = "down";
terminal = "${pkgs.alacritty}/bin/alacritty";
menu = "${pkgs.wofi}/bin/wofi --show drun,run";
fonts = {
names = [ "pango:JetBrainsMono Nerd Font Mono" ];
size = 11.0;
};
input = {
"*" = {
xkb_layout = keymap;
xkb_options = mkIf isQwerty "compose:ralt";
};
"12951:6519:ZSA_Technology_Labs_Voyager" = {
xkb_layout = "us";
xkb_options = "compose:ralt";
};
"Synaptics TM3276-022" = {
dwt = "enabled";
tap = "enabled";
natural_scroll = "enabled";
middle_emulation = "enabled";
};
};
seat = {
"seat0" = {
"xcursor_theme" = "Nordzy-cursors";
};
};
output =
builtins.listToAttrs (
builtins.map (monitor: {
name = monitor.name;
value = {
resolution = monitor.resolution;
position = monitor.position;
};
}) config.desktop.monitors
)
// {
"*".bg = "/home/dala/Perso/wallpapers/tanuki.jpg fill";
};
workspaceOutputAssign = map (monitor: {
output = monitor.name;
workspace = builtins.toString monitor.defaultWorkspace;
}) config.desktop.monitors;
startup = [
{
command = ''
${pkgs.swayidle}/bin/swayidle -w \
timeout 1200 '${pkgs.swaylock}/bin/swaylock -f' \
timeout 1800 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' \
before-sleep '${pkgs.swaylock}/bin/swaylock -f'
'';
}
{ command = "${pkgs.nextcloud-client}/bin/nextcloud --background"; }
{ command = "${pkgs.keepassxc}/bin/keepassxc"; }
{
command = ''
${pkgs.wl-clipboard}/bin/wl-paste -t text --watch ${pkgs.clipman}/bin/clipman store --no-persist
'';
}
{
command = "${pkgs.glib}/bin/gsettings set ${gnomeSchema} gtk-theme 'Nordic'";
always = true;
}
{
command = "${pkgs.glib}/bin/gsettings set ${gnomeSchema} cursor-theme 'Nordzy-cursors'";
always = true;
}
{
command = "${pkgs.glib}/bin/gsettings set ${gnomeSchema} font-name 'JetBrainsMono Nerd Font Mono'";
always = true;
}
];
modes = {
resize = {
"Left" = "resize shrink width 10px";
"Down" = "resize grow height 10px";
"Up" = "resize shrink height 10px";
"Right" = "resize grow width 10px";
"Return" = "mode default";
"Escape" = "mode default";
};
};
gaps = {
inner = 5;
smartGaps = true;
};
floating = {
modifier = "${modifier} normal";
};
bars = [ { command = "${pkgs.waybar}/bin/waybar"; } ];
keybindings = {
"${modifier}+Return" = "exec ${terminal}";
"${modifier}+Shift+q" = "kill";
"${modifier}+d" = "exec ${menu}";
"${modifier}+Shift+r" = "reload";
"${modifier}+Shift+e" = "exec swaymsg exit";
"${modifier}+Shift+l" = "exec swaylock -f";
"${modifier}+Left" = "focus left";
"${modifier}+Down" = "focus down";
"${modifier}+Up" = "focus up";
"${modifier}+Right" = "focus right";
"${modifier}+Shift+Left" = "move left";
"${modifier}+Shift+Down" = "move down";
"${modifier}+Shift+Up" = "move up";
"${modifier}+Shift+Right" = "move right";
"${modifier}+1" = "workspace 1";
"${modifier}+2" = "workspace 2";
"${modifier}+3" = "workspace 3";
"${modifier}+4" = "workspace 4";
"${modifier}+5" = "workspace 5";
"${modifier}+6" = "workspace 6";
"${modifier}+7" = "workspace 7";
"${modifier}+8" = "workspace 8";
"${modifier}+9" = "workspace 9";
"${modifier}+0" = "workspace 10";
"${modifier}+ampersand" = "workspace 1";
"${modifier}+eacute" = "workspace 2";
"${modifier}+quotedbl" = "workspace 3";
"${modifier}+apostrophe" = "workspace 4";
"${modifier}+parenleft" = "workspace 5";
"${modifier}+minus" = "workspace 6";
"${modifier}+egrave" = "workspace 7";
"${modifier}+underscore" = "workspace 8";
"${modifier}+ccedilla" = "workspace 9";
"${modifier}+agrave" = "workspace 10";
"${modifier}+Shift+1" = "move container to workspace 1";
"${modifier}+Shift+2" = "move container to workspace 2";
"${modifier}+Shift+3" = "move container to workspace 3";
"${modifier}+Shift+4" = "move container to workspace 4";
"${modifier}+Shift+5" = "move container to workspace 5";
"${modifier}+Shift+6" = "move container to workspace 6";
"${modifier}+Shift+7" = "move container to workspace 7";
"${modifier}+Shift+8" = "move container to workspace 8";
"${modifier}+Shift+9" = "move container to workspace 9";
"${modifier}+Shift+0" = "move container to workspace 10";
"${modifier}+Shift+ampersand" = "move container to workspace 1";
"${modifier}+Shift+eacute" = "move container to workspace 2";
"${modifier}+Shift+quotedbl" = "move container to workspace 3";
"${modifier}+Shift+apostrophe" = "move container to workspace 4";
"${modifier}+Shift+parenleft" = "move container to workspace 5";
"${modifier}+Shift+minus" = "move container to workspace 6";
"${modifier}+Shift+egrave" = "move container to workspace 7";
"${modifier}+Shift+underscore" = "move container to workspace 8";
"${modifier}+Shift+ccedilla" = "move container to workspace 9";
"${modifier}+Shift+agrave" = "move container to workspace 10";
"${modifier}+h" = "splith";
"${modifier}+v" = "splitv";
"${modifier}+s" = "layout stacking";
"${modifier}+w" = "layout tabbed";
"${modifier}+e" = "layout toggle split";
"${modifier}+f" = "fullscreen";
"${modifier}+Shift+space" = "floating toggle";
"${modifier}+space" = "focus mode_toggle";
"${modifier}+a" = "focus parent";
"${modifier}+Shift+parenright" = "move scratchpad";
"${modifier}+parenright" = "scratchpad show";
"${modifier}+r" = "mode resize";
"XF86AudioRaiseVolume" = "exec --no-startup-id pactl set-sink-volume 0 +5%"; # increase sound volume
"XF86AudioLowerVolume" = "exec --no-startup-id pactl set-sink-volume 0 -5%"; # decrease sound volume
"XF86AudioMute" = "exec --no-startup-id pactl set-sink-mute 0 toggle"; # mute sound
"XF86MonBrightnessUp" = "exec --no-startup-id light -A 10";
"XF86MonBrightnessDown" = "exec --no-startup-id light -U 10";
"Control+XF86AudioMute" = "exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle";
"Print" = "exec grim -g \"$(${pkgs.slurp}/bin/slurp)\" -t png - | wl-copy --type image/png";
};
};
extraConfig = ''
for_window [class=".*"] inhibit_idle fullscreen
for_window [app_id=".*"] inhibit_idle fullscreen
default_border pixel
'';
xwayland = false;
extraSessionCommands = ''
${wlrRendererLine}
export WLR_NO_HARDWARE_CURSORS=1
export XDG_CURRENT_DESKTOP=sway
export _JAVA_AWT_WM_NONREPARENTING=1
export NIXOS_OZONE_WL=1
export QT_QPA_PLATFORM=wayland
export QT_QPA_PLATFORMTHEME=qt5ct
export QT_WAYLAND_DISABLE_WINDOWDECORATION=1
export MOZ_ENABLE_WAYLAND=1
export SDL_VIDEODRIVER=wayland
'';
};
}

View file

@ -0,0 +1,321 @@
{
config,
pkgs,
lib,
keymap,
isNvidiaGpu,
...
}:
with lib;
let
isQwerty = keymap == "us";
wlrRendererLine = if isNvidiaGpu then "export WLR_RENDERER=vulkan" else "";
gnomeSchema = "org.gnome.desktop.interface";
monitorModule = types.submodule {
options = {
name = mkOption { type = types.str; };
resolution = mkOption { type = types.str; };
position = mkOption { type = types.str; };
defaultWorkspace = mkOption { type = types.int; };
};
};
desktopPackages =
with pkgs;
[
grim
slurp
wl-clipboard
clipman
wf-recorder
(nerdfonts.override { fonts = [ "JetBrainsMono" ]; })
qt5ct
libsForQt5.qtstyleplugin-kvantum
font-awesome
nordzy-cursor-theme
jetbrains-mono
xdg-utils
libnotify
adwaita-icon-theme
]
++ (
if isNvidiaGpu then
[
vulkan-validation-layers
vulkan-headers
vulkan-caps-viewer
vulkan-extension-layer
vulkan-tools
]
else
[ ]
);
in
{
imports = [
./swaylock.nix
./waybar.nix
./wofi.nix
./mako.nix
];
options = {
my.desktop.sway = {
enable = mkOption {
type = types.bool;
default = true;
};
monitors = mkOption { type = types.listOf monitorModule; };
};
};
config = mkIf config.my.desktop.sway.enable {
home.packages = desktopPackages;
dconf = {
enable = true;
settings."org/gnome/desktop/interface".color-scheme = "prefer-dark";
};
# Theming GTK
gtk = {
enable = true;
theme = {
name = "Nordic-darker";
package = pkgs.nordic;
};
cursorTheme = {
name = "Nordzy-cursors";
package = pkgs.nordzy-cursor-theme;
};
};
wayland.windowManager.sway = {
enable = true;
systemd.enable = false;
checkConfig = false;
config = rec {
modifier = "Mod4";
left = "left";
right = "right";
up = "up";
down = "down";
terminal = "${pkgs.alacritty}/bin/alacritty";
menu = "${pkgs.wofi}/bin/wofi --show drun,run";
fonts = {
names = [ "pango:JetBrainsMono Nerd Font Mono" ];
size = 11.0;
};
input = {
"*" = {
xkb_layout = keymap;
xkb_options = mkIf isQwerty "compose:ralt";
};
"12951:6519:ZSA_Technology_Labs_Voyager" = {
xkb_layout = "us";
xkb_options = "compose:ralt";
};
"Synaptics TM3276-022" = {
dwt = "enabled";
tap = "enabled";
natural_scroll = "enabled";
middle_emulation = "enabled";
};
};
seat = {
"seat0" = {
"xcursor_theme" = "Nordzy-cursors";
};
};
output =
builtins.listToAttrs (
builtins.map (monitor: {
name = monitor.name;
value = {
resolution = monitor.resolution;
position = monitor.position;
};
}) config.my.desktop.sway.monitors
)
// {
"*".bg = "/home/dala/Perso/wallpapers/tanuki.jpg fill";
};
workspaceOutputAssign = map (monitor: {
output = monitor.name;
workspace = builtins.toString monitor.defaultWorkspace;
}) config.my.desktop.sway.monitors;
startup = [
{
command = ''
${pkgs.swayidle}/bin/swayidle -w \
timeout 1200 '${pkgs.swaylock}/bin/swaylock -f' \
timeout 1800 'swaymsg "output * dpms off"' resume 'swaymsg "output * dpms on"' \
before-sleep '${pkgs.swaylock}/bin/swaylock -f'
'';
}
{ command = "${pkgs.nextcloud-client}/bin/nextcloud --background"; }
{ command = "${pkgs.keepassxc}/bin/keepassxc"; }
{
command = ''
${pkgs.wl-clipboard}/bin/wl-paste -t text --watch ${pkgs.clipman}/bin/clipman store --no-persist
'';
}
{
command = "${pkgs.glib}/bin/gsettings set ${gnomeSchema} gtk-theme 'Nordic'";
always = true;
}
{
command = "${pkgs.glib}/bin/gsettings set ${gnomeSchema} cursor-theme 'Nordzy-cursors'";
always = true;
}
{
command = "${pkgs.glib}/bin/gsettings set ${gnomeSchema} font-name 'JetBrainsMono Nerd Font Mono'";
always = true;
}
];
modes = {
resize = {
"Left" = "resize shrink width 10px";
"Down" = "resize grow height 10px";
"Up" = "resize shrink height 10px";
"Right" = "resize grow width 10px";
"Return" = "mode default";
"Escape" = "mode default";
};
};
gaps = {
inner = 5;
smartGaps = true;
};
floating = {
modifier = "${modifier} normal";
};
bars = [ { command = "${pkgs.waybar}/bin/waybar"; } ];
keybindings = {
"${modifier}+Return" = "exec ${terminal}";
"${modifier}+Shift+q" = "kill";
"${modifier}+d" = "exec ${menu}";
"${modifier}+Shift+r" = "reload";
"${modifier}+Shift+e" = "exec swaymsg exit";
"${modifier}+Shift+l" = "exec swaylock -f";
"${modifier}+Left" = "focus left";
"${modifier}+Down" = "focus down";
"${modifier}+Up" = "focus up";
"${modifier}+Right" = "focus right";
"${modifier}+Shift+Left" = "move left";
"${modifier}+Shift+Down" = "move down";
"${modifier}+Shift+Up" = "move up";
"${modifier}+Shift+Right" = "move right";
"${modifier}+1" = "workspace 1";
"${modifier}+2" = "workspace 2";
"${modifier}+3" = "workspace 3";
"${modifier}+4" = "workspace 4";
"${modifier}+5" = "workspace 5";
"${modifier}+6" = "workspace 6";
"${modifier}+7" = "workspace 7";
"${modifier}+8" = "workspace 8";
"${modifier}+9" = "workspace 9";
"${modifier}+0" = "workspace 10";
"${modifier}+ampersand" = "workspace 1";
"${modifier}+eacute" = "workspace 2";
"${modifier}+quotedbl" = "workspace 3";
"${modifier}+apostrophe" = "workspace 4";
"${modifier}+parenleft" = "workspace 5";
"${modifier}+minus" = "workspace 6";
"${modifier}+egrave" = "workspace 7";
"${modifier}+underscore" = "workspace 8";
"${modifier}+ccedilla" = "workspace 9";
"${modifier}+agrave" = "workspace 10";
"${modifier}+Shift+1" = "move container to workspace 1";
"${modifier}+Shift+2" = "move container to workspace 2";
"${modifier}+Shift+3" = "move container to workspace 3";
"${modifier}+Shift+4" = "move container to workspace 4";
"${modifier}+Shift+5" = "move container to workspace 5";
"${modifier}+Shift+6" = "move container to workspace 6";
"${modifier}+Shift+7" = "move container to workspace 7";
"${modifier}+Shift+8" = "move container to workspace 8";
"${modifier}+Shift+9" = "move container to workspace 9";
"${modifier}+Shift+0" = "move container to workspace 10";
"${modifier}+Shift+ampersand" = "move container to workspace 1";
"${modifier}+Shift+eacute" = "move container to workspace 2";
"${modifier}+Shift+quotedbl" = "move container to workspace 3";
"${modifier}+Shift+apostrophe" = "move container to workspace 4";
"${modifier}+Shift+parenleft" = "move container to workspace 5";
"${modifier}+Shift+minus" = "move container to workspace 6";
"${modifier}+Shift+egrave" = "move container to workspace 7";
"${modifier}+Shift+underscore" = "move container to workspace 8";
"${modifier}+Shift+ccedilla" = "move container to workspace 9";
"${modifier}+Shift+agrave" = "move container to workspace 10";
"${modifier}+h" = "splith";
"${modifier}+v" = "splitv";
"${modifier}+s" = "layout stacking";
"${modifier}+w" = "layout tabbed";
"${modifier}+e" = "layout toggle split";
"${modifier}+f" = "fullscreen";
"${modifier}+Shift+space" = "floating toggle";
"${modifier}+space" = "focus mode_toggle";
"${modifier}+a" = "focus parent";
"${modifier}+Shift+parenright" = "move scratchpad";
"${modifier}+parenright" = "scratchpad show";
"${modifier}+r" = "mode resize";
"XF86AudioRaiseVolume" = "exec --no-startup-id pactl set-sink-volume 0 +5%"; # increase sound volume
"XF86AudioLowerVolume" = "exec --no-startup-id pactl set-sink-volume 0 -5%"; # decrease sound volume
"XF86AudioMute" = "exec --no-startup-id pactl set-sink-mute 0 toggle"; # mute sound
"XF86MonBrightnessUp" = "exec --no-startup-id light -A 10";
"XF86MonBrightnessDown" = "exec --no-startup-id light -U 10";
"Control+XF86AudioMute" = "exec --no-startup-id pactl set-source-mute @DEFAULT_SOURCE@ toggle";
"Print" = "exec grim -g \"$(${pkgs.slurp}/bin/slurp)\" -t png - | wl-copy --type image/png";
};
};
extraConfig = ''
for_window [class=".*"] inhibit_idle fullscreen
for_window [app_id=".*"] inhibit_idle fullscreen
default_border pixel
'';
xwayland = false;
extraSessionCommands = ''
${wlrRendererLine}
export WLR_NO_HARDWARE_CURSORS=1
export XDG_CURRENT_DESKTOP=sway
export _JAVA_AWT_WM_NONREPARENTING=1
export NIXOS_OZONE_WL=1
export QT_QPA_PLATFORM=wayland
export QT_QPA_PLATFORMTHEME=qt5ct
export QT_WAYLAND_DISABLE_WINDOWDECORATION=1
export MOZ_ENABLE_WAYLAND=1
export SDL_VIDEODRIVER=wayland
'';
};
};
}

View file

@ -1,7 +1,7 @@
{ lib, config, ... }: { lib, config, ... }:
with lib; with lib;
{ {
services.mako = mkIf config.desktop.enableSwayStack { services.mako = mkIf config.my.desktop.sway.enable {
enable = true; enable = true;
layer = "overlay"; layer = "overlay";

View file

@ -1,7 +1,7 @@
{ lib, config, ... }: { lib, config, ... }:
with lib; with lib;
{ {
programs.swaylock = mkIf config.desktop.enableSwayStack { programs.swaylock = mkIf config.my.desktop.sway.enable {
enable = true; enable = true;
settings = { settings = {

View file

@ -1,9 +1,8 @@
{ config, lib, ... }: { config, lib, ... }:
with lib; with lib;
{ {
programs.waybar = mkIf config.desktop.enableSwayStack { programs.waybar = mkIf config.my.desktop.sway.enable {
enable = true; enable = true;
#systemd.enable = false;
settings = [ settings = [
{ {

View file

@ -6,7 +6,7 @@
}: }:
with lib; with lib;
{ {
programs.wofi = mkIf config.desktop.enableSwayStack { programs.wofi = mkIf config.my.desktop.sway.enable {
enable = true; enable = true;
settings = { settings = {

View file

@ -8,7 +8,7 @@ with lib;
{ {
imports = [ ./embedded.nix ]; imports = [ ./embedded.nix ];
options.development.enableGit = mkOption { options.my.development.git.enable = mkOption {
type = types.bool; type = types.bool;
default = true; default = true;
example = false; example = false;
@ -17,12 +17,12 @@ with lib;
''; '';
}; };
config.programs.git = mkIf config.development.enableGit { config.programs.git = mkIf config.my.development.git.enable {
enable = true; enable = true;
package = pkgs.gitAndTools.gitFull; package = pkgs.gitAndTools.gitFull;
userName = "Victor Mignot"; userName = "Victor Mignot";
userEmail = "dala@dalaran.fr"; userEmail = "dala@dalaran.fr";
signing = mkIf config.enableGPGKeyring { signing = mkIf config.my.pgp.enable {
key = "BEAFED3D"; key = "BEAFED3D";
signByDefault = true; signByDefault = true;
}; };

View file

@ -6,7 +6,7 @@
}: }:
with lib; with lib;
{ {
options.development.embedded.enableTools = mkOption { options.my.development.embedded-tools.enable = mkOption {
type = types.bool; type = types.bool;
default = false; default = false;
example = true; example = true;
@ -15,7 +15,7 @@ with lib;
''; '';
}; };
options.development.embedded.toolsList = mkOption { options.my.development.embedded-tools.packages = mkOption {
type = types.listOf types.package; type = types.listOf types.package;
default = with pkgs; [ default = with pkgs; [
qemu qemu
@ -23,5 +23,5 @@ with lib;
]; ];
}; };
config.home.packages = lib.mkIf config.development.embedded.enableTools config.development.embedded.toolsList; config.home.packages = lib.mkIf config.my.development.embedded-tools.enable config.my.development.embedded-tools.packages;
} }

View file

@ -6,12 +6,19 @@
... ...
}: }:
with lib; with lib;
let
swayLaunchScript =
if config.my.desktop.sway.enable then
''
if [ -z $DISPLAY ] && [ "$(tty)" = /dev/tty1 ]
exec sway
end
''
else
"";
in
{ {
options.enableFishShell = mkOption { type = types.bool; }; config.programs.fish = mkIf config.programs.fish.enable {
config.programs.fish = mkIf config.enableFishShell {
enable = true;
plugins = [ plugins = [
{ {
name = "bobthefish"; name = "bobthefish";
@ -27,9 +34,7 @@ with lib;
shellInit = '' shellInit = ''
set -g theme_color_scheme nord set -g theme_color_scheme nord
if [ -z $DISPLAY ] && [ "$(tty)" = /dev/tty1 ] ${swayLauncScript}
exec sway
end
''; '';
}; };
} }

View file

@ -6,7 +6,7 @@
}: }:
with lib; with lib;
{ {
options.enableGPGKeyring = mkOption { options.my.pgp.enable = mkOption {
type = types.bool; type = types.bool;
default = true; default = true;
example = false; example = false;
@ -15,7 +15,7 @@ with lib;
''; '';
}; };
config = mkIf config.enableGPGKeyring { config = mkIf config.my.pgp.enable {
programs.gpg.enable = true; programs.gpg.enable = true;
services.gpg-agent = { services.gpg-agent = {

View file

@ -37,10 +37,10 @@ let
showSignature = "append"; showSignature = "append";
}; };
hasNoAddress = config.communication.mailAccounts == null; hasNoAddress = config.my.communications.mail.accounts == null;
in in
{ {
options.communication.mailAccounts = mkOption { options.my.communications.mail.accounts = mkOption {
type = types.nullOr (types.attrsOf mailAccountModule); type = types.nullOr (types.attrsOf mailAccountModule);
default = null; default = null;
}; };
@ -75,7 +75,7 @@ in
name = "${name}/${mb}"; name = "${name}/${mb}";
}) defaultExtraMailboxes; }) defaultExtraMailboxes;
}; };
}) config.communication.mailAccounts; }) config.my.communications.mail.accounts;
services.mbsync.enable = true; services.mbsync.enable = true;
programs.mbsync.enable = true; programs.mbsync.enable = true;

View file

@ -1,51 +0,0 @@
{
lib,
config,
pkgs,
...
}:
with lib;
let
tmuxExtraConfig = ''
set -ag terminal-overrides ",xterm-256color:RGB"
'';
in
{
options.enableTermux = mkOption {
type = types.bool;
default = true;
example = false;
description = ''
Enable termux and the associated config.
'';
};
config.programs.tmux = mkIf config.enableTermux {
enable = true;
# Make windows count start to 1
baseIndex = 1;
# Use 24h clock
clock24 = true;
shell = if config.enableFishShell then "${pkgs.fish}/bin/fish" else "${pkgs.bash}/bin/bash";
keyMode = "vi";
tmuxp.enable = true;
terminal = "tmux-256color";
plugins = with pkgs.tmuxPlugins; [
{
plugin = nord;
extraConfig = ''
set -g @plugin "arcticicestudio/nord-tmux"
'';
}
];
extraConfig = tmuxExtraConfig;
};
}