Refactor NixOS and Home Manager modules

This makes them more modular and configurable by allowing features to be
enabled per-host.

Squashed commit of the following:

commit e9896d6166125de7aa26ddc63dac3adb196e8c23
Author: Oliver Davies <oliver@oliverdavies.dev>
Date:   Mon Nov 25 23:06:23 2024 +0000

    Use mkMerge

    To ensure features isn't overridden and values aren't lost accidentally

commit c9c8ff5d059f08ade3aee9bb4e25bd51d4817a6d
Author: Oliver Davies <oliver@oliverdavies.dev>
Date:   Mon Nov 25 22:56:38 2024 +0000

    Move NixOS module imports

commit 4a85bbac9dfa8f06825f6b1fee45ef27befa16d3
Author: Oliver Davies <oliver@oliverdavies.dev>
Date:   Mon Nov 25 22:39:54 2024 +0000

    Move Home Manager module imports

commit 6d7a1b0aac68ccc8649fa2d8cd6e8b17ecebb4f0
Author: Oliver Davies <oliver@oliverdavies.dev>
Date:   Mon Nov 25 21:15:54 2024 +0000

    Add host-specific Home Manager configurations

commit b32da2fbf7498c9684d8289be0f02800994e9110
Author: Oliver Davies <oliver@oliverdavies.dev>
Date:   Mon Nov 25 18:00:00 2024 +0000

    Start to parameterise Home Manager modules

commit e80e89b415849cc4c6051a07b70587ac98724e2c
Author: Oliver Davies <oliver@oliverdavies.dev>
Date:   Mon Nov 25 18:00:00 2024 +0000

    Rename wsl commands to home-manager

commit 6d82ed73da3c104fb25117fb843c3f3b5d833180
Author: Oliver Davies <oliver@oliverdavies.dev>
Date:   Mon Nov 25 18:00:00 2024 +0000

    Refactor NixOS Home Manager configuration

commit cc5cbf5ac1a407a456d7258dd65a78ba3128a88f
Author: Oliver Davies <oliver@oliverdavies.dev>
Date:   Mon Nov 25 08:05:00 2024 +0000

    Refactor WSL Home Manager configuration

commit deaf664a0997871b6f2bb0a8f97d638a91cb10bc
Author: Oliver Davies <oliver@oliverdavies.dev>
Date:   Mon Nov 25 08:04:00 2024 +0000

    Refactor lemp11 configuration
This commit is contained in:
Oliver Davies 2024-11-26 08:13:46 +00:00
parent 7973d6ebad
commit af9edbfe1a
31 changed files with 673 additions and 843 deletions

View file

@ -11,7 +11,7 @@
outputs = outputs =
{ {
nixos-hardware, home-manager,
nixpkgs, nixpkgs,
self, self,
... ...
@ -24,21 +24,12 @@
username = "opdavies"; username = "opdavies";
mkNixos = import ./nix/lib/nixos { specialArgs = {
inherit
inputs
outputs
nixos-hardware
pkgs
self
username
;
};
mkWsl = import ./nix/lib/wsl2 {
inherit inherit
inputs inputs
outputs outputs
self self
system
username username
; ;
}; };
@ -60,24 +51,32 @@
overlays = import ./nix/overlays { inherit inputs; }; overlays = import ./nix/overlays { inherit inputs; };
nixosModules.default = ./nix/modules/nixos;
nixosConfigurations = { nixosConfigurations = {
lemp11 = mkNixos { lemp11 = nixpkgs.lib.nixosSystem {
specialArgs = specialArgs // {
desktop = true; desktop = true;
hostname = "lemp11"; hostname = "lemp11";
};
# TODO: move the rest of the modules here. modules = [ ./nix/hosts/lemp11 ];
modules = [
nixos-hardware.nixosModules.common-cpu-intel
nixos-hardware.nixosModules.common-gpu-intel
nixos-hardware.nixosModules.common-pc-laptop
nixos-hardware.nixosModules.common-pc-laptop-hdd
nixos-hardware.nixosModules.system76
];
}; };
}; };
homeConfigurations = { homeConfigurations = {
wsl2 = mkWsl { system = "x86_64-linux"; }; "${username}@PW05CH3L" = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
extraSpecialArgs = specialArgs // {
desktop = false;
hostname = "PW05CH3L";
};
modules = [
./nix/home/opdavies
];
};
}; };
}; };
} }

