From d25971bc1c20b30bd971791e1749bcc25d9b4e66 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 15 Feb 2022 23:18:57 +0100 Subject: [PATCH] home: use proper modules --- users/max/home.nix | 88 ++++++++++++++++++++++------------------- users/max/home/bat.nix | 12 +++--- users/max/home/fzf.nix | 8 ++-- users/max/home/git.nix | 48 +++++++++++----------- users/max/home/htop.nix | 26 ++++++------ users/max/home/lsd.nix | 10 +++-- users/max/home/ssh.nix | 64 +++++++++++++++--------------- 7 files changed, 138 insertions(+), 118 deletions(-) diff --git a/users/max/home.nix b/users/max/home.nix index 039e724..5f6c313 100644 --- a/users/max/home.nix +++ b/users/max/home.nix @@ -12,20 +12,59 @@ let meta = if args ? meta then args.meta else import ./userinfo.nix pkgs; isNixos = args ? isNixos; + + optionalDesktopModule = lib.optional (systemProfile == "desktop") { + # other files + home.file.templates-directory = import ./home/templates.nix meta; + home.file.steam-skins = { + source = inputs.self.packages.x86_64-linux.steam-metro-skin; + target = ".local/share/Steam/skins/metro-for-steam"; + recursive = true; + }; + home.file.sound-theme = let + bell = "${pkgs.gnome.gnome-control-center}/share/sounds/gnome/default/alerts/sonar.ogg"; + themeFile = pkgs.writeText "index.theme" (lib.generators.toINI {} { + "Sound Theme" = { + Name = "Custom"; + Inherits = "freedesktop"; + Directories = "."; + }; + }); + in { + source = pkgs.linkFarm "sound-theme" [ + { name = "bell-terminal.ogg"; path = bell; } + { name = "bell-window-system.ogg"; path = bell; } + { name = "index.theme"; path = themeFile; } + ]; + target = ".local/share/sounds/__custom"; + recursive = true; + }; + + # chromium extensions + programs.chromium = import ./home/chromium.nix pkgs.ungoogled-chromium inputs.nix-crx.packages.x86_64-linux; + + gtk.enable = true; + gtk.theme.name = "Adwaita-dark"; + dconf.settings = import ./home/dconf { inherit meta config; }; + }; + in -lib.recursiveUpdate { manual.json.enable = false; manual.html.enable = false; manual.manpages.enable = false; + _module.args = { inherit meta inputs; }; + # general program config - programs.bat = import ./home/bat.nix meta; - programs.fzf = import ./home/fzf.nix meta; - programs.lsd = import ./home/lsd.nix meta; - programs.git = import ./home/git.nix { inherit lib meta pkgs; }; - programs.htop = import ./home/htop.nix meta; - programs.ssh = import ./home/ssh.nix meta; + imports = [ + ./home/bat.nix + ./home/fzf.nix + ./home/lsd.nix + ./home/git.nix + ./home/htop.nix + ./home/ssh.nix + ] ++ optionalDesktopModule; # direnv programs.direnv.enable = true; @@ -36,37 +75,4 @@ lib.recursiveUpdate home.packages = with pkgs; [ neovim-remote ]; -} (lib.optionalAttrs (systemProfile == "desktop") { - # other files - home.file.templates-directory = import ./home/templates.nix meta; - home.file.steam-skins = { - source = inputs.self.packages.x86_64-linux.steam-metro-skin; - target = ".local/share/Steam/skins/metro-for-steam"; - recursive = true; - }; - home.file.sound-theme = let - bell = "${pkgs.gnome.gnome-control-center}/share/sounds/gnome/default/alerts/sonar.ogg"; - themeFile = pkgs.writeText "index.theme" (lib.generators.toINI {} { - "Sound Theme" = { - Name = "Custom"; - Inherits = "freedesktop"; - Directories = "."; - }; - }); - in { - source = pkgs.linkFarm "sound-theme" [ - { name = "bell-terminal.ogg"; path = bell; } - { name = "bell-window-system.ogg"; path = bell; } - { name = "index.theme"; path = themeFile; } - ]; - target = ".local/share/sounds/__custom"; - recursive = true; - }; - - # chromium extensions - programs.chromium = import ./home/chromium.nix pkgs.ungoogled-chromium inputs.nix-crx.packages.x86_64-linux; - - gtk.enable = true; - gtk.theme.name = "Adwaita-dark"; - dconf.settings = import ./home/dconf { inherit meta config; }; -}) +} diff --git a/users/max/home/bat.nix b/users/max/home/bat.nix index 751c9fd..f4c07ae 100644 --- a/users/max/home/bat.nix +++ b/users/max/home/bat.nix @@ -1,7 +1,9 @@ -meta: { - enable = true; - config = { - paging = "never"; - theme = "DarkNeon"; +{ + programs.bat = { + enable = true; + config = { + paging = "never"; + theme = "DarkNeon"; + }; }; } diff --git a/users/max/home/fzf.nix b/users/max/home/fzf.nix index 25885a9..983fc8d 100644 --- a/users/max/home/fzf.nix +++ b/users/max/home/fzf.nix @@ -1,4 +1,6 @@ -meta: { - enable = true; - enableZshIntegration = true; +{ + programs.fzf = { + enable = true; + enableZshIntegration = true; + }; } diff --git a/users/max/home/git.nix b/users/max/home/git.nix index 8777df7..c7dc233 100644 --- a/users/max/home/git.nix +++ b/users/max/home/git.nix @@ -1,27 +1,31 @@ -{ lib, meta, pkgs }: { - enable = true; +{ lib, meta, pkgs, ... }: - userName = meta.firstName; - userEmail = meta.email; +{ + programs.git = { + enable = true; - aliases = rec { - ac = "!git add . && git commit"; - dump = "!cd ~/Projects/dump && git clone --depth=1"; - grab = "clone --depth=1"; - graph = "log --all --decorate --graph --oneline"; - gud = ac; - honk = "push"; - next = "!git add --all && git commit -am next"; - nuke = "!git reset --hard HEAD && git clean -d -f"; - patchwork = "!git init && git add . && git commit -m pre"; - strip = "!rm -rf .git/ && echo Stripped repository information"; - unfuck = "reset --hard"; - what = "diff HEAD"; - where = "diff --name-status HEAD"; - }; + userName = meta.firstName; + userEmail = meta.email; - extraConfig = { - init.defaultBranch = "master"; - pull.rebase = true; + aliases = rec { + ac = "!git add . && git commit"; + dump = "!cd ~/Projects/dump && git clone --depth=1"; + grab = "clone --depth=1"; + graph = "log --all --decorate --graph --oneline"; + gud = ac; + honk = "push"; + next = "!git add --all && git commit -am next"; + nuke = "!git reset --hard HEAD && git clean -d -f"; + patchwork = "!git init && git add . && git commit -m pre"; + strip = "!rm -rf .git/ && echo Stripped repository information"; + unfuck = "reset --hard"; + what = "diff HEAD"; + where = "diff --name-status HEAD"; + }; + + extraConfig = { + init.defaultBranch = "master"; + pull.rebase = true; + }; }; } diff --git a/users/max/home/htop.nix b/users/max/home/htop.nix index 075f801..49a2471 100644 --- a/users/max/home/htop.nix +++ b/users/max/home/htop.nix @@ -1,14 +1,16 @@ -meta: { - enable = true; - settings = { - detailed_cpu_time = true; - hide_userland_threads = true; - highlight_base_name = true; - show_cpu_frequency = true; - show_program_path = false; - column_meters_0 = [ "LeftCPUs" "Memory" "Swap" ]; - column_meters_1 = [ "RightCPUs" "Tasks" "LoadAverage" "Uptime" ]; - column_meter_modes_0 = [ 0 0 0 ]; - column_meter_modes_1 = [ 0 0 0 0 ]; +{ + programs.htop = { + enable = true; + settings = { + detailed_cpu_time = true; + hide_userland_threads = true; + highlight_base_name = true; + show_cpu_frequency = true; + show_program_path = false; + column_meters_0 = [ "LeftCPUs" "Memory" "Swap" ]; + column_meters_1 = [ "RightCPUs" "Tasks" "LoadAverage" "Uptime" ]; + column_meter_modes_0 = [ 0 0 0 ]; + column_meter_modes_1 = [ 0 0 0 0 ]; + }; }; } diff --git a/users/max/home/lsd.nix b/users/max/home/lsd.nix index 114d147..6940091 100644 --- a/users/max/home/lsd.nix +++ b/users/max/home/lsd.nix @@ -1,5 +1,7 @@ -meta: { - enable = true; - enableAliases = true; - settings = { date = "relative"; }; +{ + programs.lsd = { + enable = true; + enableAliases = true; + settings = { date = "relative"; }; + }; } diff --git a/users/max/home/ssh.nix b/users/max/home/ssh.nix index c5c70f7..8d9b077 100644 --- a/users/max/home/ssh.nix +++ b/users/max/home/ssh.nix @@ -1,4 +1,4 @@ -meta: +{ meta, ... }: let gitHost = { user = "git"; @@ -23,37 +23,39 @@ let }; equip = host: cfgSet: cfgSet // { inherit host; }; in { - enable = true; - controlMaster = "auto"; - controlPersist = "15m"; - controlPath = "~/.ssh/muxctl:%h:%p:%r"; + programs.ssh = { + enable = true; + controlMaster = "auto"; + controlPersist = "15m"; + controlPath = "~/.ssh/muxctl:%h:%p:%r"; - forwardAgent = true; - serverAliveInterval = 60; + forwardAgent = true; + serverAliveInterval = 60; - extraOptionOverrides = { - ExitOnForwardFailure = "yes"; - TCPKeepAlive = "no"; - GSSAPIAuthentication = "yes"; - GSSAPIDelegateCredentials = "yes"; - VerifyHostKeyDNS = "yes"; - PKCS11Provider = builtins.elemAt meta.security.pkcs11Providers 0; - CanonicalDomains = builtins.concatStringsSep " " - ((map (sub: "${sub}.${meta.orgDomain}") [ - "backbone" - "services" - "int" - "core" - "node" - "search" - ]) ++ [ meta.orgDomain ]); - CanonicalizeHostname = "always"; - CanonicalizeMaxDots = "0"; + extraOptionOverrides = { + ExitOnForwardFailure = "yes"; + TCPKeepAlive = "no"; + GSSAPIAuthentication = "yes"; + GSSAPIDelegateCredentials = "yes"; + VerifyHostKeyDNS = "yes"; + PKCS11Provider = builtins.elemAt meta.security.pkcs11Providers 0; + CanonicalDomains = builtins.concatStringsSep " " + ((map (sub: "${sub}.${meta.orgDomain}") [ + "backbone" + "services" + "int" + "core" + "node" + "search" + ]) ++ [ meta.orgDomain ]); + CanonicalizeHostname = "always"; + CanonicalizeMaxDots = "0"; + }; + + matchBlocks.github = equip "github.com" gitHost; + matchBlocks.gnomeGitlab = equip "gitlab.gnome.org" gitHost; + matchBlocks.pveGitlab = equip "git.${meta.orgDomain}" gitHost // { user = "gitlab"; }; + matchBlocks.labHost = equip "*.lab" labHost; + matchBlocks.mdnsLocal = equip "*.local" features.noFancyDNS; }; - - matchBlocks.github = equip "github.com" gitHost; - matchBlocks.gnomeGitlab = equip "gitlab.gnome.org" gitHost; - matchBlocks.pveGitlab = equip "git.${meta.orgDomain}" gitHost // { user = "gitlab"; }; - matchBlocks.labHost = equip "*.lab" labHost; - matchBlocks.mdnsLocal = equip "*.local" features.noFancyDNS; }