feat: start migrating things

This commit is contained in:
Kat Inskip 2022-12-03 19:51:56 +01:00
parent d0b95b4b9e
commit ed581ca5b4
Signed by: kat
GPG key ID: 465E64DECEA8CF0F
8 changed files with 530 additions and 9 deletions

View file

@ -1,4 +1,4 @@
{ self, utils, nixpkgs, darwin, home-manager, ragenix, scalpel, mach-nix, ... }@inputs: let { self, utils, nixpkgs, darwin, home-manager, ragenix, scalpel, mach-nix, arcexprs, ... }@inputs: let
tree = (inputs.tree.tree { tree = (inputs.tree.tree {
inherit inputs; inherit inputs;
folder = ./.; folder = ./.;
@ -9,6 +9,25 @@
"default" "default"
]; ];
}; };
"nixos/modules" = {
functor = {
enable = true;
external = with (import (arcexprs + "/modules")).nixos; [
base16
base16-shared
];
};
};
"home/modules" = {
functor = {
enable = true;
external = with (import (arcexprs + "/modules")).home-manager; [
base16
base16-shared
];
};
};
"home".evaluateDefault = true;
"home/*" = { "home/*" = {
functor.enable = true; functor.enable = true;
}; };
@ -24,10 +43,6 @@ in utils.lib.mkFlake {
hostDefaults = { hostDefaults = {
system = "x86_64-linux"; system = "x86_64-linux";
modules = [
home-manager.nixosModules.home-manager
ragenix.nixosModules.age
];
extraArgs = { extraArgs = {
inherit inputs tree; inherit inputs tree;
}; };
@ -42,11 +57,25 @@ in utils.lib.mkFlake {
"x86_64-linux" = nixpkgs.lib.nixosSystem; "x86_64-linux" = nixpkgs.lib.nixosSystem;
"aarch64-darwin" = darwin.lib.darwinSystem; "aarch64-darwin" = darwin.lib.darwinSystem;
}.${system}; }.${system};
modulesForSystem = system: {
"x86_64-linux" = [
home-manager.nixosModules.home-manager
ragenix.nixosModules.age
tree.nixos.modules
];
"aarch64-darwin" = [
home-manager.darwinModules.home-manager
ragenix.nixosModules.age
tree.darwin.modules
];
}.${system};
mapSystem = system: name: path: { mapSystem = system: name: path: {
inherit system; inherit system;
output = outputForSystem system; output = outputForSystem system;
builder = builderForSystem system; builder = builderForSystem system;
modules = singleton path; modules = (modulesForSystem system) ++ [
path
];
extraArgs = { extraArgs = {
machine = name; machine = name;
}; };
@ -69,7 +98,13 @@ in utils.lib.mkFlake {
machine = name; machine = name;
}; };
modules = [ modules = [
tree.home.common ({ config, ... }: {
home = {
username = "kat";
stateVersion = "22.11";
homeDirectory = "/home/kat";
};
})
path path
]; ];
}) tree.home; }) tree.home;

18
flake.lock generated
View file

@ -21,6 +21,23 @@
"type": "github" "type": "github"
} }
}, },
"arcexprs": {
"flake": false,
"locked": {
"lastModified": 1669933794,
"narHash": "sha256-+7kYj0AhffjlrLXksTmCfcovRqDrBOF9TZA2jSlsfws=",
"owner": "arcnmx",
"repo": "nixexprs",
"rev": "1adfd2810dd37e78ee98e5cd18afe2e87d4bbe38",
"type": "github"
},
"original": {
"owner": "arcnmx",
"ref": "master",
"repo": "nixexprs",
"type": "github"
}
},
"darwin": { "darwin": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -177,6 +194,7 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"arcexprs": "arcexprs",
"darwin": "darwin", "darwin": "darwin",
"empty": "empty", "empty": "empty",
"home-manager": "home-manager", "home-manager": "home-manager",

View file

@ -40,6 +40,10 @@
flake-utils.follows = "utils"; flake-utils.follows = "utils";
}; };
}; };
arcexprs = {
url = "github:arcnmx/nixexprs/master";
flake = false;
};
}; };
outputs = { ... }@inputs: import ./default.nix inputs; outputs = { ... }@inputs: import ./default.nix inputs;
} }

View file

@ -1,2 +0,0 @@
{ config, ... }: {
}

View file