View file

@ -1,13 +1,33 @@
{ {
config, config,
desktop, desktop,
hostname,
inputs, inputs,
pkgs, outputs,
self, self,
system,
username, username,
... ...
}: }:
let let
pkgs = import inputs.nixpkgs {
inherit system;
config = {
allowUnfree = true;
permittedInsecurePackages = [
"electron-27.3.11"
];
};
overlays = [
outputs.overlays.additions
outputs.overlays.modifications
outputs.overlays.stable-packages
];
};
inherit (pkgs) lib; inherit (pkgs) lib;
desktop-config = import ./desktop.nix { desktop-config = import ./desktop.nix {
@ -18,14 +38,19 @@ let
username username
; ;
}; };
shared-config = import "${self}/nix/lib/shared/home-manager.nix" { shared-config = import "${self}/nix/lib/shared/home-manager.nix" {
inherit inherit
config
hostname
inputs inputs
lib
pkgs pkgs
self self
username username
; ;
}; };
shared-packages = import "${self}/nix/lib/shared/home-manager-packages.nix" { shared-packages = import "${self}/nix/lib/shared/home-manager-packages.nix" {
inherit inherit
desktop desktop

View file

@ -1,18 +1,12 @@
{ { ... }:
config,
inputs,
pkgs,
username,
}:
{ {
imports = [ imports = [
../../modules/home-manager/alacritty.nix
../../modules/home-manager/copyq.nix ../../modules/home-manager/copyq.nix
../../modules/home-manager/bluetuith.nix ../../modules/home-manager/bluetuith.nix
../../modules/home-manager/espanso.nix ../../modules/home-manager/espanso.nix
../../modules/home-manager/gtk.nix ../../modules/home-manager/gtk.nix
../../modules/home-manager/flameshot.nix ../../modules/home-manager/flameshot.nix
../../modules/home-manager/gtk.nix ../../modules/home-manager/gtk.nix
../../modules/home-manager/mpv.nix
]; ];
} }

View file

@ -0,0 +1,7 @@
{
features = {
desktop = {
alacritty.enable = false;
};
};
}

View file

@ -0,0 +1,9 @@
{ ... }:
{
features = {
desktop = {
mpv.enable = true;
};
};
}

View file

@ -1,23 +1,88 @@
# Edit this configuration file to define what should be installed on {
# your system. Help is available in the configuration.nix(5) man page hostname,
# and in the NixOS manual (accessible by running nixos-help). inputs,
outputs,
{ config, pkgs, ... }: pkgs,
desktop ? false,
self,
system,
username,
...
}:
{ {
imports = [ imports = [
# Include the results of the hardware scan. inputs.home-manager.nixosModules.home-manager
inputs.nixos-hardware.nixosModules.common-cpu-intel
inputs.nixos-hardware.nixosModules.common-gpu-intel
inputs.nixos-hardware.nixosModules.common-pc-laptop
inputs.nixos-hardware.nixosModules.common-pc-laptop-hdd
inputs.nixos-hardware.nixosModules.system76
outputs.nixosModules.default
./hardware-configuration.nix ./hardware-configuration.nix
]; ];
home-manager = {
extraSpecialArgs = {
inherit
hostname
inputs
outputs
desktop
self
system
username
;
};
useGlobalPkgs = true;
useUserPackages = true;
users."${username}" = import "${self}/nix/home/${username}";
};
nixpkgs = {
config = {
allowUnfree = true;
permittedInsecurePackages = [ "electron-27.3.11" ];
};
overlays = [
outputs.overlays.additions
outputs.overlays.modifications
outputs.overlays.stable-packages
];
};
nix.nixPath = [ "nixpkgs=${inputs.nixpkgs}" ];
# Bootloader. # Bootloader.
boot.loader.systemd-boot.enable = true; boot = {
boot.loader.efi.canTouchEfiVariables = true; loader = {
boot.loader.efi.efiSysMountPoint = "/boot/efi"; systemd-boot = {
enable = true;
configurationLimit = 10;
};
boot.kernelPackages = pkgs.linuxPackages_latest; efi = {
canTouchEfiVariables = true;
efiSysMountPoint = "/boot/efi";
};
};
};
services.thermald.enable = true;
services.power-profiles-daemon.enable = false;
systemd.extraConfig = ''
DefaultTimeoutStopSec=10s
'';
networking.hostName = hostname;
networking.hostName = "lemp11"; # Define your hostname.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# Configure network proxy if necessary # Configure network proxy if necessary
@ -48,65 +113,97 @@
# Enable the X11 windowing system. # Enable the X11 windowing system.
services.xserver.enable = true; services.xserver.enable = true;
# Enable the KDE Plasma Desktop Environment.
services.xserver.displayManager.sddm.enable = true;
services.xserver.desktopManager.plasma5.enable = true;
# Configure keymap in X11
services.xserver = { services.xserver = {
xkb = {
layout = "gb"; layout = "gb";
xkbVariant = ""; variant = "";
};
}; };
# Configure console keymap # Configure console keymap
console.keyMap = "uk"; console.keyMap = "uk";
# Enable CUPS to print documents. services.avahi.enable = true;
services.avahi.nssmdns4 = true;
services.avahi.openFirewall = true;
services.printing.enable = true; services.printing.enable = true;
# Enable sound with pipewire. # Enable sound with pipewire.
hardware.pulseaudio.enable = false; hardware.pulseaudio.enable = false;
security.rtkit.enable = true;
hardware.bluetooth.enable = true;
security = {
polkit.enable = true;
rtkit.enable = true;
};
services.pipewire = { services.pipewire = {
enable = true; enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
# If you want to use JACK applications, uncomment this
#jack.enable = true;
# use the example session manager (no others are packaged yet so this is enabled by default, alsa = {
# no need to redefine it in your config for now) enable = true;
#media-session.enable = true; support32Bit = true;
};
pulse.enable = true;
}; };
# Enable touchpad support (enabled default in most desktopManager). # Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true; # services.xserver.libinput.enable = true;
# Define a user account. Don't forget to set a password with passwd. users.users.${username} = {
users.users.opdavies = {
isNormalUser = true; isNormalUser = true;
description = "Oliver Davies"; description = "Oliver Davies";
extraGroups = [ extraGroups = [
"jellyfin" "docker"
"networkmanager" "networkmanager"
"wheel" "wheel"
]; ];
packages = with pkgs; [ packages = [ ];
firefox
kate
# thunderbird
];
}; };
# Allow unfree packages security.sudo.wheelNeedsPassword = false;
nixpkgs.config.allowUnfree = true;
# List packages installed in system profile. To search, run: # List packages installed in system profile. To search, run:
# $ nix search wget # $ nix search wget
environment.systemPackages = with pkgs; [ environment.systemPackages =
# vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. with pkgs;
# wget [
caffeine-ng
gtypist
fastfetch
mermaid-cli
mkcert
taskopen
taskwarrior3
taskwarrior-tui
ttyper
yt-dlp
ytfzf
]
++ pkgs.lib.optionals desktop [
acpi
arandr
bluetuith
brightnessctl
cpufrequtils
libnotify
pmutils
ffmpegthumbnailer
libreoffice
logseq
rclone
rclone-browser
shotwell
slack
vscode
xfce.thunar
xfce.thunar-volman
xfce.tumbler
# Games.
zeroad
]; ];
# Some programs need SUID wrappers, can be configured further or are # Some programs need SUID wrappers, can be configured further or are
@ -120,10 +217,12 @@
# List services that you want to enable: # List services that you want to enable:
# Enable the OpenSSH daemon. # Enable the OpenSSH daemon.
# services.openssh.enable = true; services.openssh.enable = true;
# Open ports in the firewall. # Open ports in the firewall.
# networking.firewall.allowedTCPPorts = [ ... ]; networking.firewall.allowedTCPPorts = [
9003 # xdebug
];
# networking.firewall.allowedUDPPorts = [ ... ]; # networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether. # Or disable the firewall altogether.
# networking.firewall.enable = false; # networking.firewall.enable = false;
@ -136,4 +235,91 @@
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "22.11"; # Did you read the comment? system.stateVersion = "22.11"; # Did you read the comment?
programs.dconf.enable = true;
programs.zsh.enable = true;
programs.zsh.histSize = 5000;
users.defaultUserShell = "/etc/profiles/per-user/${username}/bin/zsh";
zramSwap.enable = true;
nix = {
extraOptions = ''
trusted-users = root ${username}
'';
gc = {
automatic = true;
dates = "daily";
options = "--delete-older-than 7d";
};
optimise.automatic = true;
settings = {
auto-optimise-store = true;
experimental-features = [
"nix-command"
"flakes"
];
warn-dirty = false;
};
};
# Make Caps lock work as an Escape key on press and Ctrl on hold.
services.interception-tools =
let
dfkConfig = pkgs.writeText "dual-function-keys.yaml" ''
MAPPINGS:
- KEY: KEY_CAPSLOCK
TAP: KEY_ESC
HOLD: KEY_LEFTCTRL
'';
in
{
enable = true;
plugins = pkgs.lib.mkForce [ pkgs.interception-tools-plugins.dual-function-keys ];
udevmonConfig = ''
- JOB: "${pkgs.interception-tools}/bin/intercept -g $DEVNODE | ${pkgs.interception-tools-plugins.dual-function-keys}/bin/dual-function-keys -c ${dfkConfig} | ${pkgs.interception-tools}/bin/uinput -d $DEVNODE"
DEVICE:
NAME: "AT Translated Set 2 keyboard"
EVENTS:
EV_KEY: [[KEY_CAPSLOCK, KEY_ESC, KEY_LEFTCTRL]]
'';
};
services.gvfs.enable = true;
programs.gnupg.agent = {
enable = true;
enableSSHSupport = true;
pinentryPackage = pkgs.pinentry-qt;
};
programs.firefox = {
enable = true;
languagePacks = [ "en-GB" ];
preferences = {
"intl.accept_languages" = "en-GB, en";
"intl.regional_prefs.use_os_locales" = true;
};
};
services.blueman.enable = true;
services.cron = {
enable = true;
systemCronJobs = [ "* * * * * opdavies /home/${username}/.local/bin/notify-battery" ];
};
services.auto-cpufreq.enable = true;
services.udev = {
enable = true;
extraRules = ''
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", MODE="0660", GROUP="users", TAG+="uaccess", TAG+="udev-acl"
'';
};
} }

