From 5ab67429b277608d5388b3411c386e68c4ce0777 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Sun, 23 Jul 2023 01:18:29 +0200 Subject: [PATCH] First working version of NixOS intall --- README.md | 18 + common/flakes.nix | 10 + common/locales.nix | 6 + common/user.nix | 24 ++ flake.lock | 47 +++ flake.nix | 21 ++ hosts/mrmeeseeks/configuration.nix | 72 ++++ hosts/mrmeeseeks/hardware-configuration.nix | 67 ++++ modules/home/cli/default.nix | 10 + modules/home/cli/git.nix | 9 + modules/home/cli/gnupg.nix | 20 + modules/home/cli/neovim.nix | 382 ++++++++++++++++++++ modules/home/cli/pass.nix | 6 + modules/home/cli/zsh.nix | 68 ++++ modules/home/desktop/default.nix | 16 + modules/home/desktop/fonts.nix | 11 + modules/home/desktop/gtk.nix | 29 ++ modules/home/desktop/qt.nix | 8 + modules/home/desktop/sway/default.nix | 11 + modules/home/desktop/sway/fuzzel.nix | 27 ++ modules/home/desktop/sway/mako.nix | 37 ++ modules/home/desktop/sway/sway.nix | 198 ++++++++++ modules/home/desktop/sway/swayidle.nix | 27 ++ modules/home/desktop/sway/swaylock.nix | 30 ++ modules/home/desktop/sway/waybar.nix | 10 + modules/home/desktop/xdg.nix | 14 + modules/home/firefox/conf/doh.nix | 7 + modules/home/firefox/conf/drm.nix | 12 + modules/home/firefox/conf/experiments.nix | 21 ++ modules/home/firefox/conf/extensions.nix | 11 + modules/home/firefox/conf/preferences.nix | 28 ++ modules/home/firefox/conf/privacy.nix | 119 ++++++ modules/home/firefox/conf/safebrowsing.nix | 14 + modules/home/firefox/conf/suggest.nix | 11 + modules/home/firefox/conf/telemetry.nix | 38 ++ modules/home/firefox/conf/theme.nix | 4 + modules/home/firefox/conf/tracking.nix | 82 +++++ modules/home/firefox/default.nix | 154 ++++++++ modules/home/foot.nix | 47 +++ modules/home/lutris.nix | 20 + modules/home/zathura.nix | 11 + modules/nixos/doas.nix | 5 + modules/nixos/neovim.nix | 13 + modules/nixos/pipewire.nix | 9 + modules/nixos/steam.nix | 7 + modules/nixos/xdg-portal.nix | 9 + result | 1 + 47 files changed, 1801 insertions(+) create mode 100644 README.md create mode 100644 common/flakes.nix create mode 100644 common/locales.nix create mode 100644 common/user.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 hosts/mrmeeseeks/configuration.nix create mode 100644 hosts/mrmeeseeks/hardware-configuration.nix create mode 100644 modules/home/cli/default.nix create mode 100644 modules/home/cli/git.nix create mode 100644 modules/home/cli/gnupg.nix create mode 100644 modules/home/cli/neovim.nix create mode 100644 modules/home/cli/pass.nix create mode 100644 modules/home/cli/zsh.nix create mode 100644 modules/home/desktop/default.nix create mode 100644 modules/home/desktop/fonts.nix create mode 100644 modules/home/desktop/gtk.nix create mode 100644 modules/home/desktop/qt.nix create mode 100644 modules/home/desktop/sway/default.nix create mode 100644 modules/home/desktop/sway/fuzzel.nix create mode 100644 modules/home/desktop/sway/mako.nix create mode 100644 modules/home/desktop/sway/sway.nix create mode 100644 modules/home/desktop/sway/swayidle.nix create mode 100644 modules/home/desktop/sway/swaylock.nix create mode 100644 modules/home/desktop/sway/waybar.nix create mode 100644 modules/home/desktop/xdg.nix create mode 100644 modules/home/firefox/conf/doh.nix create mode 100644 modules/home/firefox/conf/drm.nix create mode 100644 modules/home/firefox/conf/experiments.nix create mode 100644 modules/home/firefox/conf/extensions.nix create mode 100644 modules/home/firefox/conf/preferences.nix create mode 100644 modules/home/firefox/conf/privacy.nix create mode 100644 modules/home/firefox/conf/safebrowsing.nix create mode 100644 modules/home/firefox/conf/suggest.nix create mode 100644 modules/home/firefox/conf/telemetry.nix create mode 100644 modules/home/firefox/conf/theme.nix create mode 100644 modules/home/firefox/conf/tracking.nix create mode 100644 modules/home/firefox/default.nix create mode 100644 modules/home/foot.nix create mode 100644 modules/home/lutris.nix create mode 100644 modules/home/zathura.nix create mode 100644 modules/nixos/doas.nix create mode 100644 modules/nixos/neovim.nix create mode 100644 modules/nixos/pipewire.nix create mode 100644 modules/nixos/steam.nix create mode 100644 modules/nixos/xdg-portal.nix create mode 120000 result diff --git a/README.md b/README.md new file mode 100644 index 0000000..9be1177 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +My NixOS configuration +---------------------- + +My configurations for NixOS using flakes. For now only my desktop computer is +configured with this system. + +## Install + +``` +doas nixos-rebuild switch --flake ".#mrmeeseeks" +``` + +## Update the flakes.lock + +``` +nix flake update +doas nixos-rebuild switch --flake ".#mrmeeseeks" +``` diff --git a/common/flakes.nix b/common/flakes.nix new file mode 100644 index 0000000..7f2c37b --- /dev/null +++ b/common/flakes.nix @@ -0,0 +1,10 @@ +{ pkgs, ... }: +{ + nix = { + package = pkgs.nixUnstable; + extraOptions = '' + experimental-features = nix-command flakes + ''; + }; +} + diff --git a/common/locales.nix b/common/locales.nix new file mode 100644 index 0000000..2d8ac2c --- /dev/null +++ b/common/locales.nix @@ -0,0 +1,6 @@ +{ config, ... }: +{ + time.timeZone = "Europe/Paris"; + # English locale with YYY/MM/DD date format + i18n.defaultLocale = "en_DK.UTF-8"; +} diff --git a/common/user.nix b/common/user.nix new file mode 100644 index 0000000..62d48f5 --- /dev/null +++ b/common/user.nix @@ -0,0 +1,24 @@ +{ config, pkgs, ... }: +{ + # Services + services.pcscd.enable = true; + + # Programs + programs.ssh.startAgent = true; + programs.zsh.enable = true; + # programs.dconf.enable = true; + + # Configs + fonts.fontconfig.enable = true; + + users.users.ephase = { + shell = pkgs.zsh; + isNormalUser = true; + extraGroups = [ "video" "wheel" ]; + home = "/home/ephase"; + packages = with pkgs; [ + remmina + gcc + ]; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a78eaed --- /dev/null +++ b/flake.lock @@ -0,0 +1,47 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1690027126, + "narHash": "sha256-DeUhQQxbu41Qn0uHyNazPBiTJ0lNsf26ThFopWBRRnM=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "76dd6c66190db0d46ac6b3ca816cc17b581df42c", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1690031011, + "narHash": "sha256-kzK0P4Smt7CL53YCdZCBbt9uBFFhE0iNvCki20etAf4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "12303c652b881435065a98729eb7278313041e49", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..ce932a0 --- /dev/null +++ b/flake.nix @@ -0,0 +1,21 @@ +{ + description = "My systems installation"; + inputs = { + nixpkgs.url = "nixpkgs/nixos-unstable"; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + }; + outputs = { self, nixpkgs, home-manager, ... }@inputs: { + nixosConfigurations = { + mrmeeseeks = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./hosts/mrmeeseeks/configuration.nix + home-manager.nixosModule + ]; + }; + }; + }; +} diff --git a/hosts/mrmeeseeks/configuration.nix b/hosts/mrmeeseeks/configuration.nix new file mode 100644 index 0000000..b5a3079 --- /dev/null +++ b/hosts/mrmeeseeks/configuration.nix @@ -0,0 +1,72 @@ +{ config, pkgs, lib, ... }: + +{ + imports = + [ # Include the results of the hardware scan. + ./hardware-configuration.nix + ../../common/locales.nix + ../../common/flakes.nix + ../../common/user.nix + ../../modules/nixos/pipewire.nix + ../../modules/nixos/steam.nix + ../../modules/nixos/xdg-portal.nix + ../../modules/nixos/doas.nix + ]; + + nixpkgs.config.allowUnfree = true; + + # Use the systemd-boot EFI boot loader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + boot.kernelPackages = pkgs.linuxPackages_latest; + #CPU + hardware.cpu.amd.updateMicrocode = true; + # GPU + hardware.opengl.driSupport = true; + hardware.opengl.driSupport32Bit = true; + + # Bluetooth + hardware.bluetooth.enable = true; + hardware.xpadneo.enable = true; + networking.hostName = "mrmeeseeks"; + + console = { + earlySetup = true; + font = "${pkgs.terminus_font}/share/consolefonts/ter-132n.psf.gz"; + packages = with pkgs; [terminus_font]; + # keyMap = "us"; + useXkbConfig = true; # use xkbOptions in tty. + }; + + security.rtkit.enable = true; + security.pam.services.swaylock = {}; + + environment.systemPackages = with pkgs; [ + git + zsh + lvm2_dmeventd + ]; + + services.lvm.enable = true; + services.lvm.dmeventd.enable = true; + + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + users.ephase = { + home.stateVersion = "23.05"; + programs.home-manager.enable = true; + imports = [ + ../../modules/home/desktop + ../../modules/home/cli + ../../modules/home/firefox + ../../modules/home/foot.nix + ../../modules/home/lutris.nix + ../../modules/home/zathura.nix + ]; + }; + }; + + system.stateVersion = "23.05"; +} diff --git a/hosts/mrmeeseeks/hardware-configuration.nix b/hosts/mrmeeseeks/hardware-configuration.nix new file mode 100644 index 0000000..3105f97 --- /dev/null +++ b/hosts/mrmeeseeks/hardware-configuration.nix @@ -0,0 +1,67 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ + "nvme" + "xhci_pci" + "ahci" + "usbhid" + "usb_storage" + "sd_mod" + "amdgpu" + ]; + boot.initrd.kernelModules = [ + "dm-cache-default" + ]; + boot.kernelModules = [ + "kvm-amd" + "amdgpu" + ]; + + boot.extraModulePackages = [ ]; + boot.initrd.luks.devices."nixos".device = "/dev/disk/by-uuid/ea7fa60d-35e5-48b8-95d7-142f37b262cd"; + boot.initrd.luks.devices."nixos".preLVM = true; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/9d1e5022-0265-4ce7-824e-282ee550d52d"; + fsType = "btrfs"; + options = [ "subvol=@root" ]; + }; + + fileSystems."/home" = + { device = "/dev/disk/by-uuid/9d1e5022-0265-4ce7-824e-282ee550d52d"; + fsType = "btrfs"; + options = [ "subvol=@home" ]; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/F027-F53F"; + fsType = "vfat"; + }; + + fileSystems."/mnt/gamelib" = + { device = "/dev/mapper/tank-gamelib"; + fsType = "ext4"; + }; + + swapDevices = [ ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp34s0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp37s0.useDHCP = lib.mkDefault true; + + services.lvm.boot.thin.enable = true; + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/modules/home/cli/default.nix b/modules/home/cli/default.nix new file mode 100644 index 0000000..b7ac4e9 --- /dev/null +++ b/modules/home/cli/default.nix @@ -0,0 +1,10 @@ +{ ... }: +{ + imports = [ + ./zsh.nix + ./git.nix + ./pass.nix + ./gnupg.nix + ./neovim.nix + ]; +} diff --git a/modules/home/cli/git.nix b/modules/home/cli/git.nix new file mode 100644 index 0000000..8edf5c9 --- /dev/null +++ b/modules/home/cli/git.nix @@ -0,0 +1,9 @@ +{ pkgs, ... }: +{ + programs.git = { + enable = true; + package = pkgs.gitFull; + userName = "Yorick Barbanneau"; + userEmail = "ephase@xieme-art.org"; + }; +} diff --git a/modules/home/cli/gnupg.nix b/modules/home/cli/gnupg.nix new file mode 100644 index 0000000..90b9b86 --- /dev/null +++ b/modules/home/cli/gnupg.nix @@ -0,0 +1,20 @@ +{ pkgs, ... }: +{ + home.packages = with pkgs; [ + pinentry-gnome + pkgs.gcr + ]; + + programs.gpg = { + enable = true; + scdaemonSettings = { + disable-ccid = true; + }; + }; + services.gpg-agent = { + enable = true; + enableScDaemon = true; + enableZshIntegration = true; + pinentryFlavor = "gnome3"; + }; +} diff --git a/modules/home/cli/neovim.nix b/modules/home/cli/neovim.nix new file mode 100644 index 0000000..a195172 --- /dev/null +++ b/modules/home/cli/neovim.nix @@ -0,0 +1,382 @@ +{ pkgs, ... }: +{ + programs.neovim = { + enable = true; + defaultEditor = true; + vimAlias = true; + withNodeJs = true; + withPython3 = true; + extraLuaConfig = '' + -- General Option + vim.g.mapleader = " " + vim.g.maplocalleader = " " + + vim.opt.autoindent = true + vim.opt.background = 'dark' + vim.opt.backupdir = os.getenv("HOME") .. '/.local/tmp/nvim' + vim.opt.clipboard = 'unnamedplus' --Use system clipboard + vim.opt.colorcolumn = '80' + vim.opt.directory = os.getenv("HOME") .. '/.local/tmp/nvim' + vim.opt.expandtab = true + vim.opt.foldmethod = 'syntax' + vim.opt.gdefault = true -- search: all occurrences by default + vim.opt.hlsearch = true -- search: hightlight terms + vim.opt.ignorecase = true + vim.opt.incsearch = true + vim.opt.laststatus = 1 + -- show special character + vim.opt.listchars = {tab = '→ ', trail = '␣', eol = '', extends = '…' } + + vim.opt.signcolumn = "yes" -- alway show sign column + vim.opt.number = true + vim.opt.relativenumber = true + vim.opt.cursorline = true -- highlight current line + vim.opt.shiftwidth = 4 + vim.opt.showmatch = true + vim.opt.smartcase = true -- search: try :to be smart about cases + vim.opt.smartindent = true + vim.opt.tabstop = 4 + vim.opt.termguicolors = true -- 24 bits color support + vim.opt.wildmenu = true -- activate enhanced user menu + vim.opt.wildmode = 'lastused:full,list' -- enhance menu + vim.opt.pumheight = 10 + vim.opt.pumwidth = 50 + vim.opt.pumblend = 10 + + -- Options than need vim.cmd + -- vim.cmd('syntax on') + + -- -- Code Fold + -- "Load and save view atomatocally (save and restore fold) + vim.cmd('au BufWinLeave *.* mkview') + vim.cmd('au BufWinEnter *.* silent! loadview') + + + -- Diagnostic settings + -- + -- diagnostic windows must be float + vim.diagnostic.config { + virtual_text = false, + signs = true, + underline = true, + } + + local signs = { Error = "", Warn = "", Hint = "󰌶", Info = "" } + for type, icon in pairs(signs) do + local hl = "DiagnosticSign" .. type + vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl }) + end + + -- You will likely want to reduce updatetime which affects CursorHold + -- note: this setting is global and should be set only once + vim.o.updatetime = 250 + vim.cmd [[autocmd! CursorHold,CursorHoldI * lua vim.diagnostic.open_float(nil, {scope='cursor', header = "", prefix = "", focus=false})]] + + -- Autotype + vim.cmd('au BufRead,BufNewFile *.md setlocal textwidth=80') + vim.cmd('au BufRead,BufNewFile *.tex setlocal textwidth=80') + vim.cmd('au BufRead,BufNewFile *.nix setlocal tabstop=2 shiftwidth=2 ') + vim.cmd('au BufNewFile,BufRead /tmp/neomutt* set tw=72 fo=awq comments+=nb:> noautoindent filetype=mail') + + -- Ignore these filenames during enhanced command line completion. + vim.opt.wildignore = { + '*.bak', + '*.class', + '*.aux', + '*.out', + '*.toc', + '*.jpg', + '*.bmp', + '*.gif', + '*.png', + '*.luac', + '*.o', + '*.obj', + '*.exe', + '*.dll', + '*.manifest', + '*.pyc', + '*.spl', + '*.sw?' + } + + -- Key biding + -- " ---------- + local opts = { noremap = true, silent = true} + + vim.api.nvim_set_keymap('n', '/', ':nohlsearch', opts) + + -- Move tabs with \[ and \] + vim.api.nvim_set_keymap('n', ']', ':tabnext', opts) + vim.api.nvim_set_keymap('n', '[', ':tabprev', opts) + vim.api.nvim_set_keymap('n', 'l', ':set list!', {silent = true}) + ''; + plugins = with pkgs.vimPlugins; [ + { + plugin = nvim-autopairs; + type = "lua"; + config = '' + local autopair = require("nvim-autopairs").setup {} + ''; + } + { + plugin = nvim-base16; + type = "lua"; + config = '' + vim.cmd.colorscheme 'base16-default-dark' + ''; + } + { + plugin = nvim-cmp; + type = "lua"; + config = '' + 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 + -- Add additional capabilities supported by nvim-cmp + local capabilities = require('cmp_nvim_lsp').default_capabilities() + local luasnip = require("luasnip") + local kind_icons = { + Text = "", + Method = "󰆧", + Function = "󰊕", + Constructor = "", + Field = "󰇽", + Variable = "󰂡", + Class = "󰠱", + Interface = "", + Module = "", + Property = "󰜢", + Unit = "", + Value = "󰎠", + Enum = "", + Keyword = "󰌋", + Snippet = "", + Color = "󰏘", + File = "󰈙", + Reference = "", + Folder = "󰉋", + EnumMember = "", + Constant = "󰏿", + Struct = "", + Event = "", + Operator = "󰆕", + TypeParameter = "󰅲", + } + -- nvim-cmp setup + local cmp = require 'cmp' + cmp.setup { + mapping = { + [""] = 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" }), + + [""] = 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" }), + }, + formatting = { + format = function(_, vim_item) + vim_item.kind = string.format('%s %s', kind_icons[vim_item.kind], vim_item.kind) + return vim_item + end, + }, + sources = { + { name = 'nvim_lsp' }, + { name = 'luasnip' }, + { name = 'path' }, + { name = 'buffer' }, + }, + } + ''; + } + cmp-buffer + cmp-nvim-lsp + cmp-path + cmp-cmdline + cmp_luasnip + { + plugin = gitsigns-nvim; + type = "lua"; + config = '' + require('gitsigns').setup { + on_attach = function(bufnr) + local gs = package.loaded.gitsigns + + local function map(mode, l, r, opts) + opts = opts or {} + opts.buffer = bufnr + vim.keymap.set(mode, l, r, opts) + end + + -- Navigation + map('n', 'gn', function() + if vim.wo.diff then return ']c' end + vim.schedule(function() gs.next_hunk() end) + return '' + end, {expr=true}) + + map('n', 'gN', function() + if vim.wo.diff then return '[c' end + vim.schedule(function() gs.prev_hunk() end) + return '' + end, {expr=true}) + + map('n', 'gs', gs.stage_hunk) + map('n', 'gr', gs.reset_hunk) + map('n', 'gd', gs.diffthis) + map('n', 'gd', function() gs.diffthis('~') end) + end + } + ''; + } + indent-blankline-nvim + { + plugin = nvim-lspconfig; + type = "lua"; + config = '' + local lspconfig = require('lspconfig') + ''; + } + { + plugin = lualine-nvim; + type = "lua"; + config = '' + + require('lualine').setup { + options = { + icons_enabled = true, + theme = 'base16', + component_separators = { left = '|', right = '|'}, + section_separators = { left = "", right = ""}, + disabled_filetypes = {}, + always_divide_middle = true, + globalstatus = true, + }, + sections = { + lualine_a = {'mode'}, + lualine_b = {'branch', 'diff', 'diagnostics'}, + lualine_c = {'filename'}, + lualine_x = {'encoding', 'fileformat', 'filetype'}, + lualine_y = {'progress'}, + lualine_z = {'location'} + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = {'filename'}, + lualine_x = {'location'}, + lualine_y = {}, + lualine_z = {} + }, + tabline = {}, + extensions = {} + } + ''; + } + mason-lspconfig-nvim + { + plugin = mason-nvim; + type = "lua"; + config = '' + local mason = require("mason").setup{ + ensure_installed= { + 'shellcheck', + 'shfmt' + } + } + local mason_lspconfig = require("mason-lspconfig").setup{ + ensure_installed={ + 'ansiblels', + 'bashls' + } + } + require("mason-lspconfig").setup_handlers({ + -- The first entry (without a key) will be the default handler + -- and will be called for each installed server that doesn't have + -- a dedicated handler. + function (server_name) -- default handler (optional) + require("lspconfig")[server_name].setup {} + end, + -- Next, you can provide targeted overrides for specific servers. + }) + ''; + } + { + plugin = neo-tree-nvim; + type = "lua"; + config = '' + local neotree = require 'neo-tree' + neotree.setup({ + event_handlers = { + { + event = "file_opened", + handler = function(file_path) + -- auto close + require("neo-tree.command").execute({action = "close"}) + end + }, + } + }) + vim.api.nvim_set_keymap('n', 'fm', + ':Neotree toggle', + { table.unpack(opts), desc = 'Toggle NeoTree' } + ) + ''; + } + nui-nvim + plenary-nvim + { + plugin = (nvim-treesitter.withPlugins (p: [ + p.bash p.c p.cmake p.dockerfile p.latex p.lua p.markdown + p.markdown_inline p.python p.vim p.yaml + ]) + ); + type = "lua"; + config = '' + -- Tree sitter + local ts = require 'nvim-treesitter.configs' + + ts.setup { + sync_install = false, + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + } + } + ''; + } + { + plugin = which-key-nvim; + type = "lua"; + config = '' + local wk = require 'which-key' + wk.register() + ''; + } + ]; + }; +} diff --git a/modules/home/cli/pass.nix b/modules/home/cli/pass.nix new file mode 100644 index 0000000..1f129f7 --- /dev/null +++ b/modules/home/cli/pass.nix @@ -0,0 +1,6 @@ +{ pkgs, ... }: +{ + programs.password-store = { + enable = true; + }; +} diff --git a/modules/home/cli/zsh.nix b/modules/home/cli/zsh.nix new file mode 100644 index 0000000..39799c3 --- /dev/null +++ b/modules/home/cli/zsh.nix @@ -0,0 +1,68 @@ +{ pkgs, ... }: +{ + programs.zsh = { + enable = true; + dotDir = ".config/zsh"; + defaultKeymap = "viins"; + enableCompletion = true; + history = { + expireDuplicatesFirst = true; + save = 10000; + share = true; + path = ".local/share/zsh/history"; + }; + historySubstringSearch = { + enable = true; + searchDownKey = "^[OB"; + searchUpKey = "^[OA"; + }; + completionInit = '' +autoload -Uz compinit +for dump in ''${ZDOTDIR}/.zcompdump(N.mh+24); do + compinit +done +compinit -C + + ''; + plugins = [ + { + name = "pure"; + src = pkgs.fetchFromGitHub { + owner = "sindresorhus"; + repo = "pure"; + rev = "v1.21.0"; + hash = "sha256-YfasTKCABvMtncrfoWR1Su9QxzCqPED18/BTXaJHttg="; + }; + } + { + name = "base16-shell"; + src = pkgs.fetchFromGitHub { + owner = "chriskempson"; + repo = "base16-shell"; + rev = "588691ba71b47e75793ed9edfcfaa058326a6f41"; + hash = "sha256-X89FsG9QICDw3jZvOCB/KsPBVOLUeE7xN3VCtf0DD3E="; + }; + } + { + name = "fast-syntax-highlighting"; + src = pkgs.fetchFromGitHub { + owner = "zdharma-continuum"; + repo = "fast-syntax-highlighting"; + rev = "v1.55"; + hash = "sha256-DWVFBoICroKaKgByLmDEo4O+xo6eA8YO792g8t8R7kA="; + }; + } + { + name = "history-search-multi-word"; + src = pkgs.fetchFromGitHub { + owner = "zdharma-continuum"; + repo = "history-search-multi-word"; + rev = "c4dcddc1cd17e7e0909471703f3526170db0f475"; + hash = "sha256-KgKm9qzFnwXDXwmTruPgC0tjmiTY5AiGdrWW4zDWUF4="; + }; + }]; + localVariables = { + BASE16_THEME = "$HOME/.config/zsh/plugins/base16"; + }; + }; +} diff --git a/modules/home/desktop/default.nix b/modules/home/desktop/default.nix new file mode 100644 index 0000000..4bbeed4 --- /dev/null +++ b/modules/home/desktop/default.nix @@ -0,0 +1,16 @@ +{ pkgs, ... }: +{ + home.packages = with pkgs; [ + emojione + (pkgs.nerdfonts.override { fonts = ["FiraCode"];}) + + libnotify + wl-clipboard + ]; + imports = [ + ./sway + ./qt.nix + ./gtk.nix + ./xdg.nix + ]; +} diff --git a/modules/home/desktop/fonts.nix b/modules/home/desktop/fonts.nix new file mode 100644 index 0000000..f99b171 --- /dev/null +++ b/modules/home/desktop/fonts.nix @@ -0,0 +1,11 @@ +{pkgs, ...}: +{ + fonts.fonts = with pkgs; [ + font-awesome + (nerdfonts.override { + fonts = [ + "FiraCode" + ]; + }) + ]; +} diff --git a/modules/home/desktop/gtk.nix b/modules/home/desktop/gtk.nix new file mode 100644 index 0000000..3159bab --- /dev/null +++ b/modules/home/desktop/gtk.nix @@ -0,0 +1,29 @@ +{ pkgs, ... }: +{ + gtk = { + enable = true; + theme = { + name = "Arc-Darker"; + package = pkgs.arc-theme; + }; + iconTheme = { + name = "Papirus"; + package = pkgs.papirus-icon-theme; + }; + font = { + name = "Deja Vu Sans"; + package = "${pkgs.dejavu_fonts}"; + size = 10; + }; + }; + + home.pointerCursor = { + name = "Adwaita"; + package = pkgs.gnome.adwaita-icon-theme; + size = 24; + x11 = { + enable = true; + defaultCursor = "Adwaita"; + }; + }; +} diff --git a/modules/home/desktop/qt.nix b/modules/home/desktop/qt.nix new file mode 100644 index 0000000..c0e8a26 --- /dev/null +++ b/modules/home/desktop/qt.nix @@ -0,0 +1,8 @@ +{ pkgs, ... }: +{ + qt = { + enable = true; + platformTheme = "gnome"; + style.name = "adwaita-dark"; + }; +} diff --git a/modules/home/desktop/sway/default.nix b/modules/home/desktop/sway/default.nix new file mode 100644 index 0000000..2bfe550 --- /dev/null +++ b/modules/home/desktop/sway/default.nix @@ -0,0 +1,11 @@ +{ ... }: +{ + imports = [ + ./sway.nix + ./mako.nix + ./waybar.nix + ./swaylock.nix + ./swayidle.nix + ./fuzzel.nix + ]; +} diff --git a/modules/home/desktop/sway/fuzzel.nix b/modules/home/desktop/sway/fuzzel.nix new file mode 100644 index 0000000..eb170e2 --- /dev/null +++ b/modules/home/desktop/sway/fuzzel.nix @@ -0,0 +1,27 @@ +{ pkgs, ... }: +{ + programs.fuzzel = { + enable = true; + settings = { + main = { + font = "Fira Code Nerd Font Mono:size=9"; + icon-theme = "Papirus-Dark"; + width = 60; + show-actions = "yes"; + launch-prefix = "swaymsg exec --"; + }; + border = { + radius = 0; + width = 1; + }; + colors = { + border = "f268b3ff"; + background = "121212ff"; + text = "ccccccff"; + selection = "323232ff"; + selection-text = "ccccccff"; + match = "f268b3ff"; + }; + }; + }; +} diff --git a/modules/home/desktop/sway/mako.nix b/modules/home/desktop/sway/mako.nix new file mode 100644 index 0000000..23b3eb7 --- /dev/null +++ b/modules/home/desktop/sway/mako.nix @@ -0,0 +1,37 @@ +{ pkgs, ... }: +{ + + systemd.user.services.mako = { + Service = { + ExecStart = "${pkgs.mako}/bin/mako"; + }; + Install = { + After = [ "sway-session.target" ]; + WantedBy = [ "sway-session.target" ]; + }; + }; + services.mako = { + enable = true; + font = "Fira Code 10"; + backgroundColor = "#353535FF"; + borderColor = "#1CD180"; + progressColor = "over #5566AAFF"; + textColor = "#FDFDFD"; + width = 300; + height = 100; + borderRadius = 0; + borderSize = 2; + icons = true; + maxIconSize = 64; + layer = "overlay"; + anchor = "top-right"; + extraConfig = '' + [urgency="high"] + border-color=#F268b3 + + [app-name="cmus"] + border-color=#00000000 + default-timeout=10000 + ''; + }; +} diff --git a/modules/home/desktop/sway/sway.nix b/modules/home/desktop/sway/sway.nix new file mode 100644 index 0000000..4214769 --- /dev/null +++ b/modules/home/desktop/sway/sway.nix @@ -0,0 +1,198 @@ +{ pkgs, config, ...}: +{ + wayland.windowManager.sway = { + enable = true; + wrapperFeatures.gtk = true; + systemd.enable = true; + config = { + modifier = "Mod4"; + terminal = "${pkgs.foot}/bin/foot"; + left = "h"; + down = "j"; + up = "k"; + right = "l"; + input = { + "*" = { + xkb_layout = "us"; + xkb_variant = "altgr-intl"; + }; + }; + output = { + "Iiyama North America PL2792UH 1166310803122" = { + mode = "3840x2160@60Hz"; + position = "0,0"; + scale = "2"; + }; + "Iiyama North America PL2792UH 1176923201598" = { + mode = "3840x2160@60Hz"; + position = "1920,0"; + scale = "2"; + transform = "90"; + }; + }; + bars= []; + keybindings = let + mod = config.wayland.windowManager.sway.config.modifier; + inherit (config.wayland.windowManager.sway.config) + left down up right terminal; + in + { + "${mod}+1" = "workspace $ws1"; + "${mod}+Shift+1" = "move container to workspace $ws1"; + "${mod}+2" = "workspace $ws2"; + "${mod}+Shift+2" = "move container to workspace $ws2"; + "${mod}+3" = "workspace $ws3"; + "${mod}+Shift+3" = "move container to workspace $ws3"; + "${mod}+4" = "workspace $ws4"; + "${mod}+Shift+4" = "move container to workspace $ws4"; + "${mod}+5" = "workspace $ws5"; + "${mod}+Shift+5" = "move container to workspace $ws5"; + "${mod}+6" = "workspace $ws6"; + "${mod}+Shift+6" = "move container to workspace $ws6"; + "${mod}+7" = "workspace $ws7"; + "${mod}+Shift+7" = "move container to workspace $ws7"; + "${mod}+8" = "workspace $ws8"; + "${mod}+Shift+8" = "move container to workspace $ws8"; + "${mod}+9" = "workspace $ws9"; + "${mod}+Shift+9" = "move container to workspace $ws9"; + "${mod}+0" = "workspace $ws0"; + "${mod}+Shift+0" = "move container to workspace $ws0"; + "${mod}+Return" = "exec ${terminal}"; + "${mod}+Shift+q" = "kill"; + "${mod}+d" = "exec ${pkgs.fuzzel}/bin/fuzzel"; + "${mod}+Shift+c" = "reload"; + "${mod}+Alt+l" = "exec ${pkgs.swaylock}/bin/swaylock"; + "${mod}+${left} focus" = "left"; + "${mod}+${down} focus" = "down"; + "${mod}+${up} focus" = "up"; + "${mod}+${right} focus" = "right"; + "${mod}+Left" = "focus left"; + "${mod}+Down" = "focus down"; + "${mod}+Up" = "focus up"; + "${mod}+Right" = "focus right"; + "${mod}+Shift+${left} move" = "left"; + "${mod}+Shift+${down} move" = "down"; + "${mod}+Shift+${up} move" = "up"; + "${mod}+Shift+${right} move" = "right"; + "${mod}+Shift+Left" = "move left"; + "${mod}+Shift+Down" = "move down"; + "${mod}+Shift+Up" = "move up"; + "${mod}+Shift+Right" = "move right"; + "${mod}+b" = "splith"; + "${mod}+v" = "splitv"; + "${mod}+s" = "layout stacking"; + "${mod}+w" = "layout tabbed"; + "${mod}+e" = "layout toggle split"; + "${mod}+f" = "fullscreen"; + "${mod}+Shift+space" = "floating toggle"; + "${mod}+space" = "focus mode_toggle"; + "${mod}+a" = "focus parent"; + "${mod}+Shift+p" = "move scratchpad"; + "${mod}+p" = "scratchpad show"; + "${mod}+F1" = "exec brightnessctl s 1%-"; + "${mod}+F2" = "exec brightnessctl s +1%"; + "${mod}+F3" = "exec pactl set-sink-volume @DEFAULT_SINK@ -5%"; + "${mod}+F4" = "exec pactl set-sink-volume @DEFAULT_SINK@ +5%"; + "${mod}+F5" = "exec pactl set-sink-mute @DEFAULT_SINK@ toggle"; + "${mod}+m" = "exec pactl set-source-mute @DEFAULT_SOURCE@ toggle"; + "${mod}+r" = "mode resize"; + "${mod}+n" = "exec makoctl dismiss"; + "${mod}+shift+n" = "exec makoctl dismiss -a"; + "${mod}+alt+n" = "mode notification"; + }; + modes = + let + inherit (config.wayland.windowManager.sway.config) + left down up right; + in { + "resize" = { + "${left}" = "resize shrink width 10 px or 10 ppt"; + "${down}" = "resize grow height 10 px or 10 ppt"; + "${up}" = "resize shrink height 10 px or 10 ppt"; + "${right}" = "resize grow width 10 px or 10 ppt"; + "Return" = "mode default"; + "Escape" = "mode default"; + }; + "notification" = { + "r" = "exec ${pkgs.mako}/bin/makoctl restore"; + "Escape" = "mode default"; + }; + }; + colors = { + focused = { + border = "#f268b3"; + background = "#f268b3"; + text = "#000000"; + indicator = "#1cd180"; + childBorder = "#f268b3"; + }; + focusedInactive = { + border = "#323232"; + background = "#323232"; + text = "#f268b3"; + indicator = "#1cd180"; + childBorder = "#323232"; + }; + unfocused = { + border = "#323232"; + background = "#323232"; + text = "#cccccc"; + indicator = "#1cd180"; + childBorder = "#323232"; + }; + urgent = { + border = "#2f343a"; + background = "#900000"; + text = "#cccccc"; + indicator = "#900000"; + childBorder = "#900000" ; + }; + #focused_tab_title = { + # boder = "#2f343a"; + # background = "#2f343a"; + # text = "#ffffff"; + #}; + }; + window = { + border = 1; + titlebar = false; + commands = [ + { + command = "inhibit_idle fullscreen"; + criteria = { + title = "^.*"; + }; + } + { + command = "inhibit_idle fullscreen"; + criteria = { + app_id = "^.*"; + }; + } + ]; + }; + gaps = { + smartGaps = true; + smartBorders = "on"; + inner = 2; + }; + }; + extraConfigEarly = '' + set $ws1 1:  + set $ws2 2: 󰇮 + set $ws3 3: 󰈹 + set $ws4 4: 󰍦 + set $ws5 5:  + set $ws6 6: 󰈙 + set $ws7 7:  + set $ws8 8:  + set $ws9 9:  + set $ws0 10:  + default_orientation auto + workspace_layout default + font pango:Fira Code Nerd Font Mono 10 + default_border pixel 1 + title_align right + ''; + }; +} diff --git a/modules/home/desktop/sway/swayidle.nix b/modules/home/desktop/sway/swayidle.nix new file mode 100644 index 0000000..82f17d0 --- /dev/null +++ b/modules/home/desktop/sway/swayidle.nix @@ -0,0 +1,27 @@ +{ pkgs, ... }: +{ + services.swayidle = { + enable = true; + timeouts = [ + { + timeout = 300; + command = "${pkgs.swaylock}/bin/swaylock -f"; + } + { + timeout = 600; + command = "swaymsg 'output * dpms off'"; + resumeCommand = "swaymsg 'output * dpms on"; + } + ]; + events = [ + { + event = "before-sleep"; + command = "${pkgs.swaylock}/bin/swaylock -f"; + } + { + event = "lock"; + command = "${pkgs.swaylock}/bin/swaylock -f"; + } + ]; + }; +} diff --git a/modules/home/desktop/sway/swaylock.nix b/modules/home/desktop/sway/swaylock.nix new file mode 100644 index 0000000..f40fb29 --- /dev/null +++ b/modules/home/desktop/sway/swaylock.nix @@ -0,0 +1,30 @@ +{ pkgs, ... }: +{ + programs.swaylock = { + enable = true; + settings = { + image = "~/medias/images/wallpapers/lockscreen.png"; + scaling = "center"; + color = "000000"; + indicator-radius = 70; + indicator-y-position = 150; + font = "Fira Code Nerd Font Mono"; + font-size = "14"; + inside-color = "00000000"; + ring-color = "323232"; + ring-ver-color = "1cd180"; + inside-ver-color = "1cd180cc"; + ring-wrong-color = "f268b3"; + inside-wrong-color = "f268b3cc"; + key-hl-color = "1cd180"; + caps-lock-key-hl-color = "1cd180"; + caps-lock-bs-hl-color = "f268b3"; + bs-hl-color = "f268b3ff"; + separator-color = "00000000"; + ignore-empty-password = true; + show-failed-attempts = true; + daemonize = true; + line-uses-inside = true; + }; + }; +} diff --git a/modules/home/desktop/sway/waybar.nix b/modules/home/desktop/sway/waybar.nix new file mode 100644 index 0000000..88d5434 --- /dev/null +++ b/modules/home/desktop/sway/waybar.nix @@ -0,0 +1,10 @@ +{ pkgs, config, ...}: +{ + programs.waybar = { + enable = true; + systemd = { + enable = true; + target = "sway-session.target"; + }; + }; +} diff --git a/modules/home/desktop/xdg.nix b/modules/home/desktop/xdg.nix new file mode 100644 index 0000000..3c0ab01 --- /dev/null +++ b/modules/home/desktop/xdg.nix @@ -0,0 +1,14 @@ +{ ... }: +{ + xdg = { + enable = true; + userDirs = { + enable = true; + documents = "documents"; + download = "downloads"; + music = "medias/music"; + pictures = "medias/images"; + videos = "medias/video"; + }; + }; +} diff --git a/modules/home/firefox/conf/doh.nix b/modules/home/firefox/conf/doh.nix new file mode 100644 index 0000000..73f526a --- /dev/null +++ b/modules/home/firefox/conf/doh.nix @@ -0,0 +1,7 @@ +{ +# DNS over HTTP (DoH), aka. Trusted Recursive Resolver (TRR) +# (https://wiki.mozilla.org/Trusted_Recursive_Resolver), uses a server run by +# Cloudflare to resolve hostnames, even when the system uses another (normal) DNS +# server. This setting disables it and sets the mode to explicit opt-out (5). + "network.trr.mode" = 5; +} diff --git a/modules/home/firefox/conf/drm.nix b/modules/home/firefox/conf/drm.nix new file mode 100644 index 0000000..94b210c --- /dev/null +++ b/modules/home/firefox/conf/drm.nix @@ -0,0 +1,12 @@ +{ +# Disables playback of DRM-controlled HTML5 content +# if enabled, automatically downloads the Widevine Content Decryption Module +# provided by Google Inc. Details +# (https://support.mozilla.org/en-US/kb/enable-drm#w_opt-out-of-cdm-playback-uninstall-cdms-and-stop-all-cdm-downloads) + "media.eme.enabled" = false; + +# Disables the Widevine Content Decryption Module provided by Google Inc. +# Used for the playback of DRM-controlled HTML5 content Details +# (https://support.mozilla.org/en-US/kb/enable-drm#w_disable-the-google-widevine-cdm-without-uninstalling) + "media.gmp-widevinecdm.enabled" = false; +} diff --git a/modules/home/firefox/conf/experiments.nix b/modules/home/firefox/conf/experiments.nix new file mode 100644 index 0000000..27d435a --- /dev/null +++ b/modules/home/firefox/conf/experiments.nix @@ -0,0 +1,21 @@ +{ + +# Disable shield studies +# Mozilla shield studies (https://wiki.mozilla.org/Firefox/Shield) is a feature +# which allows mozilla to remotely install experimental addons. + "app.normandy.enabled" = false; + "app.normandy.api_url" = ""; + "app.shield.optoutstudies.enabled" = false; + "extensions.shield-recipe-client.enabled" = false; + "extensions.shield-recipe-client.api_url" = ""; + +# Disable experiments +# Telemetry Experiments (https://wiki.mozilla.org/Telemetry/Experiments) is a +# feature that allows Firefox to automatically download and run specially-designed +# restartless addons based on certain conditions. + "experiments.enabled" = false; + "experiments.manifest.uri" = ""; + "experiments.supported" = false; + "experiments.activeExperiment" = false; + "network.allow-experiments" = false; +} diff --git a/modules/home/firefox/conf/extensions.nix b/modules/home/firefox/conf/extensions.nix new file mode 100644 index 0000000..5ed22b5 --- /dev/null +++ b/modules/home/firefox/conf/extensions.nix @@ -0,0 +1,11 @@ +{ +# Firefox sends data about installed addons as metadata updates +# (https://blog.mozilla.org/addons/how-to-opt-out-of-add-on-metadata-updates/), so +# Mozilla is able to recommend you other addons. + "extensions.getAddons.cache.enabled" = false; + +# Disable about:addons' Get Add-ons panel +# The start page with recommended addons uses google analytics. + "extensions.getAddons.showPane" = false; + "extensions.webservice.discoverURL" = ""; +} diff --git a/modules/home/firefox/conf/preferences.nix b/modules/home/firefox/conf/preferences.nix new file mode 100644 index 0000000..e4e6504 --- /dev/null +++ b/modules/home/firefox/conf/preferences.nix @@ -0,0 +1,28 @@ +{ + + "browser.sessionstore.enabled" = true; + "browser.sessionstore.restore_hidden_tabs" = true; + "browser.sessionstore.restore_pinned_tabs_on_demand" = true; + "browser.sessionstore.resume_after_os_start" = true; + +# use blank page for new tabs + "browser.newtabpage.enabled" = false; + +# Disable preloading of the new tab page. +# By default Firefox preloads the new tab page (with website thumbnails) in the +# background before it is even opened. + "browser.newtab.preload" = false; + + +# Disable check for captive portal. +# By default, Firefox checks for the presence of a captive portal on every +# startup. This involves traffic to Akamai +# (https://support.mozilla.org/questions/1169302). + "network.captive-portal-service.enabled" = false; + + +# Disable Javascript in PDF viewer +# Disables executing of JavaScript in the PDF form viewer. It is possible that +# some PDFs are not rendered correctly due to missing functions. + "pdfjs.enableScripting" = true; +} diff --git a/modules/home/firefox/conf/privacy.nix b/modules/home/firefox/conf/privacy.nix new file mode 100644 index 0000000..8110895 --- /dev/null +++ b/modules/home/firefox/conf/privacy.nix @@ -0,0 +1,119 @@ +{ +# Disable access to device sensor data +# Disallow websites to access sensor data (ambient light, motion, device +# orientation and proximity data). + "device.sensors.ambientLight.enabled" = false; + "device.sensors.enabled" = false; + "device.sensors.motion.enabled" = false; + "device.sensors.orientation.enabled" = false; + "device.sensors.proximity.enabled" = false; + +# Using a popular useragent string +# (https://techblog.willshouse.com/2012/01/03/most-common-user-agents/) avoids +# attracting attention i.e. with an Iceweasel UA. (keep blank to use the default) + +# Block Cookies +# Block 3rd-Party cookies or even all cookies. + "network.cookie.cookieBehavior" = 1; + +# Block Referer +# Firefox tells a website, from which site you're coming (the so called RefControl +# (http://kb.mozillazine.org/Network.http.sendRefererHeader">referer). You can +# find more detailed settings in this ghacks +# article or install the IndexedDB is a way, +# websites can store structured data. This can be fingerprinting with WebGL. Another +# issue is, that websites can privacy.resistFingerprinting setting coming from the + # tor-browser hides some system properties. See discussion in our bug tracker. + # (https://bugzilla.mozilla.org/show_bug.cgi?id=1308340">Bug #1308340 for more + # information. This option may interfere with other privacy related settings, see + # the