@ -0,0 +1,87 @@
{ config, lib, pkgs, ... }:
let
inherit (lib.modules) mkIf;
inherit (lib.strings) concatStringsSep fixedWidthNumber hasInfix;
inherit (lib.attrsets) mapAttrs filterAttrs;
packDir = builtins.toString(pkgs.vimUtils.packDir config.programs.neovim.generatedConfigViml.configure.packages);
initLua = pkgs.substituteAll ({
name = "init.lua";
src = ./init.lua;
inherit packDir;
base16ShellPath = config.base16.shell.package;
defaultSchemeName = config.base16.defaultSchemeName;
defaultSchemeSlug = config.base16.defaultScheme.slug;
} // mapAttrs (_: col: fixedWidthNumber 2 col.ansiIndex)
(filterAttrs (var: _: hasInfix "base" var) config.base16.defaultScheme));
in mkIf config.programs.neovim.enable {
home.sessionVariables.EDITOR = "nvim";
programs.neovim = {
vimAlias = true;
viAlias = true;
plugins = with pkgs.vimPlugins; [
# Libraries
plenary-nvim
# Disables and re-enables highlighting when searching
vim-cool
# Colour highlighting
vim-hexokinase
# Git porcelain
vim-fugitive
# Start screen
vim-startify
# Re-open with cursor at the same place
vim-lastplace
# Status Bar
lualine-nvim
# EasyMotion Equivalent
hop-nvim
# base16
config.base16.vim.plugin
# Fonts
nvim-web-devicons
# Completion
nvim-cmp
# Fuzzy Finder
telescope-nvim
# Buffers
bufferline-nvim
# Language Server
nvim-lspconfig
(pkgs.vimPlugins.nvim-treesitter.withPlugins (plugins: with pkgs.tree-sitter-grammars; [
tree-sitter-c
tree-sitter-lua
tree-sitter-rust
#tree-sitter-bash
tree-sitter-css
tree-sitter-dockerfile
tree-sitter-go
tree-sitter-hcl
tree-sitter-html
tree-sitter-javascript
tree-sitter-markdown
tree-sitter-nix
tree-sitter-norg
tree-sitter-python
tree-sitter-regex
tree-sitter-scss
]))
# Treesitter Plugins
nvim-ts-rainbow
nvim-treesitter-context
twilight-nvim
];
extraPackages = with pkgs; [
# For nvim-lspconfig, Terraform Language Server
terraform-ls
# For tree-sitter
tree-sitter
nodejs
clang
clangStdenv.cc
];
};
xdg.configFile."nvim/init.lua".source = initLua;
}

View file

