diff options
Diffstat (limited to 'use-cases')
-rw-r--r-- | use-cases/default.nix | 43 | ||||
-rw-r--r-- | use-cases/development/default.nix | 10 | ||||
-rw-r--r-- | use-cases/development/git.nix | 18 | ||||
-rw-r--r-- | use-cases/development/neovim.nix | 60 | ||||
-rw-r--r-- | use-cases/development/zsh.nix | 14 | ||||
-rw-r--r-- | use-cases/sysadmin/default.nix | 16 |
6 files changed, 161 insertions, 0 deletions
diff --git a/use-cases/default.nix b/use-cases/default.nix new file mode 100644 index 0000000..5af2903 --- /dev/null +++ b/use-cases/default.nix @@ -0,0 +1,43 @@ +# This configuration is centered around use cases, rather than profiles. Since +# all of the machines I manage are single-user machines, there's no point in +# creating multiple users. +# +# While the users don't differ, the use cases definitely do. I use some +# machines for homework and gaming, while others are used for web-browsing and +# development. Each use case is a subdirectory with (home-manager) +# configuration options. +# +# Note that e.g. "running a DNS server" is not a use case. That's specified in +# the respective host's `configuration.nix`. + +{ config, lib, flakeInputs, ... }: + +let + inherit (lib) mkEnableOption mkIf; + cfg = config.my.use-cases; +in +{ + options.my.use-cases = { + development.enable = mkEnableOption "development use case"; + sysadmin.enable = mkEnableOption "sysadmin use case"; + }; + + config = { + home-manager.users.linus = { + imports = + (lib.optional cfg.development.enable ./development) ++ + (lib.optional cfg.sysadmin.enable ./sysadmin); + # TODO: Graphical linux config (remember assertion). + + xdg.enable = true; + }; + + # Pass + home-manager.extraSpecialArgs = { + super = config; + inherit flakeInputs; + }; + + home-manager.useGlobalPkgs = true; + }; +} diff --git a/use-cases/development/default.nix b/use-cases/development/default.nix new file mode 100644 index 0000000..a2c3675 --- /dev/null +++ b/use-cases/development/default.nix @@ -0,0 +1,10 @@ +{ config, lib, ... }: + +{ + imports = + [ + ./git.nix + ./neovim.nix + ./zsh.nix + ]; +} diff --git a/use-cases/development/git.nix b/use-cases/development/git.nix new file mode 100644 index 0000000..8df44db --- /dev/null +++ b/use-cases/development/git.nix @@ -0,0 +1,18 @@ +{ ... }: + +{ + programs.git = { + enable = true; + + # Set privacy-respecting user information. + userName = "Linnnus"; + userEmail = "[email protected]"; + }; + + home.shellAliases = { + gs = "git status"; + gd = "git diff"; + gc = "git commit"; + gap = "git add --patch"; + }; +} diff --git a/use-cases/development/neovim.nix b/use-cases/development/neovim.nix new file mode 100644 index 0000000..fb7acf3 --- /dev/null +++ b/use-cases/development/neovim.nix @@ -0,0 +1,60 @@ + +# This file contains the HM configuration options for Neovim for the user +# 'linus'. Don't know him. + +{ pkgs, lib, ... }: + +{ + programs.neovim = { + enable = true; + + # Wrap neovim with LSP dependencies. + # TODO: Build fails with permission error. What? I hate computers... + # package = + # let + # base = pkgs.neovim-unwrapped; + # deps = with pkgs; [ pyright ]; + # neovim' = pkgs.runCommandLocal "neovim-with-deps" { + # buildInputs = [ pkgs.makeWrapper ]; + # } '' + # mkdir $out + # # Link every top-level folder from pkgs.hello to our new target + # ln -s ${base}/* $out + # # Except the bin folder + # rm $out/bin + # mkdir $out/bin + # # We create the bin folder ourselves and link every binary in it + # ln -s ${base}/bin/* $out/bin + # # Except the nvim binary + # rm $out/bin/nvim + # # Because we create this ourself, by creating a wrapper + # makeWrapper ${base}/bin/nvim $out/bin/nvim \ + # --prefix PATH : ${lib.makeBinPath deps} + # ''; + # in + # neovim'; + + plugins = with pkgs.vimPlugins; [ + { + plugin = nvim-lspconfig; + type = "lua"; + config = '' + local lspconfig = require("lspconfig"); + lspconfig.pyright.setup { } + ''; + } + ]; + + # Typing `vi`, `vim`, or `vimdiff` will also run neovim. + viAlias = true; + vimAlias = true; + vimdiffAlias = true; + }; + + # Set Neovim as the default editor. + home.sessionVariables.EDITOR = "nvim"; + home.sessionVariables.VISUAL = "nvim"; + + # Use neovim as man pager. + home.sessionVariables.MANPAGER = "nvim +Man!"; +} diff --git a/use-cases/development/zsh.nix b/use-cases/development/zsh.nix new file mode 100644 index 0000000..4db241d --- /dev/null +++ b/use-cases/development/zsh.nix @@ -0,0 +1,14 @@ +{ pkgs, config, ... }: + +{ + programs.zsh = { + enable = true; + + defaultKeymap = "viins"; + + # Feeble attempt at cleaning up home directory. + # TODO: dotDir = (pathRelativeTo config.xdg.configHome config.home) + "/zsh"; + dotDir = ".config/zsh"; + history.path = config.xdg.cacheHome + "/zsh/history"; + }; +} diff --git a/use-cases/sysadmin/default.nix b/use-cases/sysadmin/default.nix new file mode 100644 index 0000000..1958797 --- /dev/null +++ b/use-cases/sysadmin/default.nix @@ -0,0 +1,16 @@ +# This module defines Home Manager configuration options for the 'sysadmin' use +# case. That is, basic system administration. + +{ pkgs, super, lib, ... }: + +let + inherit (lib) optional; +in +{ + home.packages = with pkgs; [ + tree + jc + jq + # is this not the right it is the one passed to home-manager not nixos ???? 'config'? + ] ++ (optional (!super.my.use-cases.development.enable) vim); +} |