From d973d78d98bc52a6dcdbf80dcaf71ad48bcdf6df Mon Sep 17 00:00:00 2001 From: Thilo Billerbeck Date: Mon, 21 Aug 2023 02:24:55 +0200 Subject: [PATCH] modularize home manager config --- machines/common.nix | 71 --------------------- machines/desktop.nix | 31 +++------ machines/fedora.nix | 9 --- modules/machine.nix | 148 +++++++++++++++++++++++++++++++++++++++++++ modules/packages.nix | 84 ++++++++++++++++++++++++ packages.nix | 46 -------------- programs/zsh.nix | 2 +- 7 files changed, 242 insertions(+), 149 deletions(-) delete mode 100644 machines/common.nix create mode 100644 modules/machine.nix create mode 100644 modules/packages.nix delete mode 100644 packages.nix diff --git a/machines/common.nix b/machines/common.nix deleted file mode 100644 index a8e35f6..0000000 --- a/machines/common.nix +++ /dev/null @@ -1,71 +0,0 @@ -{ config, pkgs, lib, ... }: - -{ - nixpkgs.config.allowUnfree = true; - news.display = "silent"; - - imports = [ - ./../programs/alacritty.nix - ./../programs/bat.nix - ./../programs/beets.nix - ./../programs/command-not-found.nix - ./../programs/dircolors.nix - ./../programs/direnv.nix - ./../programs/fzf.nix - ./../programs/git.nix - ./../programs/htop.nix - ./../programs/neovim.nix - ./../programs/starship.nix - ./../programs/topgrade.nix - ./../programs/yt-dlp.nix - ./../programs/zsh.nix - ./../programs/go.nix - ./../packages.nix - ]; - - home = { - username = "thilo"; - homeDirectory = "/home/thilo"; - stateVersion = "22.11"; - file = { - ".config/nano/nanorc".text = '' - set linenumbers - include "/usr/share/nano/*.nanorc" - ''; - ".ssh/config".source = ./../dotfiles/ssh-config; - ".gitignore".source = ./../dotfiles/.gitignore; - }; - sessionVariables = { - - }; - activation = { - linkDesktopApplications = { - after = [ "writeBoundary" "createXdgUserDirectories" ]; - before = [ ]; - data = '' - for dir in ${config.home.homeDirectory}/.nix-profile/share/applications/*; do - chmod +x $(realpath $dir) -v - done - ''; - }; - setNodeGlobalDir = { - after = [ "writeBoundary" "createXdgUserDirectories" ]; - before = [ ]; - data = '' - mkdir -p ${config.home.homeDirectory}/.node-global - ${pkgs.nodejs}/bin/npm config set prefix ${config.home.homeDirectory}/.node-global - ''; - }; - }; - sessionPath = [ "${config.home.homeDirectory}/.node-global/bin" ]; - }; - - programs.home-manager.enable = true; - - nix = { - package = pkgs.nixUnstable; - extraOptions = '' - experimental-features = nix-command flakes - ''; - }; -} diff --git a/machines/desktop.nix b/machines/desktop.nix index 3393563..10b796e 100644 --- a/machines/desktop.nix +++ b/machines/desktop.nix @@ -1,29 +1,16 @@ { config, pkgs, lib, ... }: -let - chromeArgs = lib.strings.concatStringsSep " " [ - "--force-dark-mode" - "--enable-features=WebUIDarkMode" - "--enable-smooth-scrolling" - "--ozone-platform-hint=auto" - "--ignore-gpu-blocklist" - "--enable-gpu-rasterization" - "--enable-zero-copy" - "--force-device-scale-factor=1.0" - "--use-gl=desktop" - ]; -in { +{ imports = [ - ./common.nix + ./../modules/machine.nix ]; - gtk = { - enable = true; - theme = { - name = "adw-gtk3-dark"; - package = pkgs.adw-gtk3; - }; + machine = { + username = "thilo"; + isGeneric = false; + nixPackage = pkgs.nixUnstable; + isGnome = true; + noiseSuppression.enable = true; + isGraphical = true; }; - - news.display = "silent"; } diff --git a/machines/fedora.nix b/machines/fedora.nix index 0c3532f..2be8429 100644 --- a/machines/fedora.nix +++ b/machines/fedora.nix @@ -17,13 +17,4 @@ in { ./common.nix ./../wrappers/fedora.nix ]; - - targets.genericLinux.enable = true; - news.display = "silent"; - - programs.alacritty.package = (nixGLWrap pkgs.alacritty); - - home.packages = with pkgs; [ - - ]; } diff --git a/modules/machine.nix b/modules/machine.nix new file mode 100644 index 0000000..b78cd7e --- /dev/null +++ b/modules/machine.nix @@ -0,0 +1,148 @@ +{ lib, pkgs, config, ... }: +with lib; +{ + imports = [ + ./../programs/alacritty.nix + ./../programs/bat.nix + ./../programs/beets.nix + ./../programs/command-not-found.nix + ./../programs/dircolors.nix + ./../programs/direnv.nix + ./../programs/fzf.nix + ./../programs/git.nix + ./../programs/htop.nix + ./../programs/neovim.nix + ./../programs/starship.nix + ./../programs/topgrade.nix + ./../programs/yt-dlp.nix + ./../programs/zsh.nix + ./../programs/go.nix + ./packages.nix + ]; + + options = { + machine = { + username = mkOption { + type = types.str; + default = "thilo"; + description = "The username of the user"; + }; + isGeneric = mkOption { + type = types.bool; + default = false; + description = "Whether the system is generic or not"; + }; + nixPackage = mkOption { + type = types.package; + default = pkgs.nixUnstable; + description = "The version of nix to use"; + }; + isGraphical = mkOption { + type = types.bool; + default = false; + description = "Whether the system is graphical or not"; + }; + isGnome = mkOption { + type = types.bool; + default = false; + description = "Whether the system is gnome or not"; + }; + noiseSuppression.enable = mkOption { + type = types.bool; + default = false; + description = "Whether to enable noise suppression or not"; + }; + }; + }; + + config = { + nixpkgs.config.allowUnfree = true; + news.display = "silent"; + targets.genericLinux.enable = config.machine.isGeneric; + + home = { + username = "${config.machine.username}"; + homeDirectory = "/home/${config.machine.username}"; + stateVersion = "22.11"; + file = { + ".config/nano/nanorc".text = '' + set linenumbers + include "/usr/share/nano/*.nanorc" + ''; + ".ssh/config".source = ./../dotfiles/ssh-config; + ".gitignore".source = ./../dotfiles/.gitignore; + } // mkIf config.machine.noiseSuppression.enable { + ".config/pipewire/pipewire.conf.d/99-noise-suppression.conf".text = '' + context.modules = [{ + name = libpipewire-module-filter-chain + args = { + node.description = "Noise Canceling source" + media.name = "Noise Canceling source" + filter.graph = { + nodes = [{ + type = ladspa + name = rnnoise + plugin = ${pkgs.rnnoise-plugin}/lib/ladspa/librnnoise_ladspa.so + label = noise_suppressor_stereo + control = { + "VAD Threshold (%)" 50.0 + "VAD Grace Period (ms)" 200 + "Retroactive VAD Grace (ms)" 0 + } + }] + } + capture.props = { + node.name = "capture.rnnoise_source" + node.passive = true + audio.rate = 48000 + } + playback.props = { + node.name = "rnnoise_source" + media.class = Audio/Source + audio.rate = 48000 + } + } + }] + ''; + }; + activation = { + setNodeGlobalDir = { + after = [ "writeBoundary" "createXdgUserDirectories" ]; + before = [ ]; + data = '' + mkdir -p ${config.home.homeDirectory}/.node-global + ${pkgs.nodejs}/bin/npm config set prefix ${config.home.homeDirectory}/.node-global + ''; + }; + } // mkIf config.machine.isGeneric { + linkDesktopApplications = { + after = [ "writeBoundary" "createXdgUserDirectories" ]; + before = [ ]; + data = '' + for dir in ${config.home.homeDirectory}/.nix-profile/share/applications/*; do + chmod +x $(realpath $dir) -v + done + ''; + }; + }; + sessionPath = [ "${config.home.homeDirectory}/.node-global/bin" ]; + }; + + programs.home-manager.enable = true; + + nix = { + package = config.machine.nixPackage; + extraOptions = '' + experimental-features = nix-command flakes + ''; + }; + + gtk = { + enable = config.machine.isGnome; + theme = { + name = "adw-gtk3-dark"; + package = pkgs.adw-gtk3; + }; + }; + }; +} diff --git a/modules/packages.nix b/modules/packages.nix new file mode 100644 index 0000000..61290d6 --- /dev/null +++ b/modules/packages.nix @@ -0,0 +1,84 @@ +{ config, pkgs, lib, ... }: + +with lib; +let + nix-software-center = import (pkgs.fetchFromGitHub { + owner = "vlinkz"; + repo = "nix-software-center"; + rev = "0.1.2"; + sha256 = "xiqF1mP8wFubdsAQ1BmfjzCgOD3YZf7EGWl9i69FTls="; + }) {}; +in { + config = { + home.packages = with pkgs; [ + up + rbenv + cargo-update + htop + rustup + nixfmt + nodejs + bun + deno + devbox + tldr + flutter + nurl + hcloud + tea + dgraph + nix-init + nodePackages.nodemon + pocketbase + # surrealdb + thefuck + hub + httpie + manix + (pkgs.writeShellScriptBin "ssh-fix-permissions" + (builtins.readFile ./../scripts/ssh-fix-permissions.sh)) + (pkgs.writeShellScriptBin "yt-dlp-audio" + (builtins.readFile ./../scripts/yt-dlp-audio.sh)) + (pkgs.writeShellScriptBin "nix-shell-init" + (builtins.readFile ./../scripts/nix-shell-init.sh)) + (callPackage ./../pkgs/docker-craft-cms-dev-env.nix { + inherit lib; + }) + (import (fetchTarball + "https://github.com/cachix/devenv/archive/v0.6.2.tar.gz")).default + nixpkgs-fmt + toolbox + distrobox + ] ++ (if config.machine.isGraphical then [ + (pkgs.nerdfonts.override { + fonts = [ "JetBrainsMono" "FiraCode" "FiraMono" ]; + }) + anki + corefonts + vistafonts + jetbrains.webstorm + element-desktop + ludusavi + dbeaver + insomnia + onlyoffice-bin + nix-software-center + spotify + (lutris.override { + extraPkgs = pkgs: [ + wineWowPackages.full + winetricks + ]; + }) + google-chrome + vscode + discord + ] else [ ]) ++ (if config.machine.isGnome then [ + gnomeExtensions.blur-my-shell + gnomeExtensions.dash-to-panel + gnomeExtensions.user-themes + gnomeExtensions.vitals + gnomeExtensions.custom-accent-colors + ] else [ ]); + }; +} diff --git a/packages.nix b/packages.nix deleted file mode 100644 index 0575a4d..0000000 --- a/packages.nix +++ /dev/null @@ -1,46 +0,0 @@ -{ config, pkgs, lib, ... }: -{ - home.packages = with pkgs; - [ - up - rbenv - cargo-update - htop - rustup - nixfmt - nodejs - bun - deno - devbox - tldr - flutter - nurl - hcloud - tea - dgraph - nix-init - nodePackages.nodemon - pocketbase - # surrealdb - thefuck - corefonts - vistafonts - hub - httpie - manix - anki - ] ++ [ - (import (fetchTarball - "https://github.com/cachix/devenv/archive/v0.6.2.tar.gz")).default - (pkgs.nerdfonts.override { - fonts = [ "JetBrainsMono" "FiraCode" "FiraMono" ]; - }) - (pkgs.writeShellScriptBin "ssh-fix-permissions" - (builtins.readFile ./scripts/ssh-fix-permissions.sh)) - (pkgs.writeShellScriptBin "yt-dlp-audio" - (builtins.readFile ./scripts/yt-dlp-audio.sh)) - (pkgs.writeShellScriptBin "nix-shell-init" - (builtins.readFile ./scripts/nix-shell-init.sh)) - (callPackage pkgs/docker-craft-cms-dev-env.nix { inherit lib; }) - ]; -} diff --git a/programs/zsh.nix b/programs/zsh.nix index 590a3ef..b631e14 100644 --- a/programs/zsh.nix +++ b/programs/zsh.nix @@ -24,8 +24,8 @@ in { enable = true; enableAutosuggestions = true; enableCompletion = true; - enableSyntaxHighlighting = true; enableVteIntegration = true; + syntaxHighlighting.enable = true; shellAliases = { pub-ipv4 = "curl ip4.clerie.de"; serve = "python -m SimpleHTTPServer 8080";