run nixfmt

This commit is contained in:
Joakim Repomaa
2025-03-01 13:23:01 +02:00
parent a93d4afbcf
commit 8dfc9b5a6d
51 changed files with 1611 additions and 778 deletions

View File

@@ -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;
}

View File

@@ -2,8 +2,7 @@
let let
inherit (pkgs) crystal libffi; inherit (pkgs) crystal libffi;
in in
crystal.overrideAttrs (oldAttrs: crystal.overrideAttrs (oldAttrs: {
{
makeFlags = oldAttrs.makeFlags ++ [ makeFlags = oldAttrs.makeFlags ++ [
"interpreter=1" "interpreter=1"
]; ];
@@ -12,5 +11,4 @@ crystal.overrideAttrs (oldAttrs:
]; ];
FLAGS = [ "--single-module" ]; FLAGS = [ "--single-module" ];
doCheck = false; doCheck = false;
} })
)

View File

@@ -2,8 +2,18 @@
let let
inherit (builtins) attrNames filter readDir; inherit (builtins) attrNames filter readDir;
dirs = dirs =
let files = readDir ./.; let
in filter (name: files."${name}" == "directory") (attrNames files); files = readDir ./.;
in
filter (name: files."${name}" == "directory") (attrNames files);
util = import ./util.nix; util = import ./util.nix;
in 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
)

View File

@@ -1,4 +1,10 @@
{ lib, stdenv, fetchurl, python3, ... }: {
lib,
stdenv,
fetchurl,
python3,
...
}:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "fb-client"; pname = "fb-client";
version = "2.3.0"; version = "2.3.0";
@@ -8,8 +14,14 @@ stdenv.mkDerivation rec {
sha256 = "sha256-EWTsoG7qy0IQ1GLEuvHEAEJyphl9hz1hFm53k1OdGYM="; sha256 = "sha256-EWTsoG7qy0IQ1GLEuvHEAEJyphl9hz1hFm53k1OdGYM=";
}; };
buildInputs = buildInputs = [
[ (python3.withPackages (pyPkgs: with pyPkgs; [ pycurl pyxdg ])) ]; (python3.withPackages (
pyPkgs: with pyPkgs; [
pycurl
pyxdg
]
))
];
makeFlags = [ "PREFIX=$(out)" ]; makeFlags = [ "PREFIX=$(out)" ];

View File

@@ -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;
}

View File

