From 8dfc9b5a6da7f6fe82965d47bdf9269dbdcd0c52 Mon Sep 17 00:00:00 2001 From: Joakim Repomaa Date: Sat, 1 Mar 2025 13:23:01 +0200 Subject: [PATCH] run nixfmt --- custom-pkgs/commander-nvim/default.nix | 6 +- custom-pkgs/crystal/package.nix | 22 +- custom-pkgs/default.nix | 16 +- custom-pkgs/fb-client/package.nix | 18 +- custom-pkgs/gen-nvim/default.nix | 6 +- custom-pkgs/util.nix | 10 +- custom-pkgs/vimpeccable/default.nix | 6 +- custom-pkgs/windline-nvim/default.nix | 6 +- flake.nix | 78 ++- home/common/default.nix | 132 ++++- home/common/dnote.nix | 13 +- home/common/neovim/default.nix | 172 ++++-- home/custom-programs/default.nix | 6 +- home/custom-programs/fb-client/default.nix | 31 +- home/gnome/default.nix | 124 +++-- home/gnome/extensions/default.nix | 8 +- home/gnome/extensions/freon/default.nix | 7 +- home/gnome/extensions/paperwm/default.nix | 81 ++- home/jokke/default.nix | 35 +- home/moco/default.nix | 158 ++++-- home/modules/neovim/default.nix | 576 +++++++++++++-------- hosts/apu/configuration.nix | 68 ++- hosts/apu/hardware-configuration.nix | 66 ++- hosts/freun-dev/configuration.nix | 13 +- hosts/freun-dev/hardware-configuration.nix | 47 +- hosts/freun-dev/secrets.nix | 64 +-- hosts/freun-dev/services.nix | 18 +- hosts/radish/configuration.nix | 5 +- hosts/radish/default.nix | 7 +- hosts/radish/hardware-configuration.nix | 80 +-- hosts/radish/hardware.nix | 8 +- hosts/radish/host.nix | 7 +- hosts/radish/secrets.nix | 14 +- hosts/radish/users.nix | 14 +- modules/firewall.nix | 49 +- modules/services/dnote.nix | 28 +- modules/services/donetick.nix | 9 +- modules/services/gotosocial.nix | 11 +- modules/services/grafana.nix | 10 +- modules/services/gtrackmap.nix | 7 +- modules/services/hastebin.nix | 7 +- modules/services/mealie.nix | 10 +- modules/services/octodns.nix | 66 ++- modules/services/readeck.nix | 18 +- modules/services/vaultwarden.nix | 10 +- modules/services/webserver.nix | 45 +- modules/services/workout-sync.nix | 8 +- modules/services/workout-tracker.nix | 8 +- modules/storage-box-mounts.nix | 39 +- modules/vlans.nix | 131 +++-- secrets/secrets.nix | 11 +- 51 files changed, 1611 insertions(+), 778 deletions(-) diff --git a/custom-pkgs/commander-nvim/default.nix b/custom-pkgs/commander-nvim/default.nix index b76aef6..b6c60f2 100644 --- a/custom-pkgs/commander-nvim/default.nix +++ b/custom-pkgs/commander-nvim/default.nix @@ -1 +1,5 @@ -{ util, inputs, ... }: util.vimPlugin { name = "commander.nvim"; source = inputs.commander-nvim; } +{ util, inputs, ... }: +util.vimPlugin { + name = "commander.nvim"; + source = inputs.commander-nvim; +} diff --git a/custom-pkgs/crystal/package.nix b/custom-pkgs/crystal/package.nix index 94ad064..cc141e9 100644 --- a/custom-pkgs/crystal/package.nix +++ b/custom-pkgs/crystal/package.nix @@ -2,15 +2,13 @@ let inherit (pkgs) crystal libffi; in -crystal.overrideAttrs (oldAttrs: - { - makeFlags = oldAttrs.makeFlags ++ [ - "interpreter=1" - ]; - buildInputs = oldAttrs.buildInputs ++ [ - libffi - ]; - FLAGS = ["--single-module"]; - doCheck = false; - } -) +crystal.overrideAttrs (oldAttrs: { + makeFlags = oldAttrs.makeFlags ++ [ + "interpreter=1" + ]; + buildInputs = oldAttrs.buildInputs ++ [ + libffi + ]; + FLAGS = [ "--single-module" ]; + doCheck = false; +}) diff --git a/custom-pkgs/default.nix b/custom-pkgs/default.nix index 399937b..776f463 100644 --- a/custom-pkgs/default.nix +++ b/custom-pkgs/default.nix @@ -2,8 +2,18 @@ let inherit (builtins) attrNames filter readDir; dirs = - let files = readDir ./.; - in filter (name: files."${name}" == "directory") (attrNames files); + let + files = readDir ./.; + in + filter (name: files."${name}" == "directory") (attrNames files); util = import ./util.nix; in -lib.composeManyExtensions (map (dir: import ./${dir} { util = util dir; inherit inputs; }) dirs) +lib.composeManyExtensions ( + map ( + dir: + import ./${dir} { + util = util dir; + inherit inputs; + } + ) dirs +) diff --git a/custom-pkgs/fb-client/package.nix b/custom-pkgs/fb-client/package.nix index f67aa32..dec7733 100644 --- a/custom-pkgs/fb-client/package.nix +++ b/custom-pkgs/fb-client/package.nix @@ -1,4 +1,10 @@ -{ lib, stdenv, fetchurl, python3, ... }: +{ + lib, + stdenv, + fetchurl, + python3, + ... +}: stdenv.mkDerivation rec { pname = "fb-client"; version = "2.3.0"; @@ -8,8 +14,14 @@ stdenv.mkDerivation rec { sha256 = "sha256-EWTsoG7qy0IQ1GLEuvHEAEJyphl9hz1hFm53k1OdGYM="; }; - buildInputs = - [ (python3.withPackages (pyPkgs: with pyPkgs; [ pycurl pyxdg ])) ]; + buildInputs = [ + (python3.withPackages ( + pyPkgs: with pyPkgs; [ + pycurl + pyxdg + ] + )) + ]; makeFlags = [ "PREFIX=$(out)" ]; diff --git a/custom-pkgs/gen-nvim/default.nix b/custom-pkgs/gen-nvim/default.nix index 9a48cee..9624edf 100644 --- a/custom-pkgs/gen-nvim/default.nix +++ b/custom-pkgs/gen-nvim/default.nix @@ -1 +1,5 @@ -{ inputs, util, ... }: util.vimPlugin { name = "gen.nvim"; source = inputs.gen-nvim; } +{ inputs, util, ... }: +util.vimPlugin { + name = "gen.nvim"; + source = inputs.gen-nvim; +} diff --git a/custom-pkgs/util.nix b/custom-pkgs/util.nix index 24f3963..17f9390 100644 --- a/custom-pkgs/util.nix +++ b/custom-pkgs/util.nix @@ -1,6 +1,6 @@ -dir: -{ - vimPlugin = { name, source }: +dir: { + vimPlugin = + { name, source }: final: prev: { vimPlugins = prev.vimPlugins // { "${dir}" = prev.vimUtils.buildVimPlugin { @@ -12,5 +12,7 @@ dir: }; }; - package = attrs: final: prev: { "${dir}" = final.callPackage ./${dir}/package.nix (attrs // { pkgs = prev; }); }; + package = attrs: final: prev: { + "${dir}" = final.callPackage ./${dir}/package.nix (attrs // { pkgs = prev; }); + }; } diff --git a/custom-pkgs/vimpeccable/default.nix b/custom-pkgs/vimpeccable/default.nix index b64b4a5..4dbf278 100644 --- a/custom-pkgs/vimpeccable/default.nix +++ b/custom-pkgs/vimpeccable/default.nix @@ -1 +1,5 @@ -{ inputs, util, ... }: util.vimPlugin { name = "vimpeccable"; source = inputs.vimpeccable; } +{ inputs, util, ... }: +util.vimPlugin { + name = "vimpeccable"; + source = inputs.vimpeccable; +} diff --git a/custom-pkgs/windline-nvim/default.nix b/custom-pkgs/windline-nvim/default.nix index 1ed83dc..ca659cd 100644 --- a/custom-pkgs/windline-nvim/default.nix +++ b/custom-pkgs/windline-nvim/default.nix @@ -1 +1,5 @@ -{ inputs, util, ... }: util.vimPlugin { name = "windline.nvim"; source = inputs.windline-nvim; } +{ inputs, util, ... }: +util.vimPlugin { + name = "windline.nvim"; + source = inputs.windline-nvim; +} diff --git a/flake.nix b/flake.nix index 3407c93..426209b 100644 --- a/flake.nix +++ b/flake.nix @@ -73,7 +73,15 @@ inputs.nixpkgs.follows = "nixpkgs"; }; }; - outputs = { flake-parts, agenix, nixpkgs, self, colmena, ... }@inputs: + outputs = + { + flake-parts, + agenix, + nixpkgs, + self, + colmena, + ... + }@inputs: flake-parts.lib.mkFlake { inherit inputs; } ( let ssh.publicKeys.yubikey = "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLIUkESu5NnBi1M0+ZjYrkp6/rIFuwc3aguspf98jmOydNce6l65cnS3GRzc9oWx4lu11ahi87ZuE+pYV+gaHm4="; @@ -81,25 +89,32 @@ inherit (nixpkgs) lib; in { - systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; - perSystem = { pkgs, system, ... }: { - devShells.default = pkgs.mkShell { - packages = with pkgs; [ - agenix.packages.${system}.default - colmena.packages.${system}.colmena - colmena.packages.${system}.manual - (pkgs.writeShellScriptBin "build" '' - colmena --experimental-flake-eval build --keep-result "$@" - '') - (pkgs.writeShellScriptBin "apply" '' - colmena --experimental-flake-eval apply --keep-result "$@" - '') - (pkgs.writeShellScriptBin "apply-local" '' - colmena --experimental-flake-eval apply-local --sudo "$@" - '') - ]; + systems = [ + "x86_64-linux" + "x86_64-darwin" + "aarch64-linux" + "aarch64-darwin" + ]; + perSystem = + { pkgs, system, ... }: + { + devShells.default = pkgs.mkShell { + packages = with pkgs; [ + agenix.packages.${system}.default + colmena.packages.${system}.colmena + colmena.packages.${system}.manual + (pkgs.writeShellScriptBin "build" '' + colmena --experimental-flake-eval build --keep-result "$@" + '') + (pkgs.writeShellScriptBin "apply" '' + colmena --experimental-flake-eval apply --keep-result "$@" + '') + (pkgs.writeShellScriptBin "apply-local" '' + colmena --experimental-flake-eval apply-local --sudo "$@" + '') + ]; + }; }; - }; flake = { colmenaHive = colmena.lib.makeHive self.outputs.colmena; @@ -113,16 +128,23 @@ }; }; - defaults = { name, ... }: { - imports = [ ./modules ./hosts/${name} ]; - }; - - radish = { ... }: { - deployment = { - allowLocalDeployment = true; - targetHost = null; + defaults = + { name, ... }: + { + imports = [ + ./modules + ./hosts/${name} + ]; + }; + + radish = + { ... }: + { + deployment = { + allowLocalDeployment = true; + targetHost = null; + }; }; - }; freun-dev = { ... }: { }; diff --git a/home/common/default.nix b/home/common/default.nix index 3a59985..9140647 100644 --- a/home/common/default.nix +++ b/home/common/default.nix @@ -1,4 +1,12 @@ -{ config, lib, pkgs, inputs, self, ... }: { +{ + config, + lib, + pkgs, + inputs, + self, + ... +}: +{ nixpkgs.config.allowUnfree = true; imports = [ ../gnome @@ -83,7 +91,10 @@ home-manager.enable = true; bat = { enable = true; - extraPackages = with pkgs.bat-extras; [ batdiff batwatch ]; + extraPackages = with pkgs.bat-extras; [ + batdiff + batwatch + ]; config = { pager = "less -FR"; }; @@ -277,8 +288,13 @@ bright_white = "#ffffff"; }; component_style = { - playback_metadata = { fg = "#8abeb7"; }; - playback_progress_bar = { bg = "#1d1f21"; fg = "#c5c8c6"; }; + playback_metadata = { + fg = "#8abeb7"; + }; + playback_progress_bar = { + bg = "#1d1f21"; + fg = "#c5c8c6"; + }; }; } ]; @@ -299,6 +315,39 @@ host = "https://bin.freun.dev"; auth_token_file = "${config.xdg.configHome}/hastebin/auth_token"; clipboard_command = "${pkgs.wl-copy-both}/bin/wl-copy"; + default_renderers = + let + code = [ + "js" + "ts" + "jsx" + "tsx" + "rs" + "nix" + "cr" + "ecr" + "rb" + "erb" + "yaml" + "yml" + "json" + "toml" + "html" + "xml" + "css" + "scss" + "sass" + "less" + "sql" + "sh" + ]; + in + lib.listToAttrs ( + lib.map (name: { + inherit name; + value = "hl"; + }) code + ); }; }; zed-editor = { @@ -334,23 +383,68 @@ paperwm = { enable = true; winprops = [ - { wm_class = "vivaldi-stable"; preferredWidth = "67%"; } - { wm_class = "yubioath-flutter"; scratch_layer = true; } - { wm_class = "signal"; scratch_layer = true; } - { wm_class = "Slack"; scratch_layer = true; } - { wm_class = "Supersonic"; scratch_layer = true; } - { wm_class = "io.github.seadve.Kooha"; scratch_layer = true; } - { wm_class = "/.*/"; preferredWidth = "33"; } + { + wm_class = "vivaldi-stable"; + preferredWidth = "67%"; + } + { + wm_class = "yubioath-flutter"; + scratch_layer = true; + } + { + wm_class = "signal"; + scratch_layer = true; + } + { + wm_class = "Slack"; + scratch_layer = true; + } + { + wm_class = "Supersonic"; + scratch_layer = true; + } + { + wm_class = "io.github.seadve.Kooha"; + scratch_layer = true; + } + { + wm_class = "/.*/"; + preferredWidth = "33"; + } ]; keybindings = { - move-down = [ "Down" "j" ]; - move-left = [ "Left" "h" ]; - move-right = [ "Right" "l" ]; - move-up = [ "Up" "k" ]; - switch-down = [ "Down" "j" ]; - switch-left = [ "Left" "h" ]; - switch-right = [ "Right" "l" ]; - switch-up = [ "Up" "k" ]; + move-down = [ + "Down" + "j" + ]; + move-left = [ + "Left" + "h" + ]; + move-right = [ + "Right" + "l" + ]; + move-up = [ + "Up" + "k" + ]; + switch-down = [ + "Down" + "j" + ]; + switch-left = [ + "Left" + "h" + ]; + switch-right = [ + "Right" + "l" + ]; + switch-up = [ + "Up" + "k" + ]; }; }; freon = { diff --git a/home/common/dnote.nix b/home/common/dnote.nix index f5d5e63..9a83fb2 100644 --- a/home/common/dnote.nix +++ b/home/common/dnote.nix @@ -1,8 +1,17 @@ -{ inputs, lib, pkgs, config, ... }: +{ + inputs, + lib, + pkgs, + config, + ... +}: let completion = pkgs.stdenv.mkDerivation { name = "dnote-completion"; - phases = [ "unpackPhase" "installPhase" ]; + phases = [ + "unpackPhase" + "installPhase" + ]; src = inputs.dnote; installPhase = '' mkdir -p $out/lib/dnote/zsh-completion/completions diff --git a/home/common/neovim/default.nix b/home/common/neovim/default.nix index 413bf22..ff9f1d7 100644 --- a/home/common/neovim/default.nix +++ b/home/common/neovim/default.nix @@ -5,7 +5,13 @@ programs.neovim = let toLua = lib.generators.toLua { }; - luaMap = rhs: { rhs = rhs; lua = true; options = { silent = true; }; }; + luaMap = rhs: { + rhs = rhs; + lua = true; + options = { + silent = true; + }; + }; in { enable = true; @@ -50,7 +56,10 @@ filetypes = [ "crystal" ]; globs = [ "*.cr" ]; exe = "${pkgs.crystal}/bin/crystal"; - args = file: [ "tool" "format" ]; + args = file: [ + "tool" + "format" + ]; stdin = false; } ]; @@ -69,7 +78,11 @@ } { event = "FileType"; - pattern = [ "gitcommit" "gitrebase" "gitconfig" ]; + pattern = [ + "gitcommit" + "gitrebase" + "gitconfig" + ]; command = "set bufhidden=delete"; } { @@ -111,17 +124,41 @@ vim-crystal { plugin = telescope-nvim; - dependencies = [ plenary-nvim telescope-file-browser-nvim commander-nvim telescope-ui-select-nvim ]; + dependencies = [ + plenary-nvim + telescope-file-browser-nvim + commander-nvim + telescope-ui-select-nvim + ]; config = let commands = [ - { cmd = "!rails db:migrate"; desc = "Run rails migrations"; } - { cmd = "!yarn codegen --no-watch"; desc = "Run yarn codegen"; } - { cmd = "!rails translations:update"; desc = "Update i18n translations"; } - { cmd = "!deploy staging-v6 -t $(git branch --show-current)"; desc = "Deploy to staging"; } - { cmd = "!db-restore -d db-prod-inc"; desc = "Restore db from prod-inc"; } + { + cmd = "!rails db:migrate"; + desc = "Run rails migrations"; + } + { + cmd = "!yarn codegen --no-watch"; + desc = "Run yarn codegen"; + } + { + cmd = "!rails translations:update"; + desc = "Update i18n translations"; + } + { + cmd = "!deploy staging-v6 -t $(git branch --show-current)"; + desc = "Deploy to staging"; + } + { + cmd = "!db-restore -d db-prod-inc"; + desc = "Restore db from prod-inc"; + } ]; - mappings = { i = { "" = "which_key"; }; }; + mappings = { + i = { + "" = "which_key"; + }; + }; in '' local telescope = require('telescope') @@ -146,27 +183,21 @@ }) ''; mappings = { - normal = ( - lib.attrsets.mapAttrs - (key: value: luaMap "require('telescope.builtin').${value}") - { - "f" = "find_files"; - "r" = "live_grep"; - "b" = "buffers"; - "h" = "help_tags"; - "o" = "oldfiles"; - "s" = "git_status"; - "/" = "current_buffer_fuzzy_find"; - "c" = "git_branches"; - } - ) // ( - lib.attrsets.mapAttrs - (key: value: luaMap "require('telescope').extensions.${value}") - { - "n" = "file_browser.file_browser"; - ":" = "commander.filter"; - } - ); + normal = + (lib.attrsets.mapAttrs (key: value: luaMap "require('telescope.builtin').${value}") { + "f" = "find_files"; + "r" = "live_grep"; + "b" = "buffers"; + "h" = "help_tags"; + "o" = "oldfiles"; + "s" = "git_status"; + "/" = "current_buffer_fuzzy_find"; + "c" = "git_branches"; + }) + // (lib.attrsets.mapAttrs (key: value: luaMap "require('telescope').extensions.${value}") { + "n" = "file_browser.file_browser"; + ":" = "commander.filter"; + }); }; } { @@ -176,17 +207,25 @@ vim.cmd('colorscheme base16-tomorrow-night') ''; } - { plugin = octo-nvim; config = "require('octo').setup()"; } + { + plugin = octo-nvim; + config = "require('octo').setup()"; + } { plugin = gitsigns-nvim; dependencies = [ plenary-nvim ]; config = '' - require('gitsigns').setup(${toLua { - current_line_blame = true; - }}) + require('gitsigns').setup(${ + toLua { + current_line_blame = true; + } + }) ''; } - { plugin = windline-nvim; config = "require('wlsample.airline')"; } + { + plugin = windline-nvim; + config = "require('wlsample.airline')"; + } { plugin = luasnip; config = '' @@ -252,7 +291,10 @@ } { plugin = toggleterm-nvim; - dependencies = [ plenary-nvim pkgs.lazygit ]; + dependencies = [ + plenary-nvim + pkgs.lazygit + ]; config = '' local Terminal = require('toggleterm.terminal').Terminal local lazygit = Terminal:new({ @@ -277,16 +319,18 @@ } { plugin = copilot-cmp; - dependencies = [{ - plugin = copilot-lua; - config = '' - require('copilot').setup({ - suggestion = { enabled = false }, - panel = { enajkbled = false }, - copilot_node_command = '${pkgs.nodejs}/bin/node', - }) - ''; - }]; + dependencies = [ + { + plugin = copilot-lua; + config = '' + require('copilot').setup({ + suggestion = { enabled = false }, + panel = { enajkbled = false }, + copilot_node_command = '${pkgs.nodejs}/bin/node', + }) + ''; + } + ]; config = '' require('copilot_cmp').setup() ''; @@ -318,9 +362,11 @@ '' require('bufferline').setup({ options = ${toLua options} }) ''; - dependencies = [{ - plugin = nvim-web-devicons; - }]; + dependencies = [ + { + plugin = nvim-web-devicons; + } + ]; } ]; lsp = { @@ -342,7 +388,11 @@ name = "yamlls"; config = { settings = { - redhat = { telemetry = { enabled = false; }; }; + redhat = { + telemetry = { + enabled = false; + }; + }; yaml = { schemas = { "https://json.schemastore.org/github-workflow" = ".github/workflows/*.yml"; @@ -351,7 +401,10 @@ "https://json.schemastore.org/prettierrc.yaml" = ".prettierrc.yaml"; "https://json.schemastore.org/prettier.config.yml" = "prettier.config.yml"; "https://json.schemastore.org/prettier.config.yaml" = "prettier.config.yaml"; - "https://schema.jokke.space/caddy.json" = [ "*caddy*.yml" "*caddy*.yaml" ]; + "https://schema.jokke.space/caddy.json" = [ + "*caddy*.yml" + "*caddy*.yaml" + ]; }; }; }; @@ -363,7 +416,10 @@ config = { settings = { tailwindCSS = { - classAttributes = [ "class" "className" ]; + classAttributes = [ + "class" + "className" + ]; }; }; }; @@ -377,8 +433,14 @@ }; rootPattern = [ "package.json" ]; } - { name = "eslint"; package = vscode-langservers-extracted; } - { name = "nixd"; package = nixd; } + { + name = "eslint"; + package = vscode-langservers-extracted; + } + { + name = "nixd"; + package = nixd; + } { name = "bashls"; package = nodePackages.bash-language-server.overrideAttrs (oldAttrs: { diff --git a/home/custom-programs/default.nix b/home/custom-programs/default.nix index 1d61375..ef6c9b0 100644 --- a/home/custom-programs/default.nix +++ b/home/custom-programs/default.nix @@ -2,8 +2,10 @@ let inherit (builtins) attrNames filter readDir; dirs = - let files = readDir ./.; - in filter (name: files."${name}" == "directory") (attrNames files); + let + files = readDir ./.; + in + filter (name: files."${name}" == "directory") (attrNames files); in { imports = map (dir: ./${dir}) dirs; diff --git a/home/custom-programs/fb-client/default.nix b/home/custom-programs/fb-client/default.nix index 877e07b..d5735ed 100644 --- a/home/custom-programs/fb-client/default.nix +++ b/home/custom-programs/fb-client/default.nix @@ -1,19 +1,28 @@ -{ pkgs, config, lib, ... }: +{ + pkgs, + config, + lib, + ... +}: let cfg = config.programs.fb-client; in { - options.programs.fb-client = let inherit (lib) mkEnableOption mkOption types; in { - enable = mkEnableOption { }; - pastebin = mkOption { - type = types.str; - default = "https://paste.xinu.at"; + options.programs.fb-client = + let + inherit (lib) mkEnableOption mkOption types; + in + { + enable = mkEnableOption { }; + pastebin = mkOption { + type = types.str; + default = "https://paste.xinu.at"; + }; + clipboard_cmd = mkOption { + type = types.pathInStore; + default = "${pkgs.wl-clipboard}/bin/wl-copy"; + }; }; - clipboard_cmd = mkOption { - type = types.pathInStore; - default = "${pkgs.wl-clipboard}/bin/wl-copy"; - }; - }; config = lib.mkIf cfg.enable { home.packages = [ pkgs.fb-client ]; diff --git a/home/gnome/default.nix b/home/gnome/default.nix index 1337e1b..820b32d 100644 --- a/home/gnome/default.nix +++ b/home/gnome/default.nix @@ -1,4 +1,9 @@ -{ config, lib, osConfig, ... }: +{ + config, + lib, + osConfig, + ... +}: let cfg = config.gnome; in @@ -38,7 +43,12 @@ in }; power = { powerButton = lib.mkOption { - type = enum [ "suspend" "interactive" "hibernate" "nothing" ]; + type = enum [ + "suspend" + "interactive" + "hibernate" + "nothing" + ]; default = "interactive"; }; }; @@ -75,56 +85,66 @@ in }; config = { - dconf.settings = with lib.hm.gvariant; { - "org/gnome/shell/keybindings" = cfg.keybindings.builtin; - "org/gnome/settings-daemon/plugins/media-keys" = { - custom-keybindings = ( - lib.lists.imap0 - (i: _: "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom${toString i}/") - cfg.keybindings.custom - ); - }; - "org/gnome/desktop/input-sources" = { - sources = map (source: mkTuple [ "xkb" source ]) cfg.keyboard.sources; - }; - "org/gnome/mutter" = { - experimental-features = [ "scale-monitor-framebuffer" ]; - }; - "org/gnome/settings-daemon/plugins/xsettings" = { - overrides = [ (mkTuple [ "GdkWindowScalingFactor" cfg.scalingFactor ]) ]; - }; - "org/gnome/desktop/interface" = { - scaling-factor = cfg.scalingFactor; - }; - "org/gnome/settings-daemon/plugins/power" = { - "power-button-action" = cfg.power.powerButton; - }; - "org/gnome/settings-daemon/plugins/color" = with cfg.nightLight; { - night-light-enabled = enable; - night-light-temperature = temperature; - night-light-schedule-automatic = isNull schedule; - night-light-schedule-from = lib.mkIf (!isNull schedule) schedule.from; - night-light-schedule-to = lib.mkIf (!isNull schedule) schedule.to; - }; - "org/gnome/desktop/calendar" = { - show-weekdate = cfg.calendar.showWeekNumbers; - }; - "org/gnome/desktop/datetime" = { - automatic-timezone = cfg.automaticTimeZone; - }; - "system/locale" = { - region = cfg.region; - }; - } // ( - builtins.listToAttrs ( - lib.lists.imap0 - (i: keybinding: { - name = "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom${toString i}"; - value = keybinding; - }) - cfg.keybindings.custom - ) - ); + dconf.settings = + with lib.hm.gvariant; + { + "org/gnome/shell/keybindings" = cfg.keybindings.builtin; + "org/gnome/settings-daemon/plugins/media-keys" = { + custom-keybindings = ( + lib.lists.imap0 ( + i: _: "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom${toString i}/" + ) cfg.keybindings.custom + ); + }; + "org/gnome/desktop/input-sources" = { + sources = map ( + source: + mkTuple [ + "xkb" + source + ] + ) cfg.keyboard.sources; + }; + "org/gnome/mutter" = { + experimental-features = [ "scale-monitor-framebuffer" ]; + }; + "org/gnome/settings-daemon/plugins/xsettings" = { + overrides = [ + (mkTuple [ + "GdkWindowScalingFactor" + cfg.scalingFactor + ]) + ]; + }; + "org/gnome/desktop/interface" = { + scaling-factor = cfg.scalingFactor; + }; + "org/gnome/settings-daemon/plugins/power" = { + "power-button-action" = cfg.power.powerButton; + }; + "org/gnome/settings-daemon/plugins/color" = with cfg.nightLight; { + night-light-enabled = enable; + night-light-temperature = temperature; + night-light-schedule-automatic = isNull schedule; + night-light-schedule-from = lib.mkIf (!isNull schedule) schedule.from; + night-light-schedule-to = lib.mkIf (!isNull schedule) schedule.to; + }; + "org/gnome/desktop/calendar" = { + show-weekdate = cfg.calendar.showWeekNumbers; + }; + "org/gnome/desktop/datetime" = { + automatic-timezone = cfg.automaticTimeZone; + }; + "system/locale" = { + region = cfg.region; + }; + } + // (builtins.listToAttrs ( + lib.lists.imap0 (i: keybinding: { + name = "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom${toString i}"; + value = keybinding; + }) cfg.keybindings.custom + )); home.file.".face".source = lib.mkIf (!isNull cfg.profilePicture) cfg.profilePicture; }; } diff --git a/home/gnome/extensions/default.nix b/home/gnome/extensions/default.nix index 5f5e5b6..ef6c9b0 100644 --- a/home/gnome/extensions/default.nix +++ b/home/gnome/extensions/default.nix @@ -2,9 +2,11 @@ let inherit (builtins) attrNames filter readDir; dirs = - let files = readDir ./.; - in filter (name: files."${name}" == "directory") (attrNames files); + let + files = readDir ./.; + in + filter (name: files."${name}" == "directory") (attrNames files); in { - imports = map (dir: ./${dir}) dirs; + imports = map (dir: ./${dir}) dirs; } diff --git a/home/gnome/extensions/freon/default.nix b/home/gnome/extensions/freon/default.nix index a7eafcc..564d047 100644 --- a/home/gnome/extensions/freon/default.nix +++ b/home/gnome/extensions/freon/default.nix @@ -1,4 +1,9 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: let cfg = config.gnome.extensions.freon; in diff --git a/home/gnome/extensions/paperwm/default.nix b/home/gnome/extensions/paperwm/default.nix index 916a859..78d5702 100644 --- a/home/gnome/extensions/paperwm/default.nix +++ b/home/gnome/extensions/paperwm/default.nix @@ -1,4 +1,9 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: let cfg = config.gnome.extensions; in @@ -10,18 +15,52 @@ in type = package; default = pkgs.gnomeExtensions.paperwm; }; - cycle-height-steps = lib.mkOption { type = listOf numbers.nonnegative; default = [ 0.33 0.5 0.67 1.0 ]; }; - cycle-width-steps = lib.mkOption { type = listOf numbers.nonnegative; default = [ 0.33 0.5 0.67 1.0 ]; }; - horizontal-margin = lib.mkOption { type = ints.unsigned; default = 5; }; - vertical-margin = lib.mkOption { type = ints.unsigned; default = 5; }; - window-gap = lib.mkOption { type = ints.unsigned; default = 5; }; + cycle-height-steps = lib.mkOption { + type = listOf numbers.nonnegative; + default = [ + 0.33 + 0.5 + 0.67 + 1.0 + ]; + }; + cycle-width-steps = lib.mkOption { + type = listOf numbers.nonnegative; + default = [ + 0.33 + 0.5 + 0.67 + 1.0 + ]; + }; + horizontal-margin = lib.mkOption { + type = ints.unsigned; + default = 5; + }; + vertical-margin = lib.mkOption { + type = ints.unsigned; + default = 5; + }; + window-gap = lib.mkOption { + type = ints.unsigned; + default = 5; + }; winprops = lib.mkOption { type = listOf (submodule { options = { - wm_class = lib.mkOption { type = str; default = ""; }; - title = lib.mkOption { type = str; default = ""; }; + wm_class = lib.mkOption { + type = str; + default = ""; + }; + title = lib.mkOption { + type = str; + default = ""; + }; scratch_layer = lib.mkEnableOption { }; - preferredWidth = lib.mkOption { type = nullOr str; default = null; }; + preferredWidth = lib.mkOption { + type = nullOr str; + default = null; + }; }; }); default = [ ]; @@ -36,13 +75,23 @@ in config = lib.mkIf cfg.paperwm.enable { home.packages = [ cfg.paperwm.package ]; dconf.settings = { - "org/gnome/shell".enabled-extensions = - lib.mkIf cfg.paperwm.enable [ cfg.paperwm.package.extensionUuid ]; - "org/gnome/shell/extensions/paperwm" = with cfg.paperwm; lib.mkIf cfg.paperwm.enable { - inherit cycle-height-steps cycle-width-steps horizontal-margin vertical-margin window-gap; - winprops = map (props: builtins.toJSON props) winprops; - }; - "org/gnome/shell/extensions/paperwm/keybindings" = lib.mkIf cfg.paperwm.enable cfg.paperwm.keybindings; + "org/gnome/shell".enabled-extensions = lib.mkIf cfg.paperwm.enable [ + cfg.paperwm.package.extensionUuid + ]; + "org/gnome/shell/extensions/paperwm" = + with cfg.paperwm; + lib.mkIf cfg.paperwm.enable { + inherit + cycle-height-steps + cycle-width-steps + horizontal-margin + vertical-margin + window-gap + ; + winprops = map (props: builtins.toJSON props) winprops; + }; + "org/gnome/shell/extensions/paperwm/keybindings" = + lib.mkIf cfg.paperwm.enable cfg.paperwm.keybindings; }; }; } diff --git a/home/jokke/default.nix b/home/jokke/default.nix index 253e89d..70e5d16 100644 --- a/home/jokke/default.nix +++ b/home/jokke/default.nix @@ -40,17 +40,32 @@ ]; formatters = [ { - filetypes = [ "typescript" "typescriptreact" "svelte" ]; - globs = [ "*.ts" "*.tsx" "*.svelte" ]; + filetypes = [ + "typescript" + "typescriptreact" + "svelte" + ]; + globs = [ + "*.ts" + "*.tsx" + "*.svelte" + ]; exe = "npx"; - args = file: [ "prettier" "--stdin-filepath" file ]; + args = file: [ + "prettier" + "--stdin-filepath" + file + ]; stdin = true; } { filetypes = [ "prisma" ]; globs = [ "*.prisma" ]; exe = "${pkgs.nodePackages.prisma}/bin/prisma"; - args = file: [ "format" "--schema" ]; + args = file: [ + "format" + "--schema" + ]; stdin = false; } ]; @@ -67,13 +82,21 @@ { name = "prismals"; package = nodePackages."@prisma/language-server"; - rootPattern = [ "package.json" "deno.json" ]; + rootPattern = [ + "package.json" + "deno.json" + ]; } { name = "graphql"; package = nodePackages.graphql-language-service-cli; config = { - filetypes = [ "typescript" "typescriptreact" "graphql" "svelte" ]; + filetypes = [ + "typescript" + "typescriptreact" + "graphql" + "svelte" + ]; }; } ]; diff --git a/home/moco/default.nix b/home/moco/default.nix index 2e219de..6c9386f 100644 --- a/home/moco/default.nix +++ b/home/moco/default.nix @@ -38,7 +38,10 @@ in profilePicture = ../assets/profile-pictures/moco.png; calendar.showWeekNumbers = true; extensions.paperwm.winprops = [ - { wm_class = "gnome-pomodoro"; scratch_layer = true; } + { + wm_class = "gnome-pomodoro"; + scratch_layer = true; + } ]; }; @@ -77,16 +80,40 @@ in formatters = [ { filetypes = [ "ruby" ]; - globs = [ "*.rb" "Gemfile" "*.rake" ]; + globs = [ + "*.rb" + "Gemfile" + "*.rake" + ]; exe = "bundle"; - args = file: [ "exec" "rufo" "-x" "--filename" file ]; + args = file: [ + "exec" + "rufo" + "-x" + "--filename" + file + ]; stdin = true; } { - filetypes = [ "javascript" "typescript" "javascriptreact" "typescriptreact" ]; - globs = [ "*.js" "*.jsx" "*.ts" "*.tsx" ]; + filetypes = [ + "javascript" + "typescript" + "javascriptreact" + "typescriptreact" + ]; + globs = [ + "*.js" + "*.jsx" + "*.ts" + "*.tsx" + ]; exe = "npx"; - args = file: [ "prettier" "--stdin-filepath" file ]; + args = file: [ + "prettier" + "--stdin-filepath" + file + ]; stdin = true; } ]; @@ -109,14 +136,21 @@ in programs.ssh.matchBlocks = let - aliases = [ "moco" "mocoapp" "mocoapp.com" ]; - matcher = subdomains: + aliases = [ + "moco" + "mocoapp" + "mocoapp.com" + ]; + matcher = + subdomains: builtins.concatStringsSep " " ( - map - (alias: builtins.concatStringsSep " " ( + map ( + alias: + builtins.concatStringsSep " " ( map (subdomain: "*.${subdomain}.${alias} ${subdomain}.${alias}") subdomains - )) - aliases); + ) + ) aliases + ); in { "console.*.moco" = { @@ -126,69 +160,97 @@ in }; }; - "${matcher ["reto" "reto.intern"]}" = { - hostname = "reto.intern.mocoapp.com"; - user = "jokke"; - }; + "${matcher [ + "reto" + "reto.intern" + ]}" = + { + hostname = "reto.intern.mocoapp.com"; + user = "jokke"; + }; - "${matcher ["web"]}" = { + "${matcher [ "web" ]}" = { hostname = "mocoapp.com"; }; - "${matcher ["prod-inc"]}" = { + "${matcher [ "prod-inc" ]}" = { hostname = "prod-inc.mocoapp.com"; }; - "${matcher ["prod"]}" = { + "${matcher [ "prod" ]}" = { hostname = "web02.mocoapp"; }; - "${matcher ["pfg" "primeforcegroup"]}" = { - hostname = "primeforcegroup.mocoapp.com"; - }; - "${matcher ["crafft"]}" = { + "${matcher [ + "pfg" + "primeforcegroup" + ]}" = + { + hostname = "primeforcegroup.mocoapp.com"; + }; + "${matcher [ "crafft" ]}" = { hostname = "crafft.mocoapp.com"; }; - "${matcher ["bd" "businessdecision"]}" = { - hostname = "businessdecision.mocoapp.com"; - }; - "${matcher ["festland"]}" = { + "${matcher [ + "bd" + "businessdecision" + ]}" = + { + hostname = "businessdecision.mocoapp.com"; + }; + "${matcher [ "festland" ]}" = { hostname = "festland.mocoapp.com"; }; - "${matcher ["oi" "one-inside"]}" = { - hostname = "one-inside.mocoapp.com"; - }; - "${matcher ["se" "scope-engineering"]}" = { - hostname = "scope-engineering.mocoapp.com"; - }; - "${matcher ["cpc" "cpc-ag"]}" = { - hostname = "cpc-ag.mocoapp.com"; - }; - "${matcher ["weareact3"]}" = { + "${matcher [ + "oi" + "one-inside" + ]}" = + { + hostname = "one-inside.mocoapp.com"; + }; + "${matcher [ + "se" + "scope-engineering" + ]}" = + { + hostname = "scope-engineering.mocoapp.com"; + }; + "${matcher [ + "cpc" + "cpc-ag" + ]}" = + { + hostname = "cpc-ag.mocoapp.com"; + }; + "${matcher [ "weareact3" ]}" = { hostname = "weareact3.mocoapp.com"; }; - "${matcher ["avenit"]}" = { + "${matcher [ "avenit" ]}" = { hostname = "avenit.mocoapp.com"; }; - "${matcher ["staging"]}" = { + "${matcher [ "staging" ]}" = { hostname = "staging.mocoapp.com"; }; - "${matcher ["staging-v2"]}" = { + "${matcher [ "staging-v2" ]}" = { hostname = "staging-v2.mocoapp.com"; }; - "${matcher ["staging-v3"]}" = { + "${matcher [ "staging-v3" ]}" = { hostname = "staging-v3.mocoapp.com"; }; - "${matcher ["staging-v4"]}" = { + "${matcher [ "staging-v4" ]}" = { hostname = "staging-v4.mocoapp.com"; }; - "${matcher ["staging-v5"]}" = { + "${matcher [ "staging-v5" ]}" = { hostname = "staging-v5.mocoapp.com"; }; - "${matcher ["staging-v6"]}" = { + "${matcher [ "staging-v6" ]}" = { hostname = "staging-v6.mocoapp.com"; }; - "${matcher ["prod-db" "production-db"]}" = { - hostname = "production-db.mocoapp"; - }; - "${matcher ["pdf-renderer"]}" = { + "${matcher [ + "prod-db" + "production-db" + ]}" = + { + hostname = "production-db.mocoapp"; + }; + "${matcher [ "pdf-renderer" ]}" = { hostname = "mocoapp-pdf-renderer01.mocoapp.com"; }; "*.moco *.mocoapp *.mocoapp.com" = { diff --git a/home/modules/neovim/default.nix b/home/modules/neovim/default.nix index c103166..d0b3d28 100644 --- a/home/modules/neovim/default.nix +++ b/home/modules/neovim/default.nix @@ -1,14 +1,24 @@ -{ config, pkgs, lib, ... }: +{ + config, + pkgs, + lib, + ... +}: let cfg = config.programs.neovim; toLua = lib.generators.toLua { }; - buildPluginConfig = p: + buildPluginConfig = + p: let pluginConfig = if builtins.hasAttr "plugin" p then p else { plugin = p; }; name = pluginConfig.plugin.name; config = if (builtins.isNull pluginConfig.config or null) then "" else pluginConfig.config; - mappings = if (builtins.isNull pluginConfig.mappings or null) then "" else generateMappings pluginConfig.mappings; + mappings = + if (builtins.isNull pluginConfig.mappings or null) then + "" + else + generateMappings pluginConfig.mappings; mergedConfig = config + mappings; in [ @@ -17,9 +27,10 @@ let config = lib.modules.mkIf (mergedConfig != "") '' Plugins[${toLua name}] = {} Plugins[${toLua name}].setup = function() - ${lib.strings.concatMapStrings - (line: if line == "" then "" else " ${line}\n") - (lib.strings.splitString "\n" mergedConfig) + ${ + lib.strings.concatMapStrings (line: if line == "" then "" else " ${line}\n") ( + lib.strings.splitString "\n" mergedConfig + ) } end @@ -28,9 +39,8 @@ let ''; type = "lua"; } - ] ++ ( - lib.lists.concatMap buildPluginConfig pluginConfig.dependencies or [ ] - ); + ] + ++ (lib.lists.concatMap buildPluginConfig pluginConfig.dependencies or [ ]); lspPluginConfig = with pkgs.vimPlugins; { plugin = nvim-lspconfig; @@ -41,76 +51,100 @@ let luasnip ]; - config = (builtins.readFile ./lsp-config.lua) + '' - local capabilities = vim.lsp.protocol.make_client_capabilities() - capabilities.workspace.didChangeWatchedFiles.dynamicRegistration = true - local lspconfig = require('lspconfig') - local util = require('lspconfig.util') + config = + (builtins.readFile ./lsp-config.lua) + + '' + local capabilities = vim.lsp.protocol.make_client_capabilities() + capabilities.workspace.didChangeWatchedFiles.dynamicRegistration = true + local lspconfig = require('lspconfig') + local util = require('lspconfig.util') - local on_attach = function (client, bufnr) - local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end - local map = function (lhs, rhs) - print('set mapping ' .. lhs) - end - - -- Enable completion triggered by - buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') - - -- Mappings. - -- See `:help vim.lsp.*` for documentation on any of the below functions - - ${lib.strings.concatLines (lib.attrsets.mapAttrsToList (name: value: '' - local buf_${name} = vim.lsp.buf[${toLua name}] - if buf_${name} then - vim.keymap.set('n', ${toLua value}, buf_${name}, { buffer = bufnr }) + local on_attach = function (client, bufnr) + local function buf_set_option(...) vim.api.nvim_buf_set_option(bufnr, ...) end + local map = function (lhs, rhs) + print('set mapping ' .. lhs) end - '' - ) cfg.lsp.mappings.buf)} - ${lib.strings.concatLines (lib.attrsets.mapAttrsToList (name: value: '' - local diagnostic_${name} = vim.lsp.buf[${toLua name}] - if diagnostic_${name} then - vim.keymap.set('n', ${toLua value}, diagnostic_${name}, { buffer = bufnr }) - end - '') cfg.lsp.mappings.diagnostic)} - end - vim.env.PATH = ${toLua (lib.makeBinPath (map (s: s.package) (builtins.filter (s: builtins.hasAttr "package" s) cfg.lsp.servers)) + ":")} .. vim.env.PATH - local servers = ${toLua (map ( - { name, config ? {}, rootPattern ? null, ... }: { - inherit name; - config = config // (if (builtins.isNull rootPattern) then {} else { inherit rootPattern; }); - } - ) cfg.lsp.servers)} + -- Enable completion triggered by + buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc') - for _, server in ipairs(servers) do - local server_config = server.config - server_config.on_attach = on_attach - server_config.capabilities = capabilities - server_config.flags = { - debounce_text_changes = 150 - } + -- Mappings. + -- See `:help vim.lsp.*` for documentation on any of the below functions - if server_config.rootPattern then - server_config.root_dir = util.root_pattern( - unpack(server_config.rootPattern) + ${lib.strings.concatLines ( + lib.attrsets.mapAttrsToList (name: value: '' + local buf_${name} = vim.lsp.buf[${toLua name}] + if buf_${name} then + vim.keymap.set('n', ${toLua value}, buf_${name}, { buffer = bufnr }) + end + '') cfg.lsp.mappings.buf + )} + ${lib.strings.concatLines ( + lib.attrsets.mapAttrsToList (name: value: '' + local diagnostic_${name} = vim.lsp.buf[${toLua name}] + if diagnostic_${name} then + vim.keymap.set('n', ${toLua value}, diagnostic_${name}, { buffer = bufnr }) + end + '') cfg.lsp.mappings.diagnostic + )} + end + + vim.env.PATH = ${ + toLua ( + lib.makeBinPath ( + map (s: s.package) (builtins.filter (s: builtins.hasAttr "package" s) cfg.lsp.servers) ) - end + + ":" + ) + } .. vim.env.PATH + local servers = ${ + toLua ( + map ( + { + name, + config ? { }, + rootPattern ? null, + ... + }: + { + inherit name; + config = config // (if (builtins.isNull rootPattern) then { } else { inherit rootPattern; }); + } + ) cfg.lsp.servers + ) + } - lspconfig[server.name].setup(server_config) - end - ''; + for _, server in ipairs(servers) do + local server_config = server.config + server_config.on_attach = on_attach + server_config.capabilities = capabilities + server_config.flags = { + debounce_text_changes = 150 + } + + if server_config.rootPattern then + server_config.root_dir = util.root_pattern( + unpack(server_config.rootPattern) + ) + end + + lspconfig[server.name].setup(server_config) + end + ''; }; treesitterPluginConfig = with pkgs.vimPlugins; { plugin = nvim-treesitter.withPlugins cfg.withTreesitterPlugins; config = '' - require('nvim-treesitter.configs').setup(${toLua { - highlight = { - enable = true; - additional_vim_regex_highlighting = false; - }; - }}); + require('nvim-treesitter.configs').setup(${ + toLua { + highlight = { + enable = true; + additional_vim_regex_highlighting = false; + }; + } + }); ''; }; @@ -122,17 +156,24 @@ let formatter.setup({ filetype = { - ${lib.strings.concatMapStringsSep ",\n " ({ exe, args, stdin, no_append, filetypes, ... }: + ${lib.strings.concatMapStringsSep ",\n " ( + { + exe, + args, + stdin, + no_append, + filetypes, + ... + }: lib.strings.concatMapStringsSep ",\n " (filetype: '' [${toLua filetype}] = { function () return { exe = ${toLua exe}, args = { - ${lib.strings.concatMapStringsSep ",\n " (arg: - if arg == "<>" - then "util.escape_path(util.get_current_buffer_file_path())" - else toLua arg + ${lib.strings.concatMapStringsSep ",\n " ( + arg: + if arg == "<>" then "util.escape_path(util.get_current_buffer_file_path())" else toLua arg ) (args "<>")} }, stdin = ${toLua stdin}, @@ -153,137 +194,218 @@ let ''; }; - customTypes = let inherit (lib) mkOption mkEnableOption types; in { - mapping = types.submodule { - options = { - rhs = mkOption { type = types.str; }; - lua = mkEnableOption { }; - options = mkOption { - type = types.nullOr ( - types.submodule { - options = { - buffer = mkOption { type = types.nullOr (types.either types.int types.bool); default = null; }; - nowait = mkOption { type = types.nullOr types.bool; default = null; }; - silent = mkOption { type = types.nullOr types.bool; default = null; }; - expr = mkOption { type = types.nullOr types.bool; default = null; }; - script = mkOption { type = types.nullOr types.bool; default = null; }; - unique = mkOption { type = types.nullOr types.bool; default = null; }; - replace_keycodes = mkOption { type = types.nullOr types.bool; default = null; }; - }; - } - ); - default = { }; + customTypes = + let + inherit (lib) mkOption mkEnableOption types; + in + { + mapping = types.submodule { + options = { + rhs = mkOption { type = types.str; }; + lua = mkEnableOption { }; + options = mkOption { + type = types.nullOr ( + types.submodule { + options = { + buffer = mkOption { + type = types.nullOr (types.either types.int types.bool); + default = null; + }; + nowait = mkOption { + type = types.nullOr types.bool; + default = null; + }; + silent = mkOption { + type = types.nullOr types.bool; + default = null; + }; + expr = mkOption { + type = types.nullOr types.bool; + default = null; + }; + script = mkOption { + type = types.nullOr types.bool; + default = null; + }; + unique = mkOption { + type = types.nullOr types.bool; + default = null; + }; + replace_keycodes = mkOption { + type = types.nullOr types.bool; + default = null; + }; + }; + } + ); + default = { }; + }; + }; + }; + + modeMappings = types.attrsOf (types.either types.str customTypes.mapping); + + mappings = types.submodule { + options = { + normal = mkOption { + type = customTypes.modeMappings; + default = { }; + }; + insert = mkOption { + type = customTypes.modeMappings; + default = { }; + }; + visual = mkOption { + type = customTypes.modeMappings; + default = { }; + }; + command = mkOption { + type = customTypes.modeMappings; + default = { }; + }; + select = mkOption { + type = customTypes.modeMappings; + default = { }; + }; + }; + }; + + plugin = types.either types.package ( + types.submodule { + options = { + plugin = mkOption { type = types.package; }; + dependencies = mkOption { + type = types.listOf customTypes.plugin; + default = [ ]; + }; + mappings = mkOption { + type = customTypes.mappings; + default = { }; + }; + config = mkOption { + type = types.nullOr types.str; + default = null; + }; + }; + } + ); + + autoCommand = types.submodule { + options = { + event = mkOption { type = types.either types.str (types.listOf types.str); }; + pattern = mkOption { type = types.either types.str (types.listOf types.str); }; + command = mkOption { type = types.str; }; + }; + }; + + lspServer = types.submodule { + options = { + name = mkOption { type = types.str; }; + config = mkOption { + type = types.attrs; + default = { }; + }; + package = mkOption { + type = types.nullOr types.package; + default = null; + }; + rootPattern = mkOption { + type = types.nullOr (types.listOf types.str); + default = null; + }; + }; + }; + + formatter = types.submodule { + options = { + filetypes = mkOption { type = types.listOf types.str; }; + globs = mkOption { type = types.listOf types.str; }; + exe = mkOption { type = types.either types.path types.str; }; + args = mkOption { + type = types.functionTo (types.listOf types.str); + default = _: [ ]; + }; + stdin = mkEnableOption { }; + no_append = mkEnableOption { }; }; }; }; - modeMappings = types.attrsOf (types.either types.str customTypes.mapping); - - mappings = types.submodule { - options = { - normal = mkOption { type = customTypes.modeMappings; default = { }; }; - insert = mkOption { type = customTypes.modeMappings; default = { }; }; - visual = mkOption { type = customTypes.modeMappings; default = { }; }; - command = mkOption { type = customTypes.modeMappings; default = { }; }; - select = mkOption { type = customTypes.modeMappings; default = { }; }; - }; - }; - - plugin = types.either types.package (types.submodule { - options = { - plugin = mkOption { type = types.package; }; - dependencies = mkOption { - type = types.listOf customTypes.plugin; - default = [ ]; - }; - mappings = mkOption { type = customTypes.mappings; default = { }; }; - config = mkOption { type = types.nullOr types.str; default = null; }; - }; - }); - - autoCommand = types.submodule { - options = { - event = mkOption { type = types.either types.str (types.listOf types.str); }; - pattern = mkOption { type = types.either types.str (types.listOf types.str); }; - command = mkOption { type = types.str; }; - }; - }; - - lspServer = types.submodule { - options = { - name = mkOption { type = types.str; }; - config = mkOption { type = types.attrs; default = { }; }; - package = mkOption { type = types.nullOr types.package; default = null; }; - rootPattern = mkOption { type = types.nullOr (types.listOf types.str); default = null; }; - }; - }; - - formatter = types.submodule { - options = { - filetypes = mkOption { type = types.listOf types.str; }; - globs = mkOption { type = types.listOf types.str; }; - exe = mkOption { type = types.either types.path types.str; }; - args = mkOption { type = types.functionTo (types.listOf types.str); default = _: [ ]; }; - stdin = mkEnableOption { }; - no_append = mkEnableOption { }; - }; - }; - }; - - generateMappings = mappings: lib.strings.concatLines ( - lib.attrsets.mapAttrsToList - (mode: modeMappings: + generateMappings = + mappings: + lib.strings.concatLines ( + lib.attrsets.mapAttrsToList ( + mode: modeMappings: lib.strings.concatLines ( - lib.attrsets.mapAttrsToList - (name: value: + lib.attrsets.mapAttrsToList ( + name: value: - let - mapping = { lhs = name; lua = false; options = { }; } // (if builtins.isString value then { rhs = value; } else value); - args = [ - (toLua (builtins.substring 0 1 mode)) - (toLua mapping.lhs) - (if mapping.lua then mapping.rhs else toLua mapping.rhs) - ( - toLua ( - builtins.listToAttrs ( - builtins.filter ({ value, ... }: !isNull (value)) (lib.attrsets.attrsToList mapping.options) - ) - ) + let + mapping = { + lhs = name; + lua = false; + options = { }; + } // (if builtins.isString value then { rhs = value; } else value); + args = [ + (toLua (builtins.substring 0 1 mode)) + (toLua mapping.lhs) + (if mapping.lua then mapping.rhs else toLua mapping.rhs) + (toLua ( + builtins.listToAttrs ( + builtins.filter ({ value, ... }: !isNull (value)) (lib.attrsets.attrsToList mapping.options) ) - ]; - in - "vim.keymap.set(${lib.strings.concatStringsSep ", " args})" - ) - modeMappings + )) + ]; + in + "vim.keymap.set(${lib.strings.concatStringsSep ", " args})" + ) modeMappings ) - ) - mappings - ); + ) mappings + ); - generateAutoCommand = { event, pattern, command, group ? null }: '' - vim.api.nvim_create_autocmd(${toLua event}, { - pattern = ${toLua pattern}, - command = ${toLua command}, - group = ${if isNull group then toLua group else '' - vim.api.nvim_create_augroup(${toLua group}, { clear = true }) - ''}, - }) - ''; + generateAutoCommand = + { + event, + pattern, + command, + group ? null, + }: + '' + vim.api.nvim_create_autocmd(${toLua event}, { + pattern = ${toLua pattern}, + command = ${toLua command}, + group = ${ + if isNull group then + toLua group + else + '' + vim.api.nvim_create_augroup(${toLua group}, { clear = true }) + '' + }, + }) + ''; - generateAutoCommands = autoCommands: lib.strings.concatLines ( - map generateAutoCommand autoCommands - ); + generateAutoCommands = autoCommands: lib.strings.concatLines (map generateAutoCommand autoCommands); - generateSignDefinitions = signs: lib.strings.concatLines ( - lib.attrsets.mapAttrsToList - (name: value: + generateSignDefinitions = + signs: + lib.strings.concatLines ( + lib.attrsets.mapAttrsToList ( + name: value: let - hl = "DiagnosticSign${lib.strings.toUpper (builtins.substring 0 1 name)}${builtins.substring 1 (-1) name}"; + hl = "DiagnosticSign${ + lib.strings.toUpper (builtins.substring 0 1 name) + }${builtins.substring 1 (-1) name}"; in - "vim.fn.sign_define(${toLua hl}, ${toLua { text = value; texthl = hl; numhl = ""; }})" - ) - signs - ); + "vim.fn.sign_define(${toLua hl}, ${ + toLua { + text = value; + texthl = hl; + numhl = ""; + } + })" + ) signs + ); in { options.programs.neovim = @@ -291,12 +413,18 @@ in inherit (lib) mkOption types; in { - mappings = mkOption { type = customTypes.mappings; default = { }; }; + mappings = mkOption { + type = customTypes.mappings; + default = { }; + }; plug = mkOption { type = types.listOf customTypes.plugin; default = [ ]; }; - leader = mkOption { type = types.str; default = "\\"; }; + leader = mkOption { + type = types.str; + default = "\\"; + }; options = mkOption { type = types.attrs; default = { }; @@ -314,10 +442,22 @@ in default = { }; }; signs = { - error = mkOption { type = types.str; default = ""; }; - warning = mkOption { type = types.str; default = ""; }; - info = mkOption { type = types.str; default = ""; }; - hint = mkOption { type = types.str; default = ""; }; + error = mkOption { + type = types.str; + default = ""; + }; + warning = mkOption { + type = types.str; + default = ""; + }; + info = mkOption { + type = types.str; + default = ""; + }; + hint = mkOption { + type = types.str; + default = ""; + }; }; lsp = { servers = mkOption { @@ -325,8 +465,14 @@ in default = [ ]; }; mappings = { - buf = mkOption { type = types.attrsOf types.str; default = { }; }; - diagnostic = mkOption { type = types.attrsOf types.str; default = { }; }; + buf = mkOption { + type = types.attrsOf types.str; + default = { }; + }; + diagnostic = mkOption { + type = types.attrsOf types.str; + default = { }; + }; }; }; withTreesitterPlugins = mkOption { @@ -345,22 +491,30 @@ in "local Plugins = {}" (generateMappings cfg.mappings) (generateAutoCommands cfg.autoCommands) - (lib.strings.concatLines (lib.attrsets.mapAttrsToList (name: value: "vim.env.${name} = ${toLua value}") cfg.env)) - (lib.strings.concatLines (lib.attrsets.mapAttrsToList (name: value: "vim.opt.${name} = ${toLua value}") cfg.options)) + (lib.strings.concatLines ( + lib.attrsets.mapAttrsToList (name: value: "vim.env.${name} = ${toLua value}") cfg.env + )) + (lib.strings.concatLines ( + lib.attrsets.mapAttrsToList (name: value: "vim.opt.${name} = ${toLua value}") cfg.options + )) (generateSignDefinitions cfg.signs) "vim.g.mapleader = ${toLua cfg.leader}" '' - local undodir = ${toLua ( - if builtins.hasAttr "undodir" cfg.options - then cfg.options.undodir - else "${config.xdg.cacheHome}/nvim/undo" - )} + local undodir = ${ + toLua ( + if builtins.hasAttr "undodir" cfg.options then + cfg.options.undodir + else + "${config.xdg.cacheHome}/nvim/undo" + ) + } vim.opt.undodir = undodir vim.fn.mkdir(undodir, 'p') '' ]; plugins = lib.lists.concatMap buildPluginConfig ( - cfg.plug ++ [ + cfg.plug + ++ [ lspPluginConfig treesitterPluginConfig formatterPluginConfig @@ -371,12 +525,12 @@ in }; xdg.configFile = ( - lib.attrsets.mapAttrs' - (name: value: { - name = "nvim/${name}"; - value = { source = value; }; - }) - cfg.snippets + lib.attrsets.mapAttrs' (name: value: { + name = "nvim/${name}"; + value = { + source = value; + }; + }) cfg.snippets ); home.shellAliases = diff --git a/hosts/apu/configuration.nix b/hosts/apu/configuration.nix index 71bbcc5..4978492 100644 --- a/hosts/apu/configuration.nix +++ b/hosts/apu/configuration.nix @@ -2,7 +2,13 @@ # your system. Help is availanodev"; # https://search.nixos.org/options and in the NixOS manual (`nixos-help`). -{ ssh, pkgs, config, lib, ... }: +{ + ssh, + pkgs, + config, + lib, + ... +}: { boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/sda"; @@ -12,7 +18,10 @@ nix = { settings = { - experimental-features = [ "nix-command" "flakes" ]; + experimental-features = [ + "nix-command" + "flakes" + ]; auto-optimise-store = true; }; @@ -63,11 +72,28 @@ modules.firewall = { enable = true; interfaces = { - koti = [ "dhcp" "dns" "ssh" "web" ]; - gast = [ "dhcp" "dns" ]; - iot = [ "dhcp" "dns" ]; - cfg = [ "dhcp" "dns" ]; - "tailscale*" = [ "ssh" "web" ]; + koti = [ + "dhcp" + "dns" + "ssh" + "web" + ]; + gast = [ + "dhcp" + "dns" + ]; + iot = [ + "dhcp" + "dns" + ]; + cfg = [ + "dhcp" + "dns" + ]; + "tailscale*" = [ + "ssh" + "web" + ]; }; allInterfaces = [ ]; }; @@ -146,7 +172,9 @@ onState = [ "routable" ]; script = '' #!${pkgs.runtimeShell} - ${pkgs.ethtool}/bin/ethtool -K ${config.systemd.network.links."10-extern0".linkConfig.Name} rx-udp-gro-forwarding on rx-gro-list off + ${pkgs.ethtool}/bin/ethtool -K ${ + config.systemd.network.links."10-extern0".linkConfig.Name + } rx-udp-gro-forwarding on rx-gro-list off ''; }; }; @@ -187,13 +215,14 @@ enable = true; settings = { server = { - interface = (lib.map - (name: config.systemd.network.networks."30-${name}".dhcpServerConfig.DNS) - (lib.attrNames config.modules.vlans.networks) - ) ++ [ - "127.0.0.1" - "::1" - ]; + interface = + (lib.map (name: config.systemd.network.networks."30-${name}".dhcpServerConfig.DNS) ( + lib.attrNames config.modules.vlans.networks + )) + ++ [ + "127.0.0.1" + "::1" + ]; access-control = [ "10.0.0.0/8 allow" "127.0.0.0/8 allow" @@ -224,10 +253,11 @@ "xiaomi_aqara" "shelly" ]; - extraPackages = python3Packages: with python3Packages; [ - gtts - numpy - ]; + extraPackages = + python3Packages: with python3Packages; [ + gtts + numpy + ]; config = { homeassistant = { name = "Koti"; diff --git a/hosts/apu/hardware-configuration.nix b/hosts/apu/hardware-configuration.nix index e5daa45..78cb8d9 100644 --- a/hosts/apu/hardware-configuration.nix +++ b/hosts/apu/hardware-configuration.nix @@ -1,41 +1,57 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: +{ + config, + lib, + pkgs, + modulesPath, + ... +}: { - imports = - [ (modulesPath + "/installer/scan/not-detected.nix") - ]; + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; - boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "ehci_pci" "usb_storage" "sd_mod" "sdhci_pci" ]; + boot.initrd.availableKernelModules = [ + "xhci_pci" + "ahci" + "ehci_pci" + "usb_storage" + "sd_mod" + "sdhci_pci" + ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-amd" ]; boot.extraModulePackages = [ ]; - fileSystems."/" = - { device = "/dev/disk/by-uuid/f221c6a7-e05e-40dc-bc85-7970d7c8f22b"; - fsType = "btrfs"; - options = [ "subvol=@" ]; - }; + fileSystems."/" = { + device = "/dev/disk/by-uuid/f221c6a7-e05e-40dc-bc85-7970d7c8f22b"; + fsType = "btrfs"; + options = [ "subvol=@" ]; + }; - fileSystems."/var/log" = - { device = "/dev/disk/by-uuid/f221c6a7-e05e-40dc-bc85-7970d7c8f22b"; - fsType = "btrfs"; - options = [ "subvol=@var_log" ]; - }; + fileSystems."/var/log" = { + device = "/dev/disk/by-uuid/f221c6a7-e05e-40dc-bc85-7970d7c8f22b"; + fsType = "btrfs"; + options = [ "subvol=@var_log" ]; + }; - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/14D2-F8F4"; - fsType = "vfat"; - options = [ "fmask=0022" "dmask=0022" ]; - }; + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/14D2-F8F4"; + fsType = "vfat"; + options = [ + "fmask=0022" + "dmask=0022" + ]; + }; - fileSystems."/swap" = - { device = "/dev/disk/by-uuid/f221c6a7-e05e-40dc-bc85-7970d7c8f22b"; - fsType = "btrfs"; - options = [ "subvol=@swap" ]; - }; + fileSystems."/swap" = { + device = "/dev/disk/by-uuid/f221c6a7-e05e-40dc-bc85-7970d7c8f22b"; + fsType = "btrfs"; + options = [ "subvol=@swap" ]; + }; swapDevices = [ ]; diff --git a/hosts/freun-dev/configuration.nix b/hosts/freun-dev/configuration.nix index a57329a..df62907 100644 --- a/hosts/freun-dev/configuration.nix +++ b/hosts/freun-dev/configuration.nix @@ -2,7 +2,12 @@ # your system. Help is available in the configuration.nix(5) man page # and in the NixOS manual (accessible by running `nixos-help`). -{ config, pkgs, ssh, ... }: +{ + config, + pkgs, + ssh, + ... +}: let ipv4Address = "65.21.145.150"; ipv6Address = "2a01:4f9:c011:9ac1::1"; @@ -10,7 +15,10 @@ in { nix = { settings = { - experimental-features = [ "nix-command" "flakes" ]; + experimental-features = [ + "nix-command" + "flakes" + ]; auto-optimise-store = true; }; gc = { @@ -95,7 +103,6 @@ in # useXkbConfig = true; # use xkbOptions in tty. # }; - # Configure keymap in X11 services.xserver.xkb.layout = "us"; services.xserver.xkb.options = "eurosign:e,caps:escape"; diff --git a/hosts/freun-dev/hardware-configuration.nix b/hosts/freun-dev/hardware-configuration.nix index efbc139..13c8c3e 100644 --- a/hosts/freun-dev/hardware-configuration.nix +++ b/hosts/freun-dev/hardware-configuration.nix @@ -1,34 +1,43 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: +{ + config, + lib, + pkgs, + modulesPath, + ... +}: { - imports = - [ - (modulesPath + "/profiles/qemu-guest.nix") - ]; + imports = [ + (modulesPath + "/profiles/qemu-guest.nix") + ]; - boot.initrd.availableKernelModules = [ "xhci_pci" "virtio_scsi" "sr_mod" ]; + boot.initrd.availableKernelModules = [ + "xhci_pci" + "virtio_scsi" + "sr_mod" + ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ ]; boot.extraModulePackages = [ ]; - fileSystems."/" = - { - device = "/dev/disk/by-uuid/f594ffbc-4553-42e4-8206-4d762c94b4c3"; - fsType = "ext4"; - }; + fileSystems."/" = { + device = "/dev/disk/by-uuid/f594ffbc-4553-42e4-8206-4d762c94b4c3"; + fsType = "ext4"; + }; - fileSystems."/boot" = - { - device = "/dev/disk/by-uuid/46F1-18E3"; - fsType = "vfat"; - options = [ "fmask=0077" "dmask=0077" ]; - }; + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/46F1-18E3"; + fsType = "vfat"; + options = [ + "fmask=0077" + "dmask=0077" + ]; + }; - swapDevices = - [{ device = "/dev/disk/by-uuid/d9955575-d4e0-4a49-a3c5-41f54110d12b"; }]; + swapDevices = [ { device = "/dev/disk/by-uuid/d9955575-d4e0-4a49-a3c5-41f54110d12b"; } ]; # 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 diff --git a/hosts/freun-dev/secrets.nix b/hosts/freun-dev/secrets.nix index caf6192..611e305 100644 --- a/hosts/freun-dev/secrets.nix +++ b/hosts/freun-dev/secrets.nix @@ -1,34 +1,38 @@ { lib, config, ... }: { - age.secrets = lib.listToAttrs - ( - map (secret: { name = secret; value = { file = ../../secrets/${secret}.age; }; }) [ - "gotosocial" - "immich" - "readeck" - "storage-box-credentials" - "vaultwarden" - "donetick" - "dnote" - "octodns" - "mealie" - ] - ) // { - smtp-password = { - file = ../../secrets/smtp-password.age; - owner = - if (config.services.grafana.enable) then - config.systemd.services.grafana.serviceConfig.User - else - "root"; + age.secrets = + lib.listToAttrs ( + map + (secret: { + name = secret; + value = { + file = ../../secrets/${secret}.age; + }; + }) + [ + "gotosocial" + "immich" + "readeck" + "storage-box-credentials" + "vaultwarden" + "donetick" + "dnote" + "octodns" + "mealie" + ] + ) + // { + smtp-password = { + file = ../../secrets/smtp-password.age; + owner = + if (config.services.grafana.enable) then + config.systemd.services.grafana.serviceConfig.User + else + "root"; + }; + hastebin-tokens = { + file = ../../secrets/hastebin-tokens.age; + owner = if (config.services.hastebin.enable) then config.users.users.hastebin.name else "root"; + }; }; - hastebin-tokens = { - file = ../../secrets/hastebin-tokens.age; - owner = - if (config.services.hastebin.enable) then - config.users.users.hastebin.name - else - "root"; - }; - }; } diff --git a/hosts/freun-dev/services.nix b/hosts/freun-dev/services.nix index 158995d..be2dbb9 100644 --- a/hosts/freun-dev/services.nix +++ b/hosts/freun-dev/services.nix @@ -1,4 +1,9 @@ -{ pkgs, config, inputs, ... }: +{ + pkgs, + config, + inputs, + ... +}: let immichDataDir = "/mnt/storage/immich"; syncthingDataDir = "/mnt/storage/syncthing"; @@ -37,7 +42,7 @@ in enable = true; records."".MX = { ttl = 86400; - values = [{ exchange = "${smtp.host}."; }]; + values = [ { exchange = "${smtp.host}."; } ]; }; defaults.CNAME.ttl = 60; }; @@ -45,7 +50,8 @@ in hastebin = { enable = true; subdomain = "bin"; - renderers = with pkgs; + renderers = + with pkgs; let hl = rustPlatform.buildRustPackage { name = "syntax-renderer"; @@ -143,7 +149,11 @@ in smtp-port = smtp.port; smtp-username = smtp.username; smtp-from = smtp.from; - instance-languages = [ "de" "fi" "en" ]; + instance-languages = [ + "de" + "fi" + "en" + ]; }; }; diff --git a/hosts/radish/configuration.nix b/hosts/radish/configuration.nix index c7f19b0..f0a4212 100644 --- a/hosts/radish/configuration.nix +++ b/hosts/radish/configuration.nix @@ -2,7 +2,10 @@ { nix = { settings = { - experimental-features = [ "nix-command" "flakes" ]; + experimental-features = [ + "nix-command" + "flakes" + ]; auto-optimise-store = true; }; diff --git a/hosts/radish/default.nix b/hosts/radish/default.nix index 414024f..9012fab 100644 --- a/hosts/radish/default.nix +++ b/hosts/radish/default.nix @@ -1,6 +1,11 @@ { inputs, ... }: let - inherit (inputs) lanzaboote nixos-hardware auto-cpufreq home-manager; + inherit (inputs) + lanzaboote + nixos-hardware + auto-cpufreq + home-manager + ; in { imports = [ diff --git a/hosts/radish/hardware-configuration.nix b/hosts/radish/hardware-configuration.nix index 296710f..9a88908 100644 --- a/hosts/radish/hardware-configuration.nix +++ b/hosts/radish/hardware-configuration.nix @@ -1,56 +1,70 @@ # Do not modify this file! It was generated by ‘nixos-generate-config’ # and may be overwritten by future invocations. Please make changes # to /etc/nixos/configuration.nix instead. -{ config, lib, pkgs, modulesPath, ... }: +{ + config, + lib, + pkgs, + modulesPath, + ... +}: { - imports = - [ (modulesPath + "/installer/scan/not-detected.nix") - ]; + imports = [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; - boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "thunderbolt" "usb_storage" "sd_mod" ]; + boot.initrd.availableKernelModules = [ + "nvme" + "xhci_pci" + "thunderbolt" + "usb_storage" + "sd_mod" + ]; boot.initrd.kernelModules = [ ]; boot.kernelModules = [ "kvm-amd" ]; boot.extraModulePackages = [ ]; - fileSystems."/" = - { device = "/dev/disk/by-uuid/a331b669-f5c5-42f7-be58-434873c1b689"; - fsType = "btrfs"; - options = [ "subvol=@" ]; - }; + fileSystems."/" = { + device = "/dev/disk/by-uuid/a331b669-f5c5-42f7-be58-434873c1b689"; + fsType = "btrfs"; + options = [ "subvol=@" ]; + }; boot.initrd.luks.devices."cryptroot" = { device = "/dev/disk/by-uuid/43895585-8899-4e94-a413-889127c214f8"; allowDiscards = true; }; - fileSystems."/var/log" = - { device = "/dev/disk/by-uuid/a331b669-f5c5-42f7-be58-434873c1b689"; - fsType = "btrfs"; - options = [ "subvol=@var_log" ]; - }; + fileSystems."/var/log" = { + device = "/dev/disk/by-uuid/a331b669-f5c5-42f7-be58-434873c1b689"; + fsType = "btrfs"; + options = [ "subvol=@var_log" ]; + }; - fileSystems."/home" = - { device = "/dev/disk/by-uuid/a331b669-f5c5-42f7-be58-434873c1b689"; - fsType = "btrfs"; - options = [ "subvol=@home" ]; - }; + fileSystems."/home" = { + device = "/dev/disk/by-uuid/a331b669-f5c5-42f7-be58-434873c1b689"; + fsType = "btrfs"; + options = [ "subvol=@home" ]; + }; - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/01E6-6258"; - fsType = "vfat"; - }; + fileSystems."/boot" = { + device = "/dev/disk/by-uuid/01E6-6258"; + fsType = "vfat"; + }; - fileSystems."/swap" = - { device = "/dev/disk/by-uuid/a331b669-f5c5-42f7-be58-434873c1b689"; - fsType = "btrfs"; - options = [ "subvol=@swap" ]; - }; + fileSystems."/swap" = { + device = "/dev/disk/by-uuid/a331b669-f5c5-42f7-be58-434873c1b689"; + fsType = "btrfs"; + options = [ "subvol=@swap" ]; + }; - swapDevices = [ { - device = "/swap/swapfile"; - size = 64*1024; - } ]; + swapDevices = [ + { + device = "/swap/swapfile"; + size = 64 * 1024; + } + ]; # 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 diff --git a/hosts/radish/hardware.nix b/hosts/radish/hardware.nix index 7e82fe4..e738e1e 100644 --- a/hosts/radish/hardware.nix +++ b/hosts/radish/hardware.nix @@ -1,4 +1,10 @@ -{ pkgs, inputs, lib, config, ... }: +{ + pkgs, + inputs, + lib, + config, + ... +}: let pkgsUnstable = inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}; in diff --git a/hosts/radish/host.nix b/hosts/radish/host.nix index cf33ed9..0eb9bdc 100644 --- a/hosts/radish/host.nix +++ b/hosts/radish/host.nix @@ -3,7 +3,12 @@ networking.hostName = "radish"; time.timeZone = lib.mkForce null; # allow TZ to be set by desktop user i18n.defaultLocale = "de_DE.UTF-8"; - i18n.supportedLocales = map (locale: "${locale}.UTF-8/UTF-8") [ "C" "en_US" "de_DE" "fi_FI" ]; + i18n.supportedLocales = map (locale: "${locale}.UTF-8/UTF-8") [ + "C" + "en_US" + "de_DE" + "fi_FI" + ]; i18n.extraLocaleSettings.LANG = "en_US.UTF-8"; console = { font = "Lat2-Terminus16"; diff --git a/hosts/radish/secrets.nix b/hosts/radish/secrets.nix index 8523c9e..9548e4c 100644 --- a/hosts/radish/secrets.nix +++ b/hosts/radish/secrets.nix @@ -1,9 +1,15 @@ { lib, ... }: { - age.secrets = lib.listToAttrs - ( - map (secret: { name = secret; value = { file = ../../secrets/${secret}.age; }; }) [ + age.secrets = lib.listToAttrs ( + map + (secret: { + name = secret; + value = { + file = ../../secrets/${secret}.age; + }; + }) + [ "borgbackup-radish" ] - ); + ); } diff --git a/hosts/radish/users.nix b/hosts/radish/users.nix index 20102c4..9a9b3bc 100644 --- a/hosts/radish/users.nix +++ b/hosts/radish/users.nix @@ -11,7 +11,17 @@ isNormalUser = true; extraGroups = [ "wheel" ]; shell = pkgs.zsh; - subUidRanges = [{ startUid = 10000; count = 65536; }]; - subGidRanges = [{ startGid = 10000; count = 65536; }]; + subUidRanges = [ + { + startUid = 10000; + count = 65536; + } + ]; + subGidRanges = [ + { + startGid = 10000; + count = 65536; + } + ]; }; } diff --git a/modules/firewall.nix b/modules/firewall.nix index 74a1f08..e64e402 100644 --- a/modules/firewall.nix +++ b/modules/firewall.nix @@ -1,19 +1,48 @@ { lib, config, ... }: let services = { - ssh = { tcp = [ 22 ]; }; - dhcp = { udp = [ 67 68 ]; }; - dns = { udp = [ 53 853 ]; tcp = [ 53 853 ]; }; - web = { tcp = [ 80 443 ]; }; + ssh = { + tcp = [ 22 ]; + }; + dhcp = { + udp = [ + 67 + 68 + ]; + }; + dns = { + udp = [ + 53 + 853 + ]; + tcp = [ + 53 + 853 + ]; + }; + web = { + tcp = [ + 80 + 443 + ]; + }; }; - rulesForServices = enabledServices: + rulesForServices = + enabledServices: lib.foldr - (service: { allowedUDPPorts, allowedTCPPorts }: { - allowedUDPPorts = allowedUDPPorts ++ services.${service}.udp or [ ]; - allowedTCPPorts = allowedTCPPorts ++ services.${service}.tcp or [ ]; - }) - { allowedUDPPorts = [ ]; allowedTCPPorts = [ ]; } + ( + service: + { allowedUDPPorts, allowedTCPPorts }: + { + allowedUDPPorts = allowedUDPPorts ++ services.${service}.udp or [ ]; + allowedTCPPorts = allowedTCPPorts ++ services.${service}.tcp or [ ]; + } + ) + { + allowedUDPPorts = [ ]; + allowedTCPPorts = [ ]; + } enabledServices; cfg = config.modules.firewall; diff --git a/modules/services/dnote.nix b/modules/services/dnote.nix index f0bece2..562a7eb 100644 --- a/modules/services/dnote.nix +++ b/modules/services/dnote.nix @@ -1,4 +1,10 @@ -{ lib, inputs, config, pkgs, ... }: +{ + lib, + inputs, + config, + pkgs, + ... +}: let cfg = config.services.dnote; fqdn = "${cfg.subdomain}.${config.networking.domain}"; @@ -40,10 +46,8 @@ let WebURL = "https://${fqdn}"; }; - serializeEnvVar = value: - if (lib.isBool value) - then if value then "true" else "false" - else toString value; + serializeEnvVar = + value: if (lib.isBool value) then if value then "true" else "false" else toString value; in { options.services.dnote = { @@ -81,7 +85,9 @@ in systemd.services.dnote = { enable = true; description = "Dnote server"; - environment = lib.mapAttrs (_: value: serializeEnvVar value) (cfg.environment // immutableEnvironment); + environment = lib.mapAttrs (_: value: serializeEnvVar value) ( + cfg.environment // immutableEnvironment + ); after = [ "postgresql.service" ]; requires = [ "postgresql.service" ]; serviceConfig = { @@ -113,10 +119,12 @@ in postgresql = { enable = lib.mkDefault true; ensureDatabases = [ cfg.environment.DBName ]; - ensureUsers = [{ - name = cfg.user; - ensureDBOwnership = true; - }]; + ensureUsers = [ + { + name = cfg.user; + ensureDBOwnership = true; + } + ]; }; webserver = { diff --git a/modules/services/donetick.nix b/modules/services/donetick.nix index 6ca981f..08552e4 100644 --- a/modules/services/donetick.nix +++ b/modules/services/donetick.nix @@ -1,4 +1,9 @@ -{ lib, pkgs, config, ... }: +{ + lib, + pkgs, + config, + ... +}: let types = { jwtSettings = { @@ -206,7 +211,7 @@ in services.webserver = { enable = lib.mkDefault true; - vHosts.${fqdn}.locations."/" .proxyPort = cfg.settings.server.port; + vHosts.${fqdn}.locations."/".proxyPort = cfg.settings.server.port; }; }; } diff --git a/modules/services/gotosocial.nix b/modules/services/gotosocial.nix index 9683add..71c2676 100644 --- a/modules/services/gotosocial.nix +++ b/modules/services/gotosocial.nix @@ -38,11 +38,12 @@ in value.extraConfig = '' rewrite ^.*$ https://${fqdn}/.well-known/${path} permanent; ''; - }) [ - "host-meta" - "webfinger" - "nodeinfo" - ] + }) + [ + "host-meta" + "webfinger" + "nodeinfo" + ] ); "${fqdn}".locations."/".proxyPort = port; diff --git a/modules/services/grafana.nix b/modules/services/grafana.nix index 00003de..acc4bfb 100644 --- a/modules/services/grafana.nix +++ b/modules/services/grafana.nix @@ -50,10 +50,12 @@ in postgresql = { enable = lib.mkDefault true; ensureDatabases = [ "grafana" ]; - ensureUsers = [{ - name = "grafana"; - ensureDBOwnership = true; - }]; + ensureUsers = [ + { + name = "grafana"; + ensureDBOwnership = true; + } + ]; }; }; }; diff --git a/modules/services/gtrackmap.nix b/modules/services/gtrackmap.nix index b1211a1..5883e02 100644 --- a/modules/services/gtrackmap.nix +++ b/modules/services/gtrackmap.nix @@ -1,4 +1,9 @@ -{ lib, config, inputs, ... }: +{ + lib, + config, + inputs, + ... +}: let cfg = config.services.gtrackmap; fqdn = "${cfg.subdomain}.${config.networking.domain}"; diff --git a/modules/services/hastebin.nix b/modules/services/hastebin.nix index e03b0d2..b5767bc 100644 --- a/modules/services/hastebin.nix +++ b/modules/services/hastebin.nix @@ -1,4 +1,9 @@ -{ lib, config, inputs, ... }: +{ + lib, + config, + inputs, + ... +}: let cfg = config.services.hastebin; secrets = config.age.secrets; diff --git a/modules/services/mealie.nix b/modules/services/mealie.nix index 3e251f7..4a500e4 100644 --- a/modules/services/mealie.nix +++ b/modules/services/mealie.nix @@ -25,10 +25,12 @@ in postgresql = { enable = lib.mkDefault true; ensureDatabases = [ "mealie" ]; - ensureUsers = [{ - name = "mealie"; - ensureDBOwnership = true; - }]; + ensureUsers = [ + { + name = "mealie"; + ensureDBOwnership = true; + } + ]; }; }; }; diff --git a/modules/services/octodns.nix b/modules/services/octodns.nix index c3e213f..ae365f4 100644 --- a/modules/services/octodns.nix +++ b/modules/services/octodns.nix @@ -1,4 +1,9 @@ -{ pkgs, lib, config, ... }: +{ + pkgs, + lib, + config, + ... +}: let cfg = config.services.octodns; secrets = config.age.secrets; @@ -125,37 +130,46 @@ let yamlFormat = pkgs.formats.yaml { }; - zoneFile = yamlFormat.generate "octodns-zone" - ( - lib.filterAttrs (_: records: (lib.length records) > 0) - (lib.mapAttrs - (_: types: - lib.filter - ({ values ? [ ], value ? null, ... }: (lib.length values) > 0 || !(builtins.isNull value)) - (lib.mapAttrsToList - (type: { ttl, ... }@options: - if (type == "CNAME") - then - let - inherit (options) target toRoot; - value = if toRoot then "${config.networking.domain}." else target; - in - { inherit type ttl value; } - else - { inherit type ttl; inherit (options) values; } - ) - types - ) + zoneFile = yamlFormat.generate "octodns-zone" ( + lib.filterAttrs (_: records: (lib.length records) > 0) ( + lib.mapAttrs ( + _: types: + lib.filter + ( + { + values ? [ ], + value ? null, + ... + }: + (lib.length values) > 0 || !(builtins.isNull value) ) - cfg.records - ) - ); + ( + lib.mapAttrsToList ( + type: + { ttl, ... }@options: + if (type == "CNAME") then + let + inherit (options) target toRoot; + value = if toRoot then "${config.networking.domain}." else target; + in + { + inherit type ttl value; + } + else + { + inherit type ttl; + inherit (options) values; + } + ) types + ) + ) cfg.records + ) + ); zonesDir = pkgs.linkFarm "octodns-zones" { "${config.networking.domain}.yaml" = zoneFile; }; - configFile = yamlFormat.generate "octodns-config.yaml" { providers = { config = { diff --git a/modules/services/readeck.nix b/modules/services/readeck.nix index 29314c2..6e5814d 100644 --- a/modules/services/readeck.nix +++ b/modules/services/readeck.nix @@ -1,4 +1,10 @@ -{ lib, inputs, config, pkgs, ... }: +{ + lib, + inputs, + config, + pkgs, + ... +}: let cfg = config.services.readeck; secrets = config.age.secrets; @@ -40,10 +46,12 @@ in postgresql = { enable = lib.mkDefault true; ensureDatabases = [ "readeck" ]; - ensureUsers = [{ - name = "readeck"; - ensureDBOwnership = true; - }]; + ensureUsers = [ + { + name = "readeck"; + ensureDBOwnership = true; + } + ]; }; }; }; diff --git a/modules/services/vaultwarden.nix b/modules/services/vaultwarden.nix index a95fbdf..4573587 100644 --- a/modules/services/vaultwarden.nix +++ b/modules/services/vaultwarden.nix @@ -36,10 +36,12 @@ in postgresql = { enable = lib.mkDefault true; ensureDatabases = [ "vaultwarden" ]; - ensureUsers = [{ - name = "vaultwarden"; - ensureDBOwnership = true; - }]; + ensureUsers = [ + { + name = "vaultwarden"; + ensureDBOwnership = true; + } + ]; }; }; }; diff --git a/modules/services/webserver.nix b/modules/services/webserver.nix index d0689c8..767d45a 100644 --- a/modules/services/webserver.nix +++ b/modules/services/webserver.nix @@ -69,8 +69,10 @@ in virtualHosts = tailscaleAuthVhosts; }; - virtualHosts = lib.mapAttrs - (_: { proxyBuffering, locations, ... }: { + virtualHosts = lib.mapAttrs ( + _: + { proxyBuffering, locations, ... }: + { forceSSL = true; enableACME = true; http2 = true; @@ -79,26 +81,33 @@ in (lib.optionalString (!proxyBuffering) "proxy_buffering off;") "charset utf-8;" ]; - locations = lib.mapAttrs - (_: { proxyPort, extraConfig }: lib.mergeAttrsList [ + locations = lib.mapAttrs ( + _: + { proxyPort, extraConfig }: + lib.mergeAttrsList [ { inherit extraConfig; } - (if (lib.isInt proxyPort) then { - proxyWebsockets = true; - proxyPass = "http://localhost:${toString proxyPort}"; - } else { }) - ]) - locations; - }) - cfg.vHosts; + ( + if (lib.isInt proxyPort) then + { + proxyWebsockets = true; + proxyPass = "http://localhost:${toString proxyPort}"; + } + else + { } + ) + ] + ) locations; + } + ) cfg.vHosts; }; octodns.records = lib.filterAttrs (name: _: name != config.networking.domain) ( - lib.mapAttrs' - (fqdn: _: { - name = lib.removeSuffix ".${config.networking.domain}" fqdn; - value = { CNAME.toRoot = true; }; - }) - cfg.vHosts + lib.mapAttrs' (fqdn: _: { + name = lib.removeSuffix ".${config.networking.domain}" fqdn; + value = { + CNAME.toRoot = true; + }; + }) cfg.vHosts ); }; diff --git a/modules/services/workout-sync.nix b/modules/services/workout-sync.nix index 8d9e171..894e4a4 100644 --- a/modules/services/workout-sync.nix +++ b/modules/services/workout-sync.nix @@ -1,4 +1,10 @@ -{ pkgs, inputs, config, lib, ... }: +{ + pkgs, + inputs, + config, + lib, + ... +}: let cfg = config.services.workout-sync; fqdn = "${cfg.subdomain}.${config.networking.domain}"; diff --git a/modules/services/workout-tracker.nix b/modules/services/workout-tracker.nix index 140f8c0..c979c8d 100644 --- a/modules/services/workout-tracker.nix +++ b/modules/services/workout-tracker.nix @@ -1,4 +1,10 @@ -{ pkgs, config, lib, inputs, ... }: +{ + pkgs, + config, + lib, + inputs, + ... +}: let cfg = config.services.workout-tracker; fqdn = "${cfg.subdomain}.${config.networking.domain}"; diff --git a/modules/storage-box-mounts.nix b/modules/storage-box-mounts.nix index bd8a467..a6a1807 100644 --- a/modules/storage-box-mounts.nix +++ b/modules/storage-box-mounts.nix @@ -1,4 +1,9 @@ -{ lib, config, pkgs, ... }: +{ + lib, + config, + pkgs, + ... +}: let types = { mount = lib.types.submodule { @@ -25,17 +30,17 @@ let cfg = config.modules.storageBoxMounts; secrets = config.age.secrets; - mountOptions = { uid, gid, ... }: [ - "x-systemd.automount" - "auto" - "x-systemd.device-timeout=5s" - "x-systemd.mount-timeout=5s" - "credentials=${secrets.storage-box-credentials.path}" - ] ++ ( - if (uid != null) then [ "uid=${toString uid}" ] else [ ] - ) ++ ( - if (gid != null) then [ "gid=${toString gid}" ] else [ ] - ); + mountOptions = + { uid, gid, ... }: + [ + "x-systemd.automount" + "auto" + "x-systemd.device-timeout=5s" + "x-systemd.mount-timeout=5s" + "credentials=${secrets.storage-box-credentials.path}" + ] + ++ (if (uid != null) then [ "uid=${toString uid}" ] else [ ]) + ++ (if (gid != null) then [ "gid=${toString gid}" ] else [ ]); in { options.modules.storageBoxMounts = lib.mkOption { @@ -44,13 +49,15 @@ in }; config = { - fileSystems = lib.mapAttrs - (_: { path, user, ... }@options: { + fileSystems = lib.mapAttrs ( + _: + { path, user, ... }@options: + { device = "//${user}.your-storagebox.de${path}"; fsType = "cifs"; options = mountOptions options; - }) - cfg; + } + ) cfg; environment.systemPackages = lib.mkIf ((lib.length (lib.attrNames cfg)) > 0) [ pkgs.cifs-utils ]; }; diff --git a/modules/vlans.nix b/modules/vlans.nix index b156818..2d51a1f 100644 --- a/modules/vlans.nix +++ b/modules/vlans.nix @@ -50,20 +50,39 @@ let }; cfg = config.modules.vlans; - vlans = lib.mapAttrsToList (attrName: { name ? attrName, ... }@vlan: ({ inherit name; } // vlan)) cfg.networks; - vlanAttrs = lib.listToAttrs (lib.map ({ name, ... }@value: { inherit name value; }) vlans); + vlans = lib.mapAttrsToList ( + attrName: + { + name ? attrName, + ... + }@vlan: + ({ inherit name; } // vlan) + ) cfg.networks; + vlanAttrs = lib.listToAttrs ( + lib.map ( + { name, ... }@value: + { + inherit name value; + } + ) vlans + ); - buildNetdev = name: { id, ... }: { - name = "20-${name}"; - value = { - netdevConfig = { - Name = name; - Kind = "vlan"; - MACAddress = "00:0d:b9:49:d2:${toString id}"; + buildNetdev = + name: + { id, ... }: + { + name = "20-${name}"; + value = { + netdevConfig = { + Name = name; + Kind = "vlan"; + MACAddress = "00:0d:b9:49:d2:${toString id}"; + }; + vlanConfig = { + Id = id; + }; }; - vlanConfig = { Id = id; }; }; - }; buildStaticLease = macAddress: address: '' [DHCPServerStaticLease] @@ -71,27 +90,35 @@ let Address=${address} ''; - buildNetwork = name: { id, ipv6, staticLeases, ... }: { - name = "30-${name}"; - value = { - matchConfig = { - Name = name; + buildNetwork = + name: + { + id, + ipv6, + staticLeases, + ... + }: + { + name = "30-${name}"; + value = { + matchConfig = { + Name = name; + }; + networkConfig = { + Address = "10.${toString id}.0.1/23"; + IPMasquerade = "ipv4"; + DHCPServer = true; + IPv6AcceptRA = false; + IPv6SendRA = ipv6; + DHCPPrefixDelegation = ipv6; + }; + dhcpServerConfig = { + PoolOffset = 255; + DNS = "10.${toString id}.0.1"; + }; + extraConfig = lib.concatLines (lib.mapAttrsToList buildStaticLease staticLeases); }; - networkConfig = { - Address = "10.${toString id}.0.1/23"; - IPMasquerade = "ipv4"; - DHCPServer = true; - IPv6AcceptRA = false; - IPv6SendRA = ipv6; - DHCPPrefixDelegation = ipv6; - }; - dhcpServerConfig = { - PoolOffset = 255; - DNS = "10.${toString id}.0.1"; - }; - extraConfig = lib.concatLines (lib.mapAttrsToList buildStaticLease staticLeases); }; - }; vlanIds = lib.mapAttrsToList (_: { id, ... }: id) vlanAttrs; @@ -108,25 +135,39 @@ let ''; bridgeNetDev = - if (cfg.bridge.enable) then { - "${cfg.bridge.netdev}".bridgeConfig = { - VLANFiltering = true; - DefaultPVID = cfg.bridge.pvid; - }; - } else { }; + if (cfg.bridge.enable) then + { + "${cfg.bridge.netdev}".bridgeConfig = { + VLANFiltering = true; + DefaultPVID = cfg.bridge.pvid; + }; + } + else + { }; bridgeBindNetwork = - if (cfg.bridge.enable) then { - ${cfg.bridge.bindNetwork}.extraConfig = bridgeVLANConfig; - } else { }; + if (cfg.bridge.enable) then + { + ${cfg.bridge.bindNetwork}.extraConfig = bridgeVLANConfig; + } + else + { }; bridgeNetwork = - if (cfg.bridge.enable) then { - "${cfg.bridge.network}" = { - vlan = lib.map ({ name, ... }: name) vlans; - bridgeVLANs = lib.map ({ id, ... }: { VLAN = id; }) vlans; - }; - } else { }; + if (cfg.bridge.enable) then + { + "${cfg.bridge.network}" = { + vlan = lib.map ({ name, ... }: name) vlans; + bridgeVLANs = lib.map ( + { id, ... }: + { + VLAN = id; + } + ) vlans; + }; + } + else + { }; netdevs = lib.mergeAttrsList [ (lib.mapAttrs' buildNetdev vlanAttrs) diff --git a/secrets/secrets.nix b/secrets/secrets.nix index 2757ddd..ef4fcbb 100644 --- a/secrets/secrets.nix +++ b/secrets/secrets.nix @@ -1,13 +1,20 @@ let moco = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDRXRJUwX98l2Vl4bUZdyHGhLjlf1RGAA5VCa4dmEJdU"; jokke = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIC7UDcuAbvp8mXIPl4M8MkM1X78YfXm50SLmSY3boL9Z"; - users = [ moco jokke ]; + users = [ + moco + jokke + ]; apu = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICAZkIuXtpP9a9bHkBl+MJI//q3ClMqzx03Rd/Xe4rjc"; freun-dev = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEvCSjIjipog1Xf9mPc683r5VSGSjVc8v1UZg5VrbbxM"; radish = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIQ0fy4n3yyD64+g55eZazeI5g9FurJnlC6fRiOXbbks"; - hosts = [ apu freun-dev radish ]; + hosts = [ + apu + freun-dev + radish + ]; in { "gotosocial.age".publicKeys = users ++ [ freun-dev ];