restructured

* laptop, pc and common now live in systems
* new dev shell to run dconf2nix
* New dconf weather entry (currently not functional)
This commit is contained in:
2023-09-25 20:02:11 +02:00
parent de46bcead1
commit a2cd8d467f
27 changed files with 21 additions and 4 deletions

15
systems/common/bash.nix Normal file
View File

@ -0,0 +1,15 @@
{...}: {
programs.bash = {
enable = true;
initExtra = ''
PS1='\[\033[1;32m\][\[\e]0;\u@\h: \w\a\]\w]\$\[\033[0m\] '
'';
shellAliases = {
ll = "ls -lh";
la = "ls -lah";
".." = "cd ..";
};
};
}

View File

@ -0,0 +1,52 @@
{
config,
lib,
options,
specialArgs,
modulesPath,
}: {
home.stateVersion = "23.05";
home.username = "kristian";
home.homeDirectory = "/home/kristian";
home.sessionVariables = {
# Electron programms won't render correctly under wayland without this
NIXOS_OZONE_WL = 1;
};
# Keyboard Layout
home.keyboard.layout = "at";
imports = [
./bash.nix
./direnv.nix
./firefox.nix
./fonts.nix
./git.nix
./gnome.nix
./gpg.nix
./nvim
./packages.nix
./thunderbird.nix
./vscode.nix
./mpv.nix
];
# Programs
programs = {
home-manager.enable = true; # Allow home-manager to manage itself
obs-studio.enable = true;
yt-dlp.enable = true;
};
xdg.mimeApps = {
enable = true;
defaultApplications = {
"image/png" = ["org.gnome.eog.desktop"];
"image/jpeg" = ["org.gnome.eog.desktop"];
"video/webm" = ["mpv.desktop"];
"application/pdf" = ["org.gnome.Evince.desktop"];
};
};
}

View File

@ -0,0 +1,8 @@
{...}: {
programs.direnv = {
enable = true;
nix-direnv.enable = true;
enableBashIntegration = true;
};
}

View File

@ -0,0 +1,23 @@
{config, ...}: {
programs.firefox = {
enable = true;
profiles.kristian = {
isDefault = true;
search.default = "DuckDuckGo";
search.force = true;
extensions = with config.nur.repos.rycee.firefox-addons; [
ublock-origin
umatrix
sidebery
sponsorblock
dearrow
];
settings = {
"extensions.pocket.enabled" = false;
};
};
};
}

7
systems/common/fonts.nix Normal file
View File

@ -0,0 +1,7 @@
{pkgs, ...}: {
fonts.fontconfig.enable = true;
home.packages = with pkgs; [
nerdfonts
];
}

17
systems/common/git.nix Normal file
View File

@ -0,0 +1,17 @@
{...}: {
programs.git = rec {
enable = true;
userName = "Kristian Krsnik";
userEmail = "git@krsnik.at";
signing = {
key = userEmail;
signByDefault = true;
};
extraConfig = {
init.defaultBranch = "main";
};
};
}

112
systems/common/gnome.nix Normal file
View File

