summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md10
-rw-r--r--flake.nix4
-rw-r--r--home/default.nix30
-rw-r--r--hosts/ahmed/configuration.nix17
-rw-r--r--hosts/ahmed/home/default.nix9
-rw-r--r--hosts/common.nix81
-rw-r--r--hosts/muhammed/configuration.nix21
-rw-r--r--hosts/muhammed/home/default.nix14
-rw-r--r--hosts/muhammed/home/misc-utils/default.nix12
-rw-r--r--hosts/muhammed/home/neovim/default.nix8
-rw-r--r--hosts/muhammed/home/neovim/filetype.nix14
-rw-r--r--hosts/muhammed/home/neovim/lsp.nix148
-rw-r--r--shared/home-manager/C/default.nix22
-rw-r--r--shared/home-manager/development-full/default.nix15
-rw-r--r--shared/home-manager/development-minimal/default.nix (renamed from hosts/muhammed/home/dev-utils/default.nix)45
-rw-r--r--shared/home-manager/git/aliases.nix (renamed from home/git/aliases.nix)0
-rw-r--r--shared/home-manager/git/default.nix (renamed from home/git/default.nix)10
-rw-r--r--shared/home-manager/git/ignore.nix (renamed from home/git/ignore.nix)0
-rw-r--r--shared/home-manager/iterm2/auto_theme.py (renamed from hosts/muhammed/home/iterm2/auto_theme.py)0
-rw-r--r--shared/home-manager/iterm2/default.nix (renamed from hosts/muhammed/home/iterm2/default.nix)0
-rw-r--r--shared/home-manager/javascript/default.nix54
-rw-r--r--shared/home-manager/neovim/completion.nix (renamed from home/neovim/completion.nix)0
-rw-r--r--shared/home-manager/neovim/default.nix (renamed from home/neovim/default.nix)1
-rw-r--r--shared/home-manager/neovim/editing-plugins.nix (renamed from home/neovim/editing-plugins.nix)0
-rw-r--r--shared/home-manager/neovim/init.vim (renamed from home/neovim/init.vim)0
-rw-r--r--shared/home-manager/neovim/lsp.nix59
-rw-r--r--shared/home-manager/networking-utils/default.nix (renamed from home/networking-utils/default.nix)0
-rw-r--r--shared/home-manager/nix/default.nix14
-rw-r--r--shared/home-manager/noweb/default.nix (renamed from hosts/muhammed/home/noweb/default.nix)4
-rw-r--r--shared/home-manager/python/default.nix16
-rw-r--r--shared/home-manager/qbittorrent/default.nix (renamed from hosts/muhammed/home/qbittorrent/default.nix)0
-rw-r--r--shared/home-manager/rust/default.nix13
-rw-r--r--shared/home-manager/shell-utils/default.nix (renamed from home/shell-utils/default.nix)0
-rw-r--r--shared/home-manager/svelte/default.nix15
-rw-r--r--shared/home-manager/zsh/default.nix (renamed from home/zsh/default.nix)0
-rw-r--r--shared/home-manager/zsh/editing.nix (renamed from home/zsh/editing.nix)0
-rw-r--r--shared/home-manager/zsh/plugins.nix (renamed from home/zsh/plugins.nix)0
-rw-r--r--shared/nixos/cloudflare-proxy/default.nix (renamed from hosts/ahmed/cloudflare-proxy/default.nix)0
-rw-r--r--shared/nixos/common-hm-settings/default.nix27
-rw-r--r--shared/nixos/common-nix-settings/default.nix60
-rw-r--r--shared/nixos/common-shell-settings/default.nix44
41 files changed, 401 insertions, 366 deletions
diff --git a/README.md b/README.md
index a077538..8774c82 100644
--- a/README.md
+++ b/README.md
@@ -15,12 +15,6 @@ Most files also contain a little comment at the top, explaining what it does.
* `/hosts/ahmed/`: Mediocre home-server which runs most of my self-hosted services.
* `/hosts/muhammed/`: My personal laptop used for development.
* `/hosts/fatima/`: NAS
- * `/hosts/common.nix`: Common configuration options shared by all hosts.
- Every `configuration.nix` imports this file. It contains basic stuff like
- making `zsh` the default shell.
-* `/home/`: Contains the part of my [home-manager] configuration that is common
- to all hosts. This includes basic stuff like `zsh` plugins. It is matched by
- `/hosts/<host>/home` which contains host-specific home-manager configuration.
* `/modules/`: Contains reusable modules that are configurable using [NixOS's
module system][mod-sys] and are exported for other consumers via `flake.nix`.
* `/modules/nixos/`: Every subdirectory in this directory contains a NixOS
@@ -33,9 +27,11 @@ Most files also contain a little comment at the top, explaining what it does.
versions and fix bugs used in the repo. These are exported as
`outputs.overlays.modifications` in `flake.nix`.
* `/pkgs/`: Contains Nix packages which I haven't upstreamed into `nixpkgs` for
- some reason. `/pkgs/default.nix` lists out every package. These are also
+ some reason. `/overlays/additions.nix` lists out every package. These are also
exported in `flake.nix`. An overlay that adds all new packages is also
available as `outputs.overlays.additions`.
+* `/shared/`: This can somewhat be thought of like `nixos/modules/profiles` in
+ nixpkgs; bits of configuration which are imported to be used.
* `/secrets`: All files which can't be added to the world-readable Nix-store
are managed by [agenix].
* `/secrets/secrets.nix`: The only Nix file which isn't (indirectly) imported
diff --git a/flake.nix b/flake.nix
index bac1829..65db1a5 100644
--- a/flake.nix
+++ b/flake.nix
@@ -71,8 +71,6 @@
home-manager.darwinModules.home-manager
agenix.darwinModules.default
./hosts/muhammed/configuration.nix
- ./hosts/common.nix
- ./home
]
++ builtins.attrValues (import ./modules/darwin);
};
@@ -89,8 +87,6 @@
push-notification-api.nixosModules.default
webhook-listener.nixosModules.default
./hosts/ahmed/configuration.nix
- ./hosts/common.nix
- ./home
]
++ builtins.attrValues (import ./modules/nixos);
};
diff --git a/home/default.nix b/home/default.nix
deleted file mode 100644
index fde81b7..0000000
--- a/home/default.nix
+++ /dev/null
@@ -1,30 +0,0 @@
-{
- flakeInputs,
- flakeOutputs,
- metadata,
- ...
-}: {
- # Use the flake input pkgs so Home Manager configuration can share overlays
- # etc. with the rest of the configuration.
- home-manager.useGlobalPkgs = true;
-
- # Pass special arguments from flake.nix further down the chain. I really hate
- # this split module system.
- home-manager.extraSpecialArgs = {inherit flakeInputs flakeOutputs metadata;};
-
- # OKAY FUCK THIS SHIT. THERE IS ONE USER. IT IS ME. LINUS. I WILL ADD
- # MULTIUSER SUPPORT IF IT EVER BECOMES A REQUIREMENT.
- home-manager.users.linus = {
- imports =
- [
- ./neovim
- ./zsh
- ./git
- ./networking-utils
- ./shell-utils
- ]
- ++ builtins.attrValues flakeOutputs.homeModules;
-
- xdg.enable = true;
- };
-}
diff --git a/hosts/ahmed/configuration.nix b/hosts/ahmed/configuration.nix
index 86e7e60..81fc77a 100644
--- a/hosts/ahmed/configuration.nix
+++ b/hosts/ahmed/configuration.nix
@@ -3,13 +3,16 @@
{
config,
pkgs,
- flakeInputs,
...
}: {
imports = [
./hardware-configuration.nix
- ./cloudflare-proxy
+ ../../shared/nixos/cloudflare-proxy
+ ../../shared/nixos/common-nix-settings
+ ../../shared/nixos/common-shell-settings
+ ../../shared/nixos/common-hm-settings
+
./duksebot
./git.linus.onl
./hellohtml.linus.onl
@@ -17,7 +20,6 @@
./nofitications.linus.onl
./ssh
./torrenting
- ./home
./remote-builder
];
@@ -29,6 +31,15 @@
};
users.mutableUsers = false;
+ home-manager.users.linus = {
+ imports = [
+ # Despite this being a "just a server" it is also the only x86_64-linux
+ # host I have access to, so in practice I end up using it for development
+ # sometimes.
+ ../../shared/home-manager/development-minimal
+ ];
+ };
+
# Use the systemd-boot EFI boot loader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
diff --git a/hosts/ahmed/home/default.nix b/hosts/ahmed/home/default.nix
deleted file mode 100644
index a031e96..0000000
--- a/hosts/ahmed/home/default.nix
+++ /dev/null
@@ -1,9 +0,0 @@
-# Here we extend the HM user defined in `home/default.nix`. All the global HM
-# stuff is defined in there. The only imports here are specific to this host.
-{...}: {
- home-manager.users.linus = {
- imports = [
- # empty for now
- ];
- };
-}
diff --git a/hosts/common.nix b/hosts/common.nix
deleted file mode 100644
index 551fa47..0000000
--- a/hosts/common.nix
+++ /dev/null
@@ -1,81 +0,0 @@
-# Shared configuraion regardless of hosts.
-{
- pkgs,
- options,
- flakeInputs,
- flakeOutputs,
- ...
-}: {
- # Enable de facto stable features.
- nix.settings.experimental-features = ["nix-command" "flakes"];
-
- nixpkgs.overlays = [
- # Use local overlays.
- flakeOutputs.overlays.additions
- flakeOutputs.overlays.modifications
-
- # Add unstable nixpkgs.
- (final: prev: {unstable = flakeInputs.nixpkgs-unstable.legacyPackages.${pkgs.system};})
- ];
-
- # I'm not *that* vegan.
- nixpkgs.config.allowUnfree = true;
-
- nix.nixPath = [
- # Use overlays from this repo for building system configuration as well as
- # system-wide.
- #
- # See: https://nixos.wiki/wiki/Overlays#Using_nixpkgs.overlays_from_configuration.nix_as_.3Cnixpkgs-overlays.3E_in_your_NIX_PATH
- "nixpkgs-overlays=${flakeInputs.self}/overlays/compat.nix"
-
- # For consistency, use the same version of nixpkgs everywhere. This DOES
- # however make the system closure depend on the nixpkgs sources which would
- # be undesirable if I didn't already use all my systems interactively for
- # Nix stuff.
- "nixpkgs=${flakeInputs.nixpkgs}"
- "nixpkgs-unstable=${flakeInputs.nixpkgs-unstable}"
- ];
-
- # Set ZSH as the shell.
- # https://nixos.wiki/wiki/Command_Shell#Changing_default_shelltrue
- programs.zsh.enable = true;
- environment.shells = [pkgs.zsh];
- users.users.linus.shell = pkgs.zsh;
-
- # Very basic system administration tools.
- environment.systemPackages = with pkgs; [
- tree
- gh
- vim
- flakeInputs.comma.packages.${system}.default
- nix-index
- curl
- moreutils
- flakeInputs.agenix.packages.${system}.default
- jq
- ];
-
- # Aliases that are burned into my muscle memory.
- environment.shellAliases = {
- "mv" = "mv -i";
- "rm" = "rm -i";
- "cp" = "cp -i";
- "ls" = "ls -F -G -A --color=auto";
- "grep" = "grep --color=auto";
- "file" = "file --no-dereference";
- "tree" = "tree --dirsfirst";
-
- # See: https://github.com/NixOS/nix/issues/5858
- "nix" = "nix --print-build-logs";
-
- ".." = "cd ../";
- "..." = "cd ../../";
- "...." = "cd ../../../";
- "....." = "cd ../../../../";
- "......" = "cd ../../../../../";
- "......." = "cd ../../../../../../";
- "........" = "cd ../../../../../../../";
- "........." = "cd ../../../../../../../../";
- ".........." = "cd ../../../../../../../../../";
- };
-}
diff --git a/hosts/muhammed/configuration.nix b/hosts/muhammed/configuration.nix
index cb2216e..81ebca0 100644
--- a/hosts/muhammed/configuration.nix
+++ b/hosts/muhammed/configuration.nix
@@ -6,7 +6,10 @@
...
}: {
imports = [
- ./home
+ ../../shared/nixos/common-shell-settings
+ ../../shared/nixos/common-nix-settings
+ ../../shared/nixos/common-hm-settings
+
./remote-builders
];
@@ -20,12 +23,26 @@
# Use the Nix daemon.
services.nix-daemon.enable = true;
- # Set up main account with ZSH.
+ # Set up main account.
users.users.linus = {
description = "Personal user account";
home = "/Users/linus";
};
+ home-manager.users.linus = {
+ imports = [
+ ../../shared/home-manager/development-full
+ ../../shared/home-manager/qbittorrent
+ ../../shared/home-manager/iterm2
+ ({pkgs, ...}: {
+ home.packages = with pkgs; [
+ imagemagick
+ ffmpeg_6-full
+ ];
+ })
+ ];
+ };
+
# Should match containing folder.
networking.hostName = "muhammed";
diff --git a/hosts/muhammed/home/default.nix b/hosts/muhammed/home/default.nix
deleted file mode 100644
index 9eb78bc..0000000
--- a/hosts/muhammed/home/default.nix
+++ /dev/null
@@ -1,14 +0,0 @@
-# Here we extend the HM user defined in `home/default.nix`. All the global HM
-# stuff is defined in there.
-{...}: {
- home-manager.users.linus = {
- imports = [
- ./iterm2
- ./noweb
- ./neovim
- ./dev-utils
- ./misc-utils
- ./qbittorrent
- ];
- };
-}
diff --git a/hosts/muhammed/home/misc-utils/default.nix b/hosts/muhammed/home/misc-utils/default.nix
deleted file mode 100644
index 5065a59..0000000
--- a/hosts/muhammed/home/misc-utils/default.nix
+++ /dev/null
@@ -1,12 +0,0 @@
-# This part (module) of my home manager configuration adds some random utilities.
-{pkgs, ...}: let
- # Set some default options
- xkcdpass' = pkgs.writeShellScriptBin "xkcdpass" ''
- ${pkgs.xkcdpass}/bin/xkcdpass --delimiter \'\' --capitalize --numwords=4 "$@"
- '';
-in {
- home.packages = [
- # Generating passwords
- xkcdpass'
- ];
-}
diff --git a/hosts/muhammed/home/neovim/default.nix b/hosts/muhammed/home/neovim/default.nix
deleted file mode 100644
index 8efb97d..0000000
--- a/hosts/muhammed/home/neovim/default.nix
+++ /dev/null
@@ -1,8 +0,0 @@
-# Once again we extend the global configuration defined in `home/neovim/` with
-# some stuff specific to this host (mainly development stuff).
-{...}: {
- imports = [
- ./lsp.nix
- ./filetype.nix
- ];
-}
diff --git a/hosts/muhammed/home/neovim/filetype.nix b/hosts/muhammed/home/neovim/filetype.nix
deleted file mode 100644
index 73d5f5a..0000000
--- a/hosts/muhammed/home/neovim/filetype.nix
+++ /dev/null
@@ -1,14 +0,0 @@
-# This module configures various syntax/filetype plugins for Neovim.
-{pkgs, ...}: {
- programs.neovim.plugins = with pkgs;
- with vimPlugins; [
- # Filetype plugins
- vim-nix
- vim-noweb
- vim-janet
- nim-vim
- vim-crystal
- vim-svelte
- gleam-vim
- ];
-}
diff --git a/hosts/muhammed/home/neovim/lsp.nix b/hosts/muhammed/home/neovim/lsp.nix
deleted file mode 100644
index c301bb0..0000000
--- a/hosts/muhammed/home/neovim/lsp.nix
+++ /dev/null
@@ -1,148 +0,0 @@
-# This module sets up LSP server configurations for Neovim.
-{pkgs, ...}: {
- programs.neovim.plugins = [
- {
- plugin = pkgs.vimPlugins.nvim-lspconfig;
- type = "lua";
- config = ''
- local lspconfig = require("lspconfig")
- local util = require("lspconfig.util")
-
- -- Mappings.
- -- See `:help vim.diagnostic.*` for documentation on any of the below functions
- local opts = { noremap=true, silent=true }
- vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, opts)
- vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
- vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
- vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, opts)
-
- -- Use an on_attach function to only map the following keys
- -- after the language server attaches to the current buffer
- local on_attach = function(client, bufnr)
- -- Enable completion triggered by <c-x><c-o>
- vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-
- -- Mappings.
- -- See `:help vim.lsp.*` for documentation on any of the below functions
- local bufopts = { noremap=true, silent=true, buffer=bufnr }
- vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
- vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
- vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
- vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
- vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
- vim.keymap.set('n', '<leader>wa', vim.lsp.buf.add_workspace_folder, bufopts)
- vim.keymap.set('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
- vim.keymap.set('n', '<leader>wl', function()
- print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
- end, bufopts)
- vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, bufopts)
- vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, bufopts)
- vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, bufopts)
- vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
- vim.keymap.set('n', '<leader>f', function() vim.lsp.buf.format { async = true } end, bufopts)
- vim.keymap.set('n', '<leader>s', function() vim.cmd[[ClangdSwitchSourceHeader]] end, bufopts)
- end
-
- -- Use a loop to conveniently call 'setup' on multiple servers and
- -- map buffer local keybindings when the language server attaches
- local servers = {
- pyright = {
- cmd = { "${pkgs.pyright}/bin/pyright-langserver", "--stdio" },
- },
- nixd = {
- cmd = { "${pkgs.nixd}/bin/nixd" },
- },
- denols = {
- init_options = {
- enable = true,
- unstable = true,
- lint = true,
- nodeModulesDir = true,
- },
- cmd = { "${pkgs.unstable.deno}/bin/deno", "lsp" },
- root_dir = function(startpath)
- if util.find_package_json_ancestor(startpath) then
- -- This is a Node project; let ts_ls handle this one.
- -- This exactly mirrors how typescript-langauge-server yields to this server for Deno projects.
- return nil
- else
- -- Otherwise, we try to find the root or
- -- default to the current directory.
- return util.root_pattern("deno.json", "deno.jsonc", ".git")(startpath)
- or util.path.dirname(startpath)
- end
- end,
- },
- ts_ls = {
- cmd = { "${pkgs.nodePackages_latest.typescript-language-server}/bin/typescript-language-server", "--stdio" },
- root_dir = function(startpath)
- local find_deno_root_dir = util.root_pattern("deno.json", "deno.jsonc")
- if find_deno_root_dir(startpath) then
- -- This is a Deno project; let deno-lsp handle this one.
- -- This exactly mirrors how deno-lsp yields to this server for Node projects.
- return nil
- else
- -- Otherwise fall back to the usual resolution method.
- -- See: https://github.com/neovim/nvim-lspconfig/blob/056f569f71e4b726323b799b9cfacc53653bceb3/lua/lspconfig/server_configurations/ts_ls.lua#L15
- return util.root_pattern("tsconfig.json", "jsconfig.json", "package.json", ".git")(startpath)
- end
- end,
- -- We also have to disallow starting in without a root directory, as otherwise returning
- -- nil from find_root will just cause the LSP to be spawned in single file mode instead of yielding to deno-lsp.
- --
- -- This has the side effect that Deno LSP will be preferred in a single file context which is what we want!
- --
- -- See: https://github.com/neovim/nvim-lspconfig/blob/056f569f71e4b726323b799b9cfacc53653bceb3/lua/lspconfig/manager.lua#L281-L286
- single_file_support = false,
- },
- clangd = {
- cmd = { "${pkgs.clang-tools}/bin/clangd" },
- },
- nimls = {
- cmd = { "${pkgs.nimlsp}/bin/nimlsp" },
- },
- rust_analyzer = {
- cmd = { "${pkgs.rust-analyzer}/bin/rust-analyzer" },
- },
- rust_analyzer = {
- cmd = { "${pkgs.rust-analyzer}/bin/rust-analyzer" },
- },
- gleam = {
- cmd = { "${pkgs.unstable.gleam}/bin/gleam", "lsp" },
- },
- svelte = {
- cmd = { "${pkgs.nodePackages_latest.svelte-language-server}/bin/svelteserver", "--stdio" },
- root_dir = util.root_pattern("package.json", ".git", "deno.json", "deno.jsonc"),
- },
- };
- for server, config in pairs(servers) do
- -- set common options
- config.on_attach = on_attach;
- config.debounce_text_changes = 150;
-
- lspconfig[server].setup(config)
- end
- '';
- }
- ];
-}
-# I spent like an hour writing this, only to find it was a pretty bad idea.
-#
-# nixToLua = s:
-# if builtins.isAttrs s then
-# let
-# renderAttr = name: value: "[ [==========[" + name + "]==========] ] = " + (nixToLua value);
-# attrsList = map (name: renderAttr name s.${name}) (lib.attrNames s);
-# attrsListStr = lib.concatStringsSep ", " attrsList;
-# in
-# "{ ${attrsListStr} }"
-# else if builtins.isList s then
-# "{ " + (lib.concatStringsSep ", " (map nixToLua s)) + " }"
-# else if builtins.isString s then
-# # Oh boy I sure hope `s` doesn't contain "]==========]".
-# "[==========[" + s + "]==========]"
-# else if builtins.isInt s || builtins.isFloat s then
-# toString s
-# else
-# throw "Cannot convert ${builtins.typeOf s} to Lua value!";
-
diff --git a/shared/home-manager/C/default.nix b/shared/home-manager/C/default.nix
new file mode 100644
index 0000000..b4d42a5
--- /dev/null
+++ b/shared/home-manager/C/default.nix
@@ -0,0 +1,22 @@
+# This module configures development tools for C.
+{pkgs, ...}: {
+ home.packages = with pkgs; [
+ clang
+ cscript
+ ];
+
+ programs.neovim.extraLuaConfig = ''
+ require("lspconfig")["clangd"].setup({
+ cmd = { "${pkgs.clang-tools}/bin/clangd", "--background-index", "--clang-tidy" },
+ on_attach = function(_, bufnr)
+ vim.keymap.set("n", "<leader>s", function()
+ vim.cmd [[ClangdSwitchSourceHeader]]
+ end, {
+ noremap=true,
+ silent=true,
+ buffer=bufnr,
+ })
+ end,
+ })
+ '';
+}
diff --git a/shared/home-manager/development-full/default.nix b/shared/home-manager/development-full/default.nix
new file mode 100644
index 0000000..162edff
--- /dev/null
+++ b/shared/home-manager/development-full/default.nix
@@ -0,0 +1,15 @@
+# This module pulls in everything development related. Including it will give a
+# fully featured development environment with all the bells and whistles. It
+# will also explode the closure size, so this shouldn't be included on every
+# host!
+{...}: {
+ imports = [
+ ../C
+ ../development-minimal
+ ../javascript
+ ../nix
+ ../noweb
+ ../python
+ ../rust
+ ];
+}
diff --git a/hosts/muhammed/home/dev-utils/default.nix b/shared/home-manager/development-minimal/default.nix
index 167b713..30ef972 100644
--- a/hosts/muhammed/home/dev-utils/default.nix
+++ b/shared/home-manager/development-minimal/default.nix
@@ -1,44 +1,23 @@
-# This part (module) of my home manager configuration adds some random utilities.
+# This module pulls in other HM modules which together form a minimal
+# development enviroment. It does so while taking care not to balloon the
+# closure size too much.
{
pkgs,
lib,
...
}: {
+ imports = [
+ ../zsh
+ ../shell-utils
+
+ ../git
+ ../neovim
+ ../networking-utils
+ ];
+
home.packages = with pkgs; [
- # smol utils
- nodePackages_latest.nodemon
rlwrap
devenv
-
- # heavy hitters
- imagemagick
- ffmpeg_6-full
-
- # interpreaters
- unstable.deno
- (python311Full.withPackages (ps:
- with ps; [
- virtualenv
- tkinter
- ]))
- tcl-8_6
- crystal
- nim
- guile
- vemf
- unstable.gleam
- cscript
- erlang_nox # Required by Gleam
- rebar3 # Required by Gleam
- unstable.nodejs_latest
-
- # Rust ecosystem
- rustc
- cargo
-
- # Clojure ecosystem
- clojure
- leiningen
];
# Add system manual pages to the search path on Darwin.
diff --git a/home/git/aliases.nix b/shared/home-manager/git/aliases.nix
index 03e586c..03e586c 100644
--- a/home/git/aliases.nix
+++ b/shared/home-manager/git/aliases.nix
diff --git a/home/git/default.nix b/shared/home-manager/git/default.nix
index a761484..748025d 100644
--- a/home/git/default.nix
+++ b/shared/home-manager/git/default.nix
@@ -6,7 +6,10 @@
inherit (lib) optional;
inherit (pkgs.stdenv.hostPlatform) isDarwin;
in {
- imports = [./ignore.nix ./aliases.nix];
+ imports = [
+ ./ignore.nix
+ ./aliases.nix
+ ];
programs.git = {
enable = true;
@@ -38,4 +41,9 @@ in {
};
};
};
+
+ home.packages = with pkgs; [
+ # Add the GitHub CLI for authentication.
+ gh
+ ];
}
diff --git a/home/git/ignore.nix b/shared/home-manager/git/ignore.nix
index 8d1da2f..8d1da2f 100644
--- a/home/git/ignore.nix
+++ b/shared/home-manager/git/ignore.nix
diff --git a/hosts/muhammed/home/iterm2/auto_theme.py b/shared/home-manager/iterm2/auto_theme.py
index 0970304..0970304 100644
--- a/hosts/muhammed/home/iterm2/auto_theme.py
+++ b/shared/home-manager/iterm2/auto_theme.py
diff --git a/hosts/muhammed/home/iterm2/default.nix b/shared/home-manager/iterm2/default.nix
index b6a9ecc..b6a9ecc 100644
--- a/hosts/muhammed/home/iterm2/default.nix
+++ b/shared/home-manager/iterm2/default.nix
diff --git a/shared/home-manager/javascript/default.nix b/shared/home-manager/javascript/default.nix
new file mode 100644
index 0000000..2beaf12
--- /dev/null
+++ b/shared/home-manager/javascript/default.nix
@@ -0,0 +1,54 @@
+# This module configures development tools for JavaScript/TypeScript.
+{pkgs, ...}: {
+ home.packages = with pkgs; [
+ unstable.deno
+ unstable.nodejs_latest
+ ];
+
+ programs.neovim.extraLuaConfig = ''
+ require("lspconfig")["denols"].setup({
+ init_options = {
+ enable = true,
+ unstable = true,
+ lint = true,
+ nodeModulesDir = true,
+ },
+ cmd = { "${pkgs.unstable.deno}/bin/deno", "lsp" },
+ root_dir = function(startpath)
+ if util.find_package_json_ancestor(startpath) then
+ -- This is a Node project; let ts_ls handle this one.
+ -- This exactly mirrors how typescript-langauge-server yields to this server for Deno projects.
+ return nil
+ else
+ -- Otherwise, we try to find the root or
+ -- default to the current directory.
+ return util.root_pattern("deno.json", "deno.jsonc", ".git")(startpath)
+ or util.path.dirname(startpath)
+ end
+ end,
+ });
+
+ require("lspconfig")["ts_ls"].setup({
+ cmd = { "${pkgs.nodePackages_latest.typescript-language-server}/bin/typescript-language-server", "--stdio" },
+ root_dir = function(startpath)
+ local find_deno_root_dir = util.root_pattern("deno.json", "deno.jsonc")
+ if find_deno_root_dir(startpath) then
+ -- This is a Deno project; let deno-lsp handle this one.
+ -- This exactly mirrors how deno-lsp yields to this server for Node projects.
+ return nil
+ else
+ -- Otherwise fall back to the usual resolution method.
+ -- See: https://github.com/neovim/nvim-lspconfig/blob/056f569f71e4b726323b799b9cfacc53653bceb3/lua/lspconfig/server_configurations/ts_ls.lua#L15
+ return util.root_pattern("tsconfig.json", "jsconfig.json", "package.json", ".git")(startpath)
+ end
+ end,
+ -- We also have to disallow starting in without a root directory, as otherwise returning
+ -- nil from find_root will just cause the LSP to be spawned in single file mode instead of yielding to deno-lsp.
+ --
+ -- This has the side effect that Deno LSP will be preferred in a single file context which is what we want!
+ --
+ -- See: https://github.com/neovim/nvim-lspconfig/blob/056f569f71e4b726323b799b9cfacc53653bceb3/lua/lspconfig/manager.lua#L281-L286
+ single_file_support = false,
+ })
+ '';
+}
diff --git a/home/neovim/completion.nix b/shared/home-manager/neovim/completion.nix
index 3776674..3776674 100644
--- a/home/neovim/completion.nix
+++ b/shared/home-manager/neovim/completion.nix
diff --git a/home/neovim/default.nix b/shared/home-manager/neovim/default.nix
index f5ace73..63a7564 100644
--- a/home/neovim/default.nix
+++ b/shared/home-manager/neovim/default.nix
@@ -3,6 +3,7 @@
imports = [
./completion.nix
./editing-plugins.nix
+ ./lsp.nix
];
programs.neovim = {
diff --git a/home/neovim/editing-plugins.nix b/shared/home-manager/neovim/editing-plugins.nix
index 23c7d63..23c7d63 100644
--- a/home/neovim/editing-plugins.nix
+++ b/shared/home-manager/neovim/editing-plugins.nix
diff --git a/home/neovim/init.vim b/shared/home-manager/neovim/init.vim
index eeb6920..eeb6920 100644
--- a/home/neovim/init.vim
+++ b/shared/home-manager/neovim/init.vim
diff --git a/shared/home-manager/neovim/lsp.nix b/shared/home-manager/neovim/lsp.nix
new file mode 100644
index 0000000..bc10487
--- /dev/null
+++ b/shared/home-manager/neovim/lsp.nix
@@ -0,0 +1,59 @@
+# Installs and configures lspconfig. The actual LSPs are added in the per-language profiles.
+{pkgs, ...}: {
+ programs.neovim.plugins = [
+ {
+ plugin = pkgs.vimPlugins.nvim-lspconfig;
+ type = "lua";
+ config = ''
+ local lspconfig = require("lspconfig")
+ local util = require("lspconfig.util")
+
+ -- Mappings.
+ -- See `:help vim.diagnostic.*` for documentation on any of the below functions
+ local opts = { noremap=true, silent=true }
+ vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, opts)
+ vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
+ vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
+ vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, opts)
+
+ -- Use an on_attach function to only map the following keys
+ -- after the language server attaches to the current buffer
+ vim.api.nvim_create_autocmd("LspAttach", {
+ callback = function(args)
+ local bufnr = args.buf
+ local client = vim.lsp.get_client_by_id(args.data.client_id)
+
+ -- Enable completion triggered by <c-x><c-o>
+ if client.server_capabilities.completionProvider then
+ vim.bo[bufnr].omnifunc = "v:lua.vim.lsp.omnifunc"
+ end
+
+ -- XXX: What does this do?
+ if client.server_capabilities.definitionProvider then
+ vim.bo[bufnr].tagfunc = "v:lua.vim.lsp.tagfunc"
+ end
+
+ -- Mappings.
+ -- See `:help vim.lsp.*` for documentation on any of the below functions
+ local bufopts = { noremap=true, silent=true, buffer=bufnr }
+ vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
+ vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
+ vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
+ vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
+ vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
+ vim.keymap.set('n', '<leader>wa', vim.lsp.buf.add_workspace_folder, bufopts)
+ vim.keymap.set('n', '<leader>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
+ vim.keymap.set('n', '<leader>wl', function()
+ print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
+ end, bufopts)
+ vim.keymap.set('n', '<leader>D', vim.lsp.buf.type_definition, bufopts)
+ vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, bufopts)
+ vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, bufopts)
+ vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
+ vim.keymap.set('n', '<leader>f', function() vim.lsp.buf.format { async = true } end, bufopts)
+ end,
+ })
+ '';
+ }
+ ];
+}
diff --git a/home/networking-utils/default.nix b/shared/home-manager/networking-utils/default.nix
index 70802a9..70802a9 100644
--- a/home/networking-utils/default.nix
+++ b/shared/home-manager/networking-utils/default.nix
diff --git a/shared/home-manager/nix/default.nix b/shared/home-manager/nix/default.nix
new file mode 100644
index 0000000..dcdff2a
--- /dev/null
+++ b/shared/home-manager/nix/default.nix
@@ -0,0 +1,14 @@
+# This module configures development tools for Nix.
+{pkgs, ...}: {
+ programs.neovim = {
+ plugins = with pkgs.vimPlugins; [
+ vim-nix
+ ];
+
+ extraLuaConfig = ''
+ require("lspconfig")["nixd"].setup({
+ cmd = { "${pkgs.nixd}/bin/nixd" },
+ })
+ '';
+ };
+}
diff --git a/hosts/muhammed/home/noweb/default.nix b/shared/home-manager/noweb/default.nix
index ef67862..1506431 100644
--- a/hosts/muhammed/home/noweb/default.nix
+++ b/shared/home-manager/noweb/default.nix
@@ -5,6 +5,10 @@
yalafi-shell
];
+ programs.neovim.plugins = with pkgs; [
+ vim-noweb
+ ];
+
# Prepend nowebs STY files to the search path. I chose to do it globally,
# rather than using `makeWrapper` because I sometimes want to manually invoke
# `pdflatex` and the like on the output of `noweave`.
diff --git a/shared/home-manager/python/default.nix b/shared/home-manager/python/default.nix
new file mode 100644
index 0000000..380d352
--- /dev/null
+++ b/shared/home-manager/python/default.nix
@@ -0,0 +1,16 @@
+# This module configures development tools for Python.
+{pkgs, ...}: {
+ home.packages = with pkgs; [
+ (python311Full.withPackages (ps:
+ with ps; [
+ virtualenv
+ tkinter
+ ]))
+ ];
+
+ programs.neovim.extraLuaConfig = ''
+ require("lspconfig")["pyright"].setup({
+ cmd = { "${pkgs.pyright}/bin/pyright-langserver", "--stdio" },
+ })
+ '';
+}
diff --git a/hosts/muhammed/home/qbittorrent/default.nix b/shared/home-manager/qbittorrent/default.nix
index 0b7e2b1..0b7e2b1 100644
--- a/hosts/muhammed/home/qbittorrent/default.nix
+++ b/shared/home-manager/qbittorrent/default.nix
diff --git a/shared/home-manager/rust/default.nix b/shared/home-manager/rust/default.nix
new file mode 100644
index 0000000..3ca301c
--- /dev/null
+++ b/shared/home-manager/rust/default.nix
@@ -0,0 +1,13 @@
+# This module configures development tools for Rust.
+{pkgs, ...}: {
+ home.packages = with pkgs; [
+ rustc
+ cargo
+ ];
+
+ programs.neovim.extraLuaConfig = ''
+ require("lspconfig")["rust_analyzer"].setup({
+ cmd = { "${pkgs.rust-analyzer}/bin/rust-analyzer" },
+ })
+ '';
+}
diff --git a/home/shell-utils/default.nix b/shared/home-manager/shell-utils/default.nix
index 8635ceb..8635ceb 100644
--- a/home/shell-utils/default.nix
+++ b/shared/home-manager/shell-utils/default.nix
diff --git a/shared/home-manager/svelte/default.nix b/shared/home-manager/svelte/default.nix
new file mode 100644
index 0000000..7b76041
--- /dev/null
+++ b/shared/home-manager/svelte/default.nix
@@ -0,0 +1,15 @@
+# This module configures development tools for Svelte.
+{pkgs, ...}: {
+ programs.neovim = {
+ plugins = with pkgs.vimPlugins; [
+ vim-svelte
+ ];
+
+ extraLuaConfig = ''
+ require("lspconfig")["svelte"].setup({
+ cmd = { "${pkgs.nodePackages_latest.svelte-language-server}/bin/svelteserver", "--stdio" },
+ root_dir = util.root_pattern("package.json", ".git", "deno.json", "deno.jsonc"),
+ })
+ '';
+ };
+}
diff --git a/home/zsh/default.nix b/shared/home-manager/zsh/default.nix
index 31796a9..31796a9 100644
--- a/home/zsh/default.nix
+++ b/shared/home-manager/zsh/default.nix
diff --git a/home/zsh/editing.nix b/shared/home-manager/zsh/editing.nix
index 241ef3c..241ef3c 100644
--- a/home/zsh/editing.nix
+++ b/shared/home-manager/zsh/editing.nix
diff --git a/home/zsh/plugins.nix b/shared/home-manager/zsh/plugins.nix
index 6dbc151..6dbc151 100644
--- a/home/zsh/plugins.nix
+++ b/shared/home-manager/zsh/plugins.nix
diff --git a/hosts/ahmed/cloudflare-proxy/default.nix b/shared/nixos/cloudflare-proxy/default.nix
index 45ccaa6..45ccaa6 100644
--- a/hosts/ahmed/cloudflare-proxy/default.nix
+++ b/shared/nixos/cloudflare-proxy/default.nix
diff --git a/shared/nixos/common-hm-settings/default.nix b/shared/nixos/common-hm-settings/default.nix
new file mode 100644
index 0000000..9262f51
--- /dev/null
+++ b/shared/nixos/common-hm-settings/default.nix
@@ -0,0 +1,27 @@
+# This module sets common settings related to home-manager (HM). All hosts that
+# I directly interact with should include this module.
+#
+# NOTE: Even though this lives under `shared/nixos` the configuration in here
+# should also be compatible with nix-darwin!!
+{
+ flakeInputs,
+ flakeOutputs,
+ metadata,
+ ...
+}: {
+ # FIXME: Ideally this module would import flakeInputs.home-manager but that causes an infinite recursion for some reason.
+
+ # Use the flake input pkgs so Home Manager configuration can share overlays
+ # etc. with the rest of the configuration.
+ home-manager.useGlobalPkgs = true;
+
+ # Pass special arguments from flake.nix further down the chain. I really hate
+ # this split module system.
+ home-manager.extraSpecialArgs = {inherit flakeInputs flakeOutputs metadata;};
+
+ # All interactive systems (i.e. the ones that would use HM) have a 'linus' user.
+ home-manager.users.linus = {
+ imports = builtins.attrValues flakeOutputs.homeModules;
+ xdg.enable = true;
+ };
+}
diff --git a/shared/nixos/common-nix-settings/default.nix b/shared/nixos/common-nix-settings/default.nix
new file mode 100644
index 0000000..b5c0a02
--- /dev/null
+++ b/shared/nixos/common-nix-settings/default.nix
@@ -0,0 +1,60 @@
+# This module sets common settings related to Nix such as enabling flakes and
+# using overlays everywhere..
+#
+# NOTE: Even though this lives under `shared/nixos` the configuration in here
+# should also be compatible with nix-darwin!!
+{
+ pkgs,
+ lib,
+ config,
+ flakeInputs,
+ flakeOutputs,
+ ...
+}:
+lib.mkMerge [
+ {
+ # Enable de facto stable features.
+ nix.settings.experimental-features = ["nix-command" "flakes"];
+
+ nixpkgs.overlays = [
+ # Use local overlays.
+ flakeOutputs.overlays.additions
+ flakeOutputs.overlays.modifications
+
+ # Add unstable nixpkgs.
+ (final: prev: {unstable = flakeInputs.nixpkgs-unstable.legacyPackages.${pkgs.system};})
+ ];
+
+ # I'm not *that* vegan.
+ nixpkgs.config.allowUnfree = true;
+
+ # This will add each flake input as a registry
+ # To make nix3 commands consistent with your flake
+ nix.registry = lib.mapAttrs (_: value: {flake = value;}) flakeInputs;
+
+ nix.nixPath =
+ [
+ # Use overlays from this repo for building system configuration as well as system-wide.
+ # See: https://nixos.wiki/wiki/Overlays#Using_nixpkgs.overlays_from_configuration.nix_as_.3Cnixpkgs-overlays.3E_in_your_NIX_PATH
+ "nixpkgs-overlays=${flakeInputs.self}/overlays/compat.nix"
+
+ # This will additionally add out inputs to the system's legacy channels
+ # Making legacy nix commands consistent as well, awesome!
+ ]
+ ++ lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry;
+
+ # Add shell-utilities which are only relevant if Nix is enabled.
+ environment.systemPackages = with pkgs; [
+ # For running programs easily.
+ nix-index # Also includes nix-locate
+ flakeInputs.comma.packages.${system}.default
+
+ # For editing secrets.
+ flakeInputs.agenix.packages.${system}.default
+ ];
+ }
+ (lib.mkIf pkgs.stdenv.isLinux {
+ # There is not nix-darwin equivalent to this NixOS option.
+ nix.enable = true;
+ })
+]
diff --git a/shared/nixos/common-shell-settings/default.nix b/shared/nixos/common-shell-settings/default.nix
new file mode 100644
index 0000000..ec71861
--- /dev/null
+++ b/shared/nixos/common-shell-settings/default.nix
@@ -0,0 +1,44 @@
+# This module sets options to ensure a consistent Baseline Shell Experince™
+# across the entire fleet. This includes e.g. common utilities and aliases.
+#
+# NOTE: Even though this lives under `shared/nixos` the configuration in here
+# should also be compatible with nix-darwin!!
+{pkgs, ...}: {
+ # Set ZSH as the shell.
+ # https://nixos.wiki/wiki/Command_Shell#Changing_default_shelltrue
+ programs.zsh.enable = true;
+ environment.shells = [pkgs.zsh];
+
+ # Very basic system administration tools.
+ environment.systemPackages = with pkgs; [
+ curl
+ jq
+ moreutils
+ neovim
+ tree
+ ];
+
+ # Aliases that are burned into my muscle memory.
+ environment.shellAliases = {
+ "mv" = "mv -i";
+ "rm" = "rm -i";
+ "cp" = "cp -i";
+ "ls" = "ls -F -G -A --color=auto";
+ "grep" = "grep --color=auto";
+ "file" = "file --no-dereference";
+ "tree" = "tree --dirsfirst --gitignore";
+
+ # See: https://github.com/NixOS/nix/issues/5858
+ "nix" = "nix --print-build-logs";
+
+ ".." = "cd ../";
+ "..." = "cd ../../";
+ "...." = "cd ../../../";
+ "....." = "cd ../../../../";
+ "......" = "cd ../../../../../";
+ "......." = "cd ../../../../../../";
+ "........" = "cd ../../../../../../../";
+ "........." = "cd ../../../../../../../../";
+ ".........." = "cd ../../../../../../../../../";
+ };
+}