diff --git a/flake.nix b/flake.nix index 9d05235..b897f6d 100644 --- a/flake.nix +++ b/flake.nix @@ -11,7 +11,7 @@ outputs = { - nixos-hardware, + home-manager, nixpkgs, self, ... @@ -24,21 +24,12 @@ username = "opdavies"; - mkNixos = import ./nix/lib/nixos { - inherit - inputs - outputs - nixos-hardware - pkgs - self - username - ; - }; - mkWsl = import ./nix/lib/wsl2 { + specialArgs = { inherit inputs outputs self + system username ; }; @@ -60,24 +51,32 @@ overlays = import ./nix/overlays { inherit inputs; }; - nixosConfigurations = { - lemp11 = mkNixos { - desktop = true; - hostname = "lemp11"; + nixosModules.default = ./nix/modules/nixos; - # TODO: move the rest of the modules here. - 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 - ]; + nixosConfigurations = { + lemp11 = nixpkgs.lib.nixosSystem { + specialArgs = specialArgs // { + desktop = true; + hostname = "lemp11"; + }; + + modules = [ ./nix/hosts/lemp11 ]; }; }; 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 + ]; + }; }; }; } diff --git a/nix/home/opdavies/default.nix b/nix/home/opdavies/default.nix index f2c0370..d31fe80 100644 --- a/nix/home/opdavies/default.nix +++ b/nix/home/opdavies/default.nix @@ -1,13 +1,33 @@ { config, desktop, + hostname, inputs, - pkgs, + outputs, self, + system, username, ... }: 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; desktop-config = import ./desktop.nix { @@ -18,14 +38,19 @@ let username ; }; + shared-config = import "${self}/nix/lib/shared/home-manager.nix" { inherit + config + hostname inputs + lib pkgs self username ; }; + shared-packages = import "${self}/nix/lib/shared/home-manager-packages.nix" { inherit desktop diff --git a/nix/home/opdavies/desktop.nix b/nix/home/opdavies/desktop.nix index 6467591..2569256 100644 --- a/nix/home/opdavies/desktop.nix +++ b/nix/home/opdavies/desktop.nix @@ -1,18 +1,12 @@ -{ - config, - inputs, - pkgs, - username, -}: +{ ... }: + { imports = [ - ../../modules/home-manager/alacritty.nix ../../modules/home-manager/copyq.nix ../../modules/home-manager/bluetuith.nix ../../modules/home-manager/espanso.nix ../../modules/home-manager/gtk.nix ../../modules/home-manager/flameshot.nix ../../modules/home-manager/gtk.nix - ../../modules/home-manager/mpv.nix ]; } diff --git a/nix/home/opdavies/hosts/PW05CH3L.nix b/nix/home/opdavies/hosts/PW05CH3L.nix new file mode 100644 index 0000000..391fcad --- /dev/null +++ b/nix/home/opdavies/hosts/PW05CH3L.nix @@ -0,0 +1,7 @@ +{ + features = { + desktop = { + alacritty.enable = false; + }; + }; +} diff --git a/nix/home/opdavies/hosts/lemp11.nix b/nix/home/opdavies/hosts/lemp11.nix new file mode 100644 index 0000000..4f1c16d --- /dev/null +++ b/nix/home/opdavies/hosts/lemp11.nix @@ -0,0 +1,9 @@ +{ ... }: + +{ + features = { + desktop = { + mpv.enable = true; + }; + }; +} diff --git a/nix/hosts/lemp11/configuration.nix b/nix/hosts/lemp11/configuration.nix index 2c1b957..d0b2a7e 100644 --- a/nix/hosts/lemp11/configuration.nix +++ b/nix/hosts/lemp11/configuration.nix @@ -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 -# and in the NixOS manual (accessible by running ‘nixos-help’). - -{ config, pkgs, ... }: +{ + hostname, + inputs, + outputs, + pkgs, + desktop ? false, + self, + system, + username, + ... +}: { 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 ]; + 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. - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - boot.loader.efi.efiSysMountPoint = "/boot/efi"; + boot = { + loader = { + 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. # Configure network proxy if necessary @@ -48,66 +113,98 @@ # Enable the X11 windowing system. 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 = { - layout = "gb"; - xkbVariant = ""; + xkb = { + layout = "gb"; + variant = ""; + }; }; # Configure console keymap console.keyMap = "uk"; - # Enable CUPS to print documents. + 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.rtkit.enable = true; + + hardware.bluetooth.enable = true; + + security = { + polkit.enable = true; + rtkit.enable = true; + }; + services.pipewire = { 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, - # no need to redefine it in your config for now) - #media-session.enable = true; + alsa = { + enable = true; + support32Bit = true; + }; + + pulse.enable = true; }; # Enable touchpad support (enabled default in most desktopManager). # services.xserver.libinput.enable = true; - # Define a user account. Don't forget to set a password with ‘passwd’. - users.users.opdavies = { + users.users.${username} = { isNormalUser = true; description = "Oliver Davies"; extraGroups = [ - "jellyfin" + "docker" "networkmanager" "wheel" ]; - packages = with pkgs; [ - firefox - kate - # thunderbird - ]; + packages = [ ]; }; - # Allow unfree packages - nixpkgs.config.allowUnfree = true; + security.sudo.wheelNeedsPassword = false; # List packages installed in system profile. To search, run: # $ nix search wget - environment.systemPackages = with pkgs; [ - # vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. - # 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. @@ -120,10 +217,12 @@ # List services that you want to enable: # Enable the OpenSSH daemon. - # services.openssh.enable = true; + services.openssh.enable = true; # Open ports in the firewall. - # networking.firewall.allowedTCPPorts = [ ... ]; + networking.firewall.allowedTCPPorts = [ + 9003 # xdebug + ]; # networking.firewall.allowedUDPPorts = [ ... ]; # Or disable the firewall altogether. # networking.firewall.enable = false; @@ -136,4 +235,91 @@ # (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" + ''; + }; } diff --git a/nix/hosts/lemp11/default.nix b/nix/hosts/lemp11/default.nix new file mode 100644 index 0000000..f56e1f9 --- /dev/null +++ b/nix/hosts/lemp11/default.nix @@ -0,0 +1,3 @@ +{ + imports = [ ./configuration.nix ]; +} diff --git a/nix/hosts/lemp11/hardware-configuration.nix b/nix/hosts/lemp11/hardware-configuration.nix index a01d787..9cb083b 100644 --- a/nix/hosts/lemp11/hardware-configuration.nix +++ b/nix/hosts/lemp11/hardware-configuration.nix @@ -4,7 +4,6 @@ { config, lib, - pkgs, modulesPath, ... }: diff --git a/nix/lib/nixos/configuration.nix b/nix/lib/nixos/configuration.nix deleted file mode 100644 index 4bbe0ce..0000000 --- a/nix/lib/nixos/configuration.nix +++ /dev/null @@ -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. It‘s 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" - ''; - }; -} diff --git a/nix/lib/nixos/default.nix b/nix/lib/nixos/default.nix deleted file mode 100644 index 95e09e6..0000000 --- a/nix/lib/nixos/default.nix +++ /dev/null @@ -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; -} diff --git a/nix/lib/nixos/hardware-configuration.nix b/nix/lib/nixos/hardware-configuration.nix deleted file mode 100644 index 37d2de3..0000000 --- a/nix/lib/nixos/hardware-configuration.nix +++ /dev/null @@ -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..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; -} diff --git a/nix/lib/shared/home-manager.nix b/nix/lib/shared/home-manager.nix index 80f1bed..e4ed054 100644 --- a/nix/lib/shared/home-manager.nix +++ b/nix/lib/shared/home-manager.nix @@ -1,5 +1,8 @@ { + config, + hostname, inputs, + lib, pkgs, username, self, @@ -26,21 +29,29 @@ 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 = [ - (import ../../modules/home-manager/git.nix { inherit inputs pkgs; }) - (import ../../modules/home-manager/neovim.nix { inherit inputs pkgs; }) - ../../modules/home-manager/bat.nix - ../../modules/home-manager/bin.nix - ../../modules/home-manager/direnv.nix - ../../modules/home-manager/fzf.nix - ../../modules/home-manager/htop.nix - ../../modules/home-manager/lsd.nix - ../../modules/home-manager/pet.nix - ../../modules/home-manager/phpactor.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 + (import ../../modules/home-manager { + inherit + config + inputs + lib + pkgs + ; + }) + + ../../home/${username}/hosts/${hostname}.nix ]; } diff --git a/nix/lib/wsl2/default.nix b/nix/lib/wsl2/default.nix deleted file mode 100644 index b2d2ad4..0000000 --- a/nix/lib/wsl2/default.nix +++ /dev/null @@ -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"; - }; - } - ]; -} diff --git a/nix/modules/home-manager/alacritty.nix b/nix/modules/home-manager/alacritty.nix index 9e54ef5..e3bda68 100644 --- a/nix/modules/home-manager/alacritty.nix +++ b/nix/modules/home-manager/alacritty.nix @@ -1,4 +1,5 @@ { + config, lib, pkgs, self, @@ -11,31 +12,35 @@ let theme = import "${self}/nix/lib/theme" { inherit pkgs; }; in { - programs.alacritty = { - enable = true; + options.features.desktop.alacritty.enable = lib.mkEnableOption "Enable Alacritty"; - settings = { - env = { - TERM = "screen-256color"; - }; + config = lib.mkIf config.features.desktop.alacritty.enable { + programs.alacritty = { + enable = true; - window.padding = { - x = 15; - y = 15; - }; + settings = { + env = { + TERM = "screen-256color"; + }; - font = { - size = toInt "${theme.fonts.monospace.size}"; + window.padding = { + x = 15; + y = 15; + }; - bold.style = "Regular"; - normal.family = "${theme.fonts.monospace.name}"; + font = { + size = toInt "${theme.fonts.monospace.size}"; - offset.y = 6; - glyph_offset.y = 3; - }; + bold.style = "Regular"; + normal.family = "${theme.fonts.monospace.name}"; - terminal.shell = { - program = "zsh"; + offset.y = 6; + glyph_offset.y = 3; + }; + + terminal.shell = { + program = "zsh"; + }; }; }; }; diff --git a/nix/modules/home-manager/default.nix b/nix/modules/home-manager/default.nix new file mode 100644 index 0000000..6aa1816 --- /dev/null +++ b/nix/modules/home-manager/default.nix @@ -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 + ]; +} diff --git a/nix/modules/home-manager/mpv.nix b/nix/modules/home-manager/mpv.nix index 163205c..c0764dd 100644 --- a/nix/modules/home-manager/mpv.nix +++ b/nix/modules/home-manager/mpv.nix @@ -1,11 +1,17 @@ -{ - programs.mpv = { - enable = true; +{ config, lib, ... }: - # https://github.com/mpv-player/mpv/blob/master/etc/input.conf - bindings = { - "DOWN" = "add volume -5"; - "UP" = "add volume 5"; +{ + options.features.desktop.mpv.enable = lib.mkEnableOption "Enable mpv media player"; + + config = lib.mkIf config.features.desktop.mpv.enable { + programs.mpv = { + enable = true; + + # https://github.com/mpv-player/mpv/blob/master/etc/input.conf + bindings = { + "DOWN" = "add volume -5"; + "UP" = "add volume 5"; + }; }; }; } diff --git a/nix/modules/home-manager/neovim.nix b/nix/modules/home-manager/neovim.nix index 26e6f9d..90fd61a 100644 --- a/nix/modules/home-manager/neovim.nix +++ b/nix/modules/home-manager/neovim.nix @@ -1,201 +1,211 @@ -{ inputs, pkgs, ... }: +{ + config, + inputs, + lib, + pkgs, + ... +}: { - programs.neovim = { - enable = true; + options.features.cli.neovim.enable = lib.mkEnableOption "Enable neovim"; - plugins = with pkgs.vimPlugins; [ - comment-nvim - dial-nvim - fidget-nvim - gitsigns-nvim - harpoon - impatient-nvim - mini-nvim - neodev-nvim - nvim-spectre - nvim-web-devicons - oil-nvim - refactoring-nvim - sort-nvim - treesj - undotree - vim-abolish - vim-eunuch - vim-highlightedyank - vim-just - vim-nix - vim-obsession - vim-pasta - vim-repeat - vim-sleuth - vim-sort-motion - vim-terraform - vim-textobj-user - vim-unimpaired + config = lib.mkIf config.features.cli.neovim.enable { + programs.neovim = { + enable = true; - conf-vim - edit-alternate-vim - nvim-tmux-navigation - standard-vim - vim-autoread - vim-textobj-indent - vim-textobj-xmlattr - vim-zoom + plugins = with pkgs.vimPlugins; [ + comment-nvim + dial-nvim + fidget-nvim + gitsigns-nvim + harpoon + impatient-nvim + mini-nvim + neodev-nvim + nvim-spectre + nvim-web-devicons + oil-nvim + refactoring-nvim + sort-nvim + treesj + undotree + vim-abolish + vim-eunuch + vim-highlightedyank + vim-just + vim-nix + vim-obsession + vim-pasta + vim-repeat + vim-sleuth + vim-sort-motion + vim-terraform + vim-textobj-user + vim-unimpaired - # Testing - vim-test + conf-vim + edit-alternate-vim + nvim-tmux-navigation + standard-vim + vim-autoread + vim-textobj-indent + vim-textobj-xmlattr + vim-zoom - # Git - committia-vim - diffview-nvim - vim-fugitive + # Testing + vim-test - # Debugging - nvim-dap - nvim-dap-ui - nvim-dap-virtual-text + # Git + committia-vim + diffview-nvim + vim-fugitive - # Treesitter - (pkgs.vimPlugins.nvim-treesitter.withPlugins ( - plugins: with plugins; [ - bash - comment - css - csv - dockerfile - gitattributes - gitignore - go - html - javascript - json - kdl - lua - luadoc - make - markdown - markdown_inline - nix - php - phpdoc - query - rst - scss - sql - terraform - twig - typescript - vim - vimdoc - vue - xml - yaml - ] - )) - nvim-treesitter-textobjects + # Debugging + nvim-dap + nvim-dap-ui + nvim-dap-virtual-text - # LSP, linting and formatting - conform-nvim - lsp-status-nvim - nvim-lint - nvim-lspconfig + # Treesitter + (pkgs.vimPlugins.nvim-treesitter.withPlugins ( + plugins: with plugins; [ + bash + comment + css + csv + dockerfile + gitattributes + gitignore + go + html + javascript + json + kdl + lua + luadoc + make + markdown + markdown_inline + nix + php + phpdoc + query + rst + scss + sql + terraform + twig + typescript + vim + vimdoc + vue + xml + yaml + ] + )) + nvim-treesitter-textobjects - # Completion - cmp-buffer - cmp-calc - cmp-cmdline - cmp-nvim-lsp - cmp-path - cmp-treesitter - cmp_luasnip - lspkind-nvim - nvim-cmp + # LSP, linting and formatting + conform-nvim + lsp-status-nvim + nvim-lint + nvim-lspconfig - # Snippets - friendly-snippets - luasnip + # Completion + cmp-buffer + cmp-calc + cmp-cmdline + cmp-nvim-lsp + cmp-path + cmp-treesitter + cmp_luasnip + lspkind-nvim + nvim-cmp - # Telescope - plenary-nvim - popup-nvim - telescope-frecency-nvim - telescope-fzf-native-nvim - telescope-live-grep-args-nvim - telescope-nvim - telescope-ui-select-nvim + # Snippets + friendly-snippets + luasnip - # Databases - vim-dadbod - vim-dadbod-ui - vim-dadbod-completion + # Telescope + plenary-nvim + popup-nvim + telescope-frecency-nvim + telescope-fzf-native-nvim + telescope-live-grep-args-nvim + telescope-nvim + telescope-ui-select-nvim - # Themes - catppuccin-nvim + # Databases + vim-dadbod + vim-dadbod-ui + vim-dadbod-completion - # Configuration. - inputs.self.packages.${pkgs.system}.opdavies-nvim - ]; + # Themes + catppuccin-nvim - extraLuaConfig = '' - if vim.loader then - vim.loader.enable() - end + # Configuration. + inputs.self.packages.${pkgs.system}.opdavies-nvim + ]; - require "opdavies" + extraLuaConfig = '' + if vim.loader then + vim.loader.enable() + end + + require "opdavies" + ''; + + extraPackages = with pkgs; [ + # Languages + nodePackages.typescript + nodejs-slim + php81 + + # Language servers + gopls + lua-language-server + lua54Packages.luacheck + marksman + nixd + nodePackages."@tailwindcss/language-server" + nodePackages.bash-language-server + nodePackages.dockerfile-language-server-nodejs + nodePackages.intelephense + nodePackages.typescript-language-server + nodePackages.vls + nodePackages.vscode-langservers-extracted + nodePackages.vue-language-server + nodePackages.yaml-language-server + phpactor + terraform-ls + + # Formatters + black + eslint_d + nixfmt-rfc-style + nodePackages.prettier + stylua + yamlfmt + + # Tools + hadolint + html-tidy + nodePackages.jsonlint + nodePackages.markdownlint-cli + php82Packages.php-codesniffer + php82Packages.phpstan + proselint + shellcheck + yamllint + ]; + }; + + home.file.".markdownlint.yaml".text = '' + default: true + + line-length: false + + no-duplicate-heading: + siblings_only: true ''; - - extraPackages = with pkgs; [ - # Languages - nodePackages.typescript - nodejs-slim - php81 - - # Language servers - gopls - lua-language-server - lua54Packages.luacheck - marksman - nixd - nodePackages."@tailwindcss/language-server" - nodePackages.bash-language-server - nodePackages.dockerfile-language-server-nodejs - nodePackages.intelephense - nodePackages.typescript-language-server - nodePackages.vls - nodePackages.vscode-langservers-extracted - nodePackages.vue-language-server - nodePackages.yaml-language-server - phpactor - terraform-ls - - # Formatters - black - eslint_d - nixfmt-rfc-style - nodePackages.prettier - stylua - yamlfmt - - # Tools - hadolint - html-tidy - nodePackages.jsonlint - nodePackages.markdownlint-cli - php82Packages.php-codesniffer - php82Packages.phpstan - proselint - shellcheck - yamllint - ]; }; - - home.file.".markdownlint.yaml".text = '' - default: true - - line-length: false - - no-duplicate-heading: - siblings_only: true - ''; } diff --git a/nix/modules/home-manager/tmux.nix b/nix/modules/home-manager/tmux.nix index a723374..9dd8a10 100644 --- a/nix/modules/home-manager/tmux.nix +++ b/nix/modules/home-manager/tmux.nix @@ -1,77 +1,87 @@ -{ pkgs, ... }: +{ + config, + lib, + pkgs, + ... +}: + let inherit (pkgs) tmuxPlugins; in { - programs.tmux = { - enable = true; + options.features.cli.tmux.enable = lib.mkEnableOption "Enable tmux"; - terminal = "tmux-256color"; + config = lib.mkIf config.features.cli.tmux.enable { + programs.tmux = { + enable = true; - extraConfig = '' - set-option -g status-keys "vi" - set-option -sa terminal-features "''${TERM}:RGB" + terminal = "tmux-256color"; - bind -n S-Left resize-pane -L 2 - bind -n S-Right resize-pane -R 2 - bind -n S-Down resize-pane -D 1 - bind -n S-Up resize-pane -U 1 + extraConfig = '' + set-option -g status-keys "vi" + set-option -sa terminal-features "''${TERM}:RGB" - bind -n C-Left resize-pane -L 10 - bind -n C-Right resize-pane -R 10 - bind -n C-Down resize-pane -D 5 - bind -n C-Up resize-pane -U 5 + bind -n S-Left resize-pane -L 2 + bind -n S-Right resize-pane -R 2 + bind -n S-Down resize-pane -D 1 + bind -n S-Up resize-pane -U 1 - # Status line customisation - set-option -g status-left "" - set-option -g status-right " #{session_name}" - set-option -g status-right-length 100 - set-option -g status-style "fg=#7C7D83 bg=default" - set-option -g window-status-activity-style none - set-option -g window-status-current-style "fg=#E9E9EA" + bind -n C-Left resize-pane -L 10 + bind -n C-Right resize-pane -R 10 + bind -n C-Down resize-pane -D 5 + bind -n C-Up resize-pane -U 5 - bind c new-window -c "#{pane_current_path}" + # Status line customisation + set-option -g status-left "" + set-option -g status-right " #{session_name}" + set-option -g status-right-length 100 + set-option -g status-style "fg=#7C7D83 bg=default" + set-option -g window-status-activity-style none + set-option -g window-status-current-style "fg=#E9E9EA" - set -g base-index 1 - set -g pane-base-index 1 - set -g renumber-windows on + bind c new-window -c "#{pane_current_path}" - # Break a pane into a new window. - bind-key b break-pane -d - bind-key J command-prompt -p "join pane from: " "join-pane -h -s '%%'" + set -g base-index 1 + set -g pane-base-index 1 + set -g renumber-windows on - bind-key C-j choose-tree + # Break a pane into a new window. + bind-key b break-pane -d + bind-key J command-prompt -p "join pane from: " "join-pane -h -s '%%'" - set-window-option -g mode-keys vi - bind -T copy-mode-vi v send-keys -X begin-selection - bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard' + bind-key C-j choose-tree - bind C-j split-window -v "tmux list-sessions | sed -E 's/:.*$//' | grep -v \"^$(tmux display-message -p '#S')\$\" | fzf --reverse | xargs tmux switch-client -t" + set-window-option -g mode-keys vi + bind -T copy-mode-vi v send-keys -X begin-selection + bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard' - bind-key K run-shell 'tmux switch-client -n \; kill-session -t "$(tmux display-message -p "#S")" || tmux kill-session' + bind C-j split-window -v "tmux list-sessions | sed -E 's/:.*$//' | grep -v \"^$(tmux display-message -p '#S')\$\" | fzf --reverse | xargs tmux switch-client -t" - # Allow clearing screen with ctrl-l by using C-l - bind C-l send-keys "C-l" - bind C-k send-keys "C-k" + bind-key K run-shell 'tmux switch-client -n \; kill-session -t "$(tmux display-message -p "#S")" || tmux kill-session' - # Enable mouse support. - setw -g mouse on + # Allow clearing screen with ctrl-l by using C-l + bind C-l send-keys "C-l" + bind C-k send-keys "C-k" - # Remove delay when switching Vim modes. - set -sg escape-time 0 + # Enable mouse support. + setw -g mouse on - set-option -g pane-active-border-style "fg=#1f2335" - set-option -g pane-border-style "fg=#1f2335" + # Remove delay when switching Vim modes. + set -sg escape-time 0 - bind-key -r f run-shell "tmux new-window t" + set-option -g pane-active-border-style "fg=#1f2335" + set-option -g pane-border-style "fg=#1f2335" + + bind-key -r f run-shell "tmux new-window t" - if-shell "[ -f ~/.tmux.conf.local ]" 'source ~/.tmux.conf.local' - ''; + if-shell "[ -f ~/.tmux.conf.local ]" 'source ~/.tmux.conf.local' + ''; - plugins = [ - tmuxPlugins.vim-tmux-navigator - tmuxPlugins.yank - ]; + plugins = [ + tmuxPlugins.vim-tmux-navigator + tmuxPlugins.yank + ]; + }; }; } diff --git a/nix/modules/nixos/desktop/autorandr.nix b/nix/modules/nixos/autorandr.nix similarity index 100% rename from nix/modules/nixos/desktop/autorandr.nix rename to nix/modules/nixos/autorandr.nix diff --git a/nix/modules/nixos/default.nix b/nix/modules/nixos/default.nix index 0ee96bd..d2ecedd 100644 --- a/nix/modules/nixos/default.nix +++ b/nix/modules/nixos/default.nix @@ -1,7 +1,16 @@ { imports = [ + ./autorandr.nix ./docker.nix + ./fonts.nix + ./gitea.nix + ./i3.nix + ./immich.nix + ./jellyfin.nix ./kanata.nix + ./rofi.nix ./rsnapshot.nix + ./screenkey.nix + ./xbanish.nix ]; } diff --git a/nix/modules/nixos/desktop/default.nix b/nix/modules/nixos/desktop/default.nix deleted file mode 100644 index 126da1f..0000000 --- a/nix/modules/nixos/desktop/default.nix +++ /dev/null @@ -1,14 +0,0 @@ -{ - imports = [ - ../. - ./autorandr.nix - ./fonts.nix - ./gitea.nix - ./i3.nix - ./immich.nix - ./jellyfin.nix - ./rofi.nix - ./screenkey.nix - ./xbanish.nix - ]; -} diff --git a/nix/modules/nixos/desktop/fonts.nix b/nix/modules/nixos/fonts.nix similarity index 91% rename from nix/modules/nixos/desktop/fonts.nix rename to nix/modules/nixos/fonts.nix index 4b99f19..8bf189d 100644 --- a/nix/modules/nixos/desktop/fonts.nix +++ b/nix/modules/nixos/fonts.nix @@ -1,7 +1,7 @@ { pkgs, ... }: let - theme = import ../../../lib/theme { inherit pkgs; }; + theme = import ../../lib/theme { inherit pkgs; }; in { environment.systemPackages = with pkgs; [ diff --git a/nix/modules/nixos/desktop/gitea.nix b/nix/modules/nixos/gitea.nix similarity index 100% rename from nix/modules/nixos/desktop/gitea.nix rename to nix/modules/nixos/gitea.nix diff --git a/nix/modules/nixos/desktop/i3.nix b/nix/modules/nixos/i3.nix similarity index 100% rename from nix/modules/nixos/desktop/i3.nix rename to nix/modules/nixos/i3.nix diff --git a/nix/modules/nixos/desktop/immich.nix b/nix/modules/nixos/immich.nix similarity index 100% rename from nix/modules/nixos/desktop/immich.nix rename to nix/modules/nixos/immich.nix diff --git a/nix/modules/nixos/desktop/jellyfin.nix b/nix/modules/nixos/jellyfin.nix similarity index 100% rename from nix/modules/nixos/desktop/jellyfin.nix rename to nix/modules/nixos/jellyfin.nix diff --git a/nix/modules/nixos/desktop/rofi.nix b/nix/modules/nixos/rofi.nix similarity index 100% rename from nix/modules/nixos/desktop/rofi.nix rename to nix/modules/nixos/rofi.nix diff --git a/nix/modules/nixos/desktop/screenkey.nix b/nix/modules/nixos/screenkey.nix similarity index 100% rename from nix/modules/nixos/desktop/screenkey.nix rename to nix/modules/nixos/screenkey.nix diff --git a/nix/modules/nixos/desktop/steam.nix b/nix/modules/nixos/steam.nix similarity index 100% rename from nix/modules/nixos/desktop/steam.nix rename to nix/modules/nixos/steam.nix diff --git a/nix/modules/nixos/desktop/xbanish.nix b/nix/modules/nixos/xbanish.nix similarity index 100% rename from nix/modules/nixos/desktop/xbanish.nix rename to nix/modules/nixos/xbanish.nix diff --git a/run b/run index 614930e..3667408 100755 --- a/run +++ b/run @@ -25,6 +25,14 @@ function help { 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 { _nixos build "$@" } @@ -41,23 +49,14 @@ function update { nix flake update } -function wsl:build { - _home build wsl2 "$@" -} - -function wsl:switch { - _home switch wsl2 "$@" -} - function _home { local command="$1" - local flake="$2" - shift 2 + shift 1 NIXPKGS_ALLOW_UNFREE=1 home-manager "$command" \ --extra-experimental-features flakes \ --extra-experimental-features nix-command \ - --flake ".#$flake" \ + --flake ".#$(whoami)@$(hostname)" \ --impure "$@" }