still working

This commit is contained in:
Bryan Ramos 2023-06-05 15:14:24 -04:00
parent 64235f2775
commit 0712b63194
14 changed files with 508 additions and 174 deletions

View file

@ -30,11 +30,10 @@
in in
{ {
nixosConfigurations.socrates = nixpkgs.lib.nixosSystem { nixosConfigurations.socratesV2 = nixpkgs.lib.nixosSystem {
inherit pkgs; inherit pkgs;
modules = [ modules = [
./machines/hardware-configuration.nix ./machines
./machines/system.nix
disko.nixosModules.disko disko.nixosModules.disko
home-manager.nixosModules.home-manager{ home-manager.nixosModules.home-manager{
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;

View file

@ -1 +0,0 @@
{ imports = ./.; }

View file

@ -0,0 +1,83 @@
{ pkgs, lib, config, ... } =
with lib;
let cfg = config.modules.alacritty;
in {
options.modules.alacritty = { enable = mkEnableOption "alacritty"; };
config = mkIf cfg.enable {
programs.alacritty = {
enable = true;
settings = {
scrolling = {
history = 10000;
multiplier = 3;
};
window = {
opacity = 0.95;
};
colors = {
primary = {
background = 0x0d1117;
foreground = 0xb3b1ad;
};
normal = {
black = 0x484f58;
red = 0xff7b72;
green = 0x3fb950;
yellow = 0xd29922;
blue = 0x58a6ff;
magenta = 0xbc8cff;
cyan = 0x39c5cf;
white = 0xb1bac4;
};
bright = {
black = 0x6e7681;
red = 0xffa198;
green = 0x56d364;
yellow = 0xe3b341;
blue = 0x79c0ff;
magenta = 0xd2a8ff;
cyan = 0x56d4dd;
white = 0xf0f6fc;
};
font = {
normal = {
family = TerminusWithNerdFont;
style = Medium;
};
bold = {
family = TerminusWithNerdFont;
style = Bold;
};
italic = {
family = TerminusWithNerdFont;
style = Medium Italic;
};
bold_italic = {
family = TerminusWithNerdFont;
style = Bold Italic;
};
size = 14;
cursor = {
color = 0xffffff;
style = {
shape = Block;
blinking = Always;
blink-interval = 750;
};
};
};
};
}

View file

@ -64,7 +64,9 @@ in {
unset flake_icon unset flake_icon
} }
PROMPT_COMMAND="set_ps1_prompt; $PROMPT_COMMAND" PROMPT_COMMAND="set_ps1_prompt; $PROMPT_COMMAND"
'';
bashrcExtra = ''
function cdg() { function cdg() {
if [[ $1 == "--help" ]]; then if [[ $1 == "--help" ]]; then
echo "A simple utility for navigating to the root of a git repo" echo "A simple utility for navigating to the root of a git repo"
@ -173,10 +175,6 @@ in {
echo "Error: Invalid command. Try 'ldv --help'" echo "Error: Invalid command. Try 'ldv --help'"
fi fi
} }
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
ldv "$@"
fi
''; '';
shellAliases = { shellAliases = {

View file

@ -9,11 +9,13 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
programs.git = { programs.git = {
enable = true; enable = true;
userName = "Bryan Ramos";
userEmail = "bryan@ramos.codes";
extraConfig = { extraConfig = {
init = { defaultBranch = "main"; }; init = { defaultBranch = "main"; };
}; };
}; };
home.file = {
".gitconfig".source = ./gitconfig;
};
}; };
} }

4
modules/git/gitconfig Normal file
View file

@ -0,0 +1,4 @@
[user]
email = bryan@ramos.codes
name = Bryan Ramos
signingkey = F1F3466458452B2DF351F1E864D12BA95ACE1F2D

11
modules/gpg/default.nix Normal file
View file

@ -0,0 +1,11 @@
{ pkgs, lib, config, ... }:
with lib;
let cfg = config.modules.gpg;
in {
options.modules.gpg = { enable = mkEnableOption "gpg"; };
config = mkIf cfg.enable {
programs.gpg.enable = true;
};
}

10
modules/gtk/default.nix Normal file
View file

@ -0,0 +1,10 @@
{ pkgs, lib, config, ... }:
with lib;
let cfg = config.modules.PROGRAM;
in {
options.modules.PROGRAM = { enable = mkEnableOption "PROGRAM"; };
config = mkIf cfg.enable {
};
}

View file

@ -8,7 +8,7 @@ let cfg = config.modules.neovim;
src = pkgs.fetchFromGithub { src = pkgs.fetchFromGithub {
owner = "projekt0n"; owner = "projekt0n";
repo = "github-nvim-theme"; repo = "github-nvim-theme";
rev = "62b7b54a90c70c20cd1641f9facfced46bdd3561"; rev = "ea713c37691b2519f56cd801a2330bdf66393d0f";
sha256 = "0cwr3b5r2ac7aizxmwb3mlhdc2sh0pw670vcwps79x9jp52yrj2y"; sha256 = "0cwr3b5r2ac7aizxmwb3mlhdc2sh0pw670vcwps79x9jp52yrj2y";
}; };
}; };
@ -27,7 +27,6 @@ in {
vimAlias = true; vimAlias = true;
plugins = with pkgs.vimPlugins; [ plugins = with pkgs.vimPlugins; [
{ {
plugin = github-theme; plugin = github-theme;
config = '' config = ''
@ -37,13 +36,15 @@ in {
''; '';
} }
lazygit.nvim { plugin = lazygit.nvim; }
{ {
plugin = LazyVim; plugin = LazyVim;
config = '' config = ''
lua << EOF lua << EOF
return { return {
{'williamboman/mason.nvim', enabled = false }, {'williamboman/mason.nvim', enabled = false },
{'williamboman/mason-lspconfig.nvim', enabled = false },
{'nvim-treesitter/nvim-treesitter', enabled = false }, {'nvim-treesitter/nvim-treesitter', enabled = false },
} }
EOF EOF
@ -65,19 +66,162 @@ in {
} }
{ {
plugin = nvim-treesitter.withAllGrammars plugin = nvim-treesitter.withAllGrammars;
config = '' config = ''
lua << EOF lua << EOF
require'nvim-treesitter.configs'.setup {
highlight = {
enable = true,
},
}
EOF EOF
''; '';
} }
]; ];
extraLuaConfig = ''
lua << EOF
vim.opt.tabstop = 2
vim.opt.shiftwidth = 2
vim.opt.expandtab = true
vim.o.clipboard = "unnamedplus"
EOF
'';
generatedConfigs = {
lua = ''
require("config.lazy")
local lsp = require("lsp-zero").preset({})
lsp.on_attach(function(client, bufnr)
lsp.default_keymaps({ buffer = bufnr })
end)
lsp.setup_servers({
"tsserver",
"eslint",
"hls",
"pyright",
"nil_ls",
"cssls",
"html",
"jsonls",
"diagnosticls",
"lua_ls",
"marksman",
"purescriptls",
"tailwindcss",
"bashls",
})
require("lspconfig").lua_ls.setup(lsp.nvim_lua_ls())
lsp.setup()
local cmp = require("cmp")
cmp.setup({
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
sources = {
{ name = "nvim_lsp" },
{ name = "luasnip" },
},
})
vim.cmd([[
au BufRead,BufNewFile *.purs set filetype=purescript
]])
local has_words_before = function()
unpack = unpack or table.unpack
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
end
local luasnip = require("luasnip")
cmp.setup({
enabled = function()
-- disable completion in comments
local context = require("cmp.config.context")
-- keep command mode completion enabled when cursor is in a comment
if vim.api.nvim_get_mode().mode == "c" then
return true
else
return not context.in_treesitter_capture("comment") and not context.in_syntax_group("Comment")
end
end,
mapping = {
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
-- You could replace the expand_or_jumpable() calls with expand_or_locally_jumpable()
-- they way you will only jump inside the snippet region
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
elseif has_words_before() then
cmp.complete()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
["<CR>"] = cmp.mapping({
i = function(fallback)
if cmp.visible() and cmp.get_active_entry() then
cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false })
else
fallback()
end
end,
s = cmp.mapping.confirm({ select = true }),
c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }),
}),
},
})
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(vim.lsp.diagnostic.on_publish_diagnostics, {
-- Disable virtual_text
virtual_text = false,
})
require("notify").setup({
background_colour = "#000000",
})
'';
};
}; };
home.packages = with pkgs; [ home.packages = with pkgs; [
nodePackages.eslint
nodePackages.vscode-langservers-extracted
nodePackages.typescript-language-server
nodePackages.diagnostic-languageserver
nodePackages.pyright
nodePackages.purescript-language-server
nodePackages."@tailwindcss/language-server"
nodePackages.bash-language-server
marksman
nil nixfmt nil nixfmt
sumneko-lua-language-server stylua sumneko-lua-language-server stylua
haskell-language-server hlint haskell-language-server hlint
]; ];
}; };

View file

@ -0,0 +1,8 @@
{ ... }:
{
imports = [
./hardware.nix
./system.nix
];
}

View file

@ -3,9 +3,7 @@
{ {
imports = [ (modulesPath + "/installer/scan/not-detected.nix") ]; imports = [ (modulesPath + "/installer/scan/not-detected.nix") ];
nix.system-features = "kvm"; # Kernel
environment.systemPackages = pkgs.virt-manager;
boot.initrd.availableKernelModules = [ "vmd" "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ]; boot.initrd.availableKernelModules = [ "vmd" "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ];
boot.initrd.kernelModules = [ "dm-snapshot" ]; boot.initrd.kernelModules = [ "dm-snapshot" ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
@ -13,6 +11,22 @@
boot.kernelModules = [ "kvm-intel" "virtio" "vfio-pci" "coretemp" ]; boot.kernelModules = [ "kvm-intel" "virtio" "vfio-pci" "coretemp" ];
boot.kernelPackages = pkgs.linuxPackages_latest; boot.kernelPackages = pkgs.linuxPackages_latest;
# Bootloader
boot.loader = {
grub = {
enable = true;
useOSProber = true;
devices = [ "nodev" ];
efiSupport = true;
configurationLimit = 5;
};
efi = {
canTouchEfiVariables = true;
};
};
# FStab
fileSystems."/" = fileSystems."/" =
{ device = "/dev/disk/by-uuid/af24c5b3-8a6e-4333-a61d-922a97928cae"; { device = "/dev/disk/by-uuid/af24c5b3-8a6e-4333-a61d-922a97928cae";
fsType = "ext4"; fsType = "ext4";
@ -28,6 +42,8 @@
fsType = "vfat"; fsType = "vfat";
}; };
# GPU
programs.sway.extraOptions = "--unsupported-gpu";
services.xserver.videoDrivers = [ "nvidia" ]; services.xserver.videoDrivers = [ "nvidia" ];
hardware = { hardware = {
opengl.enable = true; opengl.enable = true;
@ -37,6 +53,20 @@
}; };
}; };
# Virtualisation
nix.system-features = "kvm";
environment.systemPackages = pkgs.virt-manager;
virtualisation.libvirtd = {
enable = true;
qemu = {
package = pkgs.qemu_kvm;
runAsRoot = true;
ovmf.enable = true;
};
};
# CPU
powerManagement.cpuFreqGovernor = lib.mkDefault "performance"; powerManagement.cpuFreqGovernor = lib.mkDefault "performance";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
} }

View file

@ -0,0 +1,79 @@
{ disks ? [ "/dev/nvme0n1" "/dev/sda" ], ... }: {
disko.devices = {
disk = {
one = {
type = "disk";
device = builtins.elemAt disks 0;
content = {
type = "table";
format = "gpt";
partitions = [
{
name = "boot";
start = "0";
end = "100M";
fs-type = "fat32";
bootable = true;
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
}
{
name = "primary";
start = "100M";
end = "100%";
content = {
type = "lvm_pv";
vg = "pool";
};
}
];
};
};
};
disk = {
two = {
type = "disk";
device = builtins.elemAt disks 1;
content = {
}
};
};
lvm_vg = {
pool = {
type = "lvm_vg";
lvs = {
aaa = {
size = "1M";
};
zzz = {
size = "1M";
};
root = {
size = "100M";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/";
mountOptions = [
"defaults"
];
};
};
home = {
size = "100%FREE";
content = {
type = "filesystem";
format = "ext4";
mountpoint = "/home";
};
};
};
};
};
};
}