@ -0,0 +1,345 @@
-----------------------------------------------------------
-- Variables
-----------------------------------------------------------
local g = vim.g -- Global variables
local opt = vim.opt -- Set options (global/buffer/windows-scoped)
local wo = vim.wo -- Window local variables
local api = vim.api -- Lua API
-----------------------------------------------------------
-- Nix Fuckery
-----------------------------------------------------------
opt.packpath:prepend{"@packDir@"}
opt.runtimepath:prepend{"@packDir@"}
-----------------------------------------------------------
-- Base16
-----------------------------------------------------------
vim.g.base16colorspace = 256
vim.g.base16background = "@defaultSchemeName@"
g.base16_shell_path = "@base16ShellPath@"
vim.cmd("colorscheme base16-@defaultSchemeSlug@")
g.colors_name = "@defaultSchemeSlug@"
local base16 = {
base00 = "@base00@",
base01 = "@base01@",
base02 = "@base02@",
base03 = "@base03@",
base04 = "@base04@",
base05 = "@base05@",
base06 = "@base06@",
base07 = "@base07@",
base08 = "@base08@",
base09 = "@base09@",
base0A = "@base0A@",
base0B = "@base0B@",
base0C = "@base0C@",
base0D = "@base0D@",
base0E = "@base0E@",
base0F = "@base0F@"
}
api.nvim_create_autocmd("vimenter", {
command = "highlight Normal guibg=NONE ctermbg=NONE"
})
api.nvim_create_autocmd("SourcePost", {
command = "highlight Normal ctermbg=NONE guibg=NONE | " ..
"highlight LineNr ctermbg=NONE guibg=NONE | " ..
"highlight SignColumn ctermbg=NONE guibg=NONE"
})
-----------------------------------------------------------
-- General
-----------------------------------------------------------
opt.mouse = 'a' -- Enable mouse support
opt.clipboard = 'unnamedplus' -- Copy/paste to system clipboard
opt.completeopt = 'longest,menuone' -- Autocomplete options
opt.backup = false -- Disable backup
opt.writebackup = false -- Disable backup
opt.ttimeoutlen = 100 -- Mapping timeout
-----------------------------------------------------------
-- Neovim UI
-----------------------------------------------------------
opt.number = true -- Show line number
opt.relativenumber = true -- Relative line numbers
opt.showmatch = true -- Highlight matching parenthesis
opt.foldmethod = 'marker' -- Enable folding (default 'foldmarker')
opt.colorcolumn = '80' -- Line length marker at 80 columns
opt.splitright = true -- Vertical split to the right
opt.splitbelow = true -- Horizontal split to the bottom
opt.ignorecase = true -- Ignore case letters when search
opt.smartcase = true -- Ignore lowercase for the whole pattern
opt.wrap = true -- Wrap on word boundary
opt.linebreak = true -- Wrap on word boundary
opt.showbreak = "" -- Character to use to display word boundary
opt.termguicolors = false -- Enable 24-bit RGB colors
opt.laststatus = 3 -- Set global statusline
opt.cursorline = true -- Highlight cursor screenline
opt.cmdheight = 1 -- Command entry line height
opt.hlsearch = true -- Highlight matches with last search pattern
-----------------------------------------------------------
-- Tabs, indent
-----------------------------------------------------------
opt.expandtab = true -- Use spaces instead of tabs
opt.shiftwidth = 2 -- Shift 2 spaces when tab
opt.tabstop = 2 -- 1 tab == 2 spaces
opt.smartindent = true -- Autoindent new lines
opt.list = true -- List chars
opt.listchars = {
tab = '» ',
extends = '',
precedes= '',
nbsp = '·',
trail = ''
}
-----------------------------------------------------------
-- Memory, CPU
-----------------------------------------------------------
opt.hidden = true -- Enable background buffers
opt.history = 100 -- Remember N lines in history
opt.lazyredraw = true -- Faster scrolling
opt.synmaxcol = 240 -- Max column for syntax highlight
opt.updatetime = 700 -- ms to wait for trigger an event
-----------------------------------------------------------
-- Plugins
-----------------------------------------------------------
-- Remove perl
g.loaded_perl_provider = 0
-- Hexokinaise
g.Hexokinase_highlighters = {'virtual'}
g.Hexokinase_optInPatterns = {
'full_hex',
'rgb',
'rgba',
'hsl',
'hsla',
'colour_names'
}
-- Lastplace
g.lastplace_ignore = 'gitcommit,gitrebase,svn,hgcommit'
-----------------------------------------------------------
-- Startup
-----------------------------------------------------------
-- Disable builtins plugins
local disabled_built_ins = {
"netrw",
"netrwPlugin",
"netrwSettings",
"netrwFileHandlers",
"gzip",
"zip",
"zipPlugin",
"tar",
"tarPlugin",
"getscript",
"getscriptPlugin",
"vimball",
"vimballPlugin",
"2html_plugin",
"logipat",
"rrhelper",
"spellfile_plugin",
"matchit"
}
for _, plugin in pairs(disabled_built_ins) do
g["loaded_" .. plugin] = 1
end
-----------------------------------------------------------
-- Plugins
-----------------------------------------------------------
-- lualine
require('lualine').setup{}
-- nvim-cmp
local cmp = require('cmp')
cmp.setup({
snippet = {
expand = function(args)
vim.fn["vsnip#anonymous"](args.body)
end,
},
mapping = {
['<C-y>'] = cmp.mapping.confirm({ select = true }),
},
sources = {
-- { name = 'neorg' },
}
})
-- lspconfig
require('lspconfig').terraformls.setup{}
api.nvim_create_autocmd('BufWritePre', {
pattern = '*.tf',
command = 'lua vim.lsp.buf.formatting_sync()'
})
--[[
-- neorg
require('neorg').setup {
-- Tell Neorg what modules to load
load = {
['core.defaults'] = {}, -- Load all the default modules
['core.norg.concealer'] = {}, -- Allows for use of icons
['core.norg.dirman'] = { -- Manage your directories with Neorg
config = {
engine = 'nvim-cmp',
workspaces = {
home = '~/neorg'
}
}
}
},
}]]--
-- telescope
local telescope = require('telescope.builtin')
vim.keymap.set("n", "<leader>ff", function()
telescope.find_files()
end, { silent = true })
vim.keymap.set("n", "<leader>fg", function()
telescope.live_grep()
end, { silent = true })
vim.keymap.set("n", "<leader>fb", function()
telescope.buffers()
end, { silent = true })
vim.keymap.set("n", "<leader>fh", function()
telescope.help_tags()
end, { silent = true })
-- treesitter
require('nvim-treesitter.configs').setup {
-- A list of parser names, or "all"
ensure_installed = {
},
sync_install = false,
auto_install = false,
ignore_install = {},
highlight = {
enable = true,
additional_vim_regex_highlighting = false,
},
indent = {
enable = true,
},
rainbow = {
enable = true,
extended_mode = true
},
}
-- twilight
require("twilight").setup {
dimming = {
alpha = 0.5,
},
context = 10,
expand = {
"function",
"method",
"table",
"if_statement",
},
}
-- bufferline
require('bufferline').setup {
options = {
mode = "buffers", -- set to "tabs" to only show tabpages instead
numbers = "ordinal",
close_command = "bdelete! %d", -- can be a string | function, see "Mouse actions"
right_mouse_command = "bdelete! %d", -- can be a string | function, see "Mouse actions"
left_mouse_command = "buffer %d", -- can be a string | function, see "Mouse actions"
middle_mouse_command = nil, -- can be a string | function, see "Mouse actions"
indicator = {
icon = '',
style = 'icon',
},
buffer_close_icon = '',
modified_icon = '',
close_icon = '',
left_trunc_marker = '',
right_trunc_marker = '',
name_formatter = function(buf) -- buf contains a "name", "path" and "bufnr"
-- remove extension from markdown files for example
if buf.name:match('%.md') then
return vim.fn.fnamemodify(buf.name, ':t:r')
end
end,
max_name_length = 18,
max_prefix_length = 15, -- prefix used when a buffer is de-duplicated
tab_size = 18,
diagnostics = "nvim_lsp",
diagnostics_update_in_insert = false,
color_icons = true,
show_buffer_icons = true, -- disable filetype icons for buffers
show_buffer_close_icons = true,
show_close_icon = false,
show_tab_indicators = true,
persist_buffer_sort = true, -- whether or not custom sorted buffers should persist
separator_style = "slant",
always_show_bufferline = true,
}
}
local barColor = base16.base00;
local highlightItems = {
BufferLineFill = "bg",
BufferLineBackground = "bg",
BufferLineSeparator = "fg",
BufferLineSeparatorSelected = "fg",
BufferLineSeparatorVisible = "fg",
}
local commandString = ""
for item, ground in pairs(highlightItems) do
commandString = "highlight " .. item .. " cterm" .. ground .. "=" .. barColor .. " | " .. commandString
end
api.nvim_create_autocmd("ColorScheme", {
command = commandString;
})
-- hop
local hop = require('hop')
local directions = require("hop.hint").HintDirection
hop.setup()
vim.keymap.set("", "t", function()
hop.hint_words()
end, {})
vim.keymap.set("", "T", function()
hop.hint_lines_skip_whitespace()
end, {remap=true})
vim.keymap.set("", "f", function()
hop.hint_char1({ direction = directions.AFTER_CURSOR, current_line_only = true })
end, {remap=true})
vim.keymap.set("", "F", function()
hop.hint_char1({ direction = directions.BEFORE_CURSOR, current_line_only = true })
end, {remap=true})