View file

@ -0,0 +1,3 @@
{
imports = [ ./configuration.nix ];
}

View file

@ -4,7 +4,6 @@
{ {
config, config,
lib, lib,
pkgs,
modulesPath, modulesPath,
... ...
}: }:

View file

@ -1,296 +0,0 @@
{
inputs,
outputs,
desktop ? false,
hostname,
username,
self,
}:
{ pkgs, ... }:
{
imports = [ ../../modules/nixos/desktop ];
_module.args = {
inherit inputs self username;
};
nixpkgs = {
config = {
allowUnfree = true;
permittedInsecurePackages = [ "electron-27.3.11" ];
};
overlays = [
outputs.overlays.additions
outputs.overlays.modifications
outputs.overlays.stable-packages
];
};
nix.nixPath = [ "nixpkgs=${inputs.nixpkgs}" ];
# Bootloader.
boot = {
loader = {
systemd-boot = {
enable = true;
configurationLimit = 10;
};
efi = {
canTouchEfiVariables = true;
efiSysMountPoint = "/boot/efi";
};
};
};
services.thermald.enable = true;
services.power-profiles-daemon.enable = false;
systemd.extraConfig = ''
DefaultTimeoutStopSec=10s
'';
networking.hostName = hostname;
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# Configure network proxy if necessary
# networking.proxy.default = "http://user:password@proxy:port/";
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Enable networking
networking.networkmanager.enable = true;
# Set your time zone.
time.timeZone = "Europe/London";
# Select internationalisation properties.
i18n.defaultLocale = "en_GB.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "en_GB.UTF-8";
LC_IDENTIFICATION = "en_GB.UTF-8";
LC_MEASUREMENT = "en_GB.UTF-8";
LC_MONETARY = "en_GB.UTF-8";
LC_NAME = "en_GB.UTF-8";
LC_NUMERIC = "en_GB.UTF-8";
LC_PAPER = "en_GB.UTF-8";
LC_TELEPHONE = "en_GB.UTF-8";
LC_TIME = "en_GB.UTF-8";
};
# Enable the X11 windowing system.
services.xserver.enable = true;
services.xserver = {
xkb = {
layout = "gb";
variant = "";
};
};
# Configure console keymap
console.keyMap = "uk";
services.avahi.enable = true;
services.avahi.nssmdns4 = true;
services.avahi.openFirewall = true;
services.printing.enable = true;
# Enable sound with pipewire.
hardware.pulseaudio.enable = false;
security = {
polkit.enable = true;
rtkit.enable = true;
};
services.pipewire = {
enable = true;
alsa = {
enable = true;
support32Bit = true;
};
pulse.enable = true;
};
# Enable touchpad support (enabled default in most desktopManager).
# services.xserver.libinput.enable = true;
users.users.${username} = {
isNormalUser = true;
description = "Oliver Davies";
extraGroups = [
"docker"
"networkmanager"
"wheel"
];
packages = with pkgs; [ ];
};
security.sudo.wheelNeedsPassword = false;
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages =
with pkgs;
[
caffeine-ng
gtypist
fastfetch
mermaid-cli
mkcert
taskopen
taskwarrior3
taskwarrior-tui
ttyper
yt-dlp
ytfzf
]
++ pkgs.lib.optionals desktop [
acpi
arandr
bluetuith
brightnessctl
cpufrequtils
libnotify
pmutils
ffmpegthumbnailer
libreoffice
logseq
rclone
rclone-browser
shotwell
slack
vscode
xfce.thunar
xfce.thunar-volman
xfce.tumbler
# Games.
zeroad
];
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
# programs.gnupg.agent = {
# enable = true;
# enableSSHSupport = true;
# };
# List services that you want to enable:
# Enable the OpenSSH daemon.
services.openssh.enable = true;
# Open ports in the firewall.
networking.firewall.allowedTCPPorts = [
9003 # xdebug
];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
# networking.firewall.enable = false;
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "22.11"; # Did you read the comment?
programs.dconf.enable = true;
programs.zsh.enable = true;
programs.zsh.histSize = 5000;
users.defaultUserShell = "/etc/profiles/per-user/${username}/bin/zsh";
zramSwap.enable = true;
nix = {
extraOptions = ''
trusted-users = root ${username}
'';
gc = {
automatic = true;
dates = "daily";
options = "--delete-older-than 7d";
};
optimise.automatic = true;
settings = {
auto-optimise-store = true;
experimental-features = [
"nix-command"
"flakes"
];
warn-dirty = false;
};
};
# Make Caps lock work as an Escape key on press and Ctrl on hold.
services.interception-tools =
let
dfkConfig = pkgs.writeText "dual-function-keys.yaml" ''
MAPPINGS:
- KEY: KEY_CAPSLOCK
TAP: KEY_ESC
HOLD: KEY_LEFTCTRL
'';
in
{
enable = true;
plugins = pkgs.lib.mkForce [ pkgs.interception-tools-plugins.dual-function-keys ];
udevmonConfig = ''
- JOB: "${pkgs.interception-tools}/bin/intercept -g $DEVNODE | ${pkgs.interception-tools-plugins.dual-function-keys}/bin/dual-function-keys -c ${dfkConfig} | ${pkgs.interception-tools}/bin/uinput -d $DEVNODE"
DEVICE:
NAME: "AT Translated Set 2 keyboard"
EVENTS:
EV_KEY: [[KEY_CAPSLOCK, KEY_ESC, KEY_LEFTCTRL]]
'';
};
services.gvfs.enable = true;
programs.gnupg.agent = {
enable = true;
enableSSHSupport = true;
pinentryPackage = pkgs.pinentry-qt;
};
programs.firefox = {
enable = true;
languagePacks = [ "en-GB" ];
preferences = {
"intl.accept_languages" = "en-GB, en";
"intl.regional_prefs.use_os_locales" = true;
};
};
services.blueman.enable = true;
services.cron = {
enable = true;
systemCronJobs = [ "* * * * * opdavies /home/${username}/.local/bin/notify-battery" ];
};
services.auto-cpufreq.enable = true;
services.udev = {
enable = true;
extraRules = ''
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", MODE="0660", GROUP="users", TAG+="uaccess", TAG+="udev-acl"
'';
};
}

