From d725ad06a7ad2ab6cf7afeb0c81c0119765709a0 Mon Sep 17 00:00:00 2001 From: Hare Date: Thu, 30 Jan 2025 21:55:28 +0900 Subject: [PATCH] Init --- README.md | 9 ++ flake.nix | 17 +++ home-manager/direnv.nix | 9 ++ home-manager/hyprland.nix | 196 ++++++++++++++++++++++++++++++++++ home-manager/tofi.nix | 35 ++++++ hosts/default.nix | 75 +++++++++++++ programs/desktop/hyprland.nix | 19 ++++ programs/docker.nix | 3 + programs/fcitx.nix | 11 ++ programs/shell.nix | 24 +++++ programs/ssh.nix | 24 +++++ programs/utility.nix | 14 +++ programs/v4l2.nix | 7 ++ programs/vscode-server.nix | 16 +++ system/core/boot.nix | 6 ++ system/core/default.nix | 11 ++ system/core/fonts.nix | 18 ++++ system/core/locale.nix | 5 + system/core/network.nix | 13 +++ system/core/nix.nix | 17 +++ system/core/sound.nix | 9 ++ system/core/uwsm.nix | 12 +++ 22 files changed, 550 insertions(+) create mode 100644 README.md create mode 100644 flake.nix create mode 100644 home-manager/direnv.nix create mode 100644 home-manager/hyprland.nix create mode 100644 home-manager/tofi.nix create mode 100644 hosts/default.nix create mode 100644 programs/desktop/hyprland.nix create mode 100644 programs/docker.nix create mode 100644 programs/fcitx.nix create mode 100644 programs/shell.nix create mode 100644 programs/ssh.nix create mode 100644 programs/utility.nix create mode 100644 programs/v4l2.nix create mode 100644 programs/vscode-server.nix create mode 100644 system/core/boot.nix create mode 100644 system/core/default.nix create mode 100644 system/core/fonts.nix create mode 100644 system/core/locale.nix create mode 100644 system/core/network.nix create mode 100644 system/core/nix.nix create mode 100644 system/core/sound.nix create mode 100644 system/core/uwsm.nix diff --git a/README.md b/README.md new file mode 100644 index 0000000..751e1fc --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +# Play.nix + +my nixos configuration + +## TODO + +- [ ] More adjustments about uwsm and hyprland +- [ ] Setting up for uniform configuration for common applications +- [ ] Make it selectable for NixOS/Nix-darwin/Standalone \ No newline at end of file diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..c59ff00 --- /dev/null +++ b/flake.nix @@ -0,0 +1,17 @@ +{ + description = "my config flake"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; + + home-manager.url = "github:nix-community/home-manager"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + + nixos-hardware.url = "github:NixOS/nixos-hardware"; + }; + + outputs = inputs: { + nixosConfigurations = (import ./hosts inputs).nixos; + homeConfigurations = (import ./hosts inputs).home-manager; + }; +} \ No newline at end of file diff --git a/home-manager/direnv.nix b/home-manager/direnv.nix new file mode 100644 index 0000000..ad23ea9 --- /dev/null +++ b/home-manager/direnv.nix @@ -0,0 +1,9 @@ +{ + programs = { + direnv = { + enable = true; + enableFishIntegration = true; # see note on other shells below + nix-direnv.enable = true; + }; + }; +} diff --git a/home-manager/hyprland.nix b/home-manager/hyprland.nix new file mode 100644 index 0000000..bad1a77 --- /dev/null +++ b/home-manager/hyprland.nix @@ -0,0 +1,196 @@ +{ + programs.kitty.enable = true; + wayland.windowManager.hyprland = { + enable = true; + systemd.enable = false; + settings = { + exec-once = [ + # "/usr/lib/polkit-kde-authentication-agent-1" + # "dunst" + "swww-daemon" + "swww img ./backgrounds/arknights-02.jpg" + # "hypridle" + # "copyq --start-server" + # "wl-paste --type text --watch cliphist store" + # "wl-paste --type image --watch cliphist store" + "eww daemon" + "eww open bar" + "eww open roundedEdge" + "dconf write /org/gnome/desktop/interface/gtk-theme 'Adwaita Dark'" + "dconf write /org/gnome/desktop/interface/icon-theme 'Adwaita Dark'" + "dconf write /org/gnome/desktop/interface/document-font-name 'Noto Sans Medium 11'" + "dconf write /org/gnome/desktop/interface/font-name 'Noto Sans Medium 11'" + "dconf write /org/gnome/desktop/interface/monospace-font-name 'Noto Sans Mono Medium 11'" + ]; + + input = { + kb_layout = "us"; + kb_variant = ""; + kb_model = ""; + kb_options = ""; + kb_rules = ""; + + follow_mouse = true; + + touchpad = { + natural_scroll = true; + }; + + natural_scroll = true; + sensitivity = -1.0; + }; + + general = { + gaps_in = 8; + gaps_out = 10; + border_size = 4; + "col.active_border" = "rgba(6e848cee) rgba(ffffffee) 45deg"; + "col.inactive_border" = "rgba(595959aa)"; + layout = "dwindle"; + allow_tearing = true; + }; + + decoration = { + rounding = 10; + blur = { + enabled = true; + size = 6; + passes = 2; + noise = 0.01; + contrast = 0.8; + brightness = 0.5; + vibrancy = 0.25; + vibrancy_darkness = 0.1; + }; + shadow = { + enabled = false; + range = 4; + render_power = 3; + color = "rgba(1a1a1aee)"; + }; + dim_inactive = false; + }; + + animations = { + enabled = true; + animation = [ + "windowsIn, 1, 1, default, popin 90%" + "windowsOut, 1, 100, default, popin 80%" + "windowsMove, 1, 3, default" + "border, 1, 10, default" + "borderangle, 1, 8, default" + "fade, 1, 7, default" + "workspaces, 1, 5, default, slidefade 10%" + ]; + }; + + dwindle = { + pseudotile = true; + preserve_split = true; + }; + + misc = { + force_default_wallpaper = false; + disable_hyprland_logo = false; + }; + + windowrulev2 = [ + "animation windowsIn 0,title:^(.*wofi.*)$" + "float,title:^(.*feh.*)$" + "center,title:^(.*feh.*)$" + "float,title:^(Picture.*)$" + "pin,title:^(Picture.*)$" + "immediate, class:^(Terraria)$" + ]; + + workspace = [ + "1, monitor:DP-2, default:true" + "r[2-9], monitor:DP-2" + "name:sub, monitor:DP-1, default:true" + ]; + + "$menu" = "uwsm app -- $(tofi-drun)"; + "$terminal" = "kitty"; + "$lock" = "hyprlock"; + bindm = [ + # Window Movement & Resizing + "SUPER, mouse:272, movewindow" + "SUPER, mouse:273, resizewindow" + ]; + bind = + [ + # basic + "SUPER, return, exec, $menu" + "SUPER, E, exec, $terminal" + "SUPER, Q, killactive," + "SUPER, L, exec, $lock" + "SUPER_SHIFT, M, exec, uwsm stop" + + # prsc + ", Print, exec, hyprshot -m window -m active --clipboard-only" + + # Clipboard + "SUPER, C, exec, copyq show" + "SUPER, V, exec, clipman pick -t dmenu" + + # Window navigation + "SUPER, F, fullscreen," + "SUPER, Y, pin" + "SUPER, I, togglefloating," + "SUPER, O, togglesplit," # dwindle + "SUPER, P, pseudo," # dwindle + + # Window focus + "SUPER, mouse_down, cyclenext, next" + "SUPER, mouse_up, cyclenext, prev" + + "SUPER, left, movefocus, l" + "SUPER, right, movefocus, r" + "SUPER, up, movefocus, u" + "SUPER, down, movefocus, d" + + "SUPER_SHIFT, left, movewindow, l" + "SUPER_SHIFT, right, movewindow, r" + "SUPER_SHIFT, up, movewindow, u" + "SUPER_SHIFT, down, movewindow, d" + + # workspaces + "SUPER, 1, workspace, 1" + "SUPER, 2, workspace, 2" + "SUPER, 3, workspace, 3" + + "SUPER_CTRL, left, workspace, m-1" + "SUPER_CTRL, right, workspace, m+1" + "SUPER_CTRL_SHIFT, left, workspace, r-1" + "SUPER_CTRL_SHIFT, right, workspace, r+1" + ] + ++ ( + # workspaces + # binds $mod + [shift +] {1..9} to [move to] workspace {1..9} + builtins.concatLists ( + builtins.genList ( + i: + let + ws = i + 1; + in + [ + "SUPER, code:1${toString i}, workspace, ${toString ws}" + "SUPER SHIFT, code:1${toString i}, movetoworkspace, ${toString ws}" + ] + ) 9 + ) + ); + }; + }; + home.sessionVariables = { + # HYPRCURSOR_THEME = "rose-pine-cursor-hyprcursor"; + # HYPRCURSOR_SIZE = "24"; + # XCURSOR_SIZE = "24"; + # GTK_BACKEND = "wayland"; + # QT_QPA_PLATFORM = "wayland;xcb"; + # QT_QPA_PLATFORMTHEME = "qt5ct"; + # XDG_SESSION_TYPE = "wayland"; + # XDG_CURRENT_DESKTOP = "Hyprland"; + # XDG_SESSION_DESKTOP = "Hyprland"; + }; +} diff --git a/home-manager/tofi.nix b/home-manager/tofi.nix new file mode 100644 index 0000000..2876f5f --- /dev/null +++ b/home-manager/tofi.nix @@ -0,0 +1,35 @@ +{ + programs.tofi.enable = true; + programs.tofi.settings = { + history = true; + text-cursor = true; + text-cursor-style = "underscore"; + text-cursor-corner-radius = 0; + auto-accept-single = true; + + font = "monospace"; + text-color = "#C8C093"; + prompt-text = "ᐢ˙꒳˙ᐢ <"; + prompt-padding = 20; + prompt-color = "#C8C093"; + placeholder-text = "Hello, World!"; + placeholder-color = "#49443C"; + selection-color = "#76946A"; + selection-match-color = "#98BB6C"; + num-results = 0; + + width = 1280; + height = 720; + result-spacing = 8; + background-color = "#1F1F28"; + outline-width = 0; + outline-color = "#000000"; + border-width = 6; + border-color = "#727169"; + corner-radius = 50; + padding-top = 20; + padding-bottom = 20; + padding-left = 100; + padding-right = 100; + }; +} diff --git a/hosts/default.nix b/hosts/default.nix new file mode 100644 index 0000000..66064b0 --- /dev/null +++ b/hosts/default.nix @@ -0,0 +1,75 @@ +inputs: +let + mkHost = + { + system, + hostname, + username, + systemModules, + homeModule, + }: + { + nixos = inputs.nixpkgs.lib.nixosSystem { + modules = + with inputs; + systemModules + ++ [ + { + users.users.${username} = { + isNormalUser = true; + description = ""; + extraGroups = [ + "networkmanager" + "wheel" + ]; + }; + programs.git.enable = true; + } + ]; + inherit system; + specialArgs = { + inherit inputs hostname username; + }; + }; + home-manager = inputs.home-manager.lib.homeManagerConfiguration { + pkgs = import inputs.nixpkgs { + inherit system; + config.allowUnfree = true; + }; + extraSpecialArgs = { + inherit inputs hostname username; + }; + modules = homeModule ++ [ + { + home = { + inherit username; + homeDirectory = "/home/${username}"; + stateVersion = "24.11"; + }; + programs.home-manager.enable = true; + } + ]; + }; + }; +in +rec { + hosts = { + myNixOS = mkHost { + system = "x86_64-linux"; + hostname = "myNixOS"; + username = "hare"; + systemModules = [ + ./myNixOS/nixos.nix + ]; + homeModule = [ + ./myNixOS/home-manager.nix + ]; + }; + }; + nixos = { + myNixOS = hosts.myNixOS.nixos; + }; + home-manager = { + myNixOS = hosts.myNixOS.home-manager; + }; +} diff --git a/programs/desktop/hyprland.nix b/programs/desktop/hyprland.nix new file mode 100644 index 0000000..0e8eb57 --- /dev/null +++ b/programs/desktop/hyprland.nix @@ -0,0 +1,19 @@ +{ pkgs, ... }: +{ + programs = { + hyprland = { + enable = true; + xwayland.enable = true; + withUWSM = true; + }; + hyprlock.enable = true; + + regreet.enable = true; + }; + services.hypridle.enable = true; + + environment.systemPackages = with pkgs; [ + swww + eww + ]; +} diff --git a/programs/docker.nix b/programs/docker.nix new file mode 100644 index 0000000..a878015 --- /dev/null +++ b/programs/docker.nix @@ -0,0 +1,3 @@ +{ + virtualisation.docker.enable = true; +} diff --git a/programs/fcitx.nix b/programs/fcitx.nix new file mode 100644 index 0000000..948081e --- /dev/null +++ b/programs/fcitx.nix @@ -0,0 +1,11 @@ +{ pkgs, ... }: +{ + i18n.inputMethod = { + type = "fcitx5"; + enable = true; + fcitx5.addons = with pkgs; [ + fcitx5-mozc + fcitx5-gtk + ]; + }; +} diff --git a/programs/shell.nix b/programs/shell.nix new file mode 100644 index 0000000..699a587 --- /dev/null +++ b/programs/shell.nix @@ -0,0 +1,24 @@ +{ pkgs, ... }: +{ + programs = { + fish.enable = true; + git.enable = true; + neovim = { + enable = true; + defaultEditor = true; + viAlias = true; + vimAlias = true; + }; + }; + + environment.systemPackages = with pkgs; [ + bc + jq + socat + acpi + btrfs-progs + duf + lsof + pciutils + ]; +} \ No newline at end of file diff --git a/programs/ssh.nix b/programs/ssh.nix new file mode 100644 index 0000000..d7b07d3 --- /dev/null +++ b/programs/ssh.nix @@ -0,0 +1,24 @@ +{ + services.openssh = { + enable = true; + ports = [ 22 ]; + settings = { + PasswordAuthentication = false; + AllowUsers = [ "hare" ]; + UseDns = true; + X11Forwarding = false; + PermitRootLogin = "prohibit-password"; + }; + hostKeys = [ + { + bits = 4096; + path = "/etc/ssh/ssh_host_rsa_key"; + type = "rsa"; + } + { + path = "/etc/ssh/ssh_host_ed25519_key"; + type = "ed25519"; + } + ]; + }; +} diff --git a/programs/utility.nix b/programs/utility.nix new file mode 100644 index 0000000..785e53f --- /dev/null +++ b/programs/utility.nix @@ -0,0 +1,14 @@ +{ pkgs, ... }: +{ + environment.systemPackages = with pkgs; [ + zip + unzip + ripgrep + btop + bat + + neovim + wezterm + kitty + nixfmt-rfc-style + ];} \ No newline at end of file diff --git a/programs/v4l2.nix b/programs/v4l2.nix new file mode 100644 index 0000000..735d139 --- /dev/null +++ b/programs/v4l2.nix @@ -0,0 +1,7 @@ +{ pkgs, ... }: +{ + environment.systemPackages = with pkgs; [ + v4l-utils + ffmpeg + ]; +} diff --git a/programs/vscode-server.nix b/programs/vscode-server.nix new file mode 100644 index 0000000..7b05691 --- /dev/null +++ b/programs/vscode-server.nix @@ -0,0 +1,16 @@ +{ pkgs, ... }: +{ + imports = [ + (fetchTarball { + url = "https://github.com/msteen/nixos-vscode-server/tarball/master"; + sha256 = "09j4kvsxw1d5dvnhbsgih0icbrxqv90nzf0b589rb5z6gnzwjnqf"; + }) + ]; + environment.systemPackages = with pkgs; [ + code-server + ]; + + services.vscode-server.enable = true; + services.vscode-server.enableFHS = true; + services.vscode-server.nodejsPackage = pkgs.nodejs_22; +} diff --git a/system/core/boot.nix b/system/core/boot.nix new file mode 100644 index 0000000..0682ce5 --- /dev/null +++ b/system/core/boot.nix @@ -0,0 +1,6 @@ +{ pkgs, ... }: +{ + boot = { + supportedFilesystems = [ "ext4" "btrfs" "xfs" "vfat" "ntfs" ]; + }; +} diff --git a/system/core/default.nix b/system/core/default.nix new file mode 100644 index 0000000..e7a517a --- /dev/null +++ b/system/core/default.nix @@ -0,0 +1,11 @@ +{ + imports = [ + ./nix.nix + ./boot.nix + ./uwsm.nix + ./locale.nix + ./network.nix + ./fonts.nix + ./sound.nix + ]; +} \ No newline at end of file diff --git a/system/core/fonts.nix b/system/core/fonts.nix new file mode 100644 index 0000000..5fc22be --- /dev/null +++ b/system/core/fonts.nix @@ -0,0 +1,18 @@ +{ pkgs, ... }: +{ + fonts = { + packages = with pkgs; [ + noto-fonts + noto-fonts-cjk-sans + noto-fonts-emoji + ibm-plex + ]; + fontconfig = { + defaultFonts = { + serif = [ "Noto Serif" ]; + sansSerif = [ "Noto Sans" ]; + monospace = [ "IBM Plex Mono" ]; + }; + }; + }; +} diff --git a/system/core/locale.nix b/system/core/locale.nix new file mode 100644 index 0000000..cf41040 --- /dev/null +++ b/system/core/locale.nix @@ -0,0 +1,5 @@ +{ + time.timeZone = "Asia/Tokyo"; + i18n.defaultLocale = "en_US.UTF-8"; + time.hardwareClockInLocalTime = true; +} diff --git a/system/core/network.nix b/system/core/network.nix new file mode 100644 index 0000000..6e44501 --- /dev/null +++ b/system/core/network.nix @@ -0,0 +1,13 @@ +{ config, hostname, ... }: +{ + networking = { + hostName = hostname; + networkmanager.enable = true; + firewall = { + enable = true; + }; + }; + + # nixpkgs issue#180175 + systemd.services.NetworkManager-wait-online.enable = false; +} diff --git a/system/core/nix.nix b/system/core/nix.nix new file mode 100644 index 0000000..f2c4730 --- /dev/null +++ b/system/core/nix.nix @@ -0,0 +1,17 @@ +{ + nix = { + settings = { + experimental-features = [ + "nix-command" + "flakes" + ]; + }; + gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 7d"; + }; + }; + + nixpkgs.config.allowUnfree = true; +} diff --git a/system/core/sound.nix b/system/core/sound.nix new file mode 100644 index 0000000..e372d47 --- /dev/null +++ b/system/core/sound.nix @@ -0,0 +1,9 @@ +{ + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; +} diff --git a/system/core/uwsm.nix b/system/core/uwsm.nix new file mode 100644 index 0000000..3bf9939 --- /dev/null +++ b/system/core/uwsm.nix @@ -0,0 +1,12 @@ +{ + programs.uwsm = { + enable = true; + waylandCompositors = { + hyprland = { + prettyName = "Hyprland"; + comment = "Hyprland compositor managed by UWSM"; + binPath = "/run/current-system/sw/bin/Hyprland"; + }; + }; + }; +}