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

@ -8,12 +8,12 @@
inputs.nixpkgs.follows = "nixpkgs";
};
nur = {
url = "github:nix-community/NUR";
inputs.nixpkgs.follows = "nixpkgs";
url = "github:nix-community/NUR";
inputs.nixpkgs.follows = "nixpkgs";
};
disko = {
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs";
};
};
@ -30,11 +30,10 @@
in
{
nixosConfigurations.socrates = nixpkgs.lib.nixosSystem {
nixosConfigurations.socratesV2 = nixpkgs.lib.nixosSystem {
inherit pkgs;
modules = [
./machines/hardware-configuration.nix
./machines/system.nix
./machines
disko.nixosModules.disko
home-manager.nixosModules.home-manager{
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,120 +64,118 @@ in {
unset flake_icon
}
PROMPT_COMMAND="set_ps1_prompt; $PROMPT_COMMAND"
'';
function cdg() {
if [[ $1 == "--help" ]]; then
echo "A simple utility for navigating to the root of a git repo"
return 0
fi
bashrcExtra = ''
function cdg() {
if [[ $1 == "--help" ]]; then
echo "A simple utility for navigating to the root of a git repo"
return 0
fi
# Check for invalid command
if [[ -n "$1" ]]; then
echo "Invalid command: $1. Try 'cdg --help'."
return 1
fi
# Check for invalid command
if [[ -n "$1" ]]; then
echo "Invalid command: $1. Try 'cdg --help'."
return 1
fi
local root_dir
root_dir=$(git rev-parse --show-toplevel 2>/dev/null)
local git_status=$?
local root_dir
root_dir=$(git rev-parse --show-toplevel 2>/dev/null)
local git_status=$?
if [ $git_status -ne 0 ]; then
echo "Error: Not a git repo."
return 1
fi
if [ $git_status -ne 0 ]; then
echo "Error: Not a git repo."
return 1
fi
cd "$root_dir"
}
cd "$root_dir"
}
function ldv() {
if [[ $1 == "help" ]] || [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
cat << EOF
ldv
A simple utility for setting up development environments effortlessly.
Commands:
ldv Start a preconfigured nix shell.
init Create a new dev template in the current working directory.
help Show available commands and options.
Contributions welcome: https://github.com/itme-brain/ldv
EOF
elif [[ $1 == "init" ]] || [[ $1 == "-i" ]] || [[ $1 == "--init" ]]; then
if [[ -e ./shell.nix ]] || [[ -e ./.envrc ]]; then
function ldv() {
if [[ $1 == "help" ]] || [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
cat << EOF
Existing environment found.
Initialization cancelled.
EOF
return
ldv
A simple utility for setting up development environments effortlessly.
Commands:
ldv Start a preconfigured nix shell.
init Create a new dev template in the current working directory.
help Show available commands and options.
Contributions welcome: https://github.com/itme-brain/ldv
EOF
elif [[ $1 == "init" ]] || [[ $1 == "-i" ]] || [[ $1 == "--init" ]]; then
if [[ -e ./shell.nix ]] || [[ -e ./.envrc ]]; then
cat << EOF
Existing environment found.
Initialization cancelled.
EOF
return
fi
cat << EOF
Initializing a new environment...
Select an environment:
1. Web
2. Elixir
3. Haskell
EOF
read -p "Enter the number of your choice: " choice
case $choice in
1)
wget -q https://raw.githubusercontent.com/itme-brain/ldv/main/shells/web.nix -O shell.nix
wget -q https://raw.githubusercontent.com/itme-brain/ldv/main/utils/flake -O flake.nix
wget -q https://raw.githubusercontent.com/itme-brain/ldv/main/utils/envrc -O .envrc
direnv allow
;;
2)
wget -q https://raw.githubusercontent.com/itme-brain/ldv/main/shells/elixir.nix -O shell.nix
wget -q https://raw.githubusercontent.com/itme-brain/ldv/main/utils/flake -O flake.nix
wget -q https://raw.githubusercontent.com/itme-brain/ldv/main/utils/envrc -O .envrc
direnv allow
;;
3)
wget -q https://raw.githubusercontent.com/itme-brain/ldv/main/shells/haskell.nix -O shell.nix
wget -q https://raw.githubusercontent.com/itme-brain/ldv/main/utils/flake -O flake.nix
wget -q https://raw.githubusercontent.com/itme-brain/ldv/main/utils/envrc -O .envrc
direnv allow
;;
*)
echo "Invalid choice."
;;
esac
elif [[ -z $1 ]]; then
cat << EOF
Select an environment:
1. Web
2. Elixir
3. Haskell
EOF
read -p "Enter the number of your choice: " choice
case $choice in
1)
(nix develop github:itme-brain/ldv#web)
;;
2)
(nix develop github:itme-brain/ldv#elixir)
;;
3)
(nix develop github:itme-brain/ldv#haskell)
;;
# Add more cases here...
*)
echo "Invalid choice."
;;
esac
else
echo "Error: Invalid command. Try 'ldv --help'"
fi
cat << EOF
Initializing a new environment...
Select an environment:
1. Web
2. Elixir
3. Haskell
EOF
read -p "Enter the number of your choice: " choice
case $choice in
1)
wget -q https://raw.githubusercontent.com/itme-brain/ldv/main/shells/web.nix -O shell.nix
wget -q https://raw.githubusercontent.com/itme-brain/ldv/main/utils/flake -O flake.nix
wget -q https://raw.githubusercontent.com/itme-brain/ldv/main/utils/envrc -O .envrc
direnv allow
;;
2)
wget -q https://raw.githubusercontent.com/itme-brain/ldv/main/shells/elixir.nix -O shell.nix
wget -q https://raw.githubusercontent.com/itme-brain/ldv/main/utils/flake -O flake.nix
wget -q https://raw.githubusercontent.com/itme-brain/ldv/main/utils/envrc -O .envrc
direnv allow
;;
3)
wget -q https://raw.githubusercontent.com/itme-brain/ldv/main/shells/haskell.nix -O shell.nix
wget -q https://raw.githubusercontent.com/itme-brain/ldv/main/utils/flake -O flake.nix
wget -q https://raw.githubusercontent.com/itme-brain/ldv/main/utils/envrc -O .envrc
direnv allow
;;
*)
echo "Invalid choice."
;;
esac
elif [[ -z $1 ]]; then
cat << EOF
Select an environment:
1. Web
2. Elixir
3. Haskell
EOF
read -p "Enter the number of your choice: " choice
case $choice in
1)
(nix develop github:itme-brain/ldv#web)
;;
2)
(nix develop github:itme-brain/ldv#elixir)
;;
3)
(nix develop github:itme-brain/ldv#haskell)
;;
# Add more cases here...
*)
echo "Invalid choice."
;;
esac
else
echo "Error: Invalid command. Try 'ldv --help'"
fi
}
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
ldv "$@"
fi
'';
}
'';
shellAliases = {
ls = "lsd";

View file

@ -9,11 +9,13 @@ in
config = mkIf cfg.enable {
programs.git = {
enable = true;
userName = "Bryan Ramos";
userEmail = "bryan@ramos.codes";
extraConfig = {
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 {
owner = "projekt0n";
repo = "github-nvim-theme";
rev = "62b7b54a90c70c20cd1641f9facfced46bdd3561";
rev = "ea713c37691b2519f56cd801a2330bdf66393d0f";
sha256 = "0cwr3b5r2ac7aizxmwb3mlhdc2sh0pw670vcwps79x9jp52yrj2y";
};
};
@ -27,7 +27,6 @@ in {
vimAlias = true;
plugins = with pkgs.vimPlugins; [
{
plugin = github-theme;
config = ''
@ -37,13 +36,15 @@ in {
'';
}
lazygit.nvim
{ plugin = lazygit.nvim; }
{
plugin = LazyVim;
config = ''
lua << EOF
return {
{'williamboman/mason.nvim', enabled = false },
{'williamboman/mason-lspconfig.nvim', enabled = false },
{'nvim-treesitter/nvim-treesitter', enabled = false },
}
EOF
@ -65,19 +66,162 @@ in {
}
{
plugin = nvim-treesitter.withAllGrammars
plugin = nvim-treesitter.withAllGrammars;
config = ''
lua << EOF
require'nvim-treesitter.configs'.setup {
highlight = {
enable = true,
},
}
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; [
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
sumneko-lua-language-server stylua
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") ];
nix.system-features = "kvm";
environment.systemPackages = pkgs.virt-manager;
# Kernel
boot.initrd.availableKernelModules = [ "vmd" "xhci_pci" "ahci" "nvme" "usbhid" "usb_storage" "sd_mod" ];
boot.initrd.kernelModules = [ "dm-snapshot" ];
boot.extraModulePackages = [ ];
@ -13,6 +11,22 @@
boot.kernelModules = [ "kvm-intel" "virtio" "vfio-pci" "coretemp" ];
boot.kernelPackages = pkgs.linuxPackages_latest;
# Bootloader
boot.loader = {
grub = {
enable = true;
useOSProber = true;
devices = [ "nodev" ];
efiSupport = true;
configurationLimit = 5;
};
efi = {
canTouchEfiVariables = true;
};
};
# FStab
fileSystems."/" =
{ device = "/dev/disk/by-uuid/af24c5b3-8a6e-4333-a61d-922a97928cae";
fsType = "ext4";
@ -28,6 +42,8 @@
fsType = "vfat";
};
# GPU
programs.sway.extraOptions = "--unsupported-gpu";
services.xserver.videoDrivers = [ "nvidia" ];
hardware = {
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";
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 = {
extraOptions = "experimental-features = nix-command flakes";
settings = {
allowed-users = "bryan";
auto-optimise-store = true;
};
gc = {
@ -22,57 +21,34 @@
security.sudo.wheelNeedsPassword = false;
boot = {
loader = {
grub = {
enable = true;
useOSProber = true;
devices = [ "nodev" ];
efiSupport = true;
configurationLimit = 5;
};
efi = {
canTouchEfiVariables = true;
};
};
# extraModprobeConfig = ''
# options vfio-pci ids=10de:1f82,10de:10fa
# '';
};
# GUI
programs = {
sway = {
enable = true;
extraPackages = with pkgs; [
rofi-wayland
grim
slurp
wl-clipboard
rofi-wayland
grim
slurp
wl-clipboard
xdg-utils
xdg-utils
fontconfig
qogir-icon-theme
emote
fontconfig
qogir-icon-theme
emote
pavucontrol
];
pavucontrol
];
extraSessionCommands = ''
if [ -z "$DISPLAY" ] && [ "$(tty)" = "/dev/tty1" ]; then
exec sway
fi
if [ "$XDG_CURRENT_DESKTOP" = "sway" ] ; then
export _JAVA_AWT_WM_NONREPARENTING=1
fi
export _JAVA_AWT_WM_NONREPARENTING=1
'';
};
xwayland = {
enable = true;
};
xwayland.enable = true;
xdg.portal.wlr.enable = true;
gnupg = {
@ -81,8 +57,6 @@
enableSSHSupport = true;
};
};
git.enable = true;
};
services.pipewire = {
@ -109,6 +83,7 @@
];
};
# System Services
services = {
trezord.enable = true;
@ -125,6 +100,7 @@
useXkbConfig = true;
};
# Locale
time = {
timeZone = "America/New_York";
};
@ -148,13 +124,4 @@
networkmanager.enable = true;
firewall.enable = true;
};
virtualisation.libvirtd = {
enable = true;
qemu = {
package = pkgs.qemu_kvm;
runAsRoot = true;
ovmf.enable = true;
};
};
}