commit da9b70bb43d95df7e55cd44ebdc5a344530a3d40 Author: Joshua Potter Date: Fri Nov 17 04:58:33 2023 -0700 Initial commit. diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..577b0a0 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +hardware-configuration.nix diff --git a/README.md b/README.md new file mode 100644 index 0000000..33103b4 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# nixos-configuration + +The collection of publically visible nixos-configuration files used for my +personal machines. diff --git a/configuration.nix b/configuration.nix new file mode 100644 index 0000000..7bb393a --- /dev/null +++ b/configuration.nix @@ -0,0 +1,108 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running `nixos-help`). + +{ config, pkgs, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + boot.loader = { + efi.canTouchEfiVariables = true; + systemd-boot.enable = true; + }; + + environment = { + # Excludes some KDE plasma applications from the default + # install. We choose to use KDE since, with wayland support, + # is is capable of fractional scaling. + plasma5.excludePackages = with pkgs.libsForQt5; [ + elisa + gwenview + khelpcenter + konsole + okular + oxygen + plasma-browser-integration + print-manager + ]; + systemPackages = with pkgs; [ + gcc + git + ]; + variables = { + EDITOR = "nvim"; + }; + }; + + hardware.bluetooth.enable = true; + + programs.neovim = { + enable = true; + configure = { + customRC = '' + set colorcolumn=80,100 + set expandtab " Spaces instead of tabs. + set shiftwidth=2 " # of spaces to use for each (auto)indent. + set tabstop=2 " # of spaces a in the file counts for. + ''; + }; + viAlias = true; + vimAlias = true; + }; + + networking.hostName = "nixos"; + networking.networkmanager.enable = true; + + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + # Recommended when using pipewire. + # https://nixos.wiki/wiki/PipeWire + security.rtkit.enable = true; + + services = { + mullvad-vpn.enable = true; + openssh.enable = true; + pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; + xserver = { + enable = true; + desktopManager.plasma5.enable = true; + desktopManager.xterm.enable = false; + displayManager.defaultSession = "plasmawayland"; + xkbOptions = "ctrl:swapcaps"; + }; + }; + + time.timeZone = "America/Denver"; + + # Don't forget to set a password with `passwd`. + users.users.jrpotter = { + isNormalUser = true; + extraGroups = [ + "networkmanager" + "wheel" # Enable `sudo` for the user. + ]; + }; + + # Copy the NixOS configuration file and link it from the resulting system + # (/run/current-system/configuration.nix). This is useful in case you + # accidentally delete configuration.nix. + # system.copySystemConfiguration = true; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It's perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "23.05"; +} + diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..842770c --- /dev/null +++ b/flake.lock @@ -0,0 +1,49 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1699748081, + "narHash": "sha256-MOmMapBydd7MTjhX4eeQZzKlCABWw8W6iSHSG4OeFKE=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "04bac349d585c9df38d78e0285b780a140dc74a4", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-23.05", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1699596684, + "narHash": "sha256-XSXP8zjBZJBVvpNb2WmY0eW8O2ce+sVyj1T0/iBRIvg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "da4024d0ead5d7820f6bd15147d3fe2a0c0cec73", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..fcce5c9 --- /dev/null +++ b/flake.nix @@ -0,0 +1,36 @@ +{ + description = "NixOS Flake"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.05"; + home-manager = { + url = "github:nix-community/home-manager/release-23.05"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + + outputs = { self, nixpkgs, home-manager, ... }: { + # Used with `nixos-rebuild --flake .#` + # nixosConfigurations."".config.system.build.toplevel must be a derivation + nixosConfigurations.nixos = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + + # Used to pass non-default parameters to submodules. + # specialArgs = {...}; + + # Modules can be attribute sets or a function that returns an attribute set. + # https://nixos-and-flakes.thiscute.world/nixos-with-flakes/nixos-with-flakes-enabled + modules = [ + ./configuration.nix + home-manager.nixosModules.home-manager + { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + users.jrpotter = import ./jrpotter; + }; + } + ]; + }; + }; +} diff --git a/jrpotter/default.nix b/jrpotter/default.nix new file mode 100644 index 0000000..ff645df --- /dev/null +++ b/jrpotter/default.nix @@ -0,0 +1,40 @@ +{ pkgs, ... }: +{ + imports = [ + ./git.nix + ./neovim + ]; + + home = { + username = "jrpotter"; + homeDirectory = "/home/jrpotter"; + + packages = with pkgs; [ + anki-bin + bitwarden + firefox + mullvad-vpn + python3 + wezterm + zotero + ]; + }; + + programs = { + bash.enable = true; + direnv.enable = true; + git.enable = true; + home-manager.enable = true; + neovim.enable = true; + }; + + # This value determines the Home Manager release that + # your configuration is compatible with. This helps avoid + # breakage when a new Home Manager release introduces + # backwards-incompatible changes. + # + # You can update Home Manager without changing this value. + # See the Home Manager release notes for a list of state + # version changes in each release. + home.stateVersion = "23.05"; +} diff --git a/jrpotter/git.nix b/jrpotter/git.nix new file mode 100644 index 0000000..eb4e667 --- /dev/null +++ b/jrpotter/git.nix @@ -0,0 +1,7 @@ +{ ... }: +{ + programs.git = { + userName = "Joshua Potter"; + userEmail = "jrpotter2112@gmail.com"; + }; +} diff --git a/jrpotter/neovim/default.nix b/jrpotter/neovim/default.nix new file mode 100644 index 0000000..06ef83c --- /dev/null +++ b/jrpotter/neovim/default.nix @@ -0,0 +1,81 @@ +args @ { pkgs, ... }: +let + conf = { + lua = import ./lua.nix args; + nix = import ./nix.nix args; + python = import ./python.nix args; + }; + + nvim-dap = { + plugin = pkgs.vimPlugins.nvim-dap; + config = '' + lua << EOF + ${builtins.concatStringsSep "\n" (builtins.map (m: "do\n${m}\nend") [ + conf.python.nvim-dap + ])} + EOF + ''; + }; + + nvim-lspconfig = { + plugin = pkgs.vimPlugins.nvim-lspconfig; + config = '' + lua << EOF + ${builtins.concatStringsSep "\n" (builtins.map (m: "do\n${m}\nend") [ + conf.lua.nvim-lspconfig + conf.nix.nvim-lspconfig + conf.python.nvim-lspconfig + ])} + EOF + ''; + }; + + nvim-treesitter = { + plugin = (pkgs.vimPlugins.nvim-treesitter.withPlugins ( + ps: with ps; [ + lua + nix + python + ] + )); + config = '' + lua << EOF + require('nvim-treesitter.configs').setup { + auto_install = false, + highlight = { enable = true }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = '', + node_incremental = '', + node_decremental = '', + scope_incremental = false, + }, + }, + } + EOF + ''; + }; +in +{ + programs.neovim = { + extraLuaConfig = '' + vim.o.colorcolumn = '80,100' + vim.o.expandtab = true -- Spaces instead of tabs. + vim.o.shiftwidth = 2 -- # of spaces to use for each (auto)indent. + vim.o.tabstop = 2 -- # of spaces a in the file counts for. + ''; + extraPackages = ( + conf.lua.extraPackages ++ + conf.nix.extraPackages ++ + conf.python.extraPackages + ); + plugins = [ + nvim-dap + nvim-lspconfig + nvim-treesitter + ]; + viAlias = true; + vimAlias = true; + }; +} diff --git a/jrpotter/neovim/lua.nix b/jrpotter/neovim/lua.nix new file mode 100644 index 0000000..505d18b --- /dev/null +++ b/jrpotter/neovim/lua.nix @@ -0,0 +1,10 @@ +{ pkgs, ... }: +{ + nvim-lspconfig = '' + require('lspconfig').lua_ls.setup { } + ''; + + extraPackages = with pkgs; [ + lua-language-server + ]; +} diff --git a/jrpotter/neovim/nix.nix b/jrpotter/neovim/nix.nix new file mode 100644 index 0000000..8d0e798 --- /dev/null +++ b/jrpotter/neovim/nix.nix @@ -0,0 +1,10 @@ +{ pkgs, ... }: +{ + nvim-lspconfig = '' + require('lspconfig').nil_ls.setup { } + ''; + + extraPackages = with pkgs; [ + nil + ]; +} diff --git a/jrpotter/neovim/python.nix b/jrpotter/neovim/python.nix new file mode 100644 index 0000000..5496a4f --- /dev/null +++ b/jrpotter/neovim/python.nix @@ -0,0 +1,61 @@ +{ pkgs, ... }: +let + venv = pkgs.python3.withPackages (ps: with ps; [ + debugpy + mccabe + pycodestyle + pyflakes + python-lsp-server + python-lsp-black + ]); +in +{ + nvim-dap = '' + local dap = require('dap') + + dap.adapters.python = function(callback, config) + callback({ + name = 'debugpy', + type = 'executable', + command = '${venv}/bin/python3.10', + args = { '-m', 'debugpy.adapter' }, + options = { + source_filetype = 'python', + }, + }) + end + + dap.configurations.python = dap.configurations.python or {} + table.insert(dap.configurations.python, { + name = 'Launch', + type = 'python', + request = 'launch', + program = "''${file}", + cwd = "''${workspaceFolder}", + }) + ''; + + nvim-lspconfig = '' + require('lspconfig').pylsp.setup { + settings = { + pylsp = { + -- `flake8` currently fails in some cases: + -- https://github.com/python-lsp/python-lsp-server/pull/434 + configurationSources = 'pycodestyle', + plugins = { + autopep8 = { enabled = false }, + black = { enabled = true }, + mccabe = { enabled = true }, + pycodestyle = { enabled = true }, + pyflakes = { enabled = true }, + yapf = { enabled = false }, + }, + }, + }, + } + ''; + + extraPackages = [ + venv + ]; +}