From f6acb92ad0ad6a7e4dd1f0c55ce91a79c0e88510 Mon Sep 17 00:00:00 2001 From: DACHXY Date: Wed, 9 Apr 2025 13:24:02 +0800 Subject: [PATCH] refactor: modulization --- flake.lock | 17 - flake.nix | 258 +++++-- home/config/electron/electron-flags.conf | 3 - home/config/kitty/kitty.conf | 10 - home/config/kitty/macchiato.conf | 80 -- home/config/nushell/config.nu | 919 ----------------------- home/config/nushell/env.nu | 101 --- home/default.nix | 16 - home/presets/basic.nix | 23 + home/server-default.nix | 32 - home/user/config.nix | 6 - home/user/default.nix | 31 - home/user/direnv.nix | 4 - home/user/{programs.nix => firefox.nix} | 25 +- home/user/git.nix | 10 +- home/user/gtk.nix | 7 +- home/user/hypr/exec.nix | 2 +- home/user/hyprland.nix | 19 +- home/user/nvim.nix | 32 +- home/user/packages.nix | 77 +- home/user/shell.nix | 17 +- home/user/shellAlias.nix | 6 +- home/user/{bin.nix => tmux.nix} | 0 home/user/virtualization.nix | 3 +- home/user/vscode.nix | 9 + home/user/yazi.nix | 27 + pkgs/overlays/default.nix | 7 + pkgs/overlays/ferium.nix | 20 + pkgs/overlays/vesktop.nix | 37 + system/dev/dn-lap/default.nix | 50 +- system/dev/dn-pre7780/default.nix | 81 +- system/dev/dn-server/default.nix | 102 +-- system/dev/dn-server/packages.nix | 83 -- system/dev/dn-server/services.nix | 5 - system/modules/auto-mount.nix | 16 + system/modules/bluetooth.nix | 25 + system/modules/default.nix | 28 - system/modules/display-manager.nix | 12 + system/modules/dn-ca.nix | 20 - system/modules/flatpak.nix | 14 + system/modules/gaming.nix | 32 +- system/modules/gc.nix | 14 +- system/modules/hardware.nix | 28 - system/modules/hyprland.nix | 7 - system/modules/lsp.nix | 29 - system/modules/networking.nix | 10 - system/modules/nixsettings.nix | 15 +- system/modules/nvidia.nix | 2 +- system/modules/obs-studio.nix | 14 + system/modules/packages.nix | 69 +- system/modules/presets/basic.nix | 29 + system/modules/presets/minimal.nix | 18 + system/modules/programs.nix | 10 + system/modules/secure-boot.nix | 10 +- system/modules/security.nix | 19 +- system/modules/server-default.nix | 19 - system/modules/services.nix | 31 +- system/modules/sound.nix | 24 +- system/modules/theme.nix | 9 - system/modules/tmux.nix | 4 +- system/modules/users.nix | 4 +- system/modules/virtualization.nix | 4 +- system/modules/wallpaper-engine.nix | 4 +- 63 files changed, 680 insertions(+), 1959 deletions(-) delete mode 100644 home/config/electron/electron-flags.conf delete mode 100755 home/config/kitty/kitty.conf delete mode 100755 home/config/kitty/macchiato.conf delete mode 100755 home/config/nushell/config.nu delete mode 100755 home/config/nushell/env.nu delete mode 100644 home/default.nix create mode 100644 home/presets/basic.nix delete mode 100644 home/server-default.nix delete mode 100644 home/user/default.nix rename home/user/{programs.nix => firefox.nix} (71%) rename home/user/{bin.nix => tmux.nix} (100%) create mode 100644 home/user/vscode.nix create mode 100644 home/user/yazi.nix create mode 100644 pkgs/overlays/default.nix create mode 100644 pkgs/overlays/ferium.nix create mode 100644 pkgs/overlays/vesktop.nix delete mode 100644 system/dev/dn-server/packages.nix create mode 100644 system/modules/auto-mount.nix create mode 100644 system/modules/bluetooth.nix delete mode 100644 system/modules/default.nix delete mode 100644 system/modules/dn-ca.nix create mode 100644 system/modules/flatpak.nix delete mode 100644 system/modules/lsp.nix create mode 100644 system/modules/obs-studio.nix create mode 100644 system/modules/presets/basic.nix create mode 100644 system/modules/presets/minimal.nix delete mode 100644 system/modules/server-default.nix delete mode 100644 system/modules/theme.nix diff --git a/flake.lock b/flake.lock index 83c0dae..675ce07 100644 --- a/flake.lock +++ b/flake.lock @@ -1057,22 +1057,6 @@ "type": "github" } }, - "nixpkgs-unstable_2": { - "locked": { - "lastModified": 1743095683, - "narHash": "sha256-gWd4urRoLRe8GLVC/3rYRae1h+xfQzt09xOfb0PaHSk=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "5e5402ecbcb27af32284d4a62553c019a3a49ea6", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "nixpkgs_2": { "locked": { "lastModified": 1743076231, @@ -1203,7 +1187,6 @@ "nix-index-database": "nix-index-database", "nix-minecraft": "nix-minecraft", "nixpkgs": "nixpkgs_4", - "nixpkgs-unstable": "nixpkgs-unstable_2", "yazi": "yazi" } }, diff --git a/flake.nix b/flake.nix index d88f0d3..bf2e4fe 100644 --- a/flake.nix +++ b/flake.nix @@ -6,20 +6,20 @@ url = "github:nixos/nixpkgs/nixos-unstable"; }; - nixpkgs-unstable = { - url = "github:nixos/nixpkgs/nixos-unstable"; - }; - firefox = { url = "github:nix-community/flake-firefox-nightly"; inputs.nixpkgs.follows = "nixpkgs"; }; - home-manager.url = "github:nix-community/home-manager"; - home-manager.inputs.nixpkgs.follows = "nixpkgs"; + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + }; - nix-index-database.url = "github:nix-community/nix-index-database"; - nix-index-database.inputs.nixpkgs.follows = "nixpkgs"; + nix-index-database = { + url = "github:nix-community/nix-index-database"; + inputs.nixpkgs.follows = "nixpkgs"; + }; ghostty = { url = "github:ghostty-org/ghostty"; @@ -70,105 +70,201 @@ }; }; - nixConfig = { - - }; - outputs = { nixpkgs, - nixpkgs-unstable, nix-index-database, lanzaboote, - disko, + home-manager, ... }@inputs: let system = "x86_64-linux"; - # pkgs = import nixpkgs { - # system = "x86_64-linux"; - # config.allowUnfree = true; - # }; nix-version = "25.05"; - username = "danny"; - git-config = { - username = "DACHXY"; - email = "danny10132024@gmail.com"; + + # Declare COMMON modules here + common-settings = { + modules = [ + home-manager.nixosModules.default + nix-index-database.nixosModules.nix-index + ]; + args = { + inherit + inputs + system + nix-version + ; + }; }; - unstable = import nixpkgs-unstable { inherit system; }; - in - { - nixosConfigurations = { - dn-pre7780 = nixpkgs.lib.nixosSystem { - modules = [ - nix-index-database.nixosModules.nix-index + + devices = { + dn-pre7780 = { + settings = { + personal = { + hostname = "dn-pre7780"; + username = "danny"; + git = { + username = "DACHXY"; + email = "Danny10132024@gmail.com"; + }; + }; + + hyprland = { + # Can leave monitors empty if only has one monitors + # This is for assign workspace to a specific monitor + # e.g. 1, 3, 5 for "DP-3"; 2, 4, 6 for "HDMI-A-2" + monitors = [ + "DP-3" + "HDMI-A-2" + ]; + cursor-size = 32; + xcursor-size = 24; + }; + + # Optional + nvidia = { + # Choose from offload, sync, rsync + mode = "offload"; + + # Only needed when using GPU hybrid mode + intel-bus-id = "PCI:0:2:0"; + nvidia-bus-id = "PCI:1:0:0"; + }; + }; + extra-modules = [ lanzaboote.nixosModules.lanzaboote ./system/dev/dn-pre7780 ]; - specialArgs = { - inherit - unstable - inputs - system - nix-version - username - git-config - ; - }; + overlays = [ + + ]; }; - dn-lap = nixpkgs.lib.nixosSystem { - modules = [ - nix-index-database.nixosModules.nix-index + dn-lap = { + settings = { + personal = { + hostname = "dn-lap"; + username = "danny"; + git = { + username = "DACHXY"; + email = "Danny10132024@gmail.com"; + }; + }; + + hyprland = { + # Can leave monitors empty if only has one monitors + # This is for assign workspace to a specific monitor + # e.g. 1, 3, 5 for "DP-3"; 2, 4, 6 for "HDMI-A-2" + monitors = [ ]; + cursor-size = 32; + xcursor-size = 24; + }; + }; + extra-modules = [ lanzaboote.nixosModules.lanzaboote ./system/dev/dn-lap ]; - specialArgs = { - inherit - unstable - inputs - system - nix-version - username - git-config - ; - }; + overlays = [ + + ]; }; - dn-server = nixpkgs.lib.nixosSystem { - modules = [ - disko.nixosModules.disko - nix-index-database.nixosModules.nix-index + dn-server = { + settings = { + personal = { + hostname = "dn-server"; + username = "danny"; + git = { + username = "DACHXY"; + email = "Danny10132024@gmail.com"; + }; + }; + + hyprland = { + # Can leave monitors empty if only has one monitors + # This is for assign workspace to a specific monitor + # e.g. 1, 3, 5 for "DP-3"; 2, 4, 6 for "HDMI-A-2" + monitors = [ ]; + cursor-size = 32; + xcursor-size = 24; + }; + + # Optional + nvidia = { + # Choose from offload, sync, rsync + mode = "offload"; + + # Only needed when using GPU hybrid mode + intel-bus-id = "PCI:0:2:0"; + nvidia-bus-id = "PCI:1:0:0"; + }; + }; + extra-modules = [ inputs.nix-minecraft.nixosModules.minecraft-servers - lanzaboote.nixosModules.lanzaboote ./system/dev/dn-server ]; - specialArgs = { - inherit - unstable - inputs - system - nix-version - username - git-config - ; - }; - }; - - # Use this for all other target - # nixos-anywhere --flake .#generic --generate-hardware-config nixos-generate-config ./hardware-configuration.nix - generic = nixpkgs.lib.nixosSystem { - inherit system; - - modules = [ - disko.nixosModules.disko - ./system/dev/generic - ./hardware-configuration.nix + overlays = [ + inputs.nix-minecraft.overlay ]; - specialArgs = { - inherit nix-version; - }; }; }; + in + { + nixosConfigurations = builtins.mapAttrs ( + dev: conf: + let + settings = conf.settings; + username = settings.personal.username; + hostname = settings.personal.hostname; + in + nixpkgs.lib.nixosSystem { + modules = + [ + ( + { config, ... }: + { + system.stateVersion = nix-version; + home-manager = { + backupFileExtension = "backup"; + useUserPackages = true; + useGlobalPkgs = true; + extraSpecialArgs = { + inherit + inputs + system + nix-version + settings + ; + }; + users."${username}" = { + imports = [ + inputs.hyprland.homeManagerModules.default + { + home = { + homeDirectory = "/home/${username}"; + stateVersion = nix-version; + }; + # Let Home Manager install and manage itself. + programs.home-manager.enable = true; + } + ]; + }; + }; + networking.hostName = hostname; + nixpkgs.hostPlatform = system; + nixpkgs.config.allowUnfree = true; + nixpkgs.overlays = [ + (import ./pkgs/overlays { inherit config; }) + ] ++ conf.overlays; + } + ) + ] + ++ common-settings.modules + ++ conf.extra-modules; + specialArgs = { + inherit settings; + } // common-settings.args; + } + ) devices; }; } diff --git a/home/config/electron/electron-flags.conf b/home/config/electron/electron-flags.conf deleted file mode 100644 index e8bbd0b..0000000 --- a/home/config/electron/electron-flags.conf +++ /dev/null @@ -1,3 +0,0 @@ ---enable-features=UseOzonePlatform ---enable-features=WaylandWindowDecorations ---ozone-platform-hint=auto diff --git a/home/config/kitty/kitty.conf b/home/config/kitty/kitty.conf deleted file mode 100755 index df700aa..0000000 --- a/home/config/kitty/kitty.conf +++ /dev/null @@ -1,10 +0,0 @@ -include ~/.config/kitty/macchiato.conf -font_family CaskaydiaCove Nerd Font Mono -font_size 16 -bold_font auto -italic_font auto -bold_italic_font auto -mouse_hide_wait 2.0 -cursor_shape block -confirm_os_window_close 0 -background_opacity 1 diff --git a/home/config/kitty/macchiato.conf b/home/config/kitty/macchiato.conf deleted file mode 100755 index d50dbe6..0000000 --- a/home/config/kitty/macchiato.conf +++ /dev/null @@ -1,80 +0,0 @@ -# vim:ft=kitty - -## name: Catppuccin Kitty Macchiato -## author: Catppuccin Org -## license: MIT -## upstream: https://github.com/catppuccin/kitty/blob/main/themes/macchiato.conf -## blurb: Soothing pastel theme for the high-spirited! - - - -# The basic colors -foreground #CAD3F5 -background #24273A -selection_foreground #24273A -selection_background #F4DBD6 - -# Cursor colors -cursor #F4DBD6 -cursor_text_color #24273A - -# URL underline color when hovering with mouse -url_color #F4DBD6 - -# Kitty window border colors -active_border_color #B7BDF8 -inactive_border_color #6E738D -bell_border_color #EED49F - -# OS Window titlebar colors -wayland_titlebar_color #24273A -macos_titlebar_color #24273A - -# Tab bar colors -active_tab_foreground #181926 -active_tab_background #C6A0F6 -inactive_tab_foreground #CAD3F5 -inactive_tab_background #1E2030 -tab_bar_background #181926 - -# Colors for marks (marked text in the terminal) -mark1_foreground #24273A -mark1_background #B7BDF8 -mark2_foreground #24273A -mark2_background #C6A0F6 -mark3_foreground #24273A -mark3_background #7DC4E4 - -# The 16 terminal colors - -# black -color0 #494D64 -color8 #5B6078 - -# red -color1 #ED8796 -color9 #ED8796 - -# green -color2 #A6DA95 -color10 #A6DA95 - -# yellow -color3 #EED49F -color11 #EED49F - -# blue -color4 #8AADF4 -color12 #8AADF4 - -# magenta -color5 #F5BDE6 -color13 #F5BDE6 - -# cyan -color6 #8BD5CA -color14 #8BD5CA - -# white -color7 #B8C0E0 -color15 #A5ADCB diff --git a/home/config/nushell/config.nu b/home/config/nushell/config.nu deleted file mode 100755 index 5d6fc07..0000000 --- a/home/config/nushell/config.nu +++ /dev/null @@ -1,919 +0,0 @@ -# Nushell Config File -# -# version = "0.100.0" - -# For more information on defining custom themes, see -# https://www.nushell.sh/book/coloring_and_theming.html -# And here is the theme collection -# https://github.com/nushell/nu_scripts/tree/main/themes -let dark_theme = { - # color for nushell primitives - separator: white - leading_trailing_space_bg: { attr: n } # no fg, no bg, attr none effectively turns this off - header: green_bold - empty: blue - # Closures can be used to choose colors for specific values. - # The value (in this case, a bool) is piped into the closure. - # eg) {|| if $in { 'light_cyan' } else { 'light_gray' } } - bool: light_cyan - int: white - filesize: cyan - duration: white - date: purple - range: white - float: white - string: white - nothing: white - binary: white - cell-path: white - row_index: green_bold - record: white - list: white - block: white - hints: dark_gray - search_result: { bg: red fg: white } - shape_and: purple_bold - shape_binary: purple_bold - shape_block: blue_bold - shape_bool: light_cyan - shape_closure: green_bold - shape_custom: green - shape_datetime: cyan_bold - shape_directory: cyan - shape_external: cyan - shape_externalarg: green_bold - shape_external_resolved: light_yellow_bold - shape_filepath: cyan - shape_flag: blue_bold - shape_float: purple_bold - # shapes are used to change the cli syntax highlighting - shape_garbage: { fg: white bg: red attr: b } - shape_glob_interpolation: cyan_bold - shape_globpattern: cyan_bold - shape_int: purple_bold - shape_internalcall: cyan_bold - shape_keyword: cyan_bold - shape_list: cyan_bold - shape_literal: blue - shape_match_pattern: green - shape_matching_brackets: { attr: u } - shape_nothing: light_cyan - shape_operator: yellow - shape_or: purple_bold - shape_pipe: purple_bold - shape_range: yellow_bold - shape_record: cyan_bold - shape_redirection: purple_bold - shape_signature: green_bold - shape_string: green - shape_string_interpolation: cyan_bold - shape_table: blue_bold - shape_variable: purple - shape_vardecl: purple - shape_raw_string: light_purple -} - -let light_theme = { - # color for nushell primitives - separator: dark_gray - leading_trailing_space_bg: { attr: n } # no fg, no bg, attr none effectively turns this off - header: green_bold - empty: blue - # Closures can be used to choose colors for specific values. - # The value (in this case, a bool) is piped into the closure. - # eg) {|| if $in { 'dark_cyan' } else { 'dark_gray' } } - bool: dark_cyan - int: dark_gray - filesize: cyan_bold - duration: dark_gray - date: purple - range: dark_gray - float: dark_gray - string: dark_gray - nothing: dark_gray - binary: dark_gray - cell-path: dark_gray - row_index: green_bold - record: dark_gray - list: dark_gray - block: dark_gray - hints: dark_gray - search_result: { fg: white bg: red } - shape_and: purple_bold - shape_binary: purple_bold - shape_block: blue_bold - shape_bool: light_cyan - shape_closure: green_bold - shape_custom: green - shape_datetime: cyan_bold - shape_directory: cyan - shape_external: cyan - shape_externalarg: green_bold - shape_external_resolved: light_purple_bold - shape_filepath: cyan - shape_flag: blue_bold - shape_float: purple_bold - # shapes are used to change the cli syntax highlighting - shape_garbage: { fg: white bg: red attr: b } - shape_glob_interpolation: cyan_bold - shape_globpattern: cyan_bold - shape_int: purple_bold - shape_internalcall: cyan_bold - shape_keyword: cyan_bold - shape_list: cyan_bold - shape_literal: blue - shape_match_pattern: green - shape_matching_brackets: { attr: u } - shape_nothing: light_cyan - shape_operator: yellow - shape_or: purple_bold - shape_pipe: purple_bold - shape_range: yellow_bold - shape_record: cyan_bold - shape_redirection: purple_bold - shape_signature: green_bold - shape_string: green - shape_string_interpolation: cyan_bold - shape_table: blue_bold - shape_variable: purple - shape_vardecl: purple - shape_raw_string: light_purple -} - -# External completer example -# let carapace_completer = {|spans| -# carapace $spans.0 nushell ...$spans | from json -# } - -# The default config record. This is where much of your global configuration is setup. -$env.config = { - show_banner: false # true or false to enable or disable the welcome banner at startup - - ls: { - use_ls_colors: true # use the LS_COLORS environment variable to colorize output - clickable_links: true # enable or disable clickable links. Your terminal has to support links. - } - - rm: { - always_trash: false # always act as if -t was given. Can be overridden with -p - } - - table: { - mode: rounded # basic, compact, compact_double, light, thin, with_love, rounded, reinforced, heavy, none, other - index_mode: always # "always" show indexes, "never" show indexes, "auto" = show indexes when a table has "index" column - show_empty: true # show 'empty list' and 'empty record' placeholders for command output - padding: { left: 1, right: 1 } # a left right padding of each column in a table - trim: { - methodology: wrapping # wrapping or truncating - wrapping_try_keep_words: true # A strategy used by the 'wrapping' methodology - truncating_suffix: "..." # A suffix used by the 'truncating' methodology - } - header_on_separator: false # show header text on separator/border line - footer_inheritance: false # render footer in parent table if child is big enough (extended table option) - # abbreviated_row_count: 10 # limit data rows from top and bottom after reaching a set point - } - - error_style: "fancy" # "fancy" or "plain" for screen reader-friendly error messages - - # Whether an error message should be printed if an error of a certain kind is triggered. - display_errors: { - exit_code: false # assume the external command prints an error message - # Core dump errors are always printed, and SIGPIPE never triggers an error. - # The setting below controls message printing for termination by all other signals. - termination_signal: true - } - - # datetime_format determines what a datetime rendered in the shell would look like. - # Behavior without this configuration point will be to "humanize" the datetime display, - # showing something like "a day ago." - datetime_format: { - # normal: '%a, %d %b %Y %H:%M:%S %z' # shows up in displays of variables or other datetime's outside of tables - # table: '%m/%d/%y %I:%M:%S%p' # generally shows up in tabular outputs such as ls. commenting this out will change it to the default human readable datetime format - } - - explore: { - status_bar_background: { fg: "#1D1F21", bg: "#C4C9C6" }, - command_bar_text: { fg: "#C4C9C6" }, - highlight: { fg: "black", bg: "yellow" }, - status: { - error: { fg: "white", bg: "red" }, - warn: {} - info: {} - }, - selected_cell: { bg: light_blue }, - } - - history: { - max_size: 100_000 # Session has to be reloaded for this to take effect - sync_on_enter: true # Enable to share history between multiple sessions, else you have to close the session to write history to file - file_format: "plaintext" # "sqlite" or "plaintext" - isolation: false # only available with sqlite file_format. true enables history isolation, false disables it. true will allow the history to be isolated to the current session using up/down arrows. false will allow the history to be shared across all sessions. - } - - completions: { - case_sensitive: false # set to true to enable case-sensitive completions - quick: true # set this to false to prevent auto-selecting completions when only one remains - partial: true # set this to false to prevent partial filling of the prompt - algorithm: "prefix" # prefix or fuzzy - sort: "smart" # "smart" (alphabetical for prefix matching, fuzzy score for fuzzy matching) or "alphabetical" - external: { - enable: true # set to false to prevent nushell looking into $env.PATH to find more suggestions, `false` recommended for WSL users as this look up may be very slow - max_results: 100 # setting it lower can improve completion performance at the cost of omitting some options - completer: null # check 'carapace_completer' above as an example - } - use_ls_colors: true # set this to true to enable file/path/directory completions using LS_COLORS - } - - filesize: { - metric: false # true => KB, MB, GB (ISO standard), false => KiB, MiB, GiB (Windows standard) - format: "auto" # b, kb, kib, mb, mib, gb, gib, tb, tib, pb, pib, eb, eib, auto - } - - cursor_shape: { - emacs: line # block, underscore, line, blink_block, blink_underscore, blink_line, inherit to skip setting cursor shape (line is the default) - vi_insert: block # block, underscore, line, blink_block, blink_underscore, blink_line, inherit to skip setting cursor shape (block is the default) - vi_normal: underscore # block, underscore, line, blink_block, blink_underscore, blink_line, inherit to skip setting cursor shape (underscore is the default) - } - - color_config: $dark_theme # if you want a more interesting theme, you can replace the empty record with `$dark_theme`, `$light_theme` or another custom record - footer_mode: 25 # always, never, number_of_rows, auto - float_precision: 2 # the precision for displaying floats in tables - buffer_editor: null # command that will be used to edit the current line buffer with ctrl+o, if unset fallback to $env.VISUAL and $env.EDITOR - use_ansi_coloring: true - bracketed_paste: true # enable bracketed paste, currently useless on windows - edit_mode: emacs # emacs, vi - shell_integration: { - # osc2 abbreviates the path if in the home_dir, sets the tab/window title, shows the running command in the tab/window title - osc2: true - # osc7 is a way to communicate the path to the terminal, this is helpful for spawning new tabs in the same directory - osc7: true - # osc8 is also implemented as the deprecated setting ls.show_clickable_links, it shows clickable links in ls output if your terminal supports it. show_clickable_links is deprecated in favor of osc8 - osc8: true - # osc9_9 is from ConEmu and is starting to get wider support. It's similar to osc7 in that it communicates the path to the terminal - osc9_9: false - # osc133 is several escapes invented by Final Term which include the supported ones below. - # 133;A - Mark prompt start - # 133;B - Mark prompt end - # 133;C - Mark pre-execution - # 133;D;exit - Mark execution finished with exit code - # This is used to enable terminals to know where the prompt is, the command is, where the command finishes, and where the output of the command is - osc133: true - # osc633 is closely related to osc133 but only exists in visual studio code (vscode) and supports their shell integration features - # 633;A - Mark prompt start - # 633;B - Mark prompt end - # 633;C - Mark pre-execution - # 633;D;exit - Mark execution finished with exit code - # 633;E - Explicitly set the command line with an optional nonce - # 633;P;Cwd= - Mark the current working directory and communicate it to the terminal - # and also helps with the run recent menu in vscode - osc633: true - # reset_application_mode is escape \x1b[?1l and was added to help ssh work better - reset_application_mode: true - } - render_right_prompt_on_last_line: false # true or false to enable or disable right prompt to be rendered on last line of the prompt. - use_kitty_protocol: true # enables keyboard enhancement protocol implemented by kitty console, only if your terminal support this. - highlight_resolved_externals: false # true enables highlighting of external commands in the repl resolved by which. - recursion_limit: 50 # the maximum number of times nushell allows recursion before stopping it - - plugins: {} # Per-plugin configuration. See https://www.nushell.sh/contributor-book/plugins.html#configuration. - - plugin_gc: { - # Configuration for plugin garbage collection - default: { - enabled: true # true to enable stopping of inactive plugins - stop_after: 10sec # how long to wait after a plugin is inactive to stop it - } - plugins: { - # alternate configuration for specific plugins, by name, for example: - # - # gstat: { - # enabled: false - # } - } - } - - hooks: { - pre_prompt: [{ null }] # run before the prompt is shown - pre_execution: [{ null }] # run before the repl input is run - env_change: { - PWD: [{|before, after| null }] # run if the PWD environment is different since the last repl input - } - display_output: "if (term size).columns >= 100 { table -e } else { table }" # run to display the output of a pipeline - command_not_found: { null } # return an error message when a command is not found - } - - menus: [ - # Configuration for default nushell menus - # Note the lack of source parameter - { - name: completion_menu - only_buffer_difference: false - marker: "| " - type: { - layout: columnar - columns: 4 - col_width: 20 # Optional value. If missing all the screen width is used to calculate column width - col_padding: 2 - } - style: { - text: green - selected_text: { attr: r } - description_text: yellow - match_text: { attr: u } - selected_match_text: { attr: ur } - } - } - { - name: ide_completion_menu - only_buffer_difference: false - marker: "| " - type: { - layout: ide - min_completion_width: 0, - max_completion_width: 50, - max_completion_height: 10, # will be limited by the available lines in the terminal - padding: 0, - border: true, - cursor_offset: 0, - description_mode: "prefer_right" - min_description_width: 0 - max_description_width: 50 - max_description_height: 10 - description_offset: 1 - # If true, the cursor pos will be corrected, so the suggestions match up with the typed text - # - # C:\> str - # str join - # str trim - # str split - correct_cursor_pos: false - } - style: { - text: green - selected_text: { attr: r } - description_text: yellow - match_text: { attr: u } - selected_match_text: { attr: ur } - } - } - { - name: history_menu - only_buffer_difference: true - marker: "? " - type: { - layout: list - page_size: 10 - } - style: { - text: green - selected_text: green_reverse - description_text: yellow - } - } - { - name: help_menu - only_buffer_difference: true - marker: "? " - type: { - layout: description - columns: 4 - col_width: 20 # Optional value. If missing all the screen width is used to calculate column width - col_padding: 2 - selection_rows: 4 - description_rows: 10 - } - style: { - text: green - selected_text: green_reverse - description_text: yellow - } - } - ] - - keybindings: [ - { - name: completion_menu - modifier: none - keycode: tab - mode: [emacs vi_normal vi_insert] - event: { - until: [ - { send: menu name: completion_menu } - { send: menunext } - { edit: complete } - ] - } - } - { - name: completion_previous_menu - modifier: shift - keycode: backtab - mode: [emacs, vi_normal, vi_insert] - event: { send: menuprevious } - } - { - name: ide_completion_menu - modifier: control - keycode: space - mode: [emacs vi_normal vi_insert] - event: { - until: [ - { send: menu name: ide_completion_menu } - { send: menunext } - { edit: complete } - ] - } - } - { - name: history_menu - modifier: control - keycode: char_r - mode: [emacs, vi_insert, vi_normal] - event: { send: menu name: history_menu } - } - { - name: help_menu - modifier: none - keycode: f1 - mode: [emacs, vi_insert, vi_normal] - event: { send: menu name: help_menu } - } - { - name: next_page_menu - modifier: control - keycode: char_x - mode: emacs - event: { send: menupagenext } - } - { - name: undo_or_previous_page_menu - modifier: control - keycode: char_z - mode: emacs - event: { - until: [ - { send: menupageprevious } - { edit: undo } - ] - } - } - { - name: escape - modifier: none - keycode: escape - mode: [emacs, vi_normal, vi_insert] - event: { send: esc } # NOTE: does not appear to work - } - { - name: cancel_command - modifier: control - keycode: char_c - mode: [emacs, vi_normal, vi_insert] - event: { send: ctrlc } - } - { - name: quit_shell - modifier: control - keycode: char_d - mode: [emacs, vi_normal, vi_insert] - event: { send: ctrld } - } - { - name: clear_screen - modifier: control - keycode: char_l - mode: [emacs, vi_normal, vi_insert] - event: { send: clearscreen } - } - { - name: search_history - modifier: control - keycode: char_q - mode: [emacs, vi_normal, vi_insert] - event: { send: searchhistory } - } - { - name: open_command_editor - modifier: control - keycode: char_o - mode: [emacs, vi_normal, vi_insert] - event: { send: openeditor } - } - { - name: move_up - modifier: none - keycode: up - mode: [emacs, vi_normal, vi_insert] - event: { - until: [ - { send: menuup } - { send: up } - ] - } - } - { - name: move_down - modifier: none - keycode: down - mode: [emacs, vi_normal, vi_insert] - event: { - until: [ - { send: menudown } - { send: down } - ] - } - } - { - name: move_left - modifier: none - keycode: left - mode: [emacs, vi_normal, vi_insert] - event: { - until: [ - { send: menuleft } - { send: left } - ] - } - } - { - name: move_right_or_take_history_hint - modifier: none - keycode: right - mode: [emacs, vi_normal, vi_insert] - event: { - until: [ - { send: historyhintcomplete } - { send: menuright } - { send: right } - ] - } - } - { - name: move_one_word_left - modifier: control - keycode: left - mode: [emacs, vi_normal, vi_insert] - event: { edit: movewordleft } - } - { - name: move_one_word_right_or_take_history_hint - modifier: control - keycode: right - mode: [emacs, vi_normal, vi_insert] - event: { - until: [ - { send: historyhintwordcomplete } - { edit: movewordright } - ] - } - } - { - name: move_to_line_start - modifier: none - keycode: home - mode: [emacs, vi_normal, vi_insert] - event: { edit: movetolinestart } - } - { - name: move_to_line_start - modifier: control - keycode: char_a - mode: [emacs, vi_normal, vi_insert] - event: { edit: movetolinestart } - } - { - name: move_to_line_end_or_take_history_hint - modifier: none - keycode: end - mode: [emacs, vi_normal, vi_insert] - event: { - until: [ - { send: historyhintcomplete } - { edit: movetolineend } - ] - } - } - { - name: move_to_line_end_or_take_history_hint - modifier: control - keycode: char_e - mode: [emacs, vi_normal, vi_insert] - event: { - until: [ - { send: historyhintcomplete } - { edit: movetolineend } - ] - } - } - { - name: move_to_line_start - modifier: control - keycode: home - mode: [emacs, vi_normal, vi_insert] - event: { edit: movetolinestart } - } - { - name: move_to_line_end - modifier: control - keycode: end - mode: [emacs, vi_normal, vi_insert] - event: { edit: movetolineend } - } - { - name: move_down - modifier: control - keycode: char_n - mode: [emacs, vi_normal, vi_insert] - event: { - until: [ - { send: menudown } - { send: down } - ] - } - } - { - name: move_up - modifier: control - keycode: char_p - mode: [emacs, vi_normal, vi_insert] - event: { - until: [ - { send: menuup } - { send: up } - ] - } - } - { - name: delete_one_character_backward - modifier: none - keycode: backspace - mode: [emacs, vi_insert] - event: { edit: backspace } - } - { - name: delete_one_word_backward - modifier: control - keycode: backspace - mode: [emacs, vi_insert] - event: { edit: backspaceword } - } - { - name: delete_one_character_forward - modifier: none - keycode: delete - mode: [emacs, vi_insert] - event: { edit: delete } - } - { - name: delete_one_character_forward - modifier: control - keycode: delete - mode: [emacs, vi_insert] - event: { edit: delete } - } - { - name: delete_one_character_backward - modifier: control - keycode: char_h - mode: [emacs, vi_insert] - event: { edit: backspace } - } - { - name: delete_one_word_backward - modifier: control - keycode: char_w - mode: [emacs, vi_insert] - event: { edit: backspaceword } - } - { - name: move_left - modifier: none - keycode: backspace - mode: vi_normal - event: { edit: moveleft } - } - { - name: newline_or_run_command - modifier: none - keycode: enter - mode: emacs - event: { send: enter } - } - { - name: move_left - modifier: control - keycode: char_b - mode: emacs - event: { - until: [ - { send: menuleft } - { send: left } - ] - } - } - { - name: move_right_or_take_history_hint - modifier: control - keycode: char_f - mode: emacs - event: { - until: [ - { send: historyhintcomplete } - { send: menuright } - { send: right } - ] - } - } - { - name: redo_change - modifier: control - keycode: char_g - mode: emacs - event: { edit: redo } - } - { - name: undo_change - modifier: control - keycode: char_z - mode: emacs - event: { edit: undo } - } - { - name: paste_before - modifier: control - keycode: char_y - mode: emacs - event: { edit: pastecutbufferbefore } - } - { - name: cut_word_left - modifier: control - keycode: char_w - mode: emacs - event: { edit: cutwordleft } - } - { - name: cut_line_to_end - modifier: control - keycode: char_k - mode: emacs - event: { edit: cuttolineend } - } - { - name: cut_line_from_start - modifier: control - keycode: char_u - mode: emacs - event: { edit: cutfromstart } - } - { - name: swap_graphemes - modifier: control - keycode: char_t - mode: emacs - event: { edit: swapgraphemes } - } - { - name: move_one_word_left - modifier: alt - keycode: left - mode: emacs - event: { edit: movewordleft } - } - { - name: move_one_word_right_or_take_history_hint - modifier: alt - keycode: right - mode: emacs - event: { - until: [ - { send: historyhintwordcomplete } - { edit: movewordright } - ] - } - } - { - name: move_one_word_left - modifier: alt - keycode: char_b - mode: emacs - event: { edit: movewordleft } - } - { - name: move_one_word_right_or_take_history_hint - modifier: alt - keycode: char_f - mode: emacs - event: { - until: [ - { send: historyhintwordcomplete } - { edit: movewordright } - ] - } - } - { - name: delete_one_word_forward - modifier: alt - keycode: delete - mode: emacs - event: { edit: deleteword } - } - { - name: delete_one_word_backward - modifier: alt - keycode: backspace - mode: emacs - event: { edit: backspaceword } - } - { - name: delete_one_word_backward - modifier: alt - keycode: char_m - mode: emacs - event: { edit: backspaceword } - } - { - name: cut_word_to_right - modifier: alt - keycode: char_d - mode: emacs - event: { edit: cutwordright } - } - { - name: upper_case_word - modifier: alt - keycode: char_u - mode: emacs - event: { edit: uppercaseword } - } - { - name: lower_case_word - modifier: alt - keycode: char_l - mode: emacs - event: { edit: lowercaseword } - } - { - name: capitalize_char - modifier: alt - keycode: char_c - mode: emacs - event: { edit: capitalizechar } - } - # The following bindings with `*system` events require that Nushell has - # been compiled with the `system-clipboard` feature. - # If you want to use the system clipboard for visual selection or to - # paste directly, uncomment the respective lines and replace the version - # using the internal clipboard. - { - name: copy_selection - modifier: control_shift - keycode: char_c - mode: emacs - event: { edit: copyselection } - # event: { edit: copyselectionsystem } - } - { - name: cut_selection - modifier: control_shift - keycode: char_x - mode: emacs - event: { edit: cutselection } - # event: { edit: cutselectionsystem } - } - # { - # name: paste_system - # modifier: control_shift - # keycode: char_v - # mode: emacs - # event: { edit: pastesystem } - # } - { - name: select_all - modifier: control_shift - keycode: char_a - mode: emacs - event: { edit: selectall } - } - ] -} - - -alias cat = bat -alias rebuild = sudo nixos-rebuild switch --flake /etc/nixos/ -alias windows = sudo bootctl set-oneshot auto-windows -def toWindows [] { - sudo bootctl set-oneshot auto-windows - reboot -} -def toBIOS [] { - sudo bootctl set-onshot auto-reboot-to-firmware-setup - reboot -} - -def fullClean [] { - nix-collect-garbage --delete-old - sudo nix-collect-garbage -d - sudo /run/current-system/bin/switch-to-configuration boot -} - diff --git a/home/config/nushell/env.nu b/home/config/nushell/env.nu deleted file mode 100755 index ce12dc7..0000000 --- a/home/config/nushell/env.nu +++ /dev/null @@ -1,101 +0,0 @@ -# Nushell Environment Config File -# -# version = "0.100.0" - -def create_left_prompt [] { - let dir = match (do --ignore-shell-errors { $env.PWD | path relative-to $nu.home-path }) { - null => $env.PWD - '' => '~' - $relative_pwd => ([~ $relative_pwd] | path join) - } - - let path_color = (if (is-admin) { ansi red_bold } else { ansi green_bold }) - let separator_color = (if (is-admin) { ansi light_red_bold } else { ansi light_green_bold }) - let path_segment = $"($path_color)($dir)(ansi reset)" - - $path_segment | str replace --all (char path_sep) $"($separator_color)(char path_sep)($path_color)" -} - -def create_right_prompt [] { - # create a right prompt in magenta with green separators and am/pm underlined - let time_segment = ([ - (ansi reset) - (ansi magenta) - (date now | format date '%x %X') # try to respect user's locale - ] | str join | str replace --regex --all "([/:])" $"(ansi green)${1}(ansi magenta)" | - str replace --regex --all "([AP]M)" $"(ansi magenta_underline)${1}") - - let last_exit_code = if ($env.LAST_EXIT_CODE != 0) {([ - (ansi rb) - ($env.LAST_EXIT_CODE) - ] | str join) - } else { "" } - - ([$last_exit_code, (char space), $time_segment] | str join) -} - -# Use nushell functions to define your right and left prompt -$env.PROMPT_COMMAND = {|| create_left_prompt } -# FIXME: This default is not implemented in rust code as of 2023-09-08. -$env.PROMPT_COMMAND_RIGHT = {|| create_right_prompt } - -# The prompt indicators are environmental variables that represent -# the state of the prompt -$env.PROMPT_INDICATOR = {|| "> " } -$env.PROMPT_INDICATOR_VI_INSERT = {|| ": " } -$env.PROMPT_INDICATOR_VI_NORMAL = {|| "> " } -$env.PROMPT_MULTILINE_INDICATOR = {|| "::: " } - -# If you want previously entered commands to have a different prompt from the usual one, -# you can uncomment one or more of the following lines. -# This can be useful if you have a 2-line prompt and it's taking up a lot of space -# because every command entered takes up 2 lines instead of 1. You can then uncomment -# the line below so that previously entered commands show with a single `🚀`. -# $env.TRANSIENT_PROMPT_COMMAND = {|| "🚀 " } -# $env.TRANSIENT_PROMPT_INDICATOR = {|| "" } -# $env.TRANSIENT_PROMPT_INDICATOR_VI_INSERT = {|| "" } -# $env.TRANSIENT_PROMPT_INDICATOR_VI_NORMAL = {|| "" } -# $env.TRANSIENT_PROMPT_MULTILINE_INDICATOR = {|| "" } -# $env.TRANSIENT_PROMPT_COMMAND_RIGHT = {|| "" } - -# 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 -$env.ENV_CONVERSIONS = { - "PATH": { - from_string: { |s| $s | split row (char esep) | path expand --no-symlink } - to_string: { |v| $v | path expand --no-symlink | str join (char esep) } - } - "Path": { - from_string: { |s| $s | split row (char esep) | path expand --no-symlink } - to_string: { |v| $v | path expand --no-symlink | str join (char esep) } - } -} - -# Directories to search for scripts when calling source or use -# The default for this is $nu.default-config-dir/scripts -$env.NU_LIB_DIRS = [ - ($nu.default-config-dir | path join 'scripts') # add /scripts - ($nu.data-dir | path join 'completions') # default home for nushell completions -] - -# Directories to search for plugin binaries when calling register -# The default for this is $nu.default-config-dir/plugins -$env.NU_PLUGIN_DIRS = [ - ($nu.default-config-dir | path join 'plugins') # add /plugins -] - -# To add entries to PATH (on Windows you might use Path), you can use the following pattern: -# $env.PATH = ($env.PATH | split row (char esep) | prepend '/some/path') -# An alternate way to add entries to $env.PATH is to use the custom command `path add` -# which is built into the nushell stdlib: -# use std "path add" -# $env.PATH = ($env.PATH | split row (char esep)) -# path add /some/path -# path add ($env.CARGO_HOME | path join "bin") -# path add ($env.HOME | path join ".local" "bin") -# $env.PATH = ($env.PATH | uniq) - -# To load from a custom file you can use: -# source ($nu.default-config-dir | path join 'custom.nu') diff --git a/home/default.nix b/home/default.nix deleted file mode 100644 index 6a0f87b..0000000 --- a/home/default.nix +++ /dev/null @@ -1,16 +0,0 @@ -{ - nix-version, - username, - ... -}: -{ - imports = [ ./user ]; - home = { - inherit username; - homeDirectory = "/home/${username}"; - stateVersion = nix-version; - }; - - # Let Home Manager install and manage itself. - programs.home-manager.enable = true; -} diff --git a/home/presets/basic.nix b/home/presets/basic.nix new file mode 100644 index 0000000..50e12e7 --- /dev/null +++ b/home/presets/basic.nix @@ -0,0 +1,23 @@ +{ ... }: +{ + imports = [ + ../user/config.nix + ../user/desktops.nix + ../user/direnv.nix + ../user/environment.nix + ../user/git.nix + ../user/gtk.nix + ../user/hyprland.nix + # ../user/music-production.nix + ../user/nvim.nix + ../user/packages.nix + ../user/firefox.nix + ../user/shell.nix + ../user/swaync.nix + ../user/tmux.nix + ../user/virtualization.nix + ../user/swaync.nix + ../user/vscode.nix + ../user/yazi.nix + ]; +} diff --git a/home/server-default.nix b/home/server-default.nix deleted file mode 100644 index 0d15107..0000000 --- a/home/server-default.nix +++ /dev/null @@ -1,32 +0,0 @@ -{ - nix-version, - username, - lib, - ... -}: -{ - imports = [ - ./user/bin.nix - ./user/config.nix - ./user/direnv.nix - ./user/environment.nix - ./user/git.nix - # ./user/gtk.nix - # ./user/hyprland.nix - ./user/nvim.nix - # ./user/programs.nix - ./user/shell.nix - # ./user/swaync.nix - # ./user/virtualization.nix - ]; - - home = { - inherit username; - homeDirectory = "/home/${username}"; - stateVersion = nix-version; - }; - - # Let Home Manager install and manage itself. - programs.home-manager.enable = true; - programs.vscode.enable = lib.mkForce false; -} diff --git a/home/user/config.nix b/home/user/config.nix index 44dbece..8b6194b 100644 --- a/home/user/config.nix +++ b/home/user/config.nix @@ -5,7 +5,6 @@ in { home.file = { ".config/wallpapers".source = "${configDir}/wallpapers"; - ".config/kitty".source = "${configDir}/kitty"; ".config/neofetch".source = "${configDir}/neofetch"; ".config/wlogout".source = "${configDir}/wlogout"; ".config/waybar" = { @@ -28,16 +27,11 @@ in recursive = true; source = "${configDir}/fcitx5"; }; - ".config/electron-flags.conf".source = "${configDir}/electron/electron-flags.conf"; ".config/ghostty" = { recursive = true; source = "${configDir}/ghostty"; }; ".face".source = "${configDir}/.face"; - ".config/yazi" = { - recursive = true; - source = "${configDir}/yazi"; - }; }; xdg.mimeApps = { diff --git a/home/user/default.nix b/home/user/default.nix deleted file mode 100644 index ae9f675..0000000 --- a/home/user/default.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ inputs, ... }: -{ - imports = [ - ./git.nix - ./gtk.nix - ./shell.nix - ./config.nix - ./packages.nix - ./programs.nix - ./environment.nix - ./virtualization.nix - ./hyprland.nix - ./swaync.nix - ./nvim.nix - ./bin.nix - ./desktops.nix - ./direnv.nix - inputs.hyprland.homeManagerModules.default - ]; - - nixpkgs = { - config = { - allowUnfree = true; - allowUnfreePredicate = _: true; - - permittedInsecurePackages = [ - "electron-25.9.0" # Obsidian - ]; - }; - }; -} diff --git a/home/user/direnv.nix b/home/user/direnv.nix index 8667d87..a70f0c4 100644 --- a/home/user/direnv.nix +++ b/home/user/direnv.nix @@ -6,8 +6,4 @@ nix-direnv.enable = true; }; }; - - home.sessionVariables = { - DIRENV_LOG_FORMAT = ""; # Stop direnv log - }; } diff --git a/home/user/programs.nix b/home/user/firefox.nix similarity index 71% rename from home/user/programs.nix rename to home/user/firefox.nix index 8ea8988..3c70710 100644 --- a/home/user/programs.nix +++ b/home/user/firefox.nix @@ -1,5 +1,4 @@ { - pkgs, inputs, system, ... @@ -22,34 +21,12 @@ let # Disable Ctrl+Q "browser.quitShortcut.disabled" = true; }; - in { programs = { - vscode = { - enable = true; - package = pkgs.vscode; - }; - - yazi = { - enable = true; - package = inputs.yazi.packages.${system}.default; - enableFishIntegration = false; - }; - - obs-studio = { - enable = true; - plugins = with pkgs.obs-studio-plugins; [ - wlrobs - obs-backgroundremoval - obs-pipewire-audio-capture - ]; - }; - firefox = { enable = true; - # package = (pkgs.wrapFirefox (pkgs.firefox-unwrapped.override { pipewireSupport = true; }) { }); - package = inputs.firefox.packages.${pkgs.system}.firefox-nightly-bin; + package = inputs.firefox.packages.${system}.firefox-nightly-bin; languagePacks = [ "en-US" "zh-TW" diff --git a/home/user/git.nix b/home/user/git.nix index 6464ba8..41fcfe6 100644 --- a/home/user/git.nix +++ b/home/user/git.nix @@ -1,13 +1,9 @@ -{ git-config, ... }: -let - userName = git-config.username; - email = git-config.email; -in +{ settings, ... }: { programs.git = { enable = true; - userName = userName; - userEmail = email; + userName = settings.personal.git.username; + userEmail = settings.personal.git.email; extraConfig = { safe.directory = [ "/etc/nixos" ]; init.defaultBranch = "main"; diff --git a/home/user/gtk.nix b/home/user/gtk.nix index 5936ee1..62cdcf6 100644 --- a/home/user/gtk.nix +++ b/home/user/gtk.nix @@ -1,12 +1,12 @@ { pkgs, - xcursor-size, + settings, ... }: let cursorName = "catppuccin-macchiato-lavender-cursors"; themeName = "catppuccin-macchiato-lavender-compact"; - cursorSize = pkgs.lib.strings.toInt xcursor-size; + cursorSize = settings.hyprland.xcursor-size; in { gtk = { @@ -49,6 +49,9 @@ in libsForQt5.qtstyleplugin-kvantum libsForQt5.lightly libsForQt5.qt5ct + adwaita-icon-theme + gsettings-desktop-schemas + glib (catppuccin-kvantum.override { accent = "lavender"; variant = "macchiato"; diff --git a/home/user/hypr/exec.nix b/home/user/hypr/exec.nix index eaf1c3a..aa263d7 100644 --- a/home/user/hypr/exec.nix +++ b/home/user/hypr/exec.nix @@ -16,7 +16,7 @@ let dconf write /org/cinnamon/desktop/applications/terminal/exec "''\'${terminal}''\'" & dconf write /org/cinnamon/desktop/applications/terminal/exec-arg "''\'''\'" & - dconf write /org/gnome/desktop/interface/cursor-size ${xcursor-size} & + dconf write /org/gnome/desktop/interface/cursor-size ${builtins.toString xcursor-size} & ${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1 & ${swayncScript}/bin/swaync-start & diff --git a/home/user/hyprland.nix b/home/user/hyprland.nix index 2a9e00d..d51b03e 100644 --- a/home/user/hyprland.nix +++ b/home/user/hyprland.nix @@ -3,10 +3,8 @@ lib, inputs, system, - hyprcursor-size, - xcursor-size, - nvidia-offload-enabled ? false, - monitors ? [ ], + osConfig, + settings, ... }: let @@ -18,8 +16,8 @@ let inputs system terminal - xcursor-size ; + xcursor-size = settings.hyprland.xcursor-size; }; mainMod = "SUPER"; window = import ./hypr/window.nix; @@ -67,7 +65,10 @@ in debug = { disable_logs = false; }; - bind = import ./hypr/bind.nix { inherit mainMod nvidia-offload-enabled; }; + bind = import ./hypr/bind.nix { + inherit mainMod; + nvidia-offload-enabled = osConfig.hardware.nvidia.prime.offload.enableOffloadCmd; + }; bindm = import ./hypr/bindm.nix { inherit mainMod; }; binde = import ./hypr/binde.nix { inherit mainMod; }; monitor = import ./hypr/monitor.nix; @@ -75,14 +76,14 @@ in exec-once = ''${startScript}''; env = [ ''HYPRCURSOR_THEME, ${cursorName}'' - ''HYPRCURSOR_SIZE, ${hyprcursor-size}'' + ''HYPRCURSOR_SIZE, ${builtins.toString settings.hyprland.cursor-size}'' ''XCURSOR_THEME, ${cursorName}'' - ''XCURSOR_SIZE, ${xcursor-size}'' + ''XCURSOR_SIZE, ${builtins.toString settings.hyprland.xcursor-size}'' ''XDG_CURRENT_DESKTOP, Hyprland'' ''XDG_SESSION_DESKTOP, Hyprland'' ''GDK_PIXBUF_MODULE_FILE, ${pkgs.librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache'' # Make rofi load svg ]; - workspace = import ./hypr/workspace.nix { inherit monitors; }; + workspace = import ./hypr/workspace.nix { monitors = settings.hyprland.monitors; }; } // window // windowrule diff --git a/home/user/nvim.nix b/home/user/nvim.nix index 5ee628a..c9588a9 100644 --- a/home/user/nvim.nix +++ b/home/user/nvim.nix @@ -1,15 +1,13 @@ { lib, pkgs, - unstable, - device-name, - username, + settings, inputs, ... }: let lazyVim = ( - unstable.vimPlugins.LazyVim.overrideAttrs (previous: { + pkgs.vimPlugins.LazyVim.overrideAttrs (previous: { version = "2025-02-15"; src = pkgs.fetchFromGitHub { owner = "LazyVim"; @@ -23,6 +21,28 @@ in { home.packages = with pkgs; [ gh + ripgrep + fd + lua-language-server + nodejs_22 + nixfmt-rfc-style + markdownlint-cli2 + shfmt + nixd + marksman + nginx-language-server + bash-language-server + tailwindcss-language-server + vscode-langservers-extracted + gopls + pyright + yaml-language-server + marksman + lazygit + + # formatter + prettierd + black ]; programs.neovim = { @@ -298,10 +318,10 @@ in }, options = { nixos = { - expr = '(builtins.getFlake ("git+file://" + toString ./.)).nixosConfigurations.${device-name}.options', + expr = '(builtins.getFlake ("git+file://" + toString ./.)).nixosConfigurations.${settings.personal.hostname}.options', }, home_manager = { - expr = '(builtins.getFlake ("git+file://" + toString ./.)).homeConfigurations."${username}@${device-name}".options', + expr = '(builtins.getFlake ("git+file://" + toString ./.)).homeConfigurations."${settings.personal.username}@${settings.personal.hostname}".options', } } } diff --git a/home/user/packages.nix b/home/user/packages.nix index d0619a3..0c03d44 100644 --- a/home/user/packages.nix +++ b/home/user/packages.nix @@ -1,51 +1,27 @@ { pkgs, lib, - nvidia-offload-enabled, + inputs, + system, + osConfig, ... }: -let - discordIcon = lib.readFile ../../pkgs/assets/discord.svg; - discordSplash = lib.readFile ../../pkgs/assets/peepoLeave.gif.base64; - vesktopOverride = pkgs.vesktop.overrideAttrs (oldAttrs: { - desktopItems = lib.optional pkgs.stdenv.hostPlatform.isLinux ( - (lib.head oldAttrs.desktopItems).override { - name = "discord"; - desktopName = "Discord"; - exec = if nvidia-offload-enabled == true then "nvidia-offload vesktop %U" else "vesktop %U"; - } - ); - - patches = oldAttrs.patches ++ [ - ../../pkgs/patches/splash.patch - ]; - - # Change Splash - preConfigure = '' - echo "${discordSplash}" | base64 -d > static/peepo.gif - ''; - - # Change Icon - postInstall = '' - rm -rf $out/share/icons/hicolor/* - mkdir -p $out/share/icons/hicolor/scalable/apps - echo '${discordIcon}' > $out/share/icons/hicolor/scalable/apps/vesktop.svg - ''; - }); -in { home.packages = - (with pkgs; [ + with pkgs; + [ + # Terminal + inputs.ghostty.packages.${system}.default + + # Discord + vesktop + # Dev stuff - gcc - go (python3.withPackages (python-pkgs: [ python-pkgs.pip python-pkgs.requests python-pkgs.weasyprint ])) - rustup - ripdrag # Work stuff libreoffice-qt @@ -55,31 +31,38 @@ in # Bluetooth blueberry - # Gaming - steam-run - protonup - # Downloads qbittorrent # Utils viewnior - catppuccin-cursors.macchiatoLavender - catppuccin-gtk cava papirus-folders inkscape # PDF Preview poppler - trash-cli - ]) - ++ [ - vesktopOverride # discord - ]; - home.sessionVariables = { + # File Manager + nemo + + # Thumbnail + ffmpegthumbnailer + ] + ++ ( + if osConfig.programs.steam.enable then + [ + steam-run + protonup + ] + else + [ + + ] + ); + + home.sessionVariables = lib.mkIf osConfig.programs.steam.enable { STEAM_EXTRA_COMPAT_TOOLS_PATHS = "\${HOME}/.steam/root/compatibilitytools.d"; }; } diff --git a/home/user/shell.nix b/home/user/shell.nix index fe8ff5b..8af9488 100644 --- a/home/user/shell.nix +++ b/home/user/shell.nix @@ -1,8 +1,21 @@ -{ pkgs, ... }: +{ pkgs, settings, ... }: let - shellAlias = import ./shellAlias.nix; + shellAlias = import ./shellAlias.nix { hostname = settings.personal.hostname; }; in { + home.packages = with pkgs; [ + # Shell + fishPlugins.done + fishPlugins.fzf-fish + fishPlugins.forgit + fishPlugins.hydro + fishPlugins.grc + grc # Colorize + zoxide # Dir jumper + starship # Shell theme + carapace # Autocomplete + ]; + programs = { fish = { enable = true; diff --git a/home/user/shellAlias.nix b/home/user/shellAlias.nix index aa08265..56334c5 100644 --- a/home/user/shellAlias.nix +++ b/home/user/shellAlias.nix @@ -1,3 +1,4 @@ +{ hostname }: { ls = "exa --icons"; lp = "exa"; # Pure output @@ -7,7 +8,7 @@ t = "tmux"; # Nixos - rebuild = "sudo nixos-rebuild switch --flake /etc/nixos"; + rebuild = "sudo nixos-rebuild switch --flake /etc/nixos#${hostname}"; fullClean = "sudo nix store gc && sudo /run/current-system/bin/switch-to-configuration boot"; # Hyprland @@ -22,4 +23,7 @@ # TTY hideTTY = ''sudo sh -c "echo 0 > /sys/class/graphics/fb0/blank"''; showTTY = ''sudo sh -c "echo 1 > /sys/class/graphics/fb0/blank"''; + + # Recover from hyprlock corruption + letMeIn = ''hyprctl --instance 0 "keyword misc:allow_session_lock_restore 1" && hyprctl --instance 0 dispatch "exec hyprlock"''; } diff --git a/home/user/bin.nix b/home/user/tmux.nix similarity index 100% rename from home/user/bin.nix rename to home/user/tmux.nix diff --git a/home/user/virtualization.nix b/home/user/virtualization.nix index a812eee..8a609f5 100644 --- a/home/user/virtualization.nix +++ b/home/user/virtualization.nix @@ -1,4 +1,5 @@ -{ ... }: { +{ ... }: +{ dconf.settings = { "org/virt-manager/virt-manager/connections" = { autoconnect = [ "qemu:///system" ]; diff --git a/home/user/vscode.nix b/home/user/vscode.nix new file mode 100644 index 0000000..b95b8dd --- /dev/null +++ b/home/user/vscode.nix @@ -0,0 +1,9 @@ +{ pkgs, ... }: +{ + programs = { + vscode = { + enable = true; + package = pkgs.vscode; + }; + }; +} diff --git a/home/user/yazi.nix b/home/user/yazi.nix new file mode 100644 index 0000000..89b27c3 --- /dev/null +++ b/home/user/yazi.nix @@ -0,0 +1,27 @@ +{ + inputs, + system, + pkgs, + ... +}: +{ + programs = { + yazi = { + enable = true; + package = inputs.yazi.packages.${system}.default; + enableFishIntegration = false; + }; + }; + + home.packages = with pkgs; [ + # Drag from yazi + ripdrag + ]; + + home.file = { + ".config/yazi" = { + recursive = true; + source = ../config/yazi; + }; + }; +} diff --git a/pkgs/overlays/default.nix b/pkgs/overlays/default.nix new file mode 100644 index 0000000..5e9da35 --- /dev/null +++ b/pkgs/overlays/default.nix @@ -0,0 +1,7 @@ +{ config }: +prev: final: { + imports = [ + ./ferium.nix + (import ./vesktop.nix { inherit config; }) + ]; +} diff --git a/pkgs/overlays/ferium.nix b/pkgs/overlays/ferium.nix new file mode 100644 index 0000000..63d43d2 --- /dev/null +++ b/pkgs/overlays/ferium.nix @@ -0,0 +1,20 @@ +prev: final: { + ferium = prev.ferium.overrideAttrs ( + final: prev: rec { + cargoHash = "sha256-yedl4KQCpT7Ai1EPvwD5kzhkHesIjGVAcxKjp5k2jmI="; + version = "4.7.0"; + src = prev.fetchFromGitHub { + owner = "gorilla-devs"; + repo = prev.pname; + rev = "v${version}"; + hash = "sha256-jj3BdaxH7ofhHNF2eu+burn6+/0bPQQZ8JfjXAFyN4A="; + }; + + cargoDeps = prev.rustPlatform.fetchCargoVendor { + inherit (final) pname src version; + useFetchCargoVendor = true; + hash = final.cargoHash; + }; + } + ); +} diff --git a/pkgs/overlays/vesktop.nix b/pkgs/overlays/vesktop.nix new file mode 100644 index 0000000..ae89f3f --- /dev/null +++ b/pkgs/overlays/vesktop.nix @@ -0,0 +1,37 @@ +{ config }: +final: prev: +let + discordIcon = prev.lib.readFile ../../pkgs/assets/discord.svg; + discordSplash = prev.lib.readFile ../../pkgs/assets/peepoLeave.gif.base64; +in +{ + vesktop = prev.vesktop.overrideAttrs (oldAttrs: { + desktopItems = prev.lib.optional prev.stdenv.hostPlatform.isLinux ( + (prev.lib.head oldAttrs.desktopItems).override { + name = "discord"; + desktopName = "Discord"; + exec = + if config.hardware.nvidia.prime.offload.enableOffloadCmd == true then + "nvidia-offload vesktop %U" + else + "vesktop %U"; + } + ); + + patches = oldAttrs.patches ++ [ + ../../pkgs/patches/splash.patch + ]; + + # Change Splash + preConfigure = '' + echo "${discordSplash}" | base64 -d > static/peepo.gif + ''; + + # Change Icon + postInstall = '' + rm -rf $out/share/icons/hicolor/* + mkdir -p $out/share/icons/hicolor/scalable/apps + echo '${discordIcon}' > $out/share/icons/hicolor/scalable/apps/vesktop.svg + ''; + }); +} diff --git a/system/dev/dn-lap/default.nix b/system/dev/dn-lap/default.nix index 278fee7..6b27ce7 100644 --- a/system/dev/dn-lap/default.nix +++ b/system/dev/dn-lap/default.nix @@ -1,58 +1,22 @@ { - lib, - unstable, - system, - inputs, - nix-version, - git-config, - username, - config, + settings, ... }: - -let - hyprcursor-size = "32"; - xcursor-size = "24"; - nvidia-offload-enabled = config.hardware.nvidia.prime.offload.enable; - device-name = "dn-lap"; - monitors = [ ]; -in { imports = [ - inputs.home-manager.nixosModules.default ./hardware-configuration.nix ./boot.nix - ../../modules - ../../modules/wireguard.nix - ../../modules/dn-ca.nix + ../../modules/presets/basic.nix ../../modules/gaming.nix + ../../modules/virtualization.nix + ../../modules/wine.nix + ../../modules/wireguard.nix ]; - # Overrides - networking.hostName = lib.mkForce device-name; - - system.stateVersion = nix-version; home-manager = { - backupFileExtension = "hm-backup"; - extraSpecialArgs = { - inherit - monitors - unstable - inputs - system - nix-version - xcursor-size - hyprcursor-size - git-config - username - nvidia-offload-enabled - device-name - ; - }; - users."${username}" = { + users."${settings.personal.username}" = { imports = [ - ../../../home - ../../../home/user/music-production.nix + ../../../home/presets/basic.nix ]; }; }; diff --git a/system/dev/dn-pre7780/default.nix b/system/dev/dn-pre7780/default.nix index a1c1f2d..b3de91a 100644 --- a/system/dev/dn-pre7780/default.nix +++ b/system/dev/dn-pre7780/default.nix @@ -1,87 +1,40 @@ { - lib, pkgs, - unstable, - inputs, - system, - nix-version, - git-config, - username, - config, + settings, ... }: -let - hyprcursor-size = "32"; - xcursor-size = "24"; - nvidia-mode = "offload"; - # Get bus id with `lshw` - intel-bus-id = "PCI:0:2:0"; - nvidia-bus-id = "PCI:1:0:0"; - nvidia-offload-enabled = config.hardware.nvidia.prime.offload.enable; - device-name = "dn-pre7780"; - monitors = [ - "DP-3" - "HDMI-A-2" - ]; -in { imports = [ - inputs.home-manager.nixosModules.default + (import ../../modules/nvidia.nix { + nvidia-mode = settings.nvidia.mode; + intel-bus-id = settings.nvidia.intel-bus-id; + nvidia-bus-id = settings.nvidia.nvidia-bus-id; + }) ./hardware-configuration.nix ./boot.nix - ../../modules + ../../modules/presets/basic.nix ../../modules/cuda.nix - (import ../../modules/nvidia.nix { - nvidia-mode = nvidia-mode; - intel-bus-id = intel-bus-id; - nvidia-bus-id = nvidia-bus-id; - }) ../../modules/gaming.nix - ../../modules/wireguard.nix - (import ../../modules/wallpaper-engine.nix { - offload = nvidia-offload-enabled; - }) - ../../modules/wine.nix ../../modules/secure-boot.nix - ]; - - # Overrides - networking.hostName = lib.mkForce device-name; - - system.stateVersion = nix-version; - services.wallpaperEngine.enable = lib.mkForce false; - - environment.systemPackages = [ - pkgs.prismlauncher + ../../modules/virtualization.nix + ../../modules/wine.nix + ../../modules/wireguard.nix ]; home-manager = { - backupFileExtension = "backup"; - useUserPackages = true; - extraSpecialArgs = { - inherit - unstable - inputs - system - nix-version - xcursor-size - hyprcursor-size - git-config - username - nvidia-offload-enabled - device-name - monitors - ; - }; - users."${username}" = { + users."${settings.personal.username}" = { imports = [ - ../../../home + ../../../home/presets/basic.nix ]; }; }; + environment.systemPackages = with pkgs; [ + prismlauncher + ]; + users.users = { - "${username}".openssh.authorizedKeys.keys = [ + "${settings.personal.username}".openssh.authorizedKeys.keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJFQA42R3fZmjb9QnUgzzOTIXQBC+D2ravE/ZLvdjoOQ danny@lap.dn" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILSHkPa6vmr5WBPXAazY16+Ph1Mqv9E24uLIf32oC2oH danny@phone.dn" ]; diff --git a/system/dev/dn-server/default.nix b/system/dev/dn-server/default.nix index d1e7e42..cc2307a 100644 --- a/system/dev/dn-server/default.nix +++ b/system/dev/dn-server/default.nix @@ -1,94 +1,52 @@ { - lib, - unstable, pkgs, inputs, - system, - nix-version, - git-config, - username, - config, + settings, ... }: -let - hyprcursor-size = "32"; - xcursor-size = "24"; - nvidia-mode = "offload"; - # Get bus id with `lshw -C display` - intel-bus-id = "PCI:0:2:0"; - nvidia-bus-id = "PCI:1:0:0"; - nvidia-offload-enabled = config.hardware.nvidia.prime.offload.enable; - device-name = "dn-server"; - monitors = [ - ]; -in { imports = [ - inputs.home-manager.nixosModules.default + (import ../../modules/nvidia.nix { + nvidia-mode = settings.nvidia.mode; + intel-bus-id = settings.nvidia.intel-bus-id; + nvidia-bus-id = settings.nvidia.nvidia-bus-id; + }) ./hardware-configuration.nix ./boot.nix ./packages.nix ./services.nix ./networking.nix - ../../modules/server-default.nix + ../../modules/presets/minimal.nix + ../../modules/bluetooth.nix ../../modules/cuda.nix - (import ../../modules/nvidia.nix { - nvidia-mode = nvidia-mode; - intel-bus-id = intel-bus-id; - nvidia-bus-id = nvidia-bus-id; - }) - # ../../modules/wine.nix + ../../modules/gc.nix ]; - nixpkgs.overlays = [ inputs.nix-minecraft.overlay ]; - - environment.systemPackages = [ - (pkgs.ferium.overrideAttrs ( - final: prev: rec { - cargoHash = "sha256-yedl4KQCpT7Ai1EPvwD5kzhkHesIjGVAcxKjp5k2jmI="; - version = "4.7.0"; - src = pkgs.fetchFromGitHub { - owner = "gorilla-devs"; - repo = prev.pname; - rev = "v${version}"; - hash = "sha256-jj3BdaxH7ofhHNF2eu+burn6+/0bPQQZ8JfjXAFyN4A="; - }; - - cargoDeps = pkgs.rustPlatform.fetchCargoVendor { - inherit (final) pname src version; - useFetchCargoVendor = true; - hash = final.cargoHash; - }; - } - )) + environment.systemPackages = with pkgs; [ + ferium ]; - # Overrides - networking.hostName = lib.mkForce device-name; - - system.stateVersion = nix-version; - home-manager = { - backupFileExtension = "backup"; - useUserPackages = true; - extraSpecialArgs = { - inherit - unstable - inputs - system - nix-version - xcursor-size - hyprcursor-size - git-config - username - nvidia-offload-enabled - device-name - monitors - ; - }; - users."${username}" = { + users."${settings.personal.username}" = { imports = [ - ../../../home/server-default.nix + ../../../home/user/config.nix + ../../../home/user/direnv.nix + ../../../home/user/environment.nix + ../../../home/user/git.nix + ../../../home/user/nvim.nix + ../../../home/user/shell.nix + ../../../home/user/tmux.nix + ../../../home/user/yazi.nix + { + home.packages = with pkgs; [ + inputs.ghostty.packages.${system}.default + (python3.withPacakges ( + p: with p; [ + pip + ] + )) + ]; + } ]; }; }; diff --git a/system/dev/dn-server/packages.nix b/system/dev/dn-server/packages.nix deleted file mode 100644 index 3880e69..0000000 --- a/system/dev/dn-server/packages.nix +++ /dev/null @@ -1,83 +0,0 @@ -{ - pkgs, - inputs, - ... -}: -{ - environment.systemPackages = with pkgs; [ - neovim - file - - cachix - - upower - jq - bat - btop - eza - fzf - neofetch - ripgrep - tree - tldr # Alternative for man - wget - unzip - p7zip - killall - zip - glxinfo # OpenGL info - pciutils # PCI info - xdotool # Keyboard input simulation - ffmpeg # Video encoding - mpv # Media player - - git - gh - gnumake - lm_sensors - openssl - openssl.dev - pkg-config # Include Lib - nodejs - yarn-berry - rustup - gcc - zig - - vim - stylua - lazygit - luajitPackages.lua - lua51Packages.lua - luajitPackages.luarocks - luajitPackages.magick - imagemagick - - fishPlugins.done - fishPlugins.fzf-fish - fishPlugins.forgit - fishPlugins.hydro - fishPlugins.grc - grc # Colorize - zoxide # Dir jumper - starship # Shell theme - carapace # Autocomplete - - usbutils - udiskie - udisks - - ffmpegthumbnailer - - libsForQt5.qt5.qtmultimedia - libsForQt5.qt5.qtquickcontrols2 - libsForQt5.qt5.qtgraphicaleffects - libsForQt5.qt5.qtsvg - libsForQt5.qt5.qtwayland - pkgs.gst_all_1.gst-libav - pkgs.gst_all_1.gstreamer - pkgs.gst_all_1.gst-plugins-good - - inputs.ghostty.packages.${system}.default - ]; -} diff --git a/system/dev/dn-server/services.nix b/system/dev/dn-server/services.nix index 16c2a3d..cf3043d 100644 --- a/system/dev/dn-server/services.nix +++ b/system/dev/dn-server/services.nix @@ -274,11 +274,6 @@ in enable = false; xkb.layout = "us"; }; - - # USB auto mount - gvfs.enable = true; - udisks2.enable = true; - devmon.enable = true; }; users.users = { diff --git a/system/modules/auto-mount.nix b/system/modules/auto-mount.nix new file mode 100644 index 0000000..443c1ff --- /dev/null +++ b/system/modules/auto-mount.nix @@ -0,0 +1,16 @@ +{ pkgs, ... }: +{ + environment.systemPackages = with pkgs; [ + # USB auto mount + usbutils + udiskie + udisks + ]; + + services = { + # USB auto mount + gvfs.enable = true; + udisks2.enable = true; + devmon.enable = true; + }; +} diff --git a/system/modules/bluetooth.nix b/system/modules/bluetooth.nix new file mode 100644 index 0000000..a1527ca --- /dev/null +++ b/system/modules/bluetooth.nix @@ -0,0 +1,25 @@ +{ + services = { + blueman.enable = true; + }; + + hardware = { + bluetooth = { + enable = true; + powerOnBoot = true; + settings.General = { + experimental = true; + Privacy = "device"; + JustWorksRepairing = "always"; + Class = "0x000100"; + FastConnectable = true; + }; + }; + }; + + boot = { + extraModprobeConfig = '' + options bluetooth disable_ertm=Y + ''; + }; +} diff --git a/system/modules/default.nix b/system/modules/default.nix deleted file mode 100644 index 192c4b4..0000000 --- a/system/modules/default.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ ... }: -{ - imports = [ - ./plymouth.nix # Boot splash - ./fonts.nix - ./hardware.nix - ./hyprland.nix - ./internationalisation.nix - ./misc.nix - ./networking.nix - ./nixsettings.nix - ./packages.nix - ./programs.nix - ./security.nix - ./services.nix - ./sound.nix - ./time.nix - ./theme.nix - ./users.nix - ./environment.nix - ./virtualization.nix - ./display-manager.nix - ./gc.nix - ./polkit.nix - ./lsp.nix - ./tmux.nix - ]; -} diff --git a/system/modules/display-manager.nix b/system/modules/display-manager.nix index ef0ccb0..62603d8 100644 --- a/system/modules/display-manager.nix +++ b/system/modules/display-manager.nix @@ -16,4 +16,16 @@ in }}"; }; }; + + environment.systemPackages = with pkgs; [ + # SDDM + libsForQt5.qt5.qtmultimedia + libsForQt5.qt5.qtquickcontrols2 + libsForQt5.qt5.qtgraphicaleffects + libsForQt5.qt5.qtsvg + libsForQt5.qt5.qtwayland + pkgs.gst_all_1.gst-libav + pkgs.gst_all_1.gstreamer + pkgs.gst_all_1.gst-plugins-good + ]; } diff --git a/system/modules/dn-ca.nix b/system/modules/dn-ca.nix deleted file mode 100644 index e8cfa9b..0000000 --- a/system/modules/dn-ca.nix +++ /dev/null @@ -1,20 +0,0 @@ -{ ... }: - -{ - # This is my CA root cerificate, you shall delete it - security.pki.certificates = [ - '' - -----BEGIN CERTIFICATE----- - MIIBhzCCAS2gAwIBAgIQUwzjgrU4LTTmE7FTvaCHlzAKBggqhkjOPQQDAjAiMQsw - CQYDVQQKEwJETjETMBEGA1UEAxMKRE4gUm9vdCBDQTAeFw0yNDExMTAwMjE5MzRa - Fw0zNDExMDgwMjE5MzRaMCIxCzAJBgNVBAoTAkROMRMwEQYDVQQDEwpETiBSb290 - IENBMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEhjokYiCE96DzqXb0pXgV7/DW - ns8BTBq67KGeLaH77Ywv15PzR1ydwaJ1NvvwNbyZh5TwpkMtXIEG7Cr44w/Ip6NF - MEMwDgYDVR0PAQH/BAQDAgEGMBIGA1UdEwEB/wQIMAYBAf8CAQEwHQYDVR0OBBYE - FBgyUYt4st+TkVu4WWEfOhuVjbzqMAoGCCqGSM49BAMCA0gAMEUCIGUdeDfQJ+m0 - tdlSDJgnIXbJyU0u4cSvi8faJa7OtVovAiEAxvEteXU7f4+5U1yyk0NxJ7jg8B6P - K5hP1e2clgjFv/k= - -----END CERTIFICATE----- - '' - ]; -} diff --git a/system/modules/flatpak.nix b/system/modules/flatpak.nix new file mode 100644 index 0000000..b6bf800 --- /dev/null +++ b/system/modules/flatpak.nix @@ -0,0 +1,14 @@ +{ pkgs, ... }: +{ + systemd.services.flatpak-repo = { + wantedBy = [ "multi-user.target" ]; + path = [ pkgs.flatpak ]; + script = '' + flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo + ''; + }; + + services = { + flatpak.enable = true; + }; +} diff --git a/system/modules/gaming.nix b/system/modules/gaming.nix index db91730..31270ed 100644 --- a/system/modules/gaming.nix +++ b/system/modules/gaming.nix @@ -1,18 +1,13 @@ { - lib, + config, pkgs, + lib, ... }: { nix = { settings = { - warn-dirty = false; - experimental-features = [ - "nix-command" - "flakes" - ]; - auto-optimise-store = true; substituters = [ "https://nix-gaming.cachix.org" ]; trusted-public-keys = [ "nix-gaming.cachix.org-1:nbjlureqMbRAxR1gJ/f3hxemL9svXaZF/Ees8vCUUs4=" @@ -35,17 +30,20 @@ gamescope ]; }; + + gamemode = { + enable = true; + settings.general.inhibit_screensaver = 0; + }; }; - hardware.steam-hardware.enable = true; + hardware = { + steam-hardware.enable = true; + # Xbox controller + xpadneo.enable = true; + }; - nixpkgs.config.allowUnfree = true; - nixpkgs.config.allowUnfreePredicate = - pkg: - builtins.elem (lib.getName pkg) [ - "steam" - "steam-original" - "steam-unwrapped" - "steam-run" - ]; + boot.extraModulePackages = with config.boot.kernelPackages; [ + xpadneo + ]; } diff --git a/system/modules/gc.nix b/system/modules/gc.nix index 9af5d59..eb5b5fb 100644 --- a/system/modules/gc.nix +++ b/system/modules/gc.nix @@ -6,11 +6,13 @@ # `nix-store --optimize` for finding and eliminating redundant copies of identical store paths # `nix-store --gc` for optimizing the nix store and removing unreferenced and obsolete store paths # `nix-collect-garbage -d` for deleting old generations of user profiles - nix.settings.auto-optimise-store = true; - nix.optimise.automatic = true; - nix.gc = { - automatic = true; - dates = "weekly"; - options = "--delete-older-than 7d"; + nix = { + settings.auto-optimise-store = true; + optimise.automatic = true; + gc = { + automatic = true; + dates = "weekly"; + options = "--delete-older-than 7d"; + }; }; } diff --git a/system/modules/hardware.nix b/system/modules/hardware.nix index aa9441c..f9d7f5d 100644 --- a/system/modules/hardware.nix +++ b/system/modules/hardware.nix @@ -1,5 +1,4 @@ { - config, pkgs, inputs, system, @@ -11,21 +10,6 @@ let in { hardware = { - bluetooth = { - enable = true; - powerOnBoot = true; - settings.General = { - experimental = true; - Privacy = "device"; - JustWorksRepairing = "always"; - Class = "0x000100"; - FastConnectable = true; - }; - }; - - # Xbox controller - xpadneo.enable = true; - graphics = { enable = true; enable32Bit = true; @@ -44,17 +28,5 @@ in enableRedistributableFirmware = true; }; - # Enable bluetooth - boot = { - extraModulePackages = with config.boot.kernelPackages; [ - xpadneo - v4l2loopback # OBS Virtual Camera - ]; - extraModprobeConfig = '' - options bluetooth disable_ertm=Y - options v4l2loopback devices=1 video_nr=1 card_label="OBS Cam" exclusive_caps=1 - ''; - }; - security.polkit.enable = true; } diff --git a/system/modules/hyprland.nix b/system/modules/hyprland.nix index 69d5c32..ce89b73 100644 --- a/system/modules/hyprland.nix +++ b/system/modules/hyprland.nix @@ -48,14 +48,7 @@ nix = { settings = { - warn-dirty = false; - experimental-features = [ - "nix-command" - "flakes" - ]; - auto-optimise-store = true; substituters = [ "https://hyprland.cachix.org" ]; - trusted-public-keys = [ "hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc=" ]; diff --git a/system/modules/lsp.nix b/system/modules/lsp.nix deleted file mode 100644 index abb5551..0000000 --- a/system/modules/lsp.nix +++ /dev/null @@ -1,29 +0,0 @@ -{ pkgs, inputs, ... }: - -{ - environment.systemPackages = with pkgs; [ - ripgrep - fd - lua-language-server - nodejs_22 - nixfmt-rfc-style - markdownlint-cli2 - shfmt - nixd - marksman - nginx-language-server - bash-language-server - tailwindcss-language-server - vscode-langservers-extracted - gopls - pyright - yaml-language-server - marksman - - # formatter - prettierd - black - ]; - - nix.nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; -} diff --git a/system/modules/networking.nix b/system/modules/networking.nix index e8a3f83..ce42169 100644 --- a/system/modules/networking.nix +++ b/system/modules/networking.nix @@ -1,19 +1,9 @@ -{ config, pkgs, ... }: - { networking = { networkmanager.enable = true; enableIPv6 = false; firewall = { enable = true; - allowedTCPPorts = [ - 22 - 20088 - ]; - allowedUDPPorts = [ - 51820 - 20088 - ]; }; }; } diff --git a/system/modules/nixsettings.nix b/system/modules/nixsettings.nix index 60bdfdd..584c481 100644 --- a/system/modules/nixsettings.nix +++ b/system/modules/nixsettings.nix @@ -1,6 +1,15 @@ -{ ... }: +{ inputs, ... }: { documentation.nixos.enable = false; - nixpkgs.config.allowUnfree = true; - nixpkgs.config.rcomSupport = true; + nix = { + settings = { + warn-dirty = false; + experimental-features = [ + "nix-command" + "flakes" + ]; + auto-optimise-store = true; + }; + nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; + }; } diff --git a/system/modules/nvidia.nix b/system/modules/nvidia.nix index 197b5b4..badc65d 100644 --- a/system/modules/nvidia.nix +++ b/system/modules/nvidia.nix @@ -54,7 +54,7 @@ lib.checkListOfEnum "Nvidia Prime Mode" validModes [ nvidia-mode ] { nvidia.nvidiaSettings = true; nvidia.dynamicBoost.enable = true; - nvidia.package = config.boot.kernelPackages.nvidiaPackages.beta; + nvidia.package = config.boot.kernelPackages.nvidiaPackages.latest; nvidia.prime = ( diff --git a/system/modules/obs-studio.nix b/system/modules/obs-studio.nix new file mode 100644 index 0000000..8882348 --- /dev/null +++ b/system/modules/obs-studio.nix @@ -0,0 +1,14 @@ +{ pkgs, ... }: +{ + programs = { + obs-studio = { + enable = true; + enableVirtualCamera = true; + plugins = with pkgs.obs-studio-plugins; [ + wlrobs + obs-backgroundremoval + obs-pipewire-audio-capture + ]; + }; + }; +} diff --git a/system/modules/packages.nix b/system/modules/packages.nix index 95b1dff..79da986 100644 --- a/system/modules/packages.nix +++ b/system/modules/packages.nix @@ -1,25 +1,16 @@ { pkgs, - inputs, - system, ... }: { - environment.systemPackages = - (with pkgs; [ - neovim + environment.systemPackages = ( + with pkgs; + [ file # Binary cache platform cachix - # gtk theme - gtk3 - adwaita-icon-theme - - # File Manager - nemo - # Utils upower jq @@ -48,63 +39,15 @@ gh # Github cli tool gnumake lm_sensors - temurin-jre-bin - openssl - openssl.dev - pkg-config # Include Lib + pkg-config nodejs yarn-berry - dotnetCorePackages.sdk_8_0_3xx - dotnetCorePackages.dotnet_9.sdk - dotnetCorePackages.dotnet_9.runtime - dotnetCorePackages.dotnet_9.aspnetcore rustup gcc zig - # Editor - vim - stylua - lazygit - luajitPackages.lua - lua51Packages.lua - luajitPackages.luarocks - luajitPackages.magick - imagemagick - - # Shell - fishPlugins.done - fishPlugins.fzf-fish - fishPlugins.forgit - fishPlugins.hydro - fishPlugins.grc - grc # Colorize - zoxide # Dir jumper - starship # Shell theme - carapace # Autocomplete - - # USB auto mount - usbutils - udiskie - udisks - # Media vlc - - # Thumbnail - ffmpegthumbnailer - - # SDDM - libsForQt5.qt5.qtmultimedia - libsForQt5.qt5.qtquickcontrols2 - libsForQt5.qt5.qtgraphicaleffects - libsForQt5.qt5.qtsvg - libsForQt5.qt5.qtwayland - pkgs.gst_all_1.gst-libav - pkgs.gst_all_1.gstreamer - pkgs.gst_all_1.gst-plugins-good - ]) - ++ [ - inputs.ghostty.packages.${system}.default - ]; + ] + ); } diff --git a/system/modules/presets/basic.nix b/system/modules/presets/basic.nix new file mode 100644 index 0000000..0f166d2 --- /dev/null +++ b/system/modules/presets/basic.nix @@ -0,0 +1,29 @@ +{ ... }: +{ + imports = [ + ../auto-mount.nix + ../bluetooth.nix + ../display-manager.nix + ../environment.nix + ../flatpak.nix + ../fonts.nix + ../gc.nix + ../hardware.nix + ../hyprland.nix + ../internationalisation.nix + ../misc.nix + ../networking.nix + ../nixsettings.nix + ../obs-studio.nix + ../packages.nix + ../plymouth.nix + ../polkit.nix + ../programs.nix + ../security.nix + ../services.nix + ../sound.nix + ../time.nix + ../tmux.nix + ../users.nix + ]; +} diff --git a/system/modules/presets/minimal.nix b/system/modules/presets/minimal.nix new file mode 100644 index 0000000..20e70e9 --- /dev/null +++ b/system/modules/presets/minimal.nix @@ -0,0 +1,18 @@ +{ ... }: +{ + imports = [ + ../environment.nix + ../fonts.nix + ../hardware.nix + ../internationalisation.nix + ../misc.nix + ../networking.nix + ../nixsettings.nix + ../packages.nix + ../programs.nix + ../services.nix + ../sound.nix + ../time.nix + ../users.nix + ]; +} diff --git a/system/modules/programs.nix b/system/modules/programs.nix index a7d208f..a7087af 100644 --- a/system/modules/programs.nix +++ b/system/modules/programs.nix @@ -1,6 +1,16 @@ { pkgs, ... }: { + + environment.systemPackages = with pkgs; [ + # neovim + luajitPackages.lua + lua51Packages.lua + luajitPackages.luarocks + luajitPackages.magick + imagemagick + ]; + programs = { gnupg = { agent = { diff --git a/system/modules/secure-boot.nix b/system/modules/secure-boot.nix index 095a9e1..064adc8 100644 --- a/system/modules/secure-boot.nix +++ b/system/modules/secure-boot.nix @@ -4,9 +4,11 @@ sbctl ]; - boot.loader.systemd-boot.enable = lib.mkForce false; - boot.lanzaboote = { - enable = true; - pkiBundle = "/var/lib/sbctl/"; + boot = { + loader.systemd-boot.enable = lib.mkForce false; + lanzaboote = { + enable = true; + pkiBundle = "/var/lib/sbctl/"; + }; }; } diff --git a/system/modules/security.nix b/system/modules/security.nix index 617b6e6..e12d3d5 100644 --- a/system/modules/security.nix +++ b/system/modules/security.nix @@ -2,15 +2,18 @@ { services.udev.packages = [ pkgs.yubikey-personalization ]; - security.pam.services.hyprlock = { }; - security.pam.u2f = { - enable = true; - settings.cue = true; - control = "sufficient"; - }; - security.pam.services = { - sudo.u2fAuth = true; + security.pam = { + services.hyprlock = { }; + services = { + sudo.u2fAuth = true; + }; + + u2f = { + enable = true; + settings.cue = true; + control = "sufficient"; + }; }; environment.systemPackages = with pkgs; [ diff --git a/system/modules/server-default.nix b/system/modules/server-default.nix deleted file mode 100644 index 6c16983..0000000 --- a/system/modules/server-default.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ ... }: -{ - imports = [ - ./fonts.nix - ./hardware.nix - ./internationalisation.nix - ./misc.nix - ./nixsettings.nix - ./programs.nix - ./security.nix - ./sound.nix - ./time.nix - ./users.nix - ./gc.nix - ./polkit.nix - ./lsp.nix - ./tmux.nix - ]; -} diff --git a/system/modules/services.nix b/system/modules/services.nix index 8b37689..325a72c 100644 --- a/system/modules/services.nix +++ b/system/modules/services.nix @@ -1,26 +1,23 @@ -{ username, pkgs, ... }: +{ settings, ... }: { - systemd.services.flatpak-repo = { - wantedBy = [ "multi-user.target" ]; - path = [ pkgs.flatpak ]; - script = '' - flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo - ''; + networking = { + firewall = { + allowedTCPPorts = [ + 22 # SSH + ]; + }; }; services = { dbus.enable = true; - - blueman.enable = true; - openssh = { enable = true; ports = [ 22 ]; settings = { PasswordAuthentication = false; - AllowUsers = [ username ]; - UseDns = false; + AllowUsers = [ settings.personal.username ]; + UseDns = true; PermitRootLogin = "no"; }; }; @@ -32,15 +29,5 @@ options = "caps:swapescape"; }; }; - - # USB auto mount - gvfs.enable = true; - udisks2.enable = true; - devmon.enable = true; - - flatpak.enable = true; - - # Thuner plugin - tumbler.enable = true; # Thumbnail }; } diff --git a/system/modules/sound.nix b/system/modules/sound.nix index c1a35fe..077afd9 100644 --- a/system/modules/sound.nix +++ b/system/modules/sound.nix @@ -2,20 +2,22 @@ { security.rtkit.enable = true; # Pipewire real-time access - services.pulseaudio.enable = false; + services = { + pulseaudio.enable = false; - services.pipewire = { - enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; - jack.enable = true; - wireplumber.enable = true; - audio.enable = true; + pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + jack.enable = true; + wireplumber.enable = true; + audio.enable = true; + }; + + playerctld.enable = true; }; - services.playerctld.enable = true; - environment.systemPackages = with pkgs; [ pavucontrol playerctl diff --git a/system/modules/theme.nix b/system/modules/theme.nix deleted file mode 100644 index 133e537..0000000 --- a/system/modules/theme.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ pkgs, ... }: - -{ - environment.systemPackages = with pkgs; [ - adwaita-icon-theme # default gnome cursors - glib - gsettings-desktop-schemas - ]; -} diff --git a/system/modules/tmux.nix b/system/modules/tmux.nix index 0598fe1..da2c77d 100644 --- a/system/modules/tmux.nix +++ b/system/modules/tmux.nix @@ -18,7 +18,9 @@ in }; }; - environment.systemPackages = with pkgs; [ tmuxinator ]; + environment.systemPackages = with pkgs; [ + tmuxinator + ]; programs = { tmux = { diff --git a/system/modules/users.nix b/system/modules/users.nix index d25f95b..09cc831 100644 --- a/system/modules/users.nix +++ b/system/modules/users.nix @@ -1,7 +1,7 @@ -{ username, pkgs, ... }: +{ settings, pkgs, ... }: { - users.users.${username} = { + users.users.${settings.personal.username} = { isNormalUser = true; shell = pkgs.bash; # Actually fish extraGroups = [ diff --git a/system/modules/virtualization.nix b/system/modules/virtualization.nix index 6ebff24..845a6e8 100644 --- a/system/modules/virtualization.nix +++ b/system/modules/virtualization.nix @@ -1,5 +1,5 @@ { - username, + settings, pkgs, config, ... @@ -7,7 +7,7 @@ { programs.virt-manager.enable = true; - users.groups.libvirtd.members = [ username ]; + users.groups.libvirtd.members = [ settings.personal.username ]; virtualisation = { docker.enable = true; diff --git a/system/modules/wallpaper-engine.nix b/system/modules/wallpaper-engine.nix index c6e8a76..ab99ca5 100644 --- a/system/modules/wallpaper-engine.nix +++ b/system/modules/wallpaper-engine.nix @@ -1,6 +1,6 @@ # Work pretty good on ONE monitor { - offload ? false, + config, ... }: { lib, ... }: @@ -15,7 +15,7 @@ in enable = true; assetsDir = assetsDir; contentDir = contentDir; - extraPrefix = lib.mkIf offload "nvidia-offload"; + extraPrefix = lib.mkIf config.hardware.nvidia.prime.offload.enableOffloadCmd "nvidia-offload"; fps = 30; monitors = { "DP-3" = {