@ -0,0 +1,112 @@
{
pkgs,
wallpaper,
...
}: {
home.packages = with pkgs.gnomeExtensions; [
quick-settings-audio-panel
tray-icons-reloaded
espresso
pano
];
dconf.settings = {
# Use `dconf watch /` to track stateful changes you are doing, then set them here.
"org/gnome/shell" = {
disable-user-extensions = false;
enabled-extensions = [
"quick-settings-audio-panel@rayzeq.github.io"
"places-menu@gnome-shell-extensions.gcampax.github.com"
"launch-new-instance@gnome-shell-extensions.gcampax.github.com"
"trayIconsReloaded@selfmade.pl"
"espresso@coadmunkee.github.com"
"pano@elhan.io"
];
};
"org/gnome/desktop/interface" = {
color-scheme = "prefer-dark";
gtk-theme = "Adwaita-dark";
};
"org/gnome/desktop/background" = let
width = 3840;
height = 2160;
in {
picture-uri = "file://${wallpaper.override {
preset = "nord-snow-aurora";
inherit width;
inherit height;
}}/share/wallpapers/nixos-wallpaper.png";
picture-uri-dark = "file://${wallpaper.override {
preset = "nord-night-aurora";
inherit width;
inherit height;
}}/share/wallpapers/nixos-wallpaper.png";
};
"org/gnome/desktop/wm/keybindings" = {
switch-to-workspace-left = ["<Alt>1"];
switch-to-workspace-right = ["<Alt>2"];
move-to-workspace-left = ["<Shift><Alt>1"];
move-to-workspace-right = ["<Shift><Alt>2"];
};
"org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0" = {
binding = "<Shift><Alt>a";
command = "kgx";
name = "Console";
};
"org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1" = {
binding = "<Shift><Alt>f";
command = "nautilus";
name = "File Manager";
};
"org/gnome/settings-daemon/plugins/media-keys" = {
custom-keybindings = [
"/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom0/"
"/org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/"
];
};
"org/gnome/mutter" = {
edge-tiling = true;
dynamic-workspaces = true;
};
"org/gnome/Console" = {
theme = "auto";
};
"org/gnome/simple-scan" = {
text-dpi = 300;
};
"org/gnome/shell/extensions/pano" = {
play-audio-on-copy = false;
# This solves the stuttering issue for me.
# https://github.com/oae/gnome-shell-pano/issues/79
send-notification-on-copy = false;
};
"org/gnome/shell/extensions/espresso" = {
show-notifications = false;
};
"org/gnome/nautilus/preferences" = {
show-image-thumbnails = "always";
};
"org/gnome/Weather" = {
locations = "[<(uint32 2, <('Vienna', 'LOWW', true, [(0.83979426423570236, 0.2891428852314914)], [(0.84124869946126679, 0.28565222672750273)])>)>]";
};
"org/gnome/shell/weather" = {
automatic-location = true;
locations = "[<(uint32 2, <('Vienna', 'LOWW', true, [(0.83979426423570236, 0.2891428852314914)], [(0.84124869946126679, 0.28565222672750273)])>)>]";
};
};
}

28
systems/common/gpg.nix Normal file
View File

@ -0,0 +1,28 @@
{...}: {
programs.gpg.enable = true;
services.gpg-agent = {
enable = true;
enableSshSupport = true;
sshKeys = ["A0B5D579ECACC45C51B2B38E317D346182083CD8"];
# The amount of time a key is kept in the cache before it is removed.
# The timer is reset after each use within that window.
defaultCacheTtl = 86400; # 1 Day
defaultCacheTtlSsh = 86400; # 1 Day
# The maximum amount after which the passphrase has to be retyped,
# even if the key is still cached.
maxCacheTtl = 86400; # 1 Day
maxCacheTtlSsh = 86400; # 1 Day
};
# Disable gnome-keyring-ssh for gpg-agent to work
# https://github.com/NixOS/nixpkgs/issues/101616
xdg.configFile."autostart/gnome-keyring-ssh.desktop".text = ''
[Desktop Entry]
Type=Application
Hidden=true
'';
}

23
systems/common/mpv.nix Normal file
View File

@ -0,0 +1,23 @@
{...}: {
programs.mpv = {
enable = true;
bindings = let
volume-step = "5";
speed-step = "0.125";
seek-step = "5";
in {
# supported commands https://raw.githubusercontent.com/mpv-player/mpv/master/etc/input.conf
WHEEL_UP = "add volume +${volume-step}";
WHEEL_DOWN = "add volume -${volume-step}";
RIGHT = "seek +${seek-step}";
LEFT = "seek -${seek-step}";
UP = "add volume +${volume-step}";
DOWN = "add volume -${volume-step}";
"Alt+h" = "vf toggle hflip";
"Alt+v" = "vf toggle vflip";
">" = "add speed +${speed-step}";
"<" = "add speed -${speed-step}";
BS = "set speed 1.0";
};
};
}