View file

@ -1,49 +0,0 @@
{
inputs,
outputs,
nixos-hardware,
pkgs,
self,
username,
}:
{
desktop ? false,
hostname,
modules ? [ ],
}:
let
configuration = import ./configuration.nix {
inherit
outputs
desktop
hostname
username
inputs
self
;
};
hardwareConfiguration = import ./hardware-configuration.nix;
in
inputs.nixpkgs.lib.nixosSystem {
modules = [
inputs.home-manager.nixosModules.home-manager
{
home-manager = {
extraSpecialArgs = {
inherit
inputs
desktop
self
username
;
};
useGlobalPkgs = true;
useUserPackages = true;
users."${username}" = import "${self}/nix/home/${username}";
};
}
configuration
hardwareConfiguration
] ++ modules;
}

View file

@ -1,59 +0,0 @@
{
config,
lib,
pkgs,
modulesPath,
...
}:
{
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
boot.initrd.availableKernelModules = [
"xhci_pci"
"thunderbolt"
"nvme"
"usb_storage"
"sd_mod"
];
boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ];
boot.kernelParams = [
"i915.modeset=1"
"i915.fastboot=1"
"i915.enable_guc=2"
"i915.enable_psr=1"
"i915.enable_fbc=1"
"i915.enable_dc=2"
];
boot.extraModulePackages = [ ];
boot.kernelPackages = pkgs.linuxPackages_zen;
hardware.enableAllFirmware = true;
hardware.system76.enableAll = true;
fileSystems."/" = {
device = "/dev/disk/by-label/nixos";
fsType = "ext4";
};
fileSystems."/boot/efi" = {
device = "/dev/disk/by-label/boot";
fsType = "vfat";
};
swapDevices = [ { device = "/dev/disk/by-label/swap"; } ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true;
# networking.interfaces.enp0s13f0u1.useDHCP = lib.mkDefault true;
# networking.interfaces.wlo1.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
hardware.bluetooth.enable = true;
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}

