refactor(flake): split NixOS Home Manager configs

Create a NixOS-specific Home Manager configuration and a reusable shared
configuration that can be imported and also used by other configurations,
such as WSL2.
This commit is contained in:
Oliver Davies 2023-08-08 20:15:31 +01:00
parent 994341071a
commit 3b890d9ee5
11 changed files with 729 additions and 729 deletions

View file

@ -1,5 +1,7 @@
{ inputs, username }:
{ desktop }:
let
configuration = import ./configuration.nix;
hardware-configuration = import ./hardware-configuration.nix;
@ -8,7 +10,7 @@ inputs.nixpkgs.lib.nixosSystem {
modules = [
inputs.home-manager.nixosModules.home-manager {
home-manager = {
extraSpecialArgs = { inherit inputs; };
extraSpecialArgs = { inherit inputs desktop username; };
useGlobalPkgs = true;
useUserPackages = true;
users."${username}" = import ./home-manager.nix;

View file

@ -1,6 +1,3 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }:
{

View file

@ -0,0 +1,240 @@
{ config, inputs, pkgs }:
{
nixpkgs = {
config.allowUnfreePredicate = pkg:
builtins.elem (inputs.lib.getName pkg) [ "postman" ];
};
services.swayidle = {
enable = true;
events = [
{
event = "before-sleep";
command = "${pkgs.swaylock}/bin/swaylock --daemonize --image ~/.config/wallpaper/wallpaper.jpg";
}
];
};
services.swayidle.timeouts = [
{
timeout = 300;
command = "${pkgs.swaylock}/bin/swaylock --daemonize --image ~/.config/wallpaper/wallpaper.jpg";
}
{
timeout = 600;
command = "swaymsg 'output * dpms off'";
resumeCommand = "swaymsg 'output * dpms on'";
}
];
programs.swaylock = {
enable = true;
settings = {
daemonize = true;
image = "~/.config/wallpaper/wallpaper.jpg";
};
};
wayland.windowManager.sway = {
enable = true;
config = {
assigns = {
"1" = [{ app_id = "firefox"; }];
"2" = [{ app_id = "Alacritty"; }];
"3" = [{ class = "vlc"; }];
"9" = [
{ class = "Slack"; }
{ class = "discord"; }
];
# Get app_id with swaymsg -t get_tree
};
bars = [
{
colors = {
background = "#222222";
focusedWorkspace = {
background = "#ffffff";
border = "#ffffff";
text = "#333333";
};
statusline = "#ffffff";
};
fonts = {
names = [ "DejaVu Sans Mono" ];
size = 16.0;
};
statusCommand = "i3status-rs ~/.config/i3status-rust/config-default.toml";
trayPadding = 10;
}
];
gaps = {
inner = 10;
smartBorders = "on";
smartGaps = true;
};
input = {
"*" = {
xkb_layout = "gb";
};
"type:touchpad" = {
dwt = "enabled";
tap = "enabled";
};
};
keybindings =
let modifier = config.wayland.windowManager.sway.config.modifier;
in inputs.nixpkgs.lib.mkOptionDefault {
"${modifier}+Escape" = "exec swaylock --daemonize";
"${modifier}+Shift+b" = "exec firefox";
"${modifier}+tab" = "workspace back_and_forth";
};
menu = "wofi --show run";
modifier = "Mod4";
output = {
"*" = {
bg = "~/.config/wallpaper/wallpaper.jpg fill";
};
eDP-1 = {
scale = "1.0";
};
};
terminal = "alacritty";
window.border = 3;
};
extraConfig = ''
set $laptop eDP-1
bindswitch --reload --locked lid:on output $laptop disable
bindswitch --reload --locked lid:off output $laptop enable
bindsym --locked XF86MonBrightnessDown exec brightnessctl set 5%-
bindsym --locked XF86MonBrightnessUp exec brightnessctl set 5%+
exec alacritty
exec firefox
for_window [class="vlc"] inhibit_idle fullscreen
for_window [app_id="zoom"] floating enable
for_window [app_id="zoom" title="Choose ONE of the audio conference options"] floating enable
for_window [app_id="firefox" title="Firefox Sharing Indicator"] floating enable
for_window [app_id="zoom" title="zoom"] floating enable
for_window [app_id="zoom" title="Zoom Meeting"] floating disable
for_window [app_id="zoom" title="Zoom - Free Account"] floating disable
'';
};
programs.i3status-rust = {
enable = true;
bars = {
default = {
blocks = [
{
block = "net";
format = " $ip ";
}
{
block = "battery";
format = " $icon $percentage $time ";
}
{
block = "cpu";
}
{
block = "memory";
format = " $icon $mem_total_used_percents.eng(w:2) ";
format_alt = " $icon_swap $swap_used_percents.eng(w:2) ";
}
{
block = "disk_space";
path = "/";
info_type = "available";
alert_unit = "GB";
interval = 20;
warning = 20.0;
alert = 10.0;
format = " $icon $available.eng(w:2) ";
}
{
block = "time";
interval = 1;
format = " $timestamp.datetime(f:'%F %T') ";
}
];
settings = {
theme = {
theme = "plain";
overrides = {
critical_bg = "#222222";
good_bg = "#222222";
good_fg = "#ffffff";
idle_bg = "#222222";
idle_fg = "#ffffff";
info_bg = "#222222";
info_fg = "#ffffff";
separator_bg = "#222222";
warning_bg = "#222222";
warning_fg = "#ffffff";
};
};
};
};
};
};
xdg.configFile.wallpaper = {
source = ../../config/wallpaper;
recursive = true;
};
programs.firefox = {
enable = true;
package = pkgs.firefox-devedition;
};
programs.alacritty = {
enable = true;
settings = {
window.opacity = 0.9;
window.padding = {
x = 15;
y = 15;
};
font = {
size = 12.0;
normal.family = "JetBrainsMono Nerd Font Mono";
italic.style = "Regular";
bolditalic.style = "Regular";
bold.style = "Regular";
offset.y = 12;
glyph_offset.y = 6;
};
shell = { program = "zsh"; };
};
};
}

View file

@ -1,50 +1,33 @@
{ inputs, pkgs, ... }:
{ inputs, desktop, username, config, pkgs, ... }:
let
desktop-config = import ./home-manager-desktop.nix { inherit config inputs pkgs; };
shared-config = import ../shared/home-manager.nix { inherit inputs pkgs username; };
shared-packages = import ../shared/home-manager-packages.nix { inherit inputs pkgs; };
in
{
imports = [
../../home-manager/modules/common.nix
../../home-manager/modules/git.nix
../../home-manager/modules/home-manager.nix
../../home-manager/modules/tmux.nix
../../home-manager/modules/zsh.nix
imports = if desktop then [ desktop-config shared-config ] else [ shared-config ];
home.packages = shared-packages ++ pkgs.lib.optionals desktop [
pkgs.discord
pkgs.meslo-lg
pkgs.pass
pkgs.pinentry
pkgs.postman
pkgs.slack
pkgs.teams
pkgs.vlc
pkgs.wofi
pkgs.xcape
pkgs.zoom-us
];
home.stateVersion = "22.05";
home.username = "opdavies";
home.homeDirectory = "/home/opdavies";
programs.firefox = {
enable = true;
package = pkgs.firefox-devedition;
home.sessionVariables = {
EDITOR = "nvim";
LANG = "en_GB.UTF-8";
LC_ALL = "en_GB.UTF-8";
LC_CTYPE = "en_GB.UTF-8";
PULUMI_SKIP_UPDATE_CHECK = "true";
RIPGREP_CONFIG_PATH = "$HOME/.config/ripgrep/config";
};
programs.alacritty = {
enable = true;
settings = {
window.opacity = 0.9;
window.padding = {
x = 15;
y = 15;
};
font = {
size = 12.0;
normal.family = "JetBrainsMono Nerd Font Mono";
italic.style = "Regular";
bolditalic.style = "Regular";
bold.style = "Regular";
offset.y = 12;
glyph_offset.y = 6;
};
shell = { program = "zsh"; };
};
};
home.packages = with pkgs; [ discord meslo-lg slack teams vlc wofi xcape zoom-us ];
}