View File

@ -0,0 +1,64 @@
-- Set up nvim-cmp.
local cmp = require'cmp'
cmp.setup({
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
end,
},
window = {
-- completion = cmp.config.window.bordered(),
-- documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
-- { name = 'vsnip' }, -- For vsnip users.
{ name = 'luasnip' }, -- For luasnip users.
-- { name = 'ultisnips' }, -- For ultisnips users.
-- { name = 'snippy' }, -- For snippy users.
}, {
{ name = 'buffer' },
})
})
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
}, {
{ name = 'buffer' },
})
})
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline({ '/', '?' }, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
-- Set up lspconfig.
local capabilities = require('cmp_nvim_lsp').default_capabilities()
-- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
require('lspconfig')['pyright'].setup {
capabilities = capabilities
}

View File

@ -0,0 +1,11 @@
require('tokyonight').setup({style = 'moon',})
function ColorMyPencils(color)
color = color or 'tokyonight'
vim.cmd.colorscheme(color)
vim.api.nvim_set_hl(0, 'Normal', { bg = 'none' })
vim.api.nvim_set_hl(0, 'NormalFloat', { bg = 'none' })
end
ColorMyPencils()

View File

@ -0,0 +1,54 @@
{pkgs, ...}: {
config.programs.neovim = {
enable = true;
defaultEditor = true;
viAlias = true;
vimAlias = true;
vimdiffAlias = true;
plugins = with pkgs.vimPlugins;
[
telescope-nvim # fuzzy finder
tokyonight-nvim # theme
undotree # undotree
vim-fugitive # git integration
nvim-treesitter # syntax highlighting
# Autocomplete and LSP
nvim-lspconfig
nvim-cmp
cmp-nvim-lsp
luasnip
]
++ (with pkgs.vimPlugins.nvim-treesitter-parsers; [
# Parsers for syntax highlighting
nix
zig
python
vim
vimdoc
markdown
dockerfile
yaml
json
toml
lua
c
glsl
bash
]);
extraPackages = [pkgs.nodePackages.pyright];
extraLuaConfig =
builtins.readFile ./keybinds.lua
+ builtins.readFile ./colors.lua
+ builtins.readFile ./undotree.lua
+ builtins.readFile ./fugitive.lua
+ builtins.readFile ./treesitter.lua
+ builtins.readFile ./telescope.lua
+ builtins.readFile ./cmp.lua
+ builtins.readFile ./lspconfig.lua;
extraConfig = "set number relativenumber";
};
}

View File

@ -0,0 +1 @@
vim.keymap.set('n', '<leader>gs', vim.cmd.Git)

View File

@ -0,0 +1,2 @@
vim.g.mapleader = ' '
vim.keymap.set('n', '<leader>pv', vim.cmd.Ex)

View File

@ -0,0 +1,40 @@
-- Global mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float)
vim.keymap.set('n', '<C-p>', vim.diagnostic.goto_prev)
vim.keymap.set('n', '<C-n>', vim.diagnostic.goto_next)
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist)
-- Use LspAttach autocommand to only map the following keys
-- after the language server attaches to the current buffer
vim.api.nvim_create_autocmd('LspAttach', {
group = vim.api.nvim_create_augroup('UserLspConfig', {}),
callback = function(ev)
-- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = 'v:lua.vim.lsp.omnifunc'
-- Buffer local mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
local opts = { buffer = ev.buf }
vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, opts)
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, opts)
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, opts)
vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, opts)
vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, opts)
vim.keymap.set('n', '<space>wl', function()
print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
end, opts)
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, opts)
vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, opts)
vim.keymap.set({ 'n', 'v' }, '<space>ca', vim.lsp.buf.code_action, opts)
vim.keymap.set('n', '<space>f', function()
vim.lsp.buf.format { async = true }
end, opts)
end,
})

View File