View file

@ -1,5 +1,8 @@
{ {
config,
hostname,
inputs, inputs,
lib,
pkgs, pkgs,
username, username,
self, self,
@ -26,21 +29,29 @@
programs.home-manager.enable = true; programs.home-manager.enable = true;
features = lib.mkMerge [
{
cli = {
neovim.enable = lib.mkDefault true;
tmux.enable = lib.mkDefault true;
};
desktop = {
alacritty.enable = lib.mkDefault true;
};
}
];
imports = [ imports = [
(import ../../modules/home-manager/git.nix { inherit inputs pkgs; }) (import ../../modules/home-manager {
(import ../../modules/home-manager/neovim.nix { inherit inputs pkgs; }) inherit
../../modules/home-manager/bat.nix config
../../modules/home-manager/bin.nix inputs
../../modules/home-manager/direnv.nix lib
../../modules/home-manager/fzf.nix pkgs
../../modules/home-manager/htop.nix ;
../../modules/home-manager/lsd.nix })
../../modules/home-manager/pet.nix
../../modules/home-manager/phpactor.nix ../../home/${username}/hosts/${hostname}.nix
../../modules/home-manager/ripgrep.nix
../../modules/home-manager/starship.nix
../../modules/home-manager/syncthing.nix
../../modules/home-manager/tmux.nix
../../modules/home-manager/zsh.nix
]; ];
} }