View file

@ -6,7 +6,6 @@
nix = { nix = {
extraOptions = "experimental-features = nix-command flakes"; extraOptions = "experimental-features = nix-command flakes";
settings = { settings = {
allowed-users = "bryan";
auto-optimise-store = true; auto-optimise-store = true;
}; };
gc = { gc = {
@ -22,28 +21,11 @@
security.sudo.wheelNeedsPassword = false; security.sudo.wheelNeedsPassword = false;
boot = { # GUI
loader = {
grub = {
enable = true;
useOSProber = true;
devices = [ "nodev" ];
efiSupport = true;
configurationLimit = 5;
};
efi = {
canTouchEfiVariables = true;
};
};
# extraModprobeConfig = ''
# options vfio-pci ids=10de:1f82,10de:10fa
# '';
};
programs = { programs = {
sway = { sway = {
enable = true; enable = true;
extraPackages = with pkgs; [ extraPackages = with pkgs; [
rofi-wayland rofi-wayland
grim grim
@ -58,21 +40,15 @@
pavucontrol pavucontrol
]; ];
extraSessionCommands = '' extraSessionCommands = ''
if [ -z "$DISPLAY" ] && [ "$(tty)" = "/dev/tty1" ]; then if [ -z "$DISPLAY" ] && [ "$(tty)" = "/dev/tty1" ]; then
exec sway exec sway
fi fi
if [ "$XDG_CURRENT_DESKTOP" = "sway" ] ; then
export _JAVA_AWT_WM_NONREPARENTING=1 export _JAVA_AWT_WM_NONREPARENTING=1
fi
''; '';
}; };
xwayland.enable = true;
xwayland = {
enable = true;
};
xdg.portal.wlr.enable = true; xdg.portal.wlr.enable = true;
gnupg = { gnupg = {
@ -81,8 +57,6 @@
enableSSHSupport = true; enableSSHSupport = true;
}; };
}; };
git.enable = true;
}; };
services.pipewire = { services.pipewire = {
@ -109,6 +83,7 @@
]; ];
}; };
# System Services
services = { services = {
trezord.enable = true; trezord.enable = true;
@ -125,6 +100,7 @@
useXkbConfig = true; useXkbConfig = true;
}; };
# Locale
time = { time = {
timeZone = "America/New_York"; timeZone = "America/New_York";
}; };
@ -148,13 +124,4 @@
networkmanager.enable = true; networkmanager.enable = true;
firewall.enable = true; firewall.enable = true;
}; };
virtualisation.libvirtd = {
enable = true;
qemu = {
package = pkgs.qemu_kvm;
runAsRoot = true;
ovmf.enable = true;
};
};
} }