@ -0,0 +1,7 @@
local telescope = require('telescope.builtin')
vim.keymap.set('n', '<leader>pf', telescope.find_files, {})
vim.keymap.set('n', '<C-p>', telescope.git_files, {})
vim.keymap.set('n', '<leader>ps', function()
telescope.grep_string({ search = vim.fn.input("Grep > ")});
end)

View File

@ -0,0 +1,8 @@
-- Treesitter
require'nvim-treesitter.configs'.setup {
highlight = {
-- `false` will disable the whole extension
enable = true,
additional_vim_regex_highlighting = false,
},
}

View File

@ -0,0 +1 @@
vim.keymap.set('n', '<leader>u', vim.cmd.UndotreeToggle)

View File

@ -0,0 +1,48 @@
{
pkgs,
lib,
...
}: {
nixpkgs.config = {
allowUnfree = false;
allowUnfreePredicate = pkg:
builtins.elem (lib.getName pkg) [
"vscode"
"vscode-extension-MS-python-vscode-pylance"
"vscode-extension-github-copilot"
"osu-lazer"
];
};
home.packages = with pkgs; [
# Basic utils
unzip
magic-wormhole
# Important graphical applications
keepassxc
logseq
xournalpp
onlyoffice-bin
# Games
osu-lazer
# Communication
webcord
telegram-desktop
signal-desktop
element-desktop
# Creative software
gimp
davinci-resolve
# Misc
gnome-decoder
tor-browser-bundle-bin
hypnotix
];
}

View File

@ -0,0 +1,10 @@
{...}: {
programs.thunderbird = {
enable = true;
profiles.kristian = {
isDefault = true;
withExternalGnupg = true;
};
};
}

81
systems/common/vscode.nix Normal file
View File

@ -0,0 +1,81 @@
{pkgs, ...}: {
programs.vscode = {
enable = true;
enableUpdateCheck = false;
enableExtensionUpdateCheck = false;
keybindings = [
{
key = "alt+a";
command = "editor.action.commentLine";
when = "editorTextFocus && !editorReadonly";
}
];
extensions = with pkgs.vscode-extensions; [
jnoortheen.nix-ide
arrterian.nix-env-selector
mkhl.direnv
ms-python.python
ms-python.vscode-pylance
james-yu.latex-workshop
github.copilot
davidanson.vscode-markdownlint
tamasfe.even-better-toml
asciidoctor.asciidoctor-vscode
streetsidesoftware.code-spell-checker
];
userSettings = {
"git.enableCommitSigning" = true;
"window.menuBarVisibility" = "hidden";
"editor.fontFamily" = "'FiraCode Nerd Font'";
"editor.fontLigatures" = true;
"editor.minimap.enabled" = false;
"[nix]" = {
"editor.formatOnSave" = true;
"editor.formatOnSaveMode" = "file"; # modificationsIfAvailable does not work
};
"[python]" = {
"editor.formatOnSave" = true;
"editor.formatOnSaveMode" = "modificationsIfAvailable";
};
"[latex]" = {
"editor.formatOnSave" = true;
"editor.formatOnSaveMode" = "file"; # modificationsIfAvailable does not work
};
"[toml]" = {
"editor.formatOnSave" = true;
"editor.modificationsIfAvailable" = "file";
};
"python.formatting.autopep8Path" = "${pkgs.python311Packages.autopep8}/bin/autopep8";
"nix.enableLanguageServer" = true;
"nix.serverPath" = "${pkgs.nil}/bin/nil";
"nix.serverSettings" = {
nil = {
formatting = {command = ["${pkgs.alejandra}/bin/alejandra"];};
};
};
"direnv.path.executable" = "${pkgs.direnv}/bin/direnv";
"latex-workshop.latex.outDir" = "%DIR%/out";
"terminal.integrated.profiles.linux" = {
"bash" = {
"path" = "${pkgs.bashInteractive}/bin/bash";
"args" = [];
};
};
"terminal.integrated.defaultProfile.linux" = "bash";
};
};
}