From 1f1c30f57cfcc7e6334abc5c53092bdb8f73c227 Mon Sep 17 00:00:00 2001 From: Pim Kunis Date: Sun, 8 Oct 2023 11:44:31 +0200 Subject: [PATCH] restructure with nixos modules --- alacritty.nix => alacritty/config.nix | 0 alacritty/default.nix | 8 + bash/default.nix | 19 ++ direnv/default.nix | 9 + {firefox-addons => firefox}/addons.json | 0 .../default.nix => firefox/addons.nix | 6 +- .../custom-addons.nix | 0 firefox/default.nix | 51 +++++ fzf/default.nix | 8 + git/default.nix | 12 ++ home.nix | 197 ++---------------- keepassxc.nix => keepassxc/config.nix | 0 keepassxc/default.nix | 8 + neovim/default.nix | 36 ++++ neovim.lua => neovim/neovim.lua | 0 ssh/default.nix | 44 ++++ syncthing/default.nix | 9 + syncthing.xml => syncthing/syncthing.xml | 0 thunderbird/default.nix | 10 + 19 files changed, 235 insertions(+), 182 deletions(-) rename alacritty.nix => alacritty/config.nix (100%) create mode 100644 alacritty/default.nix create mode 100644 bash/default.nix create mode 100644 direnv/default.nix rename {firefox-addons => firefox}/addons.json (100%) rename firefox-addons/default.nix => firefox/addons.nix (84%) rename firefox-addons/derivations.nix => firefox/custom-addons.nix (100%) create mode 100644 firefox/default.nix create mode 100644 fzf/default.nix create mode 100644 git/default.nix rename keepassxc.nix => keepassxc/config.nix (100%) create mode 100644 keepassxc/default.nix create mode 100644 neovim/default.nix rename neovim.lua => neovim/neovim.lua (100%) create mode 100644 ssh/default.nix create mode 100644 syncthing/default.nix rename syncthing.xml => syncthing/syncthing.xml (100%) create mode 100644 thunderbird/default.nix diff --git a/alacritty.nix b/alacritty/config.nix similarity index 100% rename from alacritty.nix rename to alacritty/config.nix diff --git a/alacritty/default.nix b/alacritty/default.nix new file mode 100644 index 0000000..e5541e3 --- /dev/null +++ b/alacritty/default.nix @@ -0,0 +1,8 @@ +{ + config = { + programs.alacritty = { + enable = true; + settings = import ./config.nix; + }; + }; +} diff --git a/bash/default.nix b/bash/default.nix new file mode 100644 index 0000000..0f57e05 --- /dev/null +++ b/bash/default.nix @@ -0,0 +1,19 @@ +{ + config = { + programs.bash = { + enable = true; + shellAliases = { + htop = "btop"; + gp = "git push"; + gco = "git checkout"; + gd = "git diff"; + gc = "git commit"; + gpl = "git pull"; + gb = "git branch"; + ga = "git add"; + gl = "git log"; + gs = "git status"; + }; + }; + }; +} diff --git a/direnv/default.nix b/direnv/default.nix new file mode 100644 index 0000000..fd12478 --- /dev/null +++ b/direnv/default.nix @@ -0,0 +1,9 @@ +{ + config = { + programs.direnv = { + enable = true; + enableBashIntegration = true; + nix-direnv.enable = true; + }; + }; +} diff --git a/firefox-addons/addons.json b/firefox/addons.json similarity index 100% rename from firefox-addons/addons.json rename to firefox/addons.json diff --git a/firefox-addons/default.nix b/firefox/addons.nix similarity index 84% rename from firefox-addons/default.nix rename to firefox/addons.nix index 82d58c1..2527bf5 100644 --- a/firefox-addons/default.nix +++ b/firefox/addons.nix @@ -1,7 +1,7 @@ {nurpkgs, lib, ...}@args: let rycee-addons = nurpkgs.repos.rycee.firefox-addons; - own-addons = import ./derivations.nix args; + custom-addons = import ./custom-addons.nix args; in { default = lib.concatLists [ @@ -18,7 +18,7 @@ in boring-rss # rycee.bypass-paywalls-clean ]) - (with own-addons; [ + (with custom-addons; [ http-version-indicator indicatetls sixindicator @@ -28,6 +28,6 @@ in ublock-origin istilldontcareaboutcookies keepassxc-browser - own-addons.simple-style-fox-2 + custom-addons.simple-style-fox-2 ]; } diff --git a/firefox-addons/derivations.nix b/firefox/custom-addons.nix similarity index 100% rename from firefox-addons/derivations.nix rename to firefox/custom-addons.nix diff --git a/firefox/default.nix b/firefox/default.nix new file mode 100644 index 0000000..eaf656b --- /dev/null +++ b/firefox/default.nix @@ -0,0 +1,51 @@ +{ pkgs, ...}@args: + +let + nurpkgs = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") { inherit pkgs; }; + firefoxAddons = import ./addons.nix (args // {inherit nurpkgs; }); + firefoxSettings = { + "browser.aboutConfig.showWarning" = false; + "browser.toolbars.bookmarks.visibility" = "always"; + "browser.tabs.firefox-view" = false; + "browser.shell.checkDefaultBrowser" = false; + }; +in +{ + config = { + programs.firefox = { + enable = true; + profiles = { + default = { + id = 0; + isDefault = true; + settings = firefoxSettings; + extensions = firefoxAddons.default; + }; + sue = { + id = 1; + settings = firefoxSettings; + extensions = firefoxAddons.sue; + }; + }; + }; + + xdg.desktopEntries.firefox-sue = { + categories = [ "Network" "WebBrowser" ]; + exec = "firefox -P sue --name firefox %U"; + genericName = "Web Browser"; + icon = "firefox"; + mimeType = [ + "text/html" + "text/xml" + "application/xhtml+xml" + "application/vnd.mozilla.xul+xml" + "x-scheme-handler/http" + "x-scheme-handler/https" + ]; + name = "Firefox | Sue"; + startupNotify = true; + terminal = false; + type = "Application"; + }; + }; +} diff --git a/fzf/default.nix b/fzf/default.nix new file mode 100644 index 0000000..383f47e --- /dev/null +++ b/fzf/default.nix @@ -0,0 +1,8 @@ +{ + config = { + programs.fzf = { + enable = true; + enableBashIntegration = true; + }; + }; +} diff --git a/git/default.nix b/git/default.nix new file mode 100644 index 0000000..735b4d5 --- /dev/null +++ b/git/default.nix @@ -0,0 +1,12 @@ +{ + config = { + programs.git = { + enable = true; + userName = "Pim Kunis"; + userEmail = "pim@kunis.nl"; + extraConfig = { + push.autoSetupRemote = true; + }; + }; + }; +} diff --git a/home.nix b/home.nix index 28bcd20..64651dc 100644 --- a/home.nix +++ b/home.nix @@ -1,24 +1,26 @@ -{ pkgs, lib, ... }@args: -let - nurpkgs = import (builtins.fetchTarball "https://github.com/nix-community/NUR/archive/master.tar.gz") { inherit pkgs; }; - firefox-addons = import ./firefox-addons (args // {inherit nurpkgs; }); - homeDirectory = "/home/pim"; - firefoxSettings = { - "browser.aboutConfig.showWarning" = false; - "browser.toolbars.bookmarks.visibility" = "always"; - "browser.tabs.firefox-view" = false; - "browser.shell.checkDefaultBrowser" = false; - }; -in +{ pkgs, ... }: + { + imports = [ + ./bash + ./neovim + ./firefox + ./ssh + ./syncthing + ./alacritty + ./keepassxc + ./git + ./direnv + ./thunderbird + ./fzf + ]; + home = { username = "pim"; - homeDirectory = homeDirectory; + homeDirectory = "/home/pim"; stateVersion = "23.05"; packages = with pkgs; [ - keepassxc - nil moonlight-qt vlc nicotine-plus @@ -29,146 +31,12 @@ in tree gimp libreoffice - nodePackages.pyright - neofetch - gopls ]; }; - services = { - syncthing.enable = true; - }; - programs = { home-manager.enable = true; chromium.enable = true; - - neovim = { - enable = true; - viAlias = true; - vimAlias = true; - vimdiffAlias = true; - defaultEditor = true; - plugins = with pkgs.vimPlugins; [ - nvim-lspconfig - gruvbox-nvim - leap-nvim - telescope-nvim - vim-commentary - vim-sleuth - gitsigns-nvim - nvim-cmp - cmp-nvim-lsp - friendly-snippets - neodev-nvim - ]; - extraLuaConfig = builtins.readFile ./neovim.lua; - }; - - alacritty = { - enable = true; - settings = import ./alacritty.nix; - }; - - firefox = { - enable = true; - profiles = { - default = { - id = 0; - isDefault = true; - settings = firefoxSettings; - extensions = firefox-addons.default; - }; - sue = { - id = 1; - settings = firefoxSettings; - extensions = firefox-addons.sue; - }; - }; - }; - - bash = { - enable = true; - shellAliases = { - htop = "btop"; - gp = "git push"; - gco = "git checkout"; - gd = "git diff"; - gc = "git commit"; - gpl = "git pull"; - gb = "git branch"; - ga = "git add"; - gl = "git log"; - gs = "git status"; - }; - }; - - direnv = { - enable = true; - enableBashIntegration = true; - nix-direnv.enable = true; - }; - - git = { - enable = true; - userName = "Pim Kunis"; - userEmail = "pim@kunis.nl"; - extraConfig = { - core.editor = "nvim"; - push.autoSetupRemote = true; - }; - }; - - fzf = { - enable = true; - enableBashIntegration = true; - }; - - ssh = { - enable = true; - extraConfig = "User root"; - - matchBlocks = { - gitlab-sue = lib.hm.dag.entryBefore [ "*" ] { - hostname = "gitlab.com"; - identityFile = "~/.ssh/sue_ed25519"; - identitiesOnly = true; - }; - github = lib.hm.dag.entryBefore [ "*" ] { - hostname = "github.com"; - user = "pizzapim"; - identitiesOnly = true; - }; - lewis = lib.hm.dag.entryBefore [ "*" ] { - hostname = "lewis.hyp"; - }; - atlas = lib.hm.dag.entryBefore [ "*" ] { - hostname = "atlas.hyp"; - }; - jefke = lib.hm.dag.entryBefore [ "*" ] { - hostname = "jefke.hyp"; - }; - hermes = lib.hm.dag.entryBefore [ "*" ] { - hostname = "hermes.dmz"; - }; - maestro = lib.hm.dag.entryBefore [ "*" ] { - hostname = "maestro.dmz"; - }; - bancomart = lib.hm.dag.entryBefore [ "*" ] { - hostname = "bancomart.dmz"; - }; - handjecontantje = lib.hm.dag.entryBefore [ "*" ] { - hostname = "handjecontantje.dmz"; - }; - }; - }; - - thunderbird = { - enable = true; - profiles.default = { - isDefault = true; - }; - }; }; # Let home-manager manage the X session @@ -176,34 +44,5 @@ in enable = true; }; - xdg = { - configFile = { - "keepassxc/keepassxc.ini".text = lib.generators.toINI {} (import ./keepassxc.nix); - "syncthing/config.xml".source = ./syncthing.xml; - }; - - userDirs = { - enable = true; - music = "${homeDirectory}/sync/Music"; - }; - - desktopEntries.firefox-sue = { - categories = [ "Network" "WebBrowser" ]; - exec = "firefox -P sue --name firefox %U"; - genericName = "Web Browser"; - icon = "firefox"; - mimeType = [ - "text/html" - "text/xml" - "application/xhtml+xml" - "application/vnd.mozilla.xul+xml" - "x-scheme-handler/http" - "x-scheme-handler/https" - ]; - name = "Firefox | Sue"; - startupNotify = true; - terminal = false; - type = "Application"; - }; - }; + xdg.userDirs.enable = true; } diff --git a/keepassxc.nix b/keepassxc/config.nix similarity index 100% rename from keepassxc.nix rename to keepassxc/config.nix diff --git a/keepassxc/default.nix b/keepassxc/default.nix new file mode 100644 index 0000000..b3a015c --- /dev/null +++ b/keepassxc/default.nix @@ -0,0 +1,8 @@ +{ pkgs, lib, ...}: + +{ + config = { + home.packages = [ pkgs.keepassxc ]; + xdg.configFile."keepassxc/keepassxc.ini".text = lib.generators.toINI {} (import ./config.nix); + }; +} diff --git a/neovim/default.nix b/neovim/default.nix new file mode 100644 index 0000000..d17be6b --- /dev/null +++ b/neovim/default.nix @@ -0,0 +1,36 @@ +{ pkgs, ... }: + +{ + config = { + home.packages = with pkgs; [ + nil + nodePackages.pyright + neofetch + gopls + ]; + + programs.neovim = { + enable = true; + viAlias = true; + vimAlias = true; + vimdiffAlias = true; + defaultEditor = true; + plugins = with pkgs.vimPlugins; [ + nvim-lspconfig + gruvbox-nvim + leap-nvim + telescope-nvim + vim-commentary + vim-sleuth + gitsigns-nvim + nvim-cmp + cmp-nvim-lsp + friendly-snippets + neodev-nvim + ]; + extraLuaConfig = builtins.readFile ./neovim.lua; + }; + + programs.git.extraConfig.core.editor = "nvim"; + }; +} diff --git a/neovim.lua b/neovim/neovim.lua similarity index 100% rename from neovim.lua rename to neovim/neovim.lua diff --git a/ssh/default.nix b/ssh/default.nix new file mode 100644 index 0000000..b5c52e1 --- /dev/null +++ b/ssh/default.nix @@ -0,0 +1,44 @@ +{ lib, ...}: + +{ + config = { + programs.ssh = { + enable = true; + extraConfig = "User root"; + + matchBlocks = { + gitlab-sue = lib.hm.dag.entryBefore [ "*" ] { + hostname = "gitlab.com"; + identityFile = "~/.ssh/sue_ed25519"; + identitiesOnly = true; + }; + github = lib.hm.dag.entryBefore [ "*" ] { + hostname = "github.com"; + user = "pizzapim"; + identitiesOnly = true; + }; + lewis = lib.hm.dag.entryBefore [ "*" ] { + hostname = "lewis.hyp"; + }; + atlas = lib.hm.dag.entryBefore [ "*" ] { + hostname = "atlas.hyp"; + }; + jefke = lib.hm.dag.entryBefore [ "*" ] { + hostname = "jefke.hyp"; + }; + hermes = lib.hm.dag.entryBefore [ "*" ] { + hostname = "hermes.dmz"; + }; + maestro = lib.hm.dag.entryBefore [ "*" ] { + hostname = "maestro.dmz"; + }; + bancomart = lib.hm.dag.entryBefore [ "*" ] { + hostname = "bancomart.dmz"; + }; + handjecontantje = lib.hm.dag.entryBefore [ "*" ] { + hostname = "handjecontantje.dmz"; + }; + }; + }; + }; +} diff --git a/syncthing/default.nix b/syncthing/default.nix new file mode 100644 index 0000000..f68e931 --- /dev/null +++ b/syncthing/default.nix @@ -0,0 +1,9 @@ +{ config, ... }: + +{ + config = { + services.syncthing.enable = true; + xdg.configFile."syncthing/config.xml".source = ./syncthing.xml; + xdg.userDirs.music = "${config.home.homeDirectory}/sync/Music"; + }; +} diff --git a/syncthing.xml b/syncthing/syncthing.xml similarity index 100% rename from syncthing.xml rename to syncthing/syncthing.xml diff --git a/thunderbird/default.nix b/thunderbird/default.nix new file mode 100644 index 0000000..c3d1be6 --- /dev/null +++ b/thunderbird/default.nix @@ -0,0 +1,10 @@ +{ + config = { + programs.thunderbird = { + enable = true; + profiles.default = { + isDefault = true; + }; + }; + }; +}