View file

@ -1,61 +0,0 @@
{
inputs,
outputs,
self,
username,
}:
{ system }:
let
inherit (pkgs) lib;
pkgs = import inputs.nixpkgs {
overlays = [
outputs.overlays.additions
outputs.overlays.modifications
];
};
shared-config = import "${self}/nix/lib/shared/home-manager.nix" {
inherit
inputs
pkgs
self
username
;
};
shared-packages = import "${self}/nix/lib/shared/home-manager-packages.nix" {
inherit inputs pkgs username;
desktop = false;
};
in
inputs.home-manager.lib.homeManagerConfiguration {
inherit pkgs;
extraSpecialArgs = {
inherit self;
};
modules = [
{
imports = [ shared-config ];
home.packages = shared-packages ++ [ pkgs.wsl-open ];
home.sessionVariables = {
DIRENV_LOG_FORMAT = "";
EDITOR = "nvim";
PATH = lib.concatStringsSep ":" [
"$PATH"
"$HOME/go/bin"
"./vendor/bin"
"./node_modules/.bin"
];
PULUMI_SKIP_UPDATE_CHECK = "true";
REPOS = "$HOME/Code";
RIPGREP_CONFIG_PATH = "$HOME/.config/ripgrep/config";
};
}
];
}

View file

@ -1,4 +1,5 @@
{ {
config,
lib, lib,
pkgs, pkgs,
self, self,
@ -11,6 +12,9 @@ let
theme = import "${self}/nix/lib/theme" { inherit pkgs; }; theme = import "${self}/nix/lib/theme" { inherit pkgs; };
in in
{ {
options.features.desktop.alacritty.enable = lib.mkEnableOption "Enable Alacritty";
config = lib.mkIf config.features.desktop.alacritty.enable {
programs.alacritty = { programs.alacritty = {
enable = true; enable = true;
@ -39,4 +43,5 @@ in
}; };
}; };
}; };
};
} }

