diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..6de8a8a --- /dev/null +++ b/.envrc @@ -0,0 +1,3 @@ +source_url "https://raw.githubusercontent.com/cachix/devenv/d1f7b48e35e6dee421cfd0f51481d17f77586997/direnvrc" "sha256-YBzqskFZxmNb3kYVoKD9ZixoPXJh1C9ZvTLGFRkauZ0=" + +use devenv \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c4300bc --- /dev/null +++ b/.gitignore @@ -0,0 +1,11 @@ + +# Devenv +.devenv* +devenv.local.nix + +# direnv +.direnv + +# pre-commit +.pre-commit-config.yaml + diff --git a/devenv.lock b/devenv.lock new file mode 100644 index 0000000..96dd4b1 --- /dev/null +++ b/devenv.lock @@ -0,0 +1,156 @@ +{ + "nodes": { + "devenv": { + "locked": { + "dir": "src/modules", + "lastModified": 1700140236, + "narHash": "sha256-OpukFO0rRG2hJzD+pCQq+nSWuT9dBL6DSvADQaUlmFg=", + "owner": "cachix", + "repo": "devenv", + "rev": "525d60c44de848a6b2dd468f6efddff078eb2af2", + "type": "github" + }, + "original": { + "dir": "src/modules", + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1685518550, + "narHash": "sha256-o2d0KcvaXzTrPRIo0kOLV0/QXHhDQ5DTi+OxcjO8xqY=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "a1720a10a6cfe8234c0e93907ffe81be440f4cef", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "pre-commit-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1660459072, + "narHash": "sha256-8DFJjXG8zqoONA1vXtgeKXy68KdJL5UaXR8NtVMUbx8=", + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "a20de23b925fd8264fd7fad6454652e142fd7f73", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1700444282, + "narHash": "sha256-s/+tgT+Iz0LZO+nBvSms+xsMqvHt2LqYniG9r+CYyJc=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3f21a22b5aafefa1845dec6f4a378a8f53d8681c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-stable": { + "locked": { + "lastModified": 1685801374, + "narHash": "sha256-otaSUoFEMM+LjBI1XL/xGB5ao6IwnZOXc47qhIgJe8U=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c37ca420157f4abc31e26f436c1145f8951ff373", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "pre-commit-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "flake-utils": "flake-utils", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ], + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1700064067, + "narHash": "sha256-1ZWNDzhu8UlVCK7+DUN9dVQfiHX1bv6OQP9VxstY/gs=", + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "rev": "e558068cba67b23b4fbc5537173dbb43748a17e8", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "pre-commit-hooks.nix", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": "pre-commit-hooks" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 + } diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 0000000..9abec9b --- /dev/null +++ b/devenv.nix @@ -0,0 +1,7 @@ +{ pkgs, ... }: + +{ + pre-commit.hooks = { nixpkgs-fmt.enable = true; }; + + packages = with pkgs; [ nixpkgs-fmt nixfmt ]; +} diff --git a/devenv.yaml b/devenv.yaml new file mode 100644 index 0000000..76b7cdf --- /dev/null +++ b/devenv.yaml @@ -0,0 +1,3 @@ +inputs: +nixpkgs: +url: github:NixOS/nixpkgs/nixpkgs-unstable diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..99aab77 --- /dev/null +++ b/flake.lock @@ -0,0 +1,86 @@ +{ + "nodes": { + "disko": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1699781810, + "narHash": "sha256-LD+PIUbm1yQmQmGIbSsc/PB1dtJtGqXFgxRc1C7LlfQ=", + "owner": "nix-community", + "repo": "disko", + "rev": "2d7d77878c5d70f66f3d676ff66708d8d4f9d7df", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "disko", + "type": "github" + } + }, + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1700419052, + "narHash": "sha256-U6a5f9ynbzcp8PMIHULbHPkbwp7YfPKOYmTcLqlalD4=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "993fb02d20760067b8ee19c713d94cee07037759", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "home-manager", + "type": "github" + } + }, + "nixos-hardware": { + "locked": { + "lastModified": 1700392353, + "narHash": "sha256-KARn8aVJu5fdW0jdJYoOQ1SPqWlNdz4l7r90NbArWSY=", + "owner": "NixOS", + "repo": "nixos-hardware", + "rev": "2b00bc76dc893cd996a3d76a2f059d657a5ef37a", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "master", + "repo": "nixos-hardware", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1700390070, + "narHash": "sha256-de9KYi8rSJpqvBfNwscWdalIJXPo8NjdIZcEJum1mH0=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "e4ad989506ec7d71f7302cc3067abd82730a4beb", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "disko": "disko", + "home-manager": "home-manager", + "nixos-hardware": "nixos-hardware", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..f17049e --- /dev/null +++ b/flake.nix @@ -0,0 +1,60 @@ +{ + description = "NixOS configuration of Thomas Syms"; + nixConfig = { + experimental-features = [ "nix-command" "flakes" ]; + }; + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + home-manager.url = "github:nix-community/home-manager"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + nixos-hardware.url = "github:NixOS/nixos-hardware/master"; + disko.url = "github:nix-community/disko"; + disko.inputs.nixpkgs.follows = "nixpkgs"; + + }; + outputs = + inputs@{ self, nixpkgs, home-manager, ... }: { + nixosConfigurations = { + /* nixos-test = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./hosts/nixos-test + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.extraSpecialArgs = inputs; + home-manager.users.panotaka = import ./home; + } + ]; + }; + msi-rtx4090 = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + modules = [ + ./hosts/msi-rtx4090 + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.extraSpecialArgs = inputs; + home-manager.users.panotaka = import ./home; + } + ]; + }; */ + Equinox = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { inherit inputs; }; + modules = [ + ./hosts/Equinox + home-manager.nixosModules.home-manager + { + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.extraSpecialArgs = inputs; + home-manager.users.panotaka = import ./home; + } + ]; + }; + }; + }; +} diff --git a/home/default.nix b/home/default.nix new file mode 100644 index 0000000..4e0b74a --- /dev/null +++ b/home/default.nix @@ -0,0 +1,28 @@ +{ config, pkgs, ... }: + +{ + + imports = [ + + ]; + + # Home Manager needs a bit of information about you and the + # paths it should manage. + home = { + username = "panotaka"; + homeDirectory = "/home/panotaka"; + + # This value determines the Home Manager release that your + # configuration is compatible with. This helps avoid breakage + # when a new Home Manager release introduces backwards + # incompatible changes. + # + # You can update Home Manager without changing this value. See + # the Home Manager release notes for a list of state version + # changes in each release. + stateVersion = "22.11"; + }; + + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; +} diff --git a/home/programs/browsers.nix b/home/programs/browsers.nix new file mode 100644 index 0000000..a2fd0f6 --- /dev/null +++ b/home/programs/browsers.nix @@ -0,0 +1,19 @@ +{ pkgs +, config +, ... +}: { + programs = { + chromium = { + enable = true; + commandLineArgs = [ "--enable-features=TouchpadOverscrollHistoryNavigation" ]; + extensions = [ + # {id = "";} // extension id, query from chrome web store + ]; + }; + + firefox = { + enable = true; + profiles.ryan = { }; + }; + }; +} diff --git a/home/programs/common.nix b/home/programs/common.nix new file mode 100644 index 0000000..80ee180 --- /dev/null +++ b/home/programs/common.nix @@ -0,0 +1,86 @@ +{ pkgs, ... }: { + home.packages = with pkgs; [ + # archives + zip + unzip + p7zip + + # utils + ripgrep + yq-go # https://github.com/mikefarah/yq + htop + + # misc + libnotify + wineWowPackages.wayland + xdg-utils + graphviz + + # productivity + obsidian + + # IDE + insomnia + + # cloud native + docker-compose + kubectl + + + nodejs + nodePackages.npm + nodePackages.pnpm + yarn + + # db related + dbeaver + mycli + pgcli + ]; + + programs = { + tmux = { + enable = true; + clock24 = true; + keyMode = "vi"; + extraConfig = "mouse on"; + }; + + bat = { + enable = true; + config = { + pager = "less -FR"; + theme = "Catppuccin-mocha"; + }; + themes = { + Catppuccin-mocha = builtins.readFile (pkgs.fetchurl { + url = "https://raw.githubusercontent.com/catppuccin/bat/main/Catppuccin-mocha.tmTheme"; + hash = "sha256-qMQNJGZImmjrqzy7IiEkY5IhvPAMZpq0W6skLLsng/w="; + }); + }; + }; + + btop.enable = true; # replacement of htop/nmon + exa.enable = true; # A modern replacement for ‘ls’ + jq.enable = true; # A lightweight and flexible command-line JSON processor + ssh.enable = true; + aria2.enable = true; + + skim = { + enable = true; + enableZshIntegration = true; + defaultCommand = "rg --files --hidden"; + changeDirWidgetOptions = [ + "--preview 'exa --icons --git --color always -T -L 3 {} | head -200'" + "--exact" + ]; + }; + }; + + services = { + syncthing.enable = true; + + # auto mount usb drives + udiskie.enable = true; + }; +} diff --git a/home/programs/default.nix b/home/programs/default.nix new file mode 100644 index 0000000..fae9a82 --- /dev/null +++ b/home/programs/default.nix @@ -0,0 +1,13 @@ +{ config +, pkgs +, ... +}: { + imports = [ + ./browsers.nix + ./common.nix + ./git.nix + ./media.nix + ./vscode.nix + ./xdg.nix + ]; +} diff --git a/home/programs/git.nix b/home/programs/git.nix new file mode 100644 index 0000000..66cb9d4 --- /dev/null +++ b/home/programs/git.nix @@ -0,0 +1,12 @@ +{ pkgs +, ... +}: { + home.packages = [ pkgs.gh ]; + + programs.git = { + enable = true; + + userName = "Ryan Yin"; + userEmail = "xiaoyin_c@qq.com"; + }; +} diff --git a/home/programs/media.nix b/home/programs/media.nix new file mode 100644 index 0000000..5cd2140 --- /dev/null +++ b/home/programs/media.nix @@ -0,0 +1,32 @@ +{ pkgs +, config +, ... +}: +# media - control and enjoy audio/video +{ + # imports = [ + # ]; + + home.packages = with pkgs; [ + # audio control + pavucontrol + playerctl + pulsemixer + # images + imv + ]; + + programs = { + mpv = { + enable = true; + defaultProfiles = [ "gpu-hq" ]; + scripts = [ pkgs.mpvScripts.mpris ]; + }; + + obs-studio.enable = true; + }; + + services = { + playerctld.enable = true; + }; +} diff --git a/home/programs/vscode.nix b/home/programs/vscode.nix new file mode 100644 index 0000000..80529d8 --- /dev/null +++ b/home/programs/vscode.nix @@ -0,0 +1,125 @@ +{ config +, pkgs +, home-manager +, nix-vscode-extensions +, ... +}: + +{ + + # if use vscode in wayland, uncomment this line + # environment.sessionVariables.NIXOS_OZONE_WL = "1"; + programs.vscode = { + enable = true; + userSettings = { + "editor.renderWhitespace" = "all"; + "files.autoSave" = "onFocusChange"; + "editor.rulers" = [ 80 120 ]; + "telemetry.enableTelemetry" = false; + "telemetry.enableCrashReporter" = false; + "editor.tabSize" = 2; + "files.exclude" = { "**/node_modules/**" = true; }; + "editor.formatOnSave" = false; + "breadcrumbs.enabled" = true; + "editor.useTabStops" = false; + "editor.fontFamily" = "JetBrainsMono Nerd Font"; + "editor.fontSize" = 16; + "editor.fontLigatures" = true; + "editor.lineHeight" = 20; + "workbench.fontAliasing" = "antialiased"; + "files.trimTrailingWhitespace" = true; + "editor.minimap.enabled" = false; + "workbench.editor.enablePreview" = false; + "terminal.integrated.fontFamily" = "JetBrainsMono Nerd Font"; + }; + + package = + let + config.packageOverrides = pkgs: { + vscode = pkgs.vscode-with-extensions.override { + # pkgs.vscode-extensions 里包含的 vscode 太少了 + # 必须使用社区的 才能安装更多插件 + vscodeExtensions = with nix-vscode-extensions.extensions; [ + aaron-bond.better-comments + anweber.vscode-httpyac + arrterian.nix-env-selector + bierner.markdown-mermaid + christian-kohler.path-intellisense + cschlosser.doxdocgen + DanishSarwar.reverse-search + eamodio.gitlens + esbenp.prettier-vscode + espressif.esp-idf-extension + fabiospampinato.vscode-diff + GitHub.copilot + golang.go + hashicorp.terraform + janisdd.vscode-edit-csv + jebbs.plantuml + jeff-hykin.better-cpp-syntax + jnoortheen.nix-ide + JuanBlanco.solidity + k--kato.intellij-idea-keybindings + llvm-vs-code-extensions.vscode-clangd + mcu-debug.debug-tracker-vscode + mcu-debug.memory-view + mcu-debug.rtos-views + mikestead.dotenv + mkhl.direnv + ms-azuretools.vscode-docker + ms-dotnettools.vscode-dotnet-runtime + ms-kubernetes-tools.vscode-kubernetes-tools + ms-python.isort + ms-python.python + ms-python.vscode-pylance + ms-toolsai.jupyter + ms-toolsai.jupyter-keymap + ms-toolsai.jupyter-renderers + ms-toolsai.vscode-jupyter-cell-tags + ms-toolsai.vscode-jupyter-slideshow + ms-vscode-remote.remote-containers + ms-vscode-remote.remote-ssh + ms-vscode-remote.remote-ssh-edit + ms-vscode-remote.vscode-remote-extensionpack + ms-vscode.cmake-tools + ms-vscode.cpptools + ms-vscode.cpptools-extension-pack + ms-vscode.cpptools-themes + ms-vscode.remote-explorer + ms-vscode.remote-server + pinage404.nix-extension-pack + platformio.platformio-ide + pomdtr.excalidraw-editor + redhat.java + redhat.vscode-commons + redhat.vscode-xml + redhat.vscode-yaml + rust-lang.rust-analyzer + shd101wyy.markdown-preview-enhanced + sumneko.lua + tamasfe.even-better-toml + timonwong.shellcheck + tintinweb.graphviz-interactive-preview + tintinweb.solidity-visual-auditor + tintinweb.vscode-inline-bookmarks + tintinweb.vscode-solidity-flattener + tintinweb.vscode-solidity-language + twxs.cmake + vadimcn.vscode-lldb + VisualStudioExptTeam.intellicode-api-usage-examples + VisualStudioExptTeam.vscodeintellicode + vscjava.vscode-java-debug + vscjava.vscode-java-pack + vscjava.vscode-java-test + vscjava.vscode-maven + vscode-icons-team.vscode-icons + WakaTime.vscode-wakatime + yzhang.markdown-all-in-one + zxh404.vscode-proto3 + ]; + }; + }; + in + pkgs.vscode; + }; +} diff --git a/home/programs/xdg.nix b/home/programs/xdg.nix new file mode 100644 index 0000000..d5851b1 --- /dev/null +++ b/home/programs/xdg.nix @@ -0,0 +1,49 @@ +{ config, ... }: +let + browser = [ "firefox.desktop" ]; + + # XDG MIME types + associations = { + "application/x-extension-htm" = browser; + "application/x-extension-html" = browser; + "application/x-extension-shtml" = browser; + "application/x-extension-xht" = browser; + "application/x-extension-xhtml" = browser; + "application/xhtml+xml" = browser; + "text/html" = browser; + "x-scheme-handler/about" = browser; + "x-scheme-handler/chrome" = [ "chromium-browser.desktop" ]; + "x-scheme-handler/ftp" = browser; + "x-scheme-handler/http" = browser; + "x-scheme-handler/https" = browser; + "x-scheme-handler/unknown" = browser; + + "audio/*" = [ "mpv.desktop" ]; + "video/*" = [ "mpv.dekstop" ]; + "image/*" = [ "imv.desktop" ]; + "application/json" = browser; + "application/pdf" = [ "org.pwmt.zathura.desktop.desktop" ]; + "x-scheme-handler/discord" = [ "discordcanary.desktop" ]; + "x-scheme-handler/spotify" = [ "spotify.desktop" ]; + "x-scheme-handler/tg" = [ "telegramdesktop.desktop" ]; + }; +in +{ + xdg = { + enable = true; + cacheHome = config.home.homeDirectory + "/.local/cache"; + + mimeApps = { + enable = true; + defaultApplications = associations; + }; + + userDirs = { + enable = true; + createDirectories = true; + extraConfig = { + XDG_SCREENSHOTS_DIR = "${config.xdg.userDirs.pictures}/Screenshots"; + }; + }; + }; +} diff --git a/home/shell/common.nix b/home/shell/common.nix new file mode 100644 index 0000000..a2d1604 --- /dev/null +++ b/home/shell/common.nix @@ -0,0 +1,17 @@ +{ pkgs +, ... +}: +# nix tooling +{ + home.packages = with pkgs; [ + alejandra + deadnix + statix + ]; + + programs.direnv = { + enable = true; + nix-direnv.enable = true; + enableZshIntegration = true; + }; +} diff --git a/home/shell/default.nix b/home/shell/default.nix new file mode 100644 index 0000000..2be3b3e --- /dev/null +++ b/home/shell/default.nix @@ -0,0 +1,36 @@ +{ config, ... }: +let + d = config.xdg.dataHome; + c = config.xdg.configHome; + cache = config.xdg.cacheHome; +in +{ + imports = [ + ./nushell + ./common.nix + ./starship.nix + ./terminals.nix + ]; + + # add environment variables + home.sessionVariables = { + # clean up ~ + LESSHISTFILE = cache + "/less/history"; + LESSKEY = c + "/less/lesskey"; + WINEPREFIX = d + "/wine"; + + # set default applications + EDITOR = "vim"; + BROWSER = "firefox"; + TERMINAL = "alacritty"; + + # enable scrolling in git diff + DELTA_PAGER = "less -R"; + + MANPAGER = "sh -c 'col -bx | bat -l man -p'"; + }; + + home.shellAliases = { + k = "kubectl"; + }; +} diff --git a/home/shell/nushell/config.nu b/home/shell/nushell/config.nu new file mode 100644 index 0000000..e69de29 diff --git a/home/shell/nushell/default.nix b/home/shell/nushell/default.nix new file mode 100644 index 0000000..9165426 --- /dev/null +++ b/home/shell/nushell/default.nix @@ -0,0 +1,7 @@ +{ + programs.nushell = { + enable = true; + configFile.source = ./config.nu; + envFile.source = ./env.nu; + }; +} diff --git a/home/shell/nushell/env.nu b/home/shell/nushell/env.nu new file mode 100644 index 0000000..5804d34 --- /dev/null +++ b/home/shell/nushell/env.nu @@ -0,0 +1,36 @@ +# Nushell Environment Config File + +# Specifies how environment variables are: +# - converted from a string to a value on Nushell startup (from_string) +# - converted from a value back to a string when running external commands (to_string) +# Note: The conversions happen *after* config.nu is loaded +let-env ENV_CONVERSIONS = { + "PATH": { + from_string: { |s| $s | split row (char esep) | path expand -n } + to_string: { |v| $v | path expand -n | str join (char esep) } + } + "Path": { + from_string: { |s| $s | split row (char esep) | path expand -n } + to_string: { |v| $v | path expand -n | str join (char esep) } + } +} + +# Directories to search for scripts when calling source or use +# +# By default, /scripts is added +let-env NU_LIB_DIRS = [ + ($nu.config-path | path dirname | path join 'scripts') +] + +# Directories to search for plugin binaries when calling register +# +# By default, /plugins is added +let-env NU_PLUGIN_DIRS = [ + ($nu.config-path | path dirname | path join 'plugins') +] + +# To add entries to PATH (on Windows you might use Path), you can use the following pattern: +# let-env PATH = ($env.PATH | split row (char esep) | prepend '/some/path') + +mkdir ~/.cache/starship +starship init nu | sed "s/size -c/size/" | save ~/.cache/starship/init.nu \ No newline at end of file diff --git a/home/shell/starship.nix b/home/shell/starship.nix new file mode 100644 index 0000000..afea194 --- /dev/null +++ b/home/shell/starship.nix @@ -0,0 +1,13 @@ +{ config, ... }: { + home.sessionVariables.STARSHIP_CACHE = "${config.xdg.cacheHome}/starship"; + + programs.starship = { + enable = true; + settings = { + character = { + success_symbol = "[›](bold green)"; + error_symbol = "[›](bold red)"; + }; + }; + }; +} diff --git a/home/shell/terminals.nix b/home/shell/terminals.nix new file mode 100644 index 0000000..6b2c9fb --- /dev/null +++ b/home/shell/terminals.nix @@ -0,0 +1,29 @@ +{ pkgs, ... }: + +# terminals + +let + font = "JetBrainsMono Nerd Font"; +in +{ + programs.alacritty = { + enable = true; + settings = { + window.opacity = 0.95; + window.dynamic_padding = true; + window.padding = { + x = 5; + y = 5; + }; + scrolling.history = 10000; + + font = { + normal.family = font; + bold.family = font; + italic.family = font; + size = 11; + }; + + }; + }; +} diff --git a/hosts/Equinox/default.nix b/hosts/Equinox/default.nix new file mode 100644 index 0000000..cb25c59 --- /dev/null +++ b/hosts/Equinox/default.nix @@ -0,0 +1,58 @@ +{ config, pkgs, inputs, ... }: + +let + hostname = "Equinox"; +in +{ + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + + # System version + system.stateVersion = "22.11"; + + + # Import hardware configuration + imports = [ + ../../modules/system.nix + + + inputs.nixos-hardware.nixosModules.dell-xps-15-9510 + inputs.nixos-hardware.nixosModules.dell-xps-15-9510-nvidia + inputs.disko.nixosModules.disko + ./disko.nix + ]; + + + # Set hostname and timezone + networking.hostName = hostname; + + + # Bootloader configuration + boot = { + kernelModules = [ "kvm-intel" ]; + extraModulePackages = [ ]; + + initrd = { + kernelModules = [ ]; + availableKernelModules = [ + "xhci_pci" + "thunderbolt" + "vmd" + "nvme" + "usb_storage" + "sd_mod" + "rtsx_pci_sdmmc" + ]; + }; + + loader = { + systemd-boot.enable = true; + efi = { + canTouchEfiVariables = true; + }; + }; + }; + + +} diff --git a/hosts/Equinox/disko.nix b/hosts/Equinox/disko.nix new file mode 100644 index 0000000..832018e --- /dev/null +++ b/hosts/Equinox/disko.nix @@ -0,0 +1,59 @@ +{ + disko.devices = { + disk = { + nvme0n1 = { + type = "disk"; + device = "/dev/vda"; + content = { + type = "gpt"; + partitions = { + ESP = { + size = "512M"; + type = "EF00"; + content = { + type = "filesystem"; + format = "vfat"; + mountpoint = "/boot"; + mountOptions = [ + "defaults" + ]; + }; + }; + luks = { + size = "100%"; + content = { + type = "luks"; + name = "crypted"; + settings = { + allowDiscards = true; + }; + content = { + type = "btrfs"; + extraArgs = [ "-f" ]; + subvolumes = { + "/root" = { + mountpoint = "/"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/home" = { + mountpoint = "/home"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/nix" = { + mountpoint = "/nix"; + mountOptions = [ "compress=zstd" "noatime" ]; + }; + "/swap" = { + mountpoint = "/.swapvol"; + swap.swapfile.size = "40G"; + }; + }; + }; + }; + }; + }; + }; + }; + }; + }; +} diff --git a/hosts/msi-rtx4090/default.nix b/hosts/msi-rtx4090/default.nix new file mode 100644 index 0000000..6bd5428 --- /dev/null +++ b/hosts/msi-rtx4090/default.nix @@ -0,0 +1,55 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running ‘nixos-help’). + +{ config, pkgs, ... }: + +{ + imports = + [ + ../../modules/system.nix + ../../modules/i3.nix + + # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + # Bootloader. + boot.loader = { + efi = { + canTouchEfiVariables = true; + efiSysMountPoint = "/boot/efi"; # ← use the same mount point here. + }; + systemd-boot.enable = true; + }; + + networking.hostName = "msi-rtx4090"; # Define your hostname. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # Configure network proxy if necessary + # networking.proxy.default = "http://user:password@proxy:port/"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + # Enable networking + networking.networkmanager.enable = true; + networking.defaultGateway = "192.168.5.201"; + + # for Nvidia GPU + services.xserver.videoDrivers = [ "nvidia" ]; + hardware.opengl.enable = true; + hardware.nvidia = { + package = config.boot.kernelPackages.nvidiaPackages.stable; + modesetting.enable = true; + }; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "22.11"; # Did you read the comment? + +} + + diff --git a/hosts/msi-rtx4090/hardware-configuration.nix b/hosts/msi-rtx4090/hardware-configuration.nix new file mode 100644 index 0000000..c1c82c3 --- /dev/null +++ b/hosts/msi-rtx4090/hardware-configuration.nix @@ -0,0 +1,43 @@ +# 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 = [ "xhci_pci" "ahci" "nvme" "usbhid" "uas" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { + device = "/dev/disk/by-uuid/9730ef67-577c-4dc9-8563-f431c1cf25fb"; + fsType = "ext4"; + }; + + fileSystems."/boot/efi" = + { + device = "/dev/disk/by-uuid/8DA9-86FF"; + fsType = "vfat"; + }; + + swapDevices = + [{ device = "/dev/disk/by-uuid/5364261a-3ecc-4754-b114-ff44c529627e"; }]; + + # 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.enp5s0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlo1.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/nixos-test/default.nix b/hosts/nixos-test/default.nix new file mode 100644 index 0000000..ff677d7 --- /dev/null +++ b/hosts/nixos-test/default.nix @@ -0,0 +1,53 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running ‘nixos-help’). + +{ config, pkgs, ... }: + +{ + imports = + [ + ../../modules/system.nix + ../../modules/i3.nix + + # Include the results of the hardware scan. + ./hardware-configuration.nix + ]; + + # Bootloader. + boot.loader = { + # efi = { + # canTouchEfiVariables = true; + # efiSysMountPoint = "/boot/efi"; # ← use the same mount point here. + # }; + grub = { + enable = true; + device = "/dev/sda"; # "nodev" + efiSupport = false; + useOSProber = true; + #efiInstallAsRemovable = true; # in case canTouchEfiVariables doesn't work for your system + }; + }; + + networking.hostName = "nixos-test"; # Define your hostname. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # Configure network proxy if necessary + # networking.proxy.default = "http://user:password@proxy:port/"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + # Enable networking + networking.networkmanager.enable = true; + networking.defaultGateway = "192.168.5.201"; + + # This value determines the NixOS release from which the default + # settings for stateful data, like file locations and database versions + # on your system were taken. It‘s perfectly fine and recommended to leave + # this value at the release version of the first install of this system. + # Before changing this value read the documentation for this option + # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). + system.stateVersion = "22.11"; # Did you read the comment? + +} + + diff --git a/hosts/nixos-test/hardware-configuration.nix b/hosts/nixos-test/hardware-configuration.nix new file mode 100644 index 0000000..a53d800 --- /dev/null +++ b/hosts/nixos-test/hardware-configuration.nix @@ -0,0 +1,34 @@ +# 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 + "/profiles/qemu-guest.nix") + ]; + + boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "virtio_pci" "virtio_scsi" "sd_mod" "sr_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { + device = "/dev/disk/by-uuid/b779eb19-e43d-4f07-a91f-eb08bd8e1202"; + 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.ens18.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/modules/i3.nix b/modules/i3.nix new file mode 100644 index 0000000..a6cbfa1 --- /dev/null +++ b/modules/i3.nix @@ -0,0 +1,55 @@ +{ pkgs, ... }: + + +{ + + # i3 related options + environment.pathsToLink = [ "/libexec" ]; # links /libexec from derivations to /run/current-system/sw + services.xserver = { + enable = true; + + desktopManager = { + xterm.enable = false; + }; + + displayManager = { + defaultSession = "none+i3"; + lightdm.enable = false; + gdm.enable = true; + }; + + windowManager.i3 = { + enable = true; + extraPackages = with pkgs; [ + rofi # application launcher, the same as dmenu + dunst # notification daemon + i3blocks # status bar + i3lock # default i3 screen locker + xautolock # lock screen after some time + i3status # provide information to i3bar + i3-gaps # i3 with gaps + picom # transparency and shadows + feh # set wallpaper + acpi # battery information + arandr # screen layout manager + dex # autostart applications + xbindkeys # bind keys to commands + xorg.xbacklight # control screen brightness + xorg.xdpyinfo # get screen information + sysstat # get system information + ]; + }; + + # Configure keymap in X11 + layout = "us"; + xkbVariant = ""; + }; + + # thunar file manager(part of xfce) related options + programs.thunar.plugins = with pkgs.xfce; [ + thunar-archive-plugin + thunar-volman + ]; + services.gvfs.enable = true; # Mount, trash, and other functionalities + services.tumbler.enable = true; # Thumbnail support for images +} diff --git a/modules/system.nix b/modules/system.nix new file mode 100644 index 0000000..d918273 --- /dev/null +++ b/modules/system.nix @@ -0,0 +1,130 @@ +{ config, pkgs, ... }: + +{ + # Set your time zone. + time.timeZone = "Asia/Shanghai"; + + # Select internationalisation properties. + i18n.defaultLocale = "en_US.UTF-8"; + + i18n.extraLocaleSettings = { + LC_ADDRESS = "zh_CN.UTF-8"; + LC_IDENTIFICATION = "zh_CN.UTF-8"; + LC_MEASUREMENT = "zh_CN.UTF-8"; + LC_MONETARY = "zh_CN.UTF-8"; + LC_NAME = "zh_CN.UTF-8"; + LC_NUMERIC = "zh_CN.UTF-8"; + LC_PAPER = "zh_CN.UTF-8"; + LC_TELEPHONE = "zh_CN.UTF-8"; + LC_TIME = "zh_CN.UTF-8"; + }; + + # Enable CUPS to print documents. + services.printing.enable = true; + + + fonts = { + fonts = with pkgs; [ + # icon fonts + material-design-icons + + # normal fonts + noto-fonts + noto-fonts-cjk + noto-fonts-emoji + + # nerdfonts + (nerdfonts.override { fonts = [ "FiraCode" "JetBrainsMono" ]; }) + ]; + + # use fonts specified by user rather than default ones + enableDefaultFonts = false; + + # user defined fonts + # the reason there's Noto Color Emoji everywhere is to override DejaVu's + # B&W emojis that would sometimes show instead of some Color emojis + fontconfig.defaultFonts = { + serif = [ "Noto Serif" "Noto Color Emoji" ]; + sansSerif = [ "Noto Sans" "Noto Color Emoji" ]; + monospace = [ "JetBrainsMono Nerd Font" "Noto Color Emoji" ]; + emoji = [ "Noto Color Emoji" ]; + }; + }; + + programs.dconf.enable = true; + + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + networking.firewall.enable = false; + + # Enable the OpenSSH daemon. + services.openssh = { + enable = true; + settings = { + X11Forwarding = true; + PermitRootLogin = "no"; # disable root login + PasswordAuthentication = false; # disable password login + }; + openFirewall = true; + }; + + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + # List packages installed in system profile. To search, run: + # $ nix search wget + environment.systemPackages = with pkgs; [ + vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. + wget + curl + git + sysstat + lm_sensors # for `sensors` command + # minimal screen capture tool, used by i3 blur lock to take a screenshot + # print screen key is also bound to this tool in i3 config + scrot + neofetch + xfce.thunar # xfce4's file manager + nnn # terminal file manager + ]; + + # Enable sound with pipewire. + sound.enable = true; + hardware.pulseaudio.enable = false; + services.power-profiles-daemon = { + enable = true; + }; + security.polkit.enable = true; + + services = { + dbus.packages = [ pkgs.gcr ]; + + geoclue2.enable = true; + + pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + # If you want to use JACK applications, uncomment this + jack.enable = true; + + # use the example session manager (no others are packaged yet so this is enabled by default, + # no need to redefine it in your config for now) + #media-session.enable = true; + }; + + udev.packages = with pkgs; [ gnome.gnome-settings-daemon ]; + }; + + # Define a user account. Don't forget to set a password with ‘passwd’. + users.users.panotaka = { + isNormalUser = true; + description = "panotaka"; + extraGroups = [ "networkmanager" "wheel" ]; + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJx3Sk20pLL1b2PPKZey2oTyioODrErq83xG78YpFBoj admin@ryan-MBP" + ]; + }; +} diff --git a/wallpaper.jpg b/wallpaper.jpg new file mode 100755 index 0000000..0278c49 Binary files /dev/null and b/wallpaper.jpg differ