19
nixos/modules/server.nix Normal file
View file

@ -0,0 +1,19 @@
{ config, lib, ... }: let
inherit (lib.options) mkOption mdDoc;
inherit (lib.modules) mkIf;
inherit (lib.attrsets) mapAttrsToList;
inherit (lib.types) bool;
in {
options = {
role.server = mkOption {
type = bool;
description = mdDoc "Is this system's role a server?";
default = false;
};
};
config = mkIf config.role.server {
# Prevent services from being automatically killed on log-out
# https://wiki.archlinux.org/title/systemd/User#Automatic_start-up_of_systemd_user_instances
systemd.tmpfiles.rules = mapAttrsToList (username: _: "f /var/lib/systemd/linger/${username}" ) config.users.users;
};
}

15
nixos/users/kat.nix Normal file
View file

@ -0,0 +1,15 @@
{ tree, config, ... }: with lib;
{
users.users.kat = {
uid = 1000;
isNormalUser = true;
openssh.authorizedKeys.keys = [
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQCocjQqiDIvzq+Qu3jkf7FXw5piwtvZ1Mihw9cVjdVcsra3U2c9WYtYrA3r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S5CuMdQMWg9qVbpHZUHMjA0QmNkjPgq71pUDXHk5L4mZuS8wVjyjnvlw68yIJuHEc8P7QiLcjvRHFS2L9Ck8NRmPDTQXlQi9kk6LmMyu6fdevR/kZL21b+xO1e2DMyxBbNDTot8luppiiL8adgUDMwptpIne7JCWB1o9NFCbXUVgwuCCYBif6pOGSc6bGo1JTAKMflRlcy6Mi3t5H0mR2lj/sCSTWwTlP5FM4aPIq08NvW6PeuK1bFJY9fIgTwVsUnbAKOhmsMt62w== cardno:12 078 454"
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAII74JrgGsDQ6r7tD7+k3ykxXV7DpeeFRscPMxrBsDPhz kat@goliath"
];
shell = pkgs.zsh;
extraGroups = [ "wheel" "video" "systemd-journal" "plugdev" "bird2" "vfio" "input" "uinput" ];
};
}