View file

@ -0,0 +1,37 @@
{
config,
inputs,
lib,
pkgs,
...
}:
{
imports = [
(import ./neovim.nix {
inherit
config
inputs
lib
pkgs
;
})
./alacritty.nix
./bat.nix
./bin.nix
./direnv.nix
./fzf.nix
./git.nix
./htop.nix
./lsd.nix
./mpv.nix
./pet.nix
./phpactor.nix
./ripgrep.nix
./starship.nix
./syncthing.nix
./tmux.nix
./zsh.nix
];
}

View file

@ -1,4 +1,9 @@
{ config, lib, ... }:
{ {
options.features.desktop.mpv.enable = lib.mkEnableOption "Enable mpv media player";
config = lib.mkIf config.features.desktop.mpv.enable {
programs.mpv = { programs.mpv = {
enable = true; enable = true;
@ -8,4 +13,5 @@
"UP" = "add volume 5"; "UP" = "add volume 5";
}; };
}; };
};
} }

View file

@ -1,6 +1,15 @@
{ inputs, pkgs, ... }: {
config,
inputs,
lib,
pkgs,
...
}:
{ {
options.features.cli.neovim.enable = lib.mkEnableOption "Enable neovim";
config = lib.mkIf config.features.cli.neovim.enable {
programs.neovim = { programs.neovim = {
enable = true; enable = true;
@ -198,4 +207,5 @@
no-duplicate-heading: no-duplicate-heading:
siblings_only: true siblings_only: true
''; '';
};
} }

View file

@ -1,8 +1,17 @@
{ pkgs, ... }: {
config,
lib,
pkgs,
...
}:
let let
inherit (pkgs) tmuxPlugins; inherit (pkgs) tmuxPlugins;
in in
{ {
options.features.cli.tmux.enable = lib.mkEnableOption "Enable tmux";
config = lib.mkIf config.features.cli.tmux.enable {
programs.tmux = { programs.tmux = {
enable = true; enable = true;
@ -74,4 +83,5 @@ in
tmuxPlugins.yank tmuxPlugins.yank
]; ];
}; };
};
} }

View file

@ -1,7 +1,16 @@
{ {
imports = [ imports = [
./autorandr.nix
./docker.nix ./docker.nix
./fonts.nix
./gitea.nix
./i3.nix
./immich.nix
./jellyfin.nix
./kanata.nix ./kanata.nix
./rofi.nix
./rsnapshot.nix ./rsnapshot.nix
./screenkey.nix
./xbanish.nix
]; ];
} }

View file

@ -1,14 +0,0 @@
{
imports = [
../.
./autorandr.nix
./fonts.nix
./gitea.nix
./i3.nix
./immich.nix
./jellyfin.nix
./rofi.nix
./screenkey.nix
./xbanish.nix
];
}

View file

@ -1,7 +1,7 @@
{ pkgs, ... }: { pkgs, ... }:
let let
theme = import ../../../lib/theme { inherit pkgs; }; theme = import ../../lib/theme { inherit pkgs; };
in in
{ {
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [

21
run
View file

@ -25,6 +25,14 @@ function help {
printf "\nExtended help:\n Each task has comments for general usage\n" printf "\nExtended help:\n Each task has comments for general usage\n"
} }
function home-manager:build {
_home build "$@"
}
function home-manager:switch {
_home switch "$@"
}
function nixos:build { function nixos:build {
_nixos build "$@" _nixos build "$@"
} }
@ -41,23 +49,14 @@ function update {
nix flake update nix flake update
} }
function wsl:build {
_home build wsl2 "$@"
}
function wsl:switch {
_home switch wsl2 "$@"
}
function _home { function _home {
local command="$1" local command="$1"
local flake="$2" shift 1
shift 2
NIXPKGS_ALLOW_UNFREE=1 home-manager "$command" \ NIXPKGS_ALLOW_UNFREE=1 home-manager "$command" \
--extra-experimental-features flakes \ --extra-experimental-features flakes \
--extra-experimental-features nix-command \ --extra-experimental-features nix-command \
--flake ".#$flake" \ --flake ".#$(whoami)@$(hostname)" \
--impure "$@" --impure "$@"
} }