Changes
17 changed files (+785/-0)
-
.editorconfig (new)
-
@@ -0,0 +1,13 @@[*] charset = utf-8 end_of_line = lf insert_final_newline = true trim_trailing_whitespace = true indent_size = 2 indent_style = tab [*.nix] # Nix has a bug that when multiline string uses tab for indent they are not # stripped (dedent does not work with tab indentation) # https://github.com/NixOS/nix/issues/3759 indent_style = space
-
-
README.md (new)
-
@@ -0,0 +1,11 @@# pocka/system My systems configuration using Nix/Home Manager. ## Usage 1. Run `nix-shell` 2. Inside the spawned shell, run `home-manager switch --flake .#<name>` 3. Exit the shell See [`flake.nix#outputs.homeConfiguration`](./flake.nix) for a list of `<name>`s.
-
-
essentials/default.nix (new)
-
@@ -0,0 +1,27 @@# Essential modules: every machine should include this module. # Should covers everything from admin task to daily usages. # Other modules assumes this is included. { catppuccinTheme }: { ... }: { xdg = { enable = true; }; imports = [ ( import ./tools.nix { inherit catppuccinTheme; } ) ( import ./neovim.nix { inherit catppuccinTheme; } ) ( import ./tmux.nix { inherit catppuccinTheme; } ) ./zsh.nix ]; }
-
-
essentials/neovim.nix (new)
-
@@ -0,0 +1,67 @@{ catppuccinTheme, }: { config, pkgs, ... }: { programs = { neovim = { enable = true; defaultEditor = true; extraLuaConfig = '' -- Display absolute line numbers vim.wo.number = true ''; plugins = with pkgs.vimPlugins; [ { plugin = nvim-tree-lua; type = "lua"; config = '' vim.g.loaded_netrw = 1 vim.g.loaded_netrwPlugin = 1 require("nvim-tree").setup({ renderer = { icons = { show = { file = false, folder = false, folder_arrow = false, git = false, modified = false, }, }, }, filters = { custom = { -- Fossil checkout state file "^\\.fslckout", }, }, }) ''; } { plugin = catppuccin-nvim; type = "lua"; config = '' vim.o.termguicolors = true require("catppuccin").setup({ flavour = "${catppuccinTheme}", transparent_background = true, }) vim.cmd.colorscheme "catppuccin" ''; } ]; }; }; }
-
-
essentials/tmux.nix (new)
-
@@ -0,0 +1,72 @@{ catppuccinTheme, }: { config, pkgs, ... }: { programs = { tmux = { enable = true; keyMode = "vi"; # Ctrl+t prefix = "C-t"; # Automatically spawn a session if trying to attach and none are running. newSession = true; # Use 24 hour clock. # Because I'm not insane. clock24 = true; # Whether to enable mouse support. mouse = true; # Time in milliseconds for which tmux waits after an escape is input. # NOTE: Without this, there will be a lag after hitting ESC (e.g. exiting insert mode) # https://github.com/neovim/neovim/wiki/FAQ#esc-in-tmux-or-gnu-screen-is-delayed escapeTime = 10; plugins = [ { plugin = pkgs.tmuxPlugins.catppuccin; extraConfig = '' set -g @plugin 'catppuccin/tmux' set -g @catppuccin_flavour '${catppuccinTheme}' set -g @catppuccin_no_patched_fonts_theme_enabled on ''; } ]; # True Color options: # https://gist.github.com/andersevenrud/015e61af2fd264371032763d4ed965b6 extraConfig = '' set -g default-terminal "tmux-256color" set -ga terminal-overrides ",$TERM:Tc" bind | split-window -hc "#{pane_current_path}" bind - split-window -vc "#{pane_current_path}" unbind '"' unbind % bind c new-window -c "#{pane_current_path}" bind h select-pane -L bind j select-pane -D bind k select-pane -U bind l select-pane -R unbind Up unbind Down unbind Left unbind Right set -g status-position bottom ''; }; }; }
-
-
essentials/tools.nix (new)
-
@@ -0,0 +1,102 @@{ catppuccinTheme, }: { config, pkgs, ... }: { home.packages = [ # Must-have networking CLI tool # https://curl.se/ pkgs.curl # A generator for LS_COLORS with support for multiple color themes # https://github.com/sharkdp/vivid pkgs.vivid ]; home.sessionVariables = { # Colourise exa, ls, lf, etc... LS_COLORS = "$(vivid generate catppuccin-${catppuccinTheme})"; }; # Programs available via Home Manager programs = { # A modern replacement for ls. # https://the.exa.website/ exa = { enable = true; # Whether to enable recommended exa aliases (ls, ll…). enableAliases = true; extraOptions = [ "--long" "--all" ]; }; # A terminal file manager written in Go with a heavy inspiration from ranger file manager. # https://github.com/gokcehan/lf lf = let # Linux: xdg-open # macOS: open openCommand = if pkgs.stdenv.isLinux then "xdg-open" else "open"; in { enable = true; commands = { # Open text files with nvim open = '' ''${{ case $(file --mime-type -Lb $f) in text/*) nvim $fx;; *) for f in $fx; do ${openCommand} $f > /dev/null 2> /dev/null & done;; esac }} ''; }; }; # JSON view/query tool # https://github.com/jqlang/jq jq = { enable = true; }; # Colourful `cat` # https://github.com/sharkdp/bat bat = { enable = true; themes = { "catppuccin-${catppuccinTheme}" = builtins.readFile ( pkgs.fetchFromGitHub { owner = "catppuccin"; repo = "bat"; rev = "ba4d16880d63e656acced2b7d4e034e4a93f74b1"; sha256 = "1g2r6j33f4zys853i1c5gnwcdbwb6xv5w6pazfdslxf69904lrg9"; } + "/Catppuccin-${catppuccinTheme}.tmTheme" ); }; config = { theme = "catppuccin-${catppuccinTheme}"; }; }; # `top` alternative # https://htop.dev/ htop = { enable = true; }; }; }
-
-
essentials/zsh.nix (new)
-
@@ -0,0 +1,72 @@{ config, pkgs, ... }: { programs = { zsh = { enable = true; # The default base keymap to use. defaultKeymap = "viins"; # Enable zsh completion. Don’t forget to add enableCompletion = true; # Options related to commands history configuration. history = { # Do not enter command lines into the history list if they are duplicates of the previous event. ignoreDups = true; # Save timestamp into the history file. extended = true; # Number of history lines to keep. size = 1000; }; initExtra = '' # Activate colors module in order to colourise prompt autoload -Uz colors colors # Branch character (for readability) CH_BRANCH=$'\ue0a0' function custom-prompt() { echo -e " %f%k%b''${1}%1d ''${vcs_info_msg_0_}%k%f%b %{$fg[black]%}%# %{$fg_no_bold[white]%}" } # VCS autoload -Uz vcs_info precmd () { vcs_info } zstyle ":vcs_info:git:*" check-for-changes true zstyle ":vcs_info:git:*" stagedstr "%{$fg[green]%}*" zstyle ":vcs_info:git:*" unstagedstr "%{$fg[red]%}*" zstyle ":vcs_info:*" formats "%{$fg[white]%}''${CH_BRANCH} %b%c%u%{$fg[white]%}" zstyle ":vcs_info:*" actionformats "[%b|%a]" function zle-line-init zle-keymap-select { case $KEYMAP in vicmd) PROMPT=$(custom-prompt "%{$fg[green]%}") ;; main|viins) PROMPT=$(custom-prompt "%{$fg[blue]%}") ;; esac zle reset-prompt } zle -N zle-line-init zle -N zle-keymap-select ''; }; }; }
-
-
flake.lock (new)
-
@@ -0,0 +1,48 @@{ "nodes": { "home-manager": { "inputs": { "nixpkgs": [ "nixpkgs" ] }, "locked": { "lastModified": 1691225770, "narHash": "sha256-O5slH8nW8msTAqVAS5rkvdHSkjmrO+JauuSDzZCmv2M=", "owner": "nix-community", "repo": "home-manager", "rev": "0a014a729cdd54d9919ff36b714d047909d7a4c8", "type": "github" }, "original": { "owner": "nix-community", "repo": "home-manager", "type": "github" } }, "nixpkgs": { "locked": { "lastModified": 1691218994, "narHash": "sha256-46GJ5vLf9H+Oh7Jii2gJI9GATJHGbx2iQpon5nUSFPI=", "owner": "NixOS", "repo": "nixpkgs", "rev": "0d2fb29f5071a12d7983319c2c2576be6a130582", "type": "github" }, "original": { "owner": "NixOS", "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } }, "root": { "inputs": { "home-manager": "home-manager", "nixpkgs": "nixpkgs" } } }, "root": "root", "version": 7 }
-
-
flake.nix (new)
-
@@ -0,0 +1,114 @@{ description = "My system configuration"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; }; outputs = { self, nixpkgs, home-manager, }: let # Catppuccin pallet, one of: "latte", "frappe", "macchiato", "mocha" catppuccinTheme = "mocha"; # Pre-defined modules mods = { essentials = import ./essentials { inherit catppuccinTheme; }; scm = import ./scm { username = "Shota FUJI"; email = "pockawoooh@gmail.com"; }; wayland-de = import ./wayland-de { inherit catppuccinTheme; }; webdev = ./webdev; }; mkHomeConfiguration = { # Platform (e.g. x86_64-linux) system, # OS username username, # Modules to include modules ? [ mods.essentials ], # Timezone of the machine timezone ? "Asia/Tokyo", }: let isDarwin = (builtins.match "-darwin$" system) != null; homeDir = if isDarwin then "/Users" else "/home"; in home-manager.lib.homeManagerConfiguration { pkgs = nixpkgs.legacyPackages.${system}; modules = [ { home = rec { inherit username; homeDirectory = "${homeDir}/${username}"; stateVersion = "23.11"; sessionVariables = { TZ = timezone; }; }; # Turn off Home Manager news bs news.display = "silent"; } ] ++ modules; }; in { homeConfigurations = { dev-linux = mkHomeConfiguration { system = "x86_64-linux"; username = "pocka"; modules = [ mods.essentials mods.scm mods.webdev mods.wayland-de ]; }; pixelbook = mkHomeConfiguration { system = "x86_64-linux"; username = "pockawoooh"; modules = [ mods.essentials mods.scm mods.webdev ]; }; scm-server = mkHomeConfiguration { system = "x86_64-linux"; username = "pocka"; modules = [ mods.essentials mods.scm ]; }; mbp-m1 = mkHomeConfiguration { system = "aarch64-darwin"; username = "pocka"; modules = [ mods.essentials mods.scm mods.webdev ]; }; }; }; }
-
-
scm/default.nix (new)
-
@@ -0,0 +1,17 @@# SCM module: SCM/VCS tools and their configurations. { username, email, }: { ... }: { imports = [ ( import ./git.nix { inherit username email; } ) ./fossil.nix ]; }
-
-
scm/fossil.nix (new)
-
@@ -0,0 +1,12 @@{ config, pkgs, ... }: { home.packages = with pkgs; [ fossil ]; }
-
-
scm/git.nix (new)
-
@@ -0,0 +1,61 @@{ username, email, }: { config, pkgs, ... }: { programs = { git = { enable = true; userName = username; userEmail = email; extraConfig = { core = { editor = "nvim"; }; commit = { gpgsign = true; }; init = { defaultBranch = "master"; }; }; ignores = [ # vim swap file ".*.swp" # macOS junk # https://github.com/github/gitignore/blob/main/Global/macOS.gitignore ".DS_Store" ".AppleDouble" ".LSOverride" "Icon" ]; }; }; services = { gpg-agent = { enable = true; enableZshIntegration = true; # 1day defaultCacheTtl = 86400; defaultCacheTtlSsh = 86400; # 30days maxCacheTtl = 2592000; maxCacheTtlSsh = 2592000; }; }; }
-
-
shell.nix (new)
-
@@ -0,0 +1,28 @@# Shell for using home-manager & Flakes without installing/configuring. # Based on: # https://github.com/Misterio77/nix-config/blob/68939a161c97bb875fb1ead17c172c36de24bd01/shell.nix { pkgs ? let lock = ( builtins.fromJSON (builtins.readFile ./flake.lock) ).nodes.nixpkgs.locked; # Pin nixpkgs, so the shell can be invoked without channels nixpkgs = fetchTarball { url = "https://github.com/${lock.owner}/${lock.repo}/archive/${lock.rev}.tar.gz"; sha256 = lock.narHash; }; in import nixpkgs { overlays = []; }, ... }: { default = pkgs.mkShell { shellHook = '' export NIX_CONFIG="experimental-features = nix-command flakes" ''; nativeBuildInputs = with pkgs; [ nix home-manager ]; }; }
-
-
wayland-de/default.nix (new)
-
@@ -0,0 +1,24 @@# Wayland Desktop Environment { catppuccinTheme }: { ... }: { # I'm not sure this changes behaviour in a meaningful way. targets.genericLinux = { enable = true; }; # Update ~/.profile too. # https://github.com/nix-community/home-manager/issues/1439 programs.bash = { enable = true; }; imports = [ ( import ./foot.nix { inherit catppuccinTheme; } ) ]; }
-
-
wayland-de/foot.nix (new)
-
@@ -0,0 +1,63 @@{ catppuccinTheme, }: { config, pkgs, ... }: { programs = { zsh = { # Let Zsh tell Foot a current working directory # https://codeberg.org/dnkl/foot/wiki#user-content-spawning-new-terminal-instances-in-the-current-working-directory initExtra = '' function osc7-pwd() { emulate -L zsh # also sets localoptions for us setopt extendedglob local LC_ALL=C printf '\e]7;file://%s%s\e\' $HOST ''${PWD//(#m)([^@-Za-z&-;_~])/%''${(l:2::0:)$(([##16]#MATCH))}} } function chpwd-osc7-pwd() { (( ZSH_SUBSHELL )) || osc7-pwd } autoload -Uz add-zsh-hook add-zsh-hook -Uz chpwd chpwd-osc7-pwd ''; }; # A fast, lightweight and minimalistic Wayland terminal emulator # https://codeberg.org/dnkl/foot foot = { enable = true; server.enable = true; settings = { main = { include = "${config.xdg.configHome}/foot/theme.conf"; font = "monospace:size=10"; }; colors = { alpha = 0.9; }; }; }; }; xdg = { configFile."foot/theme.conf" = { text = builtins.readFile ( pkgs.fetchFromGitHub { owner = "catppuccin"; repo = "foot"; rev = "009cd57bd3491c65bb718a269951719f94224eb7"; sha256 = "0f0r8d4rn54gibrzfhiy4yr8bi7c8j18ggp1y9lyidc1dmy9kvw0"; } + "/catppuccin-${catppuccinTheme}.conf" ); }; }; }
-
-
webdev/default.nix (new)
-
@@ -0,0 +1,7 @@{ ... }: { imports = [ ./neovim.nix ]; }
-
-
webdev/neovim.nix (new)
-
@@ -0,0 +1,47 @@# Language specific tools are not configured in this file because # these tools are project specific. Each project should have Flake # file (provided by the project or manually created by a user). { config, pkgs, ... }: { programs = { neovim = { plugins = with pkgs.vimPlugins; [ { plugin = nvim-lspconfig; type = "lua"; config = '' -- Based on https://github.com/neovim/nvim-lspconfig#suggested-configuration local lspconfig = require("lspconfig") -- Elm lspconfig.elmls.setup {} -- TypeScript lspconfig.tsserver.setup {} -- Deno lspconfig.denols.setup {} -- CSS lspconfig.cssls.setup {} -- HTML lspconfig.html.setup {} -- LSP key mappings vim.api.nvim_create_autocmd("LspAttach", { group = vim.api.nvim_create_augroup("UserLspConfig", {}), callback = function(ev) local opts = { buffer = ev.buf } vim.keymap.set("n", "K", vim.lsp.buf.hover, opts) end, }) ''; } ]; }; }; }
-