Initial commit.

main
Joshua Potter 2023-11-17 04:58:33 -07:00
commit da9b70bb43
11 changed files with 407 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
hardware-configuration.nix

4
README.md Normal file
View File

@ -0,0 +1,4 @@
# nixos-configuration
The collection of publically visible nixos-configuration files used for my
personal machines.

108
configuration.nix Normal file
View File

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

49
flake.lock Normal file
View File

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

36
flake.nix Normal file
View File

@ -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 .#<hostname>`
# nixosConfigurations."<hostname>".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;
};
}
];
};
};
}

40
jrpotter/default.nix Normal file
View File

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

7
jrpotter/git.nix Normal file
View File

@ -0,0 +1,7 @@
{ ... }:
{
programs.git = {
userName = "Joshua Potter";
userEmail = "jrpotter2112@gmail.com";
};
}

View File

@ -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 = '<Tab>',
node_incremental = '<Tab>',
node_decremental = '<S-Tab>',
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 <Tab> 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;
};
}

10
jrpotter/neovim/lua.nix Normal file
View File

@ -0,0 +1,10 @@
{ pkgs, ... }:
{
nvim-lspconfig = ''
require('lspconfig').lua_ls.setup { }
'';
extraPackages = with pkgs; [
lua-language-server
];
}

10
jrpotter/neovim/nix.nix Normal file
View File

@ -0,0 +1,10 @@
{ pkgs, ... }:
{
nvim-lspconfig = ''
require('lspconfig').nil_ls.setup { }
'';
extraPackages = with pkgs; [
nil
];
}

View File

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