@@ -1,6 +1,6 @@
dir: dir: {
{ vimPlugin =
vimPlugin = { name, source }: { name, source }:
final: prev: { final: prev: {
vimPlugins = prev.vimPlugins // { vimPlugins = prev.vimPlugins // {
"${dir}" = prev.vimUtils.buildVimPlugin { "${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; });
};
} }

View File

@@ -1 +1,5 @@
{ inputs, util, ... }: util.vimPlugin { name = "vimpeccable"; source = inputs.vimpeccable; } { inputs, util, ... }:
util.vimPlugin {
name = "vimpeccable";
source = inputs.vimpeccable;
}

View File

@@ -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;
}

View File

@@ -73,7 +73,15 @@
inputs.nixpkgs.follows = "nixpkgs"; 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; } ( flake-parts.lib.mkFlake { inherit inputs; } (
let let
ssh.publicKeys.yubikey = "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLIUkESu5NnBi1M0+ZjYrkp6/rIFuwc3aguspf98jmOydNce6l65cnS3GRzc9oWx4lu11ahi87ZuE+pYV+gaHm4="; ssh.publicKeys.yubikey = "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLIUkESu5NnBi1M0+ZjYrkp6/rIFuwc3aguspf98jmOydNce6l65cnS3GRzc9oWx4lu11ahi87ZuE+pYV+gaHm4=";
@@ -81,8 +89,15 @@
inherit (nixpkgs) lib; inherit (nixpkgs) lib;
in in
{ {
systems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; systems = [
perSystem = { pkgs, system, ... }: { "x86_64-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
];
perSystem =
{ pkgs, system, ... }:
{
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
packages = with pkgs; [ packages = with pkgs; [
agenix.packages.${system}.default agenix.packages.${system}.default
@@ -113,11 +128,18 @@
}; };
}; };
defaults = { name, ... }: { defaults =
imports = [ ./modules ./hosts/${name} ]; { name, ... }:
{
imports = [
./modules
./hosts/${name}
];
}; };
radish = { ... }: { radish =
{ ... }:
{
deployment = { deployment = {
allowLocalDeployment = true; allowLocalDeployment = true;
targetHost = null; targetHost = null;

View File

@@ -1,4 +1,12 @@
{ config, lib, pkgs, inputs, self, ... }: { {
config,
lib,
pkgs,
inputs,
self,
...
}:
{
nixpkgs.config.allowUnfree = true; nixpkgs.config.allowUnfree = true;
imports = [ imports = [
../gnome ../gnome
@@ -83,7 +91,10 @@
home-manager.enable = true; home-manager.enable = true;
bat = { bat = {
enable = true; enable = true;
extraPackages = with pkgs.bat-extras; [ batdiff batwatch ]; extraPackages = with pkgs.bat-extras; [
batdiff
batwatch
];
config = { config = {
pager = "less -FR"; pager = "less -FR";
}; };
@@ -277,8 +288,13 @@
bright_white = "#ffffff"; bright_white = "#ffffff";
}; };
component_style = { component_style = {
playback_metadata = { fg = "#8abeb7"; }; playback_metadata = {
playback_progress_bar = { bg = "#1d1f21"; fg = "#c5c8c6"; }; fg = "#8abeb7";
};
playback_progress_bar = {
bg = "#1d1f21";
fg = "#c5c8c6";
};
}; };
} }
]; ];
@@ -299,6 +315,39 @@
host = "https://bin.freun.dev"; host = "https://bin.freun.dev";
auth_token_file = "${config.xdg.configHome}/hastebin/auth_token"; auth_token_file = "${config.xdg.configHome}/hastebin/auth_token";
clipboard_command = "${pkgs.wl-copy-both}/bin/wl-copy"; 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 = { zed-editor = {
@@ -334,23 +383,68 @@
paperwm = { paperwm = {
enable = true; enable = true;
winprops = [ winprops = [
{ wm_class = "vivaldi-stable"; preferredWidth = "67%"; } {
{ wm_class = "yubioath-flutter"; scratch_layer = true; } wm_class = "vivaldi-stable";
{ wm_class = "signal"; scratch_layer = true; } preferredWidth = "67%";
{ wm_class = "Slack"; scratch_layer = true; } }
{ wm_class = "Supersonic"; scratch_layer = true; } {
{ wm_class = "io.github.seadve.Kooha"; scratch_layer = true; } wm_class = "yubioath-flutter";
{ wm_class = "/.*/"; preferredWidth = "33"; } 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 = { keybindings = {
move-down = [ "<Control><Super>Down" "<Shift><Super>j" ]; move-down = [
move-left = [ "<Control><Super>Left" "<Shift><Super>h" ]; "<Control><Super>Down"
move-right = [ "<Control><Super>Right" "<Shift><Super>l" ]; "<Shift><Super>j"
move-up = [ "<Control><Super>Up" "<Shift><Super>k" ]; ];
switch-down = [ "<Super>Down" "<Super>j" ]; move-left = [
switch-left = [ "<Super>Left" "<Super>h" ]; "<Control><Super>Left"
switch-right = [ "<Super>Right" "<Super>l" ]; "<Shift><Super>h"
switch-up = [ "<Super>Up" "<Super>k" ]; ];
move-right = [
"<Control><Super>Right"
"<Shift><Super>l"
];
move-up = [
"<Control><Super>Up"
"<Shift><Super>k"
];
switch-down = [
"<Super>Down"
"<Super>j"
];
switch-left = [
"<Super>Left"
"<Super>h"
];
switch-right = [
"<Super>Right"
"<Super>l"
];
switch-up = [
"<Super>Up"
"<Super>k"
];
}; };
}; };
freon = { freon = {

View File

@@ -1,8 +1,17 @@
{ inputs, lib, pkgs, config, ... }: {
inputs,
lib,
pkgs,
config,
...
}:
let let
completion = pkgs.stdenv.mkDerivation { completion = pkgs.stdenv.mkDerivation {
name = "dnote-completion"; name = "dnote-completion";
phases = [ "unpackPhase" "installPhase" ]; phases = [
"unpackPhase"
"installPhase"
];
src = inputs.dnote; src = inputs.dnote;
installPhase = '' installPhase = ''
mkdir -p $out/lib/dnote/zsh-completion/completions mkdir -p $out/lib/dnote/zsh-completion/completions

View File

@@ -5,7 +5,13 @@
programs.neovim = programs.neovim =
let let
toLua = lib.generators.toLua { }; toLua = lib.generators.toLua { };
luaMap = rhs: { rhs = rhs; lua = true; options = { silent = true; }; }; luaMap = rhs: {
rhs = rhs;
lua = true;
options = {
silent = true;
};
};
in in
{ {
enable = true; enable = true;
@@ -50,7 +56,10 @@
filetypes = [ "crystal" ]; filetypes = [ "crystal" ];
globs = [ "*.cr" ]; globs = [ "*.cr" ];
exe = "${pkgs.crystal}/bin/crystal"; exe = "${pkgs.crystal}/bin/crystal";
args = file: [ "tool" "format" ]; args = file: [
"tool"
"format"
];
stdin = false; stdin = false;
} }
]; ];
@@ -69,7 +78,11 @@
} }
{ {
event = "FileType"; event = "FileType";
pattern = [ "gitcommit" "gitrebase" "gitconfig" ]; pattern = [
"gitcommit"
"gitrebase"
"gitconfig"
];
command = "set bufhidden=delete"; command = "set bufhidden=delete";
} }
{ {
@@ -111,17 +124,41 @@
vim-crystal vim-crystal
{ {
plugin = telescope-nvim; 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 = config =
let let
commands = [ commands = [
{ cmd = "<cmd>!rails db:migrate<cr>"; desc = "Run rails migrations"; } {
{ cmd = "<cmd>!yarn codegen --no-watch<cr>"; desc = "Run yarn codegen"; } cmd = "<cmd>!rails db:migrate<cr>";
{ cmd = "<cmd>!rails translations:update<cr>"; desc = "Update i18n translations"; } desc = "Run rails migrations";
{ cmd = "<cmd>!deploy staging-v6 -t $(git branch --show-current)<cr>"; desc = "Deploy to staging"; } }
{ cmd = "<cmd>!db-restore -d db-prod-inc<cr>"; desc = "Restore db from prod-inc"; } {
cmd = "<cmd>!yarn codegen --no-watch<cr>";
desc = "Run yarn codegen";
}
{
cmd = "<cmd>!rails translations:update<cr>";
desc = "Update i18n translations";
}
{
cmd = "<cmd>!deploy staging-v6 -t $(git branch --show-current)<cr>";
desc = "Deploy to staging";
}
{
cmd = "<cmd>!db-restore -d db-prod-inc<cr>";
desc = "Restore db from prod-inc";
}
]; ];
mappings = { i = { "<c-h>" = "which_key"; }; }; mappings = {
i = {
"<c-h>" = "which_key";
};
};
in in
'' ''
local telescope = require('telescope') local telescope = require('telescope')
@@ -146,10 +183,8 @@
}) })
''; '';
mappings = { mappings = {
normal = ( normal =
lib.attrsets.mapAttrs (lib.attrsets.mapAttrs (key: value: luaMap "require('telescope.builtin').${value}") {
(key: value: luaMap "require('telescope.builtin').${value}")
{
"<leader>f" = "find_files"; "<leader>f" = "find_files";
"<leader>r" = "live_grep"; "<leader>r" = "live_grep";
"<leader>b" = "buffers"; "<leader>b" = "buffers";
@@ -158,15 +193,11 @@
"<leader>s" = "git_status"; "<leader>s" = "git_status";
"<leader>/" = "current_buffer_fuzzy_find"; "<leader>/" = "current_buffer_fuzzy_find";
"<leader>c" = "git_branches"; "<leader>c" = "git_branches";
} })
) // ( // (lib.attrsets.mapAttrs (key: value: luaMap "require('telescope').extensions.${value}") {
lib.attrsets.mapAttrs
(key: value: luaMap "require('telescope').extensions.${value}")
{
"<leader>n" = "file_browser.file_browser"; "<leader>n" = "file_browser.file_browser";
"<leader>:" = "commander.filter"; "<leader>:" = "commander.filter";
} });
);
}; };
} }
{ {
@@ -176,17 +207,25 @@
vim.cmd('colorscheme base16-tomorrow-night') vim.cmd('colorscheme base16-tomorrow-night')
''; '';
} }
{ plugin = octo-nvim; config = "require('octo').setup()"; } {
plugin = octo-nvim;
config = "require('octo').setup()";
}
{ {
plugin = gitsigns-nvim; plugin = gitsigns-nvim;
dependencies = [ plenary-nvim ]; dependencies = [ plenary-nvim ];
config = '' config = ''
require('gitsigns').setup(${toLua { require('gitsigns').setup(${
toLua {
current_line_blame = true; current_line_blame = true;
}}) }
})
''; '';
} }
{ plugin = windline-nvim; config = "require('wlsample.airline')"; } {
plugin = windline-nvim;
config = "require('wlsample.airline')";
}
{ {
plugin = luasnip; plugin = luasnip;
config = '' config = ''
@@ -252,7 +291,10 @@
} }
{ {
plugin = toggleterm-nvim; plugin = toggleterm-nvim;
dependencies = [ plenary-nvim pkgs.lazygit ]; dependencies = [
plenary-nvim
pkgs.lazygit
];
config = '' config = ''
local Terminal = require('toggleterm.terminal').Terminal local Terminal = require('toggleterm.terminal').Terminal
local lazygit = Terminal:new({ local lazygit = Terminal:new({
@@ -277,7 +319,8 @@
} }
{ {
plugin = copilot-cmp; plugin = copilot-cmp;
dependencies = [{ dependencies = [
{
plugin = copilot-lua; plugin = copilot-lua;
config = '' config = ''
require('copilot').setup({ require('copilot').setup({
@@ -286,7 +329,8 @@
copilot_node_command = '${pkgs.nodejs}/bin/node', copilot_node_command = '${pkgs.nodejs}/bin/node',
}) })
''; '';
}]; }
];
config = '' config = ''
require('copilot_cmp').setup() require('copilot_cmp').setup()
''; '';
@@ -318,9 +362,11 @@
'' ''
require('bufferline').setup({ options = ${toLua options} }) require('bufferline').setup({ options = ${toLua options} })
''; '';
dependencies = [{ dependencies = [
{
plugin = nvim-web-devicons; plugin = nvim-web-devicons;
}]; }
];
} }
]; ];
lsp = { lsp = {
@@ -342,7 +388,11 @@
name = "yamlls"; name = "yamlls";
config = { config = {
settings = { settings = {
redhat = { telemetry = { enabled = false; }; }; redhat = {
telemetry = {
enabled = false;
};
};
yaml = { yaml = {
schemas = { schemas = {
"https://json.schemastore.org/github-workflow" = ".github/workflows/*.yml"; "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/prettierrc.yaml" = ".prettierrc.yaml";
"https://json.schemastore.org/prettier.config.yml" = "prettier.config.yml"; "https://json.schemastore.org/prettier.config.yml" = "prettier.config.yml";
"https://json.schemastore.org/prettier.config.yaml" = "prettier.config.yaml"; "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 = { config = {
settings = { settings = {
tailwindCSS = { tailwindCSS = {
classAttributes = [ "class" "className" ]; classAttributes = [
"class"
"className"
];
}; };
}; };
}; };
@@ -377,8 +433,14 @@
}; };
rootPattern = [ "package.json" ]; 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"; name = "bashls";
package = nodePackages.bash-language-server.overrideAttrs (oldAttrs: { package = nodePackages.bash-language-server.overrideAttrs (oldAttrs: {

View File

@@ -2,8 +2,10 @@
let let
inherit (builtins) attrNames filter readDir; inherit (builtins) attrNames filter readDir;
dirs = dirs =
let files = readDir ./.; let
in filter (name: files."${name}" == "directory") (attrNames files); files = readDir ./.;
in
filter (name: files."${name}" == "directory") (attrNames files);
in in
{ {
imports = map (dir: ./${dir}) dirs; imports = map (dir: ./${dir}) dirs;

View File

@@ -1,9 +1,18 @@
{ pkgs, config, lib, ... }: {
pkgs,
config,
lib,
...
}:
let let
cfg = config.programs.fb-client; cfg = config.programs.fb-client;
in in
{ {
options.programs.fb-client = let inherit (lib) mkEnableOption mkOption types; in { options.programs.fb-client =
let
inherit (lib) mkEnableOption mkOption types;
in
{
enable = mkEnableOption { }; enable = mkEnableOption { };
pastebin = mkOption { pastebin = mkOption {
type = types.str; type = types.str;

View File

@@ -1,4 +1,9 @@
{ config, lib, osConfig, ... }: {
config,
lib,
osConfig,
...
}:
let let
cfg = config.gnome; cfg = config.gnome;
in in
@@ -38,7 +43,12 @@ in
}; };
power = { power = {
powerButton = lib.mkOption { powerButton = lib.mkOption {
type = enum [ "suspend" "interactive" "hibernate" "nothing" ]; type = enum [
"suspend"
"interactive"
"hibernate"
"nothing"
];
default = "interactive"; default = "interactive";
}; };
}; };
@@ -75,23 +85,36 @@ in
}; };
config = { config = {
dconf.settings = with lib.hm.gvariant; { dconf.settings =
with lib.hm.gvariant;
{
"org/gnome/shell/keybindings" = cfg.keybindings.builtin; "org/gnome/shell/keybindings" = cfg.keybindings.builtin;
"org/gnome/settings-daemon/plugins/media-keys" = { "org/gnome/settings-daemon/plugins/media-keys" = {
custom-keybindings = ( custom-keybindings = (
lib.lists.imap0 lib.lists.imap0 (
(i: _: "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom${toString i}/") i: _: "/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom${toString i}/"
cfg.keybindings.custom ) cfg.keybindings.custom
); );
}; };
"org/gnome/desktop/input-sources" = { "org/gnome/desktop/input-sources" = {
sources = map (source: mkTuple [ "xkb" source ]) cfg.keyboard.sources; sources = map (
source:
mkTuple [
"xkb"
source
]
) cfg.keyboard.sources;
}; };
"org/gnome/mutter" = { "org/gnome/mutter" = {
experimental-features = [ "scale-monitor-framebuffer" ]; experimental-features = [ "scale-monitor-framebuffer" ];
}; };
"org/gnome/settings-daemon/plugins/xsettings" = { "org/gnome/settings-daemon/plugins/xsettings" = {
overrides = [ (mkTuple [ "GdkWindowScalingFactor" cfg.scalingFactor ]) ]; overrides = [
(mkTuple [
"GdkWindowScalingFactor"
cfg.scalingFactor
])
];
}; };
"org/gnome/desktop/interface" = { "org/gnome/desktop/interface" = {
scaling-factor = cfg.scalingFactor; scaling-factor = cfg.scalingFactor;
@@ -115,16 +138,13 @@ in
"system/locale" = { "system/locale" = {
region = cfg.region; region = cfg.region;
}; };
} // ( }
builtins.listToAttrs ( // (builtins.listToAttrs (
lib.lists.imap0 lib.lists.imap0 (i: keybinding: {
(i: keybinding: {
name = "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom${toString i}"; name = "org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom${toString i}";
value = keybinding; value = keybinding;
}) }) cfg.keybindings.custom
cfg.keybindings.custom ));
)
);
home.file.".face".source = lib.mkIf (!isNull cfg.profilePicture) cfg.profilePicture; home.file.".face".source = lib.mkIf (!isNull cfg.profilePicture) cfg.profilePicture;
}; };
} }

View File

@@ -2,8 +2,10 @@
let let
inherit (builtins) attrNames filter readDir; inherit (builtins) attrNames filter readDir;
dirs = dirs =
let files = readDir ./.; let
in filter (name: files."${name}" == "directory") (attrNames files); files = readDir ./.;
in
filter (name: files."${name}" == "directory") (attrNames files);
in in
{ {
imports = map (dir: ./${dir}) dirs; imports = map (dir: ./${dir}) dirs;

View File

@@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
cfg = config.gnome.extensions.freon; cfg = config.gnome.extensions.freon;
in in

View File

@@ -1,4 +1,9 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
cfg = config.gnome.extensions; cfg = config.gnome.extensions;
in in
@@ -10,18 +15,52 @@ in
type = package; type = package;
default = pkgs.gnomeExtensions.paperwm; default = pkgs.gnomeExtensions.paperwm;
}; };
cycle-height-steps = lib.mkOption { type = listOf numbers.nonnegative; default = [ 0.33 0.5 0.67 1.0 ]; }; cycle-height-steps = lib.mkOption {
cycle-width-steps = lib.mkOption { type = listOf numbers.nonnegative; default = [ 0.33 0.5 0.67 1.0 ]; }; type = listOf numbers.nonnegative;
horizontal-margin = lib.mkOption { type = ints.unsigned; default = 5; }; default = [
vertical-margin = lib.mkOption { type = ints.unsigned; default = 5; }; 0.33
window-gap = lib.mkOption { type = ints.unsigned; default = 5; }; 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 { winprops = lib.mkOption {
type = listOf (submodule { type = listOf (submodule {
options = { options = {
wm_class = lib.mkOption { type = str; default = ""; }; wm_class = lib.mkOption {
title = lib.mkOption { type = str; default = ""; }; type = str;
default = "";
};
title = lib.mkOption {
type = str;
default = "";
};
scratch_layer = lib.mkEnableOption { }; scratch_layer = lib.mkEnableOption { };
preferredWidth = lib.mkOption { type = nullOr str; default = null; }; preferredWidth = lib.mkOption {
type = nullOr str;
default = null;
};
}; };
}); });
default = [ ]; default = [ ];
@@ -36,13 +75,23 @@ in
config = lib.mkIf cfg.paperwm.enable { config = lib.mkIf cfg.paperwm.enable {
home.packages = [ cfg.paperwm.package ]; home.packages = [ cfg.paperwm.package ];
dconf.settings = { dconf.settings = {
"org/gnome/shell".enabled-extensions = "org/gnome/shell".enabled-extensions = lib.mkIf cfg.paperwm.enable [
lib.mkIf cfg.paperwm.enable [ cfg.paperwm.package.extensionUuid ]; 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; "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; winprops = map (props: builtins.toJSON props) winprops;
}; };
"org/gnome/shell/extensions/paperwm/keybindings" = lib.mkIf cfg.paperwm.enable cfg.paperwm.keybindings; "org/gnome/shell/extensions/paperwm/keybindings" =
lib.mkIf cfg.paperwm.enable cfg.paperwm.keybindings;
}; };
}; };
} }

View File

@@ -40,17 +40,32 @@
]; ];
formatters = [ formatters = [
{ {
filetypes = [ "typescript" "typescriptreact" "svelte" ]; filetypes = [
globs = [ "*.ts" "*.tsx" "*.svelte" ]; "typescript"
"typescriptreact"
"svelte"
];
globs = [
"*.ts"
"*.tsx"
"*.svelte"
];
exe = "npx"; exe = "npx";
args = file: [ "prettier" "--stdin-filepath" file ]; args = file: [
"prettier"
"--stdin-filepath"
file
];
stdin = true; stdin = true;
} }
{ {
filetypes = [ "prisma" ]; filetypes = [ "prisma" ];
globs = [ "*.prisma" ]; globs = [ "*.prisma" ];
exe = "${pkgs.nodePackages.prisma}/bin/prisma"; exe = "${pkgs.nodePackages.prisma}/bin/prisma";
args = file: [ "format" "--schema" ]; args = file: [
"format"
"--schema"
];
stdin = false; stdin = false;
} }
]; ];
@@ -67,13 +82,21 @@
{ {
name = "prismals"; name = "prismals";
package = nodePackages."@prisma/language-server"; package = nodePackages."@prisma/language-server";
rootPattern = [ "package.json" "deno.json" ]; rootPattern = [
"package.json"
"deno.json"
];
} }
{ {
name = "graphql"; name = "graphql";
package = nodePackages.graphql-language-service-cli; package = nodePackages.graphql-language-service-cli;
config = { config = {
filetypes = [ "typescript" "typescriptreact" "graphql" "svelte" ]; filetypes = [
"typescript"
"typescriptreact"
"graphql"
"svelte"
];
}; };
} }
]; ];

View File

@@ -38,7 +38,10 @@ in
profilePicture = ../assets/profile-pictures/moco.png; profilePicture = ../assets/profile-pictures/moco.png;
calendar.showWeekNumbers = true; calendar.showWeekNumbers = true;
extensions.paperwm.winprops = [ extensions.paperwm.winprops = [
{ wm_class = "gnome-pomodoro"; scratch_layer = true; } {
wm_class = "gnome-pomodoro";
scratch_layer = true;
}
]; ];
}; };
@@ -77,16 +80,40 @@ in
formatters = [ formatters = [
{ {
filetypes = [ "ruby" ]; filetypes = [ "ruby" ];
globs = [ "*.rb" "Gemfile" "*.rake" ]; globs = [
"*.rb"
"Gemfile"
"*.rake"
];
exe = "bundle"; exe = "bundle";
args = file: [ "exec" "rufo" "-x" "--filename" file ]; args = file: [
"exec"
"rufo"
"-x"
"--filename"
file
];
stdin = true; stdin = true;
} }
{ {
filetypes = [ "javascript" "typescript" "javascriptreact" "typescriptreact" ]; filetypes = [
globs = [ "*.js" "*.jsx" "*.ts" "*.tsx" ]; "javascript"
"typescript"
"javascriptreact"
"typescriptreact"
];
globs = [
"*.js"
"*.jsx"
"*.ts"
"*.tsx"
];
exe = "npx"; exe = "npx";
args = file: [ "prettier" "--stdin-filepath" file ]; args = file: [
"prettier"
"--stdin-filepath"
file
];
stdin = true; stdin = true;
} }
]; ];
@@ -109,14 +136,21 @@ in
programs.ssh.matchBlocks = programs.ssh.matchBlocks =
let let
aliases = [ "moco" "mocoapp" "mocoapp.com" ]; aliases = [
matcher = subdomains: "moco"
"mocoapp"
"mocoapp.com"
];
matcher =
subdomains:
builtins.concatStringsSep " " (
map (
alias:
builtins.concatStringsSep " " ( builtins.concatStringsSep " " (
map
(alias: builtins.concatStringsSep " " (
map (subdomain: "*.${subdomain}.${alias} ${subdomain}.${alias}") subdomains map (subdomain: "*.${subdomain}.${alias} ${subdomain}.${alias}") subdomains
)) )
aliases); ) aliases
);
in in
{ {
"console.*.moco" = { "console.*.moco" = {
@@ -126,7 +160,11 @@ in
}; };
}; };
"${matcher ["reto" "reto.intern"]}" = { "${matcher [
"reto"
"reto.intern"
]}" =
{
hostname = "reto.intern.mocoapp.com"; hostname = "reto.intern.mocoapp.com";
user = "jokke"; user = "jokke";
}; };
@@ -140,25 +178,45 @@ in
"${matcher [ "prod" ]}" = { "${matcher [ "prod" ]}" = {
hostname = "web02.mocoapp"; hostname = "web02.mocoapp";
}; };
"${matcher ["pfg" "primeforcegroup"]}" = { "${matcher [
"pfg"
"primeforcegroup"
]}" =
{
hostname = "primeforcegroup.mocoapp.com"; hostname = "primeforcegroup.mocoapp.com";
}; };
"${matcher [ "crafft" ]}" = { "${matcher [ "crafft" ]}" = {
hostname = "crafft.mocoapp.com"; hostname = "crafft.mocoapp.com";
}; };
"${matcher ["bd" "businessdecision"]}" = { "${matcher [
"bd"
"businessdecision"
]}" =
{
hostname = "businessdecision.mocoapp.com"; hostname = "businessdecision.mocoapp.com";
}; };
"${matcher [ "festland" ]}" = { "${matcher [ "festland" ]}" = {
hostname = "festland.mocoapp.com"; hostname = "festland.mocoapp.com";
}; };
"${matcher ["oi" "one-inside"]}" = { "${matcher [
"oi"
"one-inside"
]}" =
{
hostname = "one-inside.mocoapp.com"; hostname = "one-inside.mocoapp.com";
}; };
"${matcher ["se" "scope-engineering"]}" = { "${matcher [
"se"
"scope-engineering"
]}" =
{
hostname = "scope-engineering.mocoapp.com"; hostname = "scope-engineering.mocoapp.com";
}; };
"${matcher ["cpc" "cpc-ag"]}" = { "${matcher [
"cpc"
"cpc-ag"
]}" =
{
hostname = "cpc-ag.mocoapp.com"; hostname = "cpc-ag.mocoapp.com";
}; };
"${matcher [ "weareact3" ]}" = { "${matcher [ "weareact3" ]}" = {
@@ -185,7 +243,11 @@ in
"${matcher [ "staging-v6" ]}" = { "${matcher [ "staging-v6" ]}" = {
hostname = "staging-v6.mocoapp.com"; hostname = "staging-v6.mocoapp.com";
}; };
"${matcher ["prod-db" "production-db"]}" = { "${matcher [
"prod-db"
"production-db"
]}" =
{
hostname = "production-db.mocoapp"; hostname = "production-db.mocoapp";
}; };
"${matcher [ "pdf-renderer" ]}" = { "${matcher [ "pdf-renderer" ]}" = {

View File

@@ -1,14 +1,24 @@
{ config, pkgs, lib, ... }: {
config,
pkgs,
lib,
...
}:
let let
cfg = config.programs.neovim; cfg = config.programs.neovim;
toLua = lib.generators.toLua { }; toLua = lib.generators.toLua { };
buildPluginConfig = p: buildPluginConfig =
p:
let let
pluginConfig = if builtins.hasAttr "plugin" p then p else { plugin = p; }; pluginConfig = if builtins.hasAttr "plugin" p then p else { plugin = p; };
name = pluginConfig.plugin.name; name = pluginConfig.plugin.name;
config = if (builtins.isNull pluginConfig.config or null) then "" else pluginConfig.config; 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; mergedConfig = config + mappings;
in in
[ [
@@ -17,9 +27,10 @@ let
config = lib.modules.mkIf (mergedConfig != "") '' config = lib.modules.mkIf (mergedConfig != "") ''
Plugins[${toLua name}] = {} Plugins[${toLua name}] = {}
Plugins[${toLua name}].setup = function() Plugins[${toLua name}].setup = function()
${lib.strings.concatMapStrings ${
(line: if line == "" then "" else " ${line}\n") lib.strings.concatMapStrings (line: if line == "" then "" else " ${line}\n") (
(lib.strings.splitString "\n" mergedConfig) lib.strings.splitString "\n" mergedConfig
)
} }
end end
@@ -28,9 +39,8 @@ let
''; '';
type = "lua"; type = "lua";
} }
] ++ ( ]
lib.lists.concatMap buildPluginConfig pluginConfig.dependencies or [ ] ++ (lib.lists.concatMap buildPluginConfig pluginConfig.dependencies or [ ]);
);
lspPluginConfig = with pkgs.vimPlugins; { lspPluginConfig = with pkgs.vimPlugins; {
plugin = nvim-lspconfig; plugin = nvim-lspconfig;
@@ -41,7 +51,9 @@ let
luasnip luasnip
]; ];
config = (builtins.readFile ./lsp-config.lua) + '' config =
(builtins.readFile ./lsp-config.lua)
+ ''
local capabilities = vim.lsp.protocol.make_client_capabilities() local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities.workspace.didChangeWatchedFiles.dynamicRegistration = true capabilities.workspace.didChangeWatchedFiles.dynamicRegistration = true
local lspconfig = require('lspconfig') local lspconfig = require('lspconfig')
@@ -59,28 +71,48 @@ let
-- Mappings. -- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions -- See `:help vim.lsp.*` for documentation on any of the below functions
${lib.strings.concatLines (lib.attrsets.mapAttrsToList (name: value: '' ${lib.strings.concatLines (
lib.attrsets.mapAttrsToList (name: value: ''
local buf_${name} = vim.lsp.buf[${toLua name}] local buf_${name} = vim.lsp.buf[${toLua name}]
if buf_${name} then if buf_${name} then
vim.keymap.set('n', ${toLua value}, buf_${name}, { buffer = bufnr }) vim.keymap.set('n', ${toLua value}, buf_${name}, { buffer = bufnr })
end end
'' '') cfg.lsp.mappings.buf
) cfg.lsp.mappings.buf)} )}
${lib.strings.concatLines (lib.attrsets.mapAttrsToList (name: value: '' ${lib.strings.concatLines (
lib.attrsets.mapAttrsToList (name: value: ''
local diagnostic_${name} = vim.lsp.buf[${toLua name}] local diagnostic_${name} = vim.lsp.buf[${toLua name}]
if diagnostic_${name} then if diagnostic_${name} then
vim.keymap.set('n', ${toLua value}, diagnostic_${name}, { buffer = bufnr }) vim.keymap.set('n', ${toLua value}, diagnostic_${name}, { buffer = bufnr })
end end
'') cfg.lsp.mappings.diagnostic)} '') cfg.lsp.mappings.diagnostic
)}
end end
vim.env.PATH = ${toLua (lib.makeBinPath (map (s: s.package) (builtins.filter (s: builtins.hasAttr "package" s) cfg.lsp.servers)) + ":")} .. vim.env.PATH vim.env.PATH = ${
local servers = ${toLua (map ( toLua (
{ name, config ? {}, rootPattern ? null, ... }: { 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; inherit name;
config = config // (if (builtins.isNull rootPattern) then { } else { inherit rootPattern; }); config = config // (if (builtins.isNull rootPattern) then { } else { inherit rootPattern; });
} }
) cfg.lsp.servers)} ) cfg.lsp.servers
)
}
for _, server in ipairs(servers) do for _, server in ipairs(servers) do
local server_config = server.config local server_config = server.config
@@ -105,12 +137,14 @@ let
treesitterPluginConfig = with pkgs.vimPlugins; { treesitterPluginConfig = with pkgs.vimPlugins; {
plugin = nvim-treesitter.withPlugins cfg.withTreesitterPlugins; plugin = nvim-treesitter.withPlugins cfg.withTreesitterPlugins;
config = '' config = ''
require('nvim-treesitter.configs').setup(${toLua { require('nvim-treesitter.configs').setup(${
toLua {
highlight = { highlight = {
enable = true; enable = true;
additional_vim_regex_highlighting = false; additional_vim_regex_highlighting = false;
}; };
}}); }
});
''; '';
}; };
@@ -122,17 +156,24 @@ let
formatter.setup({ formatter.setup({
filetype = { 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: '' lib.strings.concatMapStringsSep ",\n " (filetype: ''
[${toLua filetype}] = { [${toLua filetype}] = {
function () function ()
return { return {
exe = ${toLua exe}, exe = ${toLua exe},
args = { args = {
${lib.strings.concatMapStringsSep ",\n " (arg: ${lib.strings.concatMapStringsSep ",\n " (
if arg == "<<FILE>>" arg:
then "util.escape_path(util.get_current_buffer_file_path())" if arg == "<<FILE>>" then "util.escape_path(util.get_current_buffer_file_path())" else toLua arg
else toLua arg
) (args "<<FILE>>")} ) (args "<<FILE>>")}
}, },
stdin = ${toLua stdin}, stdin = ${toLua stdin},
@@ -153,7 +194,11 @@ let
''; '';
}; };
customTypes = let inherit (lib) mkOption mkEnableOption types; in { customTypes =
let
inherit (lib) mkOption mkEnableOption types;
in
{
mapping = types.submodule { mapping = types.submodule {
options = { options = {
rhs = mkOption { type = types.str; }; rhs = mkOption { type = types.str; };
@@ -162,13 +207,34 @@ let
type = types.nullOr ( type = types.nullOr (
types.submodule { types.submodule {
options = { options = {
buffer = mkOption { type = types.nullOr (types.either types.int types.bool); default = null; }; buffer = mkOption {
nowait = mkOption { type = types.nullOr types.bool; default = null; }; type = types.nullOr (types.either types.int types.bool);
silent = mkOption { type = types.nullOr types.bool; default = null; }; default = null;
expr = mkOption { type = types.nullOr types.bool; default = null; }; };
script = mkOption { type = types.nullOr types.bool; default = null; }; nowait = mkOption {
unique = mkOption { type = types.nullOr types.bool; default = null; }; type = types.nullOr types.bool;
replace_keycodes = mkOption { type = types.nullOr types.bool; default = null; }; 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;
};
}; };
} }
); );
@@ -181,25 +247,48 @@ let
mappings = types.submodule { mappings = types.submodule {
options = { options = {
normal = mkOption { type = customTypes.modeMappings; default = { }; }; normal = mkOption {
insert = mkOption { type = customTypes.modeMappings; default = { }; }; type = customTypes.modeMappings;
visual = mkOption { type = customTypes.modeMappings; default = { }; }; default = { };
command = mkOption { type = customTypes.modeMappings; default = { }; }; };
select = 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 { plugin = types.either types.package (
types.submodule {
options = { options = {
plugin = mkOption { type = types.package; }; plugin = mkOption { type = types.package; };
dependencies = mkOption { dependencies = mkOption {
type = types.listOf customTypes.plugin; type = types.listOf customTypes.plugin;
default = [ ]; default = [ ];
}; };
mappings = mkOption { type = customTypes.mappings; default = { }; }; mappings = mkOption {
config = mkOption { type = types.nullOr types.str; default = null; }; type = customTypes.mappings;
default = { };
}; };
}); config = mkOption {
type = types.nullOr types.str;
default = null;
};
};
}
);
autoCommand = types.submodule { autoCommand = types.submodule {
options = { options = {
@@ -212,9 +301,18 @@ let
lspServer = types.submodule { lspServer = types.submodule {
options = { options = {
name = mkOption { type = types.str; }; name = mkOption { type = types.str; };
config = mkOption { type = types.attrs; default = { }; }; config = mkOption {
package = mkOption { type = types.nullOr types.package; default = null; }; type = types.attrs;
rootPattern = mkOption { type = types.nullOr (types.listOf types.str); default = null; }; default = { };
};
package = mkOption {
type = types.nullOr types.package;
default = null;
};
rootPattern = mkOption {
type = types.nullOr (types.listOf types.str);
default = null;
};
}; };
}; };
@@ -223,66 +321,90 @@ let
filetypes = mkOption { type = types.listOf types.str; }; filetypes = mkOption { type = types.listOf types.str; };
globs = mkOption { type = types.listOf types.str; }; globs = mkOption { type = types.listOf types.str; };
exe = mkOption { type = types.either types.path types.str; }; exe = mkOption { type = types.either types.path types.str; };
args = mkOption { type = types.functionTo (types.listOf types.str); default = _: [ ]; }; args = mkOption {
type = types.functionTo (types.listOf types.str);
default = _: [ ];
};
stdin = mkEnableOption { }; stdin = mkEnableOption { };
no_append = mkEnableOption { }; no_append = mkEnableOption { };
}; };
}; };
}; };
generateMappings = mappings: lib.strings.concatLines ( generateMappings =
lib.attrsets.mapAttrsToList mappings:
(mode: modeMappings:
lib.strings.concatLines ( lib.strings.concatLines (
lib.attrsets.mapAttrsToList lib.attrsets.mapAttrsToList (
(name: value: mode: modeMappings:
lib.strings.concatLines (
lib.attrsets.mapAttrsToList (
name: value:
let let
mapping = { lhs = name; lua = false; options = { }; } // (if builtins.isString value then { rhs = value; } else value); mapping = {
lhs = name;
lua = false;
options = { };
} // (if builtins.isString value then { rhs = value; } else value);
args = [ args = [
(toLua (builtins.substring 0 1 mode)) (toLua (builtins.substring 0 1 mode))
(toLua mapping.lhs) (toLua mapping.lhs)
(if mapping.lua then mapping.rhs else toLua mapping.rhs) (if mapping.lua then mapping.rhs else toLua mapping.rhs)
( (toLua (
toLua (
builtins.listToAttrs ( builtins.listToAttrs (
builtins.filter ({ value, ... }: !isNull (value)) (lib.attrsets.attrsToList mapping.options) builtins.filter ({ value, ... }: !isNull (value)) (lib.attrsets.attrsToList mapping.options)
) )
) ))
)
]; ];
in in
"vim.keymap.set(${lib.strings.concatStringsSep ", " args})" "vim.keymap.set(${lib.strings.concatStringsSep ", " args})"
) modeMappings
) )
modeMappings ) mappings
)
)
mappings
); );
generateAutoCommand = { event, pattern, command, group ? null }: '' generateAutoCommand =
{
event,
pattern,
command,
group ? null,
}:
''
vim.api.nvim_create_autocmd(${toLua event}, { vim.api.nvim_create_autocmd(${toLua event}, {
pattern = ${toLua pattern}, pattern = ${toLua pattern},
command = ${toLua command}, command = ${toLua command},
group = ${if isNull group then toLua group else '' group = ${
if isNull group then
toLua group
else
''
vim.api.nvim_create_augroup(${toLua group}, { clear = true }) vim.api.nvim_create_augroup(${toLua group}, { clear = true })
''}, ''
},
}) })
''; '';
generateAutoCommands = autoCommands: lib.strings.concatLines ( generateAutoCommands = autoCommands: lib.strings.concatLines (map generateAutoCommand autoCommands);
map generateAutoCommand autoCommands
);
generateSignDefinitions = signs: lib.strings.concatLines ( generateSignDefinitions =
lib.attrsets.mapAttrsToList signs:
(name: value: lib.strings.concatLines (
lib.attrsets.mapAttrsToList (
name: value:
let 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 in
"vim.fn.sign_define(${toLua hl}, ${toLua { text = value; texthl = hl; numhl = ""; }})" "vim.fn.sign_define(${toLua hl}, ${
) toLua {
signs text = value;
texthl = hl;
numhl = "";
}
})"
) signs
); );
in in
{ {
@@ -291,12 +413,18 @@ in
inherit (lib) mkOption types; inherit (lib) mkOption types;
in in
{ {
mappings = mkOption { type = customTypes.mappings; default = { }; }; mappings = mkOption {
type = customTypes.mappings;
default = { };
};
plug = mkOption { plug = mkOption {
type = types.listOf customTypes.plugin; type = types.listOf customTypes.plugin;
default = [ ]; default = [ ];
}; };
leader = mkOption { type = types.str; default = "\\"; }; leader = mkOption {
type = types.str;
default = "\\";
};
options = mkOption { options = mkOption {
type = types.attrs; type = types.attrs;
default = { }; default = { };
@@ -314,10 +442,22 @@ in
default = { }; default = { };
}; };
signs = { signs = {
error = mkOption { type = types.str; default = ""; }; error = mkOption {
warning = mkOption { type = types.str; default = ""; }; type = types.str;
info = mkOption { type = types.str; default = ""; }; default = "";
hint = mkOption { type = types.str; default = ""; }; };
warning = mkOption {
type = types.str;
default = "";
};
info = mkOption {
type = types.str;
default = "";
};
hint = mkOption {
type = types.str;
default = "";
};
}; };
lsp = { lsp = {
servers = mkOption { servers = mkOption {
@@ -325,8 +465,14 @@ in
default = [ ]; default = [ ];
}; };
mappings = { mappings = {
buf = mkOption { type = types.attrsOf types.str; default = { }; }; buf = mkOption {
diagnostic = mkOption { type = types.attrsOf types.str; default = { }; }; type = types.attrsOf types.str;
default = { };
};
diagnostic = mkOption {
type = types.attrsOf types.str;
default = { };
};
}; };
}; };
withTreesitterPlugins = mkOption { withTreesitterPlugins = mkOption {
@@ -345,22 +491,30 @@ in
"local Plugins = {}" "local Plugins = {}"
(generateMappings cfg.mappings) (generateMappings cfg.mappings)
(generateAutoCommands cfg.autoCommands) (generateAutoCommands cfg.autoCommands)
(lib.strings.concatLines (lib.attrsets.mapAttrsToList (name: value: "vim.env.${name} = ${toLua value}") cfg.env)) (lib.strings.concatLines (
(lib.strings.concatLines (lib.attrsets.mapAttrsToList (name: value: "vim.opt.${name} = ${toLua value}") cfg.options)) 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) (generateSignDefinitions cfg.signs)
"vim.g.mapleader = ${toLua cfg.leader}" "vim.g.mapleader = ${toLua cfg.leader}"
'' ''
local undodir = ${toLua ( local undodir = ${
if builtins.hasAttr "undodir" cfg.options toLua (
then cfg.options.undodir if builtins.hasAttr "undodir" cfg.options then
else "${config.xdg.cacheHome}/nvim/undo" cfg.options.undodir
)} else
"${config.xdg.cacheHome}/nvim/undo"
)
}
vim.opt.undodir = undodir vim.opt.undodir = undodir
vim.fn.mkdir(undodir, 'p') vim.fn.mkdir(undodir, 'p')
'' ''
]; ];
plugins = lib.lists.concatMap buildPluginConfig ( plugins = lib.lists.concatMap buildPluginConfig (
cfg.plug ++ [ cfg.plug
++ [
lspPluginConfig lspPluginConfig
treesitterPluginConfig treesitterPluginConfig
formatterPluginConfig formatterPluginConfig
@@ -371,12 +525,12 @@ in
}; };
xdg.configFile = ( xdg.configFile = (
lib.attrsets.mapAttrs' lib.attrsets.mapAttrs' (name: value: {
(name: value: {
name = "nvim/${name}"; name = "nvim/${name}";
value = { source = value; }; value = {
}) source = value;
cfg.snippets };
}) cfg.snippets
); );
home.shellAliases = home.shellAliases =

View File

@@ -2,7 +2,13 @@
# your system. Help is availanodev"; # your system. Help is availanodev";
# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). # 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.enable = true;
boot.loader.grub.device = "/dev/sda"; boot.loader.grub.device = "/dev/sda";
@@ -12,7 +18,10 @@
nix = { nix = {
settings = { settings = {
experimental-features = [ "nix-command" "flakes" ]; experimental-features = [
"nix-command"
"flakes"
];
auto-optimise-store = true; auto-optimise-store = true;
}; };
@@ -63,11 +72,28 @@
modules.firewall = { modules.firewall = {
enable = true; enable = true;
interfaces = { interfaces = {
koti = [ "dhcp" "dns" "ssh" "web" ]; koti = [
gast = [ "dhcp" "dns" ]; "dhcp"
iot = [ "dhcp" "dns" ]; "dns"
cfg = [ "dhcp" "dns" ]; "ssh"
"tailscale*" = [ "ssh" "web" ]; "web"
];
gast = [
"dhcp"
"dns"
];
iot = [
"dhcp"
"dns"
];
cfg = [
"dhcp"
"dns"
];
"tailscale*" = [
"ssh"
"web"
];
}; };
allInterfaces = [ ]; allInterfaces = [ ];
}; };
@@ -146,7 +172,9 @@
onState = [ "routable" ]; onState = [ "routable" ];
script = '' script = ''
#!${pkgs.runtimeShell} #!${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,10 +215,11 @@
enable = true; enable = true;
settings = { settings = {
server = { server = {
interface = (lib.map interface =
(name: config.systemd.network.networks."30-${name}".dhcpServerConfig.DNS) (lib.map (name: config.systemd.network.networks."30-${name}".dhcpServerConfig.DNS) (
(lib.attrNames config.modules.vlans.networks) lib.attrNames config.modules.vlans.networks
) ++ [ ))
++ [
"127.0.0.1" "127.0.0.1"
"::1" "::1"
]; ];
@@ -224,7 +253,8 @@
"xiaomi_aqara" "xiaomi_aqara"
"shelly" "shelly"
]; ];
extraPackages = python3Packages: with python3Packages; [ extraPackages =
python3Packages: with python3Packages; [
gtts gtts
numpy numpy
]; ];

View File

@@ -1,38 +1,54 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }: {
config,
lib,
pkgs,
modulesPath,
...
}:
{ {
imports = imports = [
[ (modulesPath + "/installer/scan/not-detected.nix") (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.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-amd" ]; boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
fileSystems."/" = fileSystems."/" = {
{ device = "/dev/disk/by-uuid/f221c6a7-e05e-40dc-bc85-7970d7c8f22b"; device = "/dev/disk/by-uuid/f221c6a7-e05e-40dc-bc85-7970d7c8f22b";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=@" ]; options = [ "subvol=@" ];
}; };
fileSystems."/var/log" = fileSystems."/var/log" = {
{ device = "/dev/disk/by-uuid/f221c6a7-e05e-40dc-bc85-7970d7c8f22b"; device = "/dev/disk/by-uuid/f221c6a7-e05e-40dc-bc85-7970d7c8f22b";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=@var_log" ]; options = [ "subvol=@var_log" ];
}; };
fileSystems."/boot" = fileSystems."/boot" = {
{ device = "/dev/disk/by-uuid/14D2-F8F4"; device = "/dev/disk/by-uuid/14D2-F8F4";
fsType = "vfat"; fsType = "vfat";
options = [ "fmask=0022" "dmask=0022" ]; options = [
"fmask=0022"
"dmask=0022"
];
}; };
fileSystems."/swap" = fileSystems."/swap" = {
{ device = "/dev/disk/by-uuid/f221c6a7-e05e-40dc-bc85-7970d7c8f22b"; device = "/dev/disk/by-uuid/f221c6a7-e05e-40dc-bc85-7970d7c8f22b";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=@swap" ]; options = [ "subvol=@swap" ];
}; };

View File

@@ -2,7 +2,12 @@
# your system. Help is available in the configuration.nix(5) man page # your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running `nixos-help`). # and in the NixOS manual (accessible by running `nixos-help`).
{ config, pkgs, ssh, ... }: {
config,
pkgs,
ssh,
...
}:
let let
ipv4Address = "65.21.145.150"; ipv4Address = "65.21.145.150";
ipv6Address = "2a01:4f9:c011:9ac1::1"; ipv6Address = "2a01:4f9:c011:9ac1::1";
@@ -10,7 +15,10 @@ in
{ {
nix = { nix = {
settings = { settings = {
experimental-features = [ "nix-command" "flakes" ]; experimental-features = [
"nix-command"
"flakes"
];
auto-optimise-store = true; auto-optimise-store = true;
}; };
gc = { gc = {
@@ -95,7 +103,6 @@ in
# useXkbConfig = true; # use xkbOptions in tty. # useXkbConfig = true; # use xkbOptions in tty.
# }; # };
# Configure keymap in X11 # Configure keymap in X11
services.xserver.xkb.layout = "us"; services.xserver.xkb.layout = "us";
services.xserver.xkb.options = "eurosign:e,caps:escape"; services.xserver.xkb.options = "eurosign:e,caps:escape";

View File

@@ -1,34 +1,43 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }: {
config,
lib,
pkgs,
modulesPath,
...
}:
{ {
imports = imports = [
[
(modulesPath + "/profiles/qemu-guest.nix") (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.initrd.kernelModules = [ ];
boot.kernelModules = [ ]; boot.kernelModules = [ ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
fileSystems."/" = fileSystems."/" = {
{
device = "/dev/disk/by-uuid/f594ffbc-4553-42e4-8206-4d762c94b4c3"; device = "/dev/disk/by-uuid/f594ffbc-4553-42e4-8206-4d762c94b4c3";
fsType = "ext4"; fsType = "ext4";
}; };
fileSystems."/boot" = fileSystems."/boot" = {
{
device = "/dev/disk/by-uuid/46F1-18E3"; device = "/dev/disk/by-uuid/46F1-18E3";
fsType = "vfat"; fsType = "vfat";
options = [ "fmask=0077" "dmask=0077" ]; options = [
"fmask=0077"
"dmask=0077"
];
}; };
swapDevices = swapDevices = [ { device = "/dev/disk/by-uuid/d9955575-d4e0-4a49-a3c5-41f54110d12b"; } ];
[{ device = "/dev/disk/by-uuid/d9955575-d4e0-4a49-a3c5-41f54110d12b"; }];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # 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 # (the default) this is the recommended approach. When using systemd-networkd it's

View File

@@ -1,8 +1,15 @@
{ lib, config, ... }: { lib, config, ... }:
{ {
age.secrets = lib.listToAttrs age.secrets =
( lib.listToAttrs (
map (secret: { name = secret; value = { file = ../../secrets/${secret}.age; }; }) [ map
(secret: {
name = secret;
value = {
file = ../../secrets/${secret}.age;
};
})
[
"gotosocial" "gotosocial"
"immich" "immich"
"readeck" "readeck"
@@ -13,7 +20,8 @@
"octodns" "octodns"
"mealie" "mealie"
] ]
) // { )
// {
smtp-password = { smtp-password = {
file = ../../secrets/smtp-password.age; file = ../../secrets/smtp-password.age;
owner = owner =
@@ -24,11 +32,7 @@
}; };
hastebin-tokens = { hastebin-tokens = {
file = ../../secrets/hastebin-tokens.age; file = ../../secrets/hastebin-tokens.age;
owner = owner = if (config.services.hastebin.enable) then config.users.users.hastebin.name else "root";
if (config.services.hastebin.enable) then
config.users.users.hastebin.name
else
"root";
}; };
}; };
} }

View File

@@ -1,4 +1,9 @@
{ pkgs, config, inputs, ... }: {
pkgs,
config,
inputs,
...
}:
let let
immichDataDir = "/mnt/storage/immich"; immichDataDir = "/mnt/storage/immich";
syncthingDataDir = "/mnt/storage/syncthing"; syncthingDataDir = "/mnt/storage/syncthing";
@@ -45,7 +50,8 @@ in
hastebin = { hastebin = {
enable = true; enable = true;
subdomain = "bin"; subdomain = "bin";
renderers = with pkgs; renderers =
with pkgs;
let let
hl = rustPlatform.buildRustPackage { hl = rustPlatform.buildRustPackage {
name = "syntax-renderer"; name = "syntax-renderer";
@@ -143,7 +149,11 @@ in
smtp-port = smtp.port; smtp-port = smtp.port;
smtp-username = smtp.username; smtp-username = smtp.username;
smtp-from = smtp.from; smtp-from = smtp.from;
instance-languages = [ "de" "fi" "en" ]; instance-languages = [
"de"
"fi"
"en"
];
}; };
}; };

View File

@@ -2,7 +2,10 @@
{ {
nix = { nix = {
settings = { settings = {
experimental-features = [ "nix-command" "flakes" ]; experimental-features = [
"nix-command"
"flakes"
];
auto-optimise-store = true; auto-optimise-store = true;
}; };

View File

@@ -1,6 +1,11 @@
{ inputs, ... }: { inputs, ... }:
let let
inherit (inputs) lanzaboote nixos-hardware auto-cpufreq home-manager; inherit (inputs)
lanzaboote
nixos-hardware
auto-cpufreq
home-manager
;
in in
{ {
imports = [ imports = [

View File

@@ -1,20 +1,32 @@
# Do not modify this file! It was generated by nixos-generate-config # Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes # and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead. # to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, modulesPath, ... }: {
config,
lib,
pkgs,
modulesPath,
...
}:
{ {
imports = imports = [
[ (modulesPath + "/installer/scan/not-detected.nix") (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.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-amd" ]; boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
fileSystems."/" = fileSystems."/" = {
{ device = "/dev/disk/by-uuid/a331b669-f5c5-42f7-be58-434873c1b689"; device = "/dev/disk/by-uuid/a331b669-f5c5-42f7-be58-434873c1b689";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=@" ]; options = [ "subvol=@" ];
}; };
@@ -24,33 +36,35 @@
allowDiscards = true; allowDiscards = true;
}; };
fileSystems."/var/log" = fileSystems."/var/log" = {
{ device = "/dev/disk/by-uuid/a331b669-f5c5-42f7-be58-434873c1b689"; device = "/dev/disk/by-uuid/a331b669-f5c5-42f7-be58-434873c1b689";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=@var_log" ]; options = [ "subvol=@var_log" ];
}; };
fileSystems."/home" = fileSystems."/home" = {
{ device = "/dev/disk/by-uuid/a331b669-f5c5-42f7-be58-434873c1b689"; device = "/dev/disk/by-uuid/a331b669-f5c5-42f7-be58-434873c1b689";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=@home" ]; options = [ "subvol=@home" ];
}; };
fileSystems."/boot" = fileSystems."/boot" = {
{ device = "/dev/disk/by-uuid/01E6-6258"; device = "/dev/disk/by-uuid/01E6-6258";
fsType = "vfat"; fsType = "vfat";
}; };
fileSystems."/swap" = fileSystems."/swap" = {
{ device = "/dev/disk/by-uuid/a331b669-f5c5-42f7-be58-434873c1b689"; device = "/dev/disk/by-uuid/a331b669-f5c5-42f7-be58-434873c1b689";
fsType = "btrfs"; fsType = "btrfs";
options = [ "subvol=@swap" ]; options = [ "subvol=@swap" ];
}; };
swapDevices = [ { swapDevices = [
{
device = "/swap/swapfile"; device = "/swap/swapfile";
size = 64 * 1024; size = 64 * 1024;
} ]; }
];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking # 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 # (the default) this is the recommended approach. When using systemd-networkd it's

View File

@@ -1,4 +1,10 @@
{ pkgs, inputs, lib, config, ... }: {
pkgs,
inputs,
lib,
config,
...
}:
let let
pkgsUnstable = inputs.nixpkgs-unstable.legacyPackages.${pkgs.system}; pkgsUnstable = inputs.nixpkgs-unstable.legacyPackages.${pkgs.system};
in in

View File

@@ -3,7 +3,12 @@
networking.hostName = "radish"; networking.hostName = "radish";
time.timeZone = lib.mkForce null; # allow TZ to be set by desktop user time.timeZone = lib.mkForce null; # allow TZ to be set by desktop user
i18n.defaultLocale = "de_DE.UTF-8"; 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"; i18n.extraLocaleSettings.LANG = "en_US.UTF-8";
console = { console = {
font = "Lat2-Terminus16"; font = "Lat2-Terminus16";

View File

@@ -1,8 +1,14 @@
{ lib, ... }: { lib, ... }:
{ {
age.secrets = lib.listToAttrs age.secrets = lib.listToAttrs (
( map
map (secret: { name = secret; value = { file = ../../secrets/${secret}.age; }; }) [ (secret: {
name = secret;
value = {
file = ../../secrets/${secret}.age;
};
})
[
"borgbackup-radish" "borgbackup-radish"
] ]
); );

View File

@@ -11,7 +11,17 @@
isNormalUser = true; isNormalUser = true;
extraGroups = [ "wheel" ]; extraGroups = [ "wheel" ];
shell = pkgs.zsh; shell = pkgs.zsh;
subUidRanges = [{ startUid = 10000; count = 65536; }]; subUidRanges = [
subGidRanges = [{ startGid = 10000; count = 65536; }]; {
startUid = 10000;
count = 65536;
}
];
subGidRanges = [
{
startGid = 10000;
count = 65536;
}
];
}; };
} }

View File

@@ -1,19 +1,48 @@
{ lib, config, ... }: { lib, config, ... }:
let let
services = { services = {
ssh = { tcp = [ 22 ]; }; ssh = {
dhcp = { udp = [ 67 68 ]; }; tcp = [ 22 ];
dns = { udp = [ 53 853 ]; tcp = [ 53 853 ]; }; };
web = { tcp = [ 80 443 ]; }; dhcp = {
udp = [
67
68
];
};
dns = {
udp = [
53
853
];
tcp = [
53
853
];
};
web = {
tcp = [
80
443
];
};
}; };
rulesForServices = enabledServices: rulesForServices =
enabledServices:
lib.foldr lib.foldr
(service: { allowedUDPPorts, allowedTCPPorts }: { (
service:
{ allowedUDPPorts, allowedTCPPorts }:
{
allowedUDPPorts = allowedUDPPorts ++ services.${service}.udp or [ ]; allowedUDPPorts = allowedUDPPorts ++ services.${service}.udp or [ ];
allowedTCPPorts = allowedTCPPorts ++ services.${service}.tcp or [ ]; allowedTCPPorts = allowedTCPPorts ++ services.${service}.tcp or [ ];
}) }
{ allowedUDPPorts = [ ]; allowedTCPPorts = [ ]; } )
{
allowedUDPPorts = [ ];
allowedTCPPorts = [ ];
}
enabledServices; enabledServices;
cfg = config.modules.firewall; cfg = config.modules.firewall;

View File

@@ -1,4 +1,10 @@
{ lib, inputs, config, pkgs, ... }: {
lib,
inputs,
config,
pkgs,
...
}:
let let
cfg = config.services.dnote; cfg = config.services.dnote;
fqdn = "${cfg.subdomain}.${config.networking.domain}"; fqdn = "${cfg.subdomain}.${config.networking.domain}";
@@ -40,10 +46,8 @@ let
WebURL = "https://${fqdn}"; WebURL = "https://${fqdn}";
}; };
serializeEnvVar = value: serializeEnvVar =
if (lib.isBool value) value: if (lib.isBool value) then if value then "true" else "false" else toString value;
then if value then "true" else "false"
else toString value;
in in
{ {
options.services.dnote = { options.services.dnote = {
@@ -81,7 +85,9 @@ in
systemd.services.dnote = { systemd.services.dnote = {
enable = true; enable = true;
description = "Dnote server"; description = "Dnote server";
environment = lib.mapAttrs (_: value: serializeEnvVar value) (cfg.environment // immutableEnvironment); environment = lib.mapAttrs (_: value: serializeEnvVar value) (
cfg.environment // immutableEnvironment
);
after = [ "postgresql.service" ]; after = [ "postgresql.service" ];
requires = [ "postgresql.service" ]; requires = [ "postgresql.service" ];
serviceConfig = { serviceConfig = {
@@ -113,10 +119,12 @@ in
postgresql = { postgresql = {
enable = lib.mkDefault true; enable = lib.mkDefault true;
ensureDatabases = [ cfg.environment.DBName ]; ensureDatabases = [ cfg.environment.DBName ];
ensureUsers = [{ ensureUsers = [
{
name = cfg.user; name = cfg.user;
ensureDBOwnership = true; ensureDBOwnership = true;
}]; }
];
}; };
webserver = { webserver = {

View File

@@ -1,4 +1,9 @@
{ lib, pkgs, config, ... }: {
lib,
pkgs,
config,
...
}:
let let
types = { types = {
jwtSettings = { jwtSettings = {

View File

@@ -38,7 +38,8 @@ in
value.extraConfig = '' value.extraConfig = ''
rewrite ^.*$ https://${fqdn}/.well-known/${path} permanent; rewrite ^.*$ https://${fqdn}/.well-known/${path} permanent;
''; '';
}) [ })
[
"host-meta" "host-meta"
"webfinger" "webfinger"
"nodeinfo" "nodeinfo"

View File

@@ -50,10 +50,12 @@ in
postgresql = { postgresql = {
enable = lib.mkDefault true; enable = lib.mkDefault true;
ensureDatabases = [ "grafana" ]; ensureDatabases = [ "grafana" ];
ensureUsers = [{ ensureUsers = [
{
name = "grafana"; name = "grafana";
ensureDBOwnership = true; ensureDBOwnership = true;
}]; }
];
}; };
}; };
}; };

View File

@@ -1,4 +1,9 @@
{ lib, config, inputs, ... }: {
lib,
config,
inputs,
...
}:
let let
cfg = config.services.gtrackmap; cfg = config.services.gtrackmap;
fqdn = "${cfg.subdomain}.${config.networking.domain}"; fqdn = "${cfg.subdomain}.${config.networking.domain}";

View File

@@ -1,4 +1,9 @@
{ lib, config, inputs, ... }: {
lib,
config,
inputs,
...
}:
let let
cfg = config.services.hastebin; cfg = config.services.hastebin;
secrets = config.age.secrets; secrets = config.age.secrets;

View File

@@ -25,10 +25,12 @@ in
postgresql = { postgresql = {
enable = lib.mkDefault true; enable = lib.mkDefault true;
ensureDatabases = [ "mealie" ]; ensureDatabases = [ "mealie" ];
ensureUsers = [{ ensureUsers = [
{
name = "mealie"; name = "mealie";
ensureDBOwnership = true; ensureDBOwnership = true;
}]; }
];
}; };
}; };
}; };

View File

@@ -1,4 +1,9 @@
{ pkgs, lib, config, ... }: {
pkgs,
lib,
config,
...
}:
let let
cfg = config.services.octodns; cfg = config.services.octodns;
secrets = config.age.secrets; secrets = config.age.secrets;
@@ -125,29 +130,39 @@ let
yamlFormat = pkgs.formats.yaml { }; yamlFormat = pkgs.formats.yaml { };
zoneFile = yamlFormat.generate "octodns-zone" zoneFile = yamlFormat.generate "octodns-zone" (
( lib.filterAttrs (_: records: (lib.length records) > 0) (
lib.filterAttrs (_: records: (lib.length records) > 0) lib.mapAttrs (
(lib.mapAttrs _: types:
(_: types:
lib.filter lib.filter
({ values ? [ ], value ? null, ... }: (lib.length values) > 0 || !(builtins.isNull value)) (
(lib.mapAttrsToList {
(type: { ttl, ... }@options: values ? [ ],
if (type == "CNAME") value ? null,
then ...
}:
(lib.length values) > 0 || !(builtins.isNull value)
)
(
lib.mapAttrsToList (
type:
{ ttl, ... }@options:
if (type == "CNAME") then
let let
inherit (options) target toRoot; inherit (options) target toRoot;
value = if toRoot then "${config.networking.domain}." else target; value = if toRoot then "${config.networking.domain}." else target;
in in
{ inherit type ttl value; } {
inherit type ttl value;
}
else else
{ inherit type ttl; inherit (options) values; } {
inherit type ttl;
inherit (options) values;
}
) types
) )
types ) cfg.records
)
)
cfg.records
) )
); );
@@ -155,7 +170,6 @@ let
"${config.networking.domain}.yaml" = zoneFile; "${config.networking.domain}.yaml" = zoneFile;
}; };
configFile = yamlFormat.generate "octodns-config.yaml" { configFile = yamlFormat.generate "octodns-config.yaml" {
providers = { providers = {
config = { config = {

View File

@@ -1,4 +1,10 @@
{ lib, inputs, config, pkgs, ... }: {
lib,
inputs,
config,
pkgs,
...
}:
let let
cfg = config.services.readeck; cfg = config.services.readeck;
secrets = config.age.secrets; secrets = config.age.secrets;
@@ -40,10 +46,12 @@ in
postgresql = { postgresql = {
enable = lib.mkDefault true; enable = lib.mkDefault true;
ensureDatabases = [ "readeck" ]; ensureDatabases = [ "readeck" ];
ensureUsers = [{ ensureUsers = [
{
name = "readeck"; name = "readeck";
ensureDBOwnership = true; ensureDBOwnership = true;
}]; }
];
}; };
}; };
}; };

View File

@@ -36,10 +36,12 @@ in
postgresql = { postgresql = {
enable = lib.mkDefault true; enable = lib.mkDefault true;
ensureDatabases = [ "vaultwarden" ]; ensureDatabases = [ "vaultwarden" ];
ensureUsers = [{ ensureUsers = [
{
name = "vaultwarden"; name = "vaultwarden";
ensureDBOwnership = true; ensureDBOwnership = true;
}]; }
];
}; };
}; };
}; };

View File

@@ -69,8 +69,10 @@ in
virtualHosts = tailscaleAuthVhosts; virtualHosts = tailscaleAuthVhosts;
}; };
virtualHosts = lib.mapAttrs virtualHosts = lib.mapAttrs (
(_: { proxyBuffering, locations, ... }: { _:
{ proxyBuffering, locations, ... }:
{
forceSSL = true; forceSSL = true;
enableACME = true; enableACME = true;
http2 = true; http2 = true;
@@ -79,26 +81,33 @@ in
(lib.optionalString (!proxyBuffering) "proxy_buffering off;") (lib.optionalString (!proxyBuffering) "proxy_buffering off;")
"charset utf-8;" "charset utf-8;"
]; ];
locations = lib.mapAttrs locations = lib.mapAttrs (
(_: { proxyPort, extraConfig }: lib.mergeAttrsList [ _:
{ proxyPort, extraConfig }:
lib.mergeAttrsList [
{ inherit extraConfig; } { inherit extraConfig; }
(if (lib.isInt proxyPort) then { (
if (lib.isInt proxyPort) then
{
proxyWebsockets = true; proxyWebsockets = true;
proxyPass = "http://localhost:${toString proxyPort}"; proxyPass = "http://localhost:${toString proxyPort}";
} else { }) }
]) else
locations; { }
}) )
cfg.vHosts; ]
) locations;
}
) cfg.vHosts;
}; };
octodns.records = lib.filterAttrs (name: _: name != config.networking.domain) ( octodns.records = lib.filterAttrs (name: _: name != config.networking.domain) (
lib.mapAttrs' lib.mapAttrs' (fqdn: _: {
(fqdn: _: {
name = lib.removeSuffix ".${config.networking.domain}" fqdn; name = lib.removeSuffix ".${config.networking.domain}" fqdn;
value = { CNAME.toRoot = true; }; value = {
}) CNAME.toRoot = true;
cfg.vHosts };
}) cfg.vHosts
); );
}; };

View File

@@ -1,4 +1,10 @@
{ pkgs, inputs, config, lib, ... }: {
pkgs,
inputs,
config,
lib,
...
}:
let let
cfg = config.services.workout-sync; cfg = config.services.workout-sync;
fqdn = "${cfg.subdomain}.${config.networking.domain}"; fqdn = "${cfg.subdomain}.${config.networking.domain}";

View File

@@ -1,4 +1,10 @@
{ pkgs, config, lib, inputs, ... }: {
pkgs,
config,
lib,
inputs,
...
}:
let let
cfg = config.services.workout-tracker; cfg = config.services.workout-tracker;
fqdn = "${cfg.subdomain}.${config.networking.domain}"; fqdn = "${cfg.subdomain}.${config.networking.domain}";

View File

@@ -1,4 +1,9 @@
{ lib, config, pkgs, ... }: {
lib,
config,
pkgs,
...
}:
let let
types = { types = {
mount = lib.types.submodule { mount = lib.types.submodule {
@@ -25,17 +30,17 @@ let
cfg = config.modules.storageBoxMounts; cfg = config.modules.storageBoxMounts;
secrets = config.age.secrets; secrets = config.age.secrets;
mountOptions = { uid, gid, ... }: [ mountOptions =
{ uid, gid, ... }:
[
"x-systemd.automount" "x-systemd.automount"
"auto" "auto"
"x-systemd.device-timeout=5s" "x-systemd.device-timeout=5s"
"x-systemd.mount-timeout=5s" "x-systemd.mount-timeout=5s"
"credentials=${secrets.storage-box-credentials.path}" "credentials=${secrets.storage-box-credentials.path}"
] ++ ( ]
if (uid != null) then [ "uid=${toString uid}" ] else [ ] ++ (if (uid != null) then [ "uid=${toString uid}" ] else [ ])
) ++ ( ++ (if (gid != null) then [ "gid=${toString gid}" ] else [ ]);
if (gid != null) then [ "gid=${toString gid}" ] else [ ]
);
in in
{ {
options.modules.storageBoxMounts = lib.mkOption { options.modules.storageBoxMounts = lib.mkOption {
@@ -44,13 +49,15 @@ in
}; };
config = { config = {
fileSystems = lib.mapAttrs fileSystems = lib.mapAttrs (
(_: { path, user, ... }@options: { _:
{ path, user, ... }@options:
{
device = "//${user}.your-storagebox.de${path}"; device = "//${user}.your-storagebox.de${path}";
fsType = "cifs"; fsType = "cifs";
options = mountOptions options; options = mountOptions options;
}) }
cfg; ) cfg;
environment.systemPackages = lib.mkIf ((lib.length (lib.attrNames cfg)) > 0) [ pkgs.cifs-utils ]; environment.systemPackages = lib.mkIf ((lib.length (lib.attrNames cfg)) > 0) [ pkgs.cifs-utils ];
}; };

View File

@@ -50,10 +50,27 @@ let
}; };
cfg = config.modules.vlans; cfg = config.modules.vlans;
vlans = lib.mapAttrsToList (attrName: { name ? attrName, ... }@vlan: ({ inherit name; } // vlan)) cfg.networks; vlans = lib.mapAttrsToList (
vlanAttrs = lib.listToAttrs (lib.map ({ name, ... }@value: { inherit name value; }) vlans); attrName:
{
name ? attrName,
...
}@vlan:
({ inherit name; } // vlan)
) cfg.networks;
vlanAttrs = lib.listToAttrs (
lib.map (
{ name, ... }@value:
{
inherit name value;
}
) vlans
);
buildNetdev = name: { id, ... }: { buildNetdev =
name:
{ id, ... }:
{
name = "20-${name}"; name = "20-${name}";
value = { value = {
netdevConfig = { netdevConfig = {
@@ -61,7 +78,9 @@ let
Kind = "vlan"; Kind = "vlan";
MACAddress = "00:0d:b9:49:d2:${toString id}"; MACAddress = "00:0d:b9:49:d2:${toString id}";
}; };
vlanConfig = { Id = id; }; vlanConfig = {
Id = id;
};
}; };
}; };
@@ -71,7 +90,15 @@ let
Address=${address} Address=${address}
''; '';
buildNetwork = name: { id, ipv6, staticLeases, ... }: { buildNetwork =
name:
{
id,
ipv6,
staticLeases,
...
}:
{
name = "30-${name}"; name = "30-${name}";
value = { value = {
matchConfig = { matchConfig = {
@@ -108,25 +135,39 @@ let
''; '';
bridgeNetDev = bridgeNetDev =
if (cfg.bridge.enable) then { if (cfg.bridge.enable) then
{
"${cfg.bridge.netdev}".bridgeConfig = { "${cfg.bridge.netdev}".bridgeConfig = {
VLANFiltering = true; VLANFiltering = true;
DefaultPVID = cfg.bridge.pvid; DefaultPVID = cfg.bridge.pvid;
}; };
} else { }; }
else
{ };
bridgeBindNetwork = bridgeBindNetwork =
if (cfg.bridge.enable) then { if (cfg.bridge.enable) then
{
${cfg.bridge.bindNetwork}.extraConfig = bridgeVLANConfig; ${cfg.bridge.bindNetwork}.extraConfig = bridgeVLANConfig;
} else { }; }
else
{ };
bridgeNetwork = bridgeNetwork =
if (cfg.bridge.enable) then { if (cfg.bridge.enable) then
{
"${cfg.bridge.network}" = { "${cfg.bridge.network}" = {
vlan = lib.map ({ name, ... }: name) vlans; vlan = lib.map ({ name, ... }: name) vlans;
bridgeVLANs = lib.map ({ id, ... }: { VLAN = id; }) vlans; bridgeVLANs = lib.map (
{ id, ... }:
{
VLAN = id;
}
) vlans;
}; };
} else { }; }
else
{ };
netdevs = lib.mergeAttrsList [ netdevs = lib.mergeAttrsList [
(lib.mapAttrs' buildNetdev vlanAttrs) (lib.mapAttrs' buildNetdev vlanAttrs)

View File

@@ -1,13 +1,20 @@
let let
moco = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDRXRJUwX98l2Vl4bUZdyHGhLjlf1RGAA5VCa4dmEJdU"; moco = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDRXRJUwX98l2Vl4bUZdyHGhLjlf1RGAA5VCa4dmEJdU";
jokke = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIC7UDcuAbvp8mXIPl4M8MkM1X78YfXm50SLmSY3boL9Z"; jokke = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIC7UDcuAbvp8mXIPl4M8MkM1X78YfXm50SLmSY3boL9Z";
users = [ moco jokke ]; users = [
moco
jokke
];
apu = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICAZkIuXtpP9a9bHkBl+MJI//q3ClMqzx03Rd/Xe4rjc"; apu = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICAZkIuXtpP9a9bHkBl+MJI//q3ClMqzx03Rd/Xe4rjc";
freun-dev = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEvCSjIjipog1Xf9mPc683r5VSGSjVc8v1UZg5VrbbxM"; freun-dev = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIEvCSjIjipog1Xf9mPc683r5VSGSjVc8v1UZg5VrbbxM";
radish = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIQ0fy4n3yyD64+g55eZazeI5g9FurJnlC6fRiOXbbks"; radish = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIQ0fy4n3yyD64+g55eZazeI5g9FurJnlC6fRiOXbbks";
hosts = [ apu freun-dev radish ]; hosts = [
apu
freun-dev
radish
];
in in
{ {
"gotosocial.age".publicKeys = users ++ [ freun-dev ]; "gotosocial.age".publicKeys = users ++ [ freun-dev ];