Personal Nix setup
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add niri configs

+307 -224
+1
home/desktop/default.nix
··· 11 11 }; 12 12 13 13 imports = [ 14 + ./niri/default.nix 14 15 ./hyprland.nix 15 16 ./theme.nix 16 17 ./tools.nix
+1 -1
home/desktop/hyprland.nix
··· 17 17 in { 18 18 options.modules.desktop.hyprland = { 19 19 enable = mkOption { 20 - default = cfg.enable; 20 + default = false; 21 21 example = true; 22 22 description = "Whether to enable Hyprland configuration."; 23 23 type = types.bool;
+8
home/desktop/niri/config.kdl
··· 1 + spawn-at-startup "cosmic-ext-alternative-startup" 2 + 3 + binds { 4 + Super+T { spawn "ghostty"; } 5 + Super+Space { spawn "cosmic-launcher"; } 6 + Super+Shift+Space { spawn "cosmic-app-library"; } 7 + Super+Alt+L { spawn "cosmic-greeter"; } 8 + }
+19
home/desktop/niri/default.nix
··· 1 + { lib, config, pkgs, ... }: 2 + 3 + with lib; 4 + let 5 + cfg = config.modules.desktop; 6 + in { 7 + options.modules.desktop.niri = { 8 + enable = mkOption { 9 + default = cfg.enable; 10 + example = true; 11 + description = "Whether to enable Niri configuration."; 12 + type = types.bool; 13 + }; 14 + }; 15 + 16 + config = mkIf cfg.niri.enable { 17 + xdg.configFile."niri/config.kdl".text = (builtins.readFile ./config.kdl); 18 + }; 19 + }
+1 -1
home/desktop/theme.nix
··· 7 7 in { 8 8 options.modules.desktop.theme = { 9 9 enable = mkOption { 10 - default = cfg.enable; 10 + default = false; 11 11 example = true; 12 12 description = "Whether to enable theming configuration."; 13 13 type = types.bool;
+1 -1
home/desktop/tools.nix
··· 6 6 in { 7 7 options.modules.desktop.tools = { 8 8 enable = mkOption { 9 - default = cfg.enable; 9 + default = false; 10 10 example = true; 11 11 description = "Whether to enable basic desktop tools."; 12 12 type = types.bool;
-10
machines/pepper/configuration.nix
··· 14 14 modules = { 15 15 desktop = { 16 16 enable = true; 17 - hyprland = { 18 - input = { 19 - sensitivity = -0.5; 20 - kb_layout = "us"; 21 - }; 22 - monitor = [ 23 - "desc:Samsung Electric Company Odyssey G60SD HNAX300205, 2560x1440@360, 0x0, 1, vrr, 1, bitdepth, 10" 24 - "desc:LG Electronics 27GL850 005NTPC4Q200, preferred, auto, 1, transform, 1, vrr, 1" 25 - ]; 26 - }; 27 17 }; 28 18 server = { 29 19 enable = true;
+2
modules/desktop/audio.nix
··· 36 36 }; 37 37 38 38 config = mkIf cfg.audio.enable { 39 + xdg.sounds.enable = true; 40 + 39 41 security.rtkit.enable = true; 40 42 41 43 services = {
+1 -6
modules/desktop/default.nix
··· 18 18 }; 19 19 } // helpers.linuxAttrs { 20 20 imports = [ 21 - ./session.nix 22 21 ./affinity.nix 23 22 ./fonts.nix 24 23 ./rawaccel.nix 25 24 ./audio.nix 26 25 ./networking.nix 27 - ./hyprland.nix 26 + ./niri-cosmic.nix 28 27 ]; 29 - 30 - config = mkIf cfg.enable { 31 - users.users."${user}".extraGroups = [ "video" ]; 32 - }; 33 28 }
-127
modules/desktop/hyprland.nix
··· 1 - { lib, pkgs, config, ... }: 2 - 3 - with lib; 4 - let 5 - cfg = config.modules.desktop; 6 - 7 - mkConfig = input: monitor: pkgs.writeText "hyprland.conf" '' 8 - debug { 9 - error_position=1 10 - } 11 - 12 - general { 13 - allow_tearing=true 14 - } 15 - 16 - input { 17 - touchpad { 18 - clickfinger_behavior=true 19 - scroll_factor=0.180000 20 - tap-and-drag=false 21 - tap-to-click=false 22 - } 23 - kb_options=ctrl:nocaps,lv3:ralt_switch 24 - kb_layout=${cfg.hyprland.input.kb_layout} 25 - kb_model=${cfg.hyprland.input.kb_model} 26 - kb_variant=${cfg.hyprland.input.kb_variant} 27 - sensitivity=${toString cfg.hyprland.input.sensitivity} 28 - accel_profile = "flat" 29 - } 30 - 31 - misc { 32 - disable_hyprland_logo=true 33 - disable_splash_rendering=true 34 - vrr=1 35 - } 36 - 37 - render { 38 - direct_scanout=1 39 - expand_undersized_textures=false 40 - cm_fs_passthrough=1 41 - cm_enabled=true 42 - } 43 - 44 - experimental { 45 - xx_color_management_v4=true 46 - } 47 - 48 - cursor { 49 - sync_gsettings_theme=false 50 - } 51 - 52 - ecosystem { 53 - no_update_news = true 54 - no_donation_nag = true 55 - } 56 - 57 - ${concatMapStringsSep "\n" (x: "monitor=${x}") cfg.hyprland.monitor} 58 - monitor=, preferred, auto, 1 59 - ''; 60 - in { 61 - options.modules.desktop.hyprland = { 62 - enable = mkOption { 63 - default = cfg.enable; 64 - example = true; 65 - description = "Whether to enable Hyprland"; 66 - type = types.bool; 67 - }; 68 - 69 - input = mkOption { 70 - default = { }; 71 - type = types.submodule { 72 - options = { 73 - sensitivity = mkOption { 74 - default = 0.0; 75 - type = types.float; 76 - }; 77 - kb_model = mkOption { 78 - default = "apple"; 79 - type = types.str; 80 - }; 81 - kb_variant = mkOption { 82 - default = "mac"; 83 - type = types.str; 84 - }; 85 - kb_layout = mkOption { 86 - default = "gb"; 87 - type = types.str; 88 - }; 89 - }; 90 - }; 91 - }; 92 - 93 - monitor = mkOption { 94 - description = "Monitor configuration"; 95 - default = [ ]; 96 - type = lib.types.listOf lib.types.str; 97 - }; 98 - 99 - configFile = mkOption { 100 - default = mkConfig cfg.hyprland.input cfg.hyprland.monitor; 101 - }; 102 - }; 103 - 104 - config = mkIf cfg.hyprland.enable { 105 - programs = { 106 - hyprlock.enable = true; 107 - hyprland = { 108 - enable = true; 109 - withUWSM = true; 110 - xwayland.enable = true; 111 - }; 112 - }; 113 - 114 - security.pam.services.hyprlock = {}; 115 - 116 - xdg.portal = { 117 - enable = true; 118 - xdgOpenUsePortal = true; 119 - extraPortals = with pkgs; [ 120 - xdg-desktop-portal-hyprland 121 - xdg-desktop-portal-gtk 122 - ]; 123 - }; 124 - 125 - environment.etc."hypr/hyprland.conf".source = cfg.hyprland.configFile; 126 - }; 127 - }
+273
modules/desktop/niri-cosmic.nix
··· 1 + { lib, pkgs, config, ... }: 2 + 3 + with lib; 4 + let 5 + cfg = config.modules.desktop; 6 + 7 + corePackages = with pkgs; [ 8 + niri 9 + config.services.displayManager.cosmic-greeter.package 10 + cosmic-applets 11 + cosmic-applibrary 12 + cosmic-bg 13 + cosmic-comp 14 + cosmic-files 15 + cosmic-idle 16 + cosmic-initial-setup 17 + cosmic-launcher 18 + cosmic-notifications 19 + cosmic-osd 20 + cosmic-panel 21 + cosmic-session 22 + cosmic-settings 23 + cosmic-settings-daemon 24 + cosmic-workspaces-epoch 25 + ]; 26 + 27 + supportPackages = with pkgs; [ 28 + adwaita-icon-theme 29 + alsa-utils 30 + glib 31 + hicolor-icon-theme 32 + playerctl 33 + pop-icon-theme 34 + pop-launcher 35 + pulseaudio 36 + xdg-user-dirs 37 + ]; 38 + 39 + optionalPackages = with pkgs; [ 40 + xwayland-satellite 41 + cosmic-icons 42 + cosmic-screenshot 43 + cosmic-wallpapers 44 + ]; 45 + 46 + cosmic-base-config = let 47 + configs = { 48 + "com.system76.CosmicComp/v1/workspaces" = '' 49 + ( 50 + workspace_mode: OutputBound, 51 + workspace_layout: Horizontal, 52 + ) 53 + ''; 54 + "com.system76.CosmicComp/v1/autotile_behavior" = '' 55 + PerWorkspace 56 + ''; 57 + }; 58 + fileDrvs = 59 + attrsets.mapAttrsToList 60 + (name: text: pkgs.writeTextDir "share/cosmic/${name}" text) 61 + configs; 62 + in pkgs.buildEnv { 63 + name = "cosmic-base-config"; 64 + paths = fileDrvs; 65 + pathsToLink = [ "/share/cosmic" ]; 66 + }; 67 + 68 + cosmic-ext-niri-desktop = let 69 + startCosmicExtNiri = pkgs.writeShellApplication { 70 + name = "start-cosmic-ext-niri"; 71 + runtimeInputs = with pkgs; [ systemd coreutils ]; 72 + text = with pkgs; /*sh*/'' 73 + set -e 74 + 75 + if systemctl --user -q is-active cosmic-niri-session.service; then 76 + exit 1 77 + fi 78 + 79 + for unit in $(systemctl --user --no-legend --state=failed --plain list-units | cut -f1 -d' '); do 80 + partof="$(systemctl --user show -p PartOf --value "$unit")" 81 + for target in cosmic-session.target graphical-session.target; do 82 + if [ "$partof" = "$target" ]; then 83 + systemctl --user reset-failed "$unit" 84 + break 85 + fi 86 + done 87 + done 88 + 89 + export XDG_CURRENT_DESKTOP="''${XDG_CURRENT_DESKTOP:=niri}" 90 + export XDG_SESSION_TYPE="''${XDG_SESSION_TYPE:=wayland}" 91 + export DCONF_PROFILE=cosmic 92 + 93 + systemctl --user import-environment XDG_SESSION_TYPE XDG_CURRENT_DESKTOP DCONF_PROFILE 94 + systemctl --user --wait start cosmic-niri-session.service 95 + 96 + systemctl --user start --job-mode=replace-irreversibly niri-shutdown.target 97 + systemctl --user unset-environment WAYLAND_DISPLAY DISPLAY XDG_SESSION_TYPE XDG_CURRENT_DESKTOP NIRI_SOCKET 98 + ''; 99 + }; 100 + in (pkgs.writeTextFile { 101 + name = "cosmic-on-niri"; 102 + destination = "/share/wayland-sessions/COSMIC-on-niri.desktop"; 103 + text = '' 104 + [Desktop Entry] 105 + Name=COSMIC-on-niri 106 + Comment=This session logs you into the COSMIC desktop on niri 107 + Type=Application 108 + DesktopNames=niri 109 + Exec=${getExe startCosmicExtNiri} 110 + ''; 111 + }).overrideAttrs (old: { 112 + passthru.providedSessions = [ "COSMIC-on-niri" ]; 113 + }); 114 + 115 + cosmic-ext-alternative-startup = pkgs.rustPlatform.buildRustPackage rec { 116 + pname = "cosmic-ext-alternative-startup"; 117 + version = "unstable-2024-11-24"; 118 + src = pkgs.fetchFromGitHub { 119 + owner = "drakulix"; 120 + repo = pname; 121 + rev = "8ceda00197c7ec0905cf1dccdc2d67d738e45417"; 122 + hash = "sha256-0kqn3hZ58uQMl39XXF94yQS1EWmGIK45/JFTAigg/3M="; 123 + }; 124 + cargoHash = "sha256-DeMkAG2iINGden0Up013M9mWDN4QHrF+FXoNqpGB+mg="; 125 + meta.mainProgram = pname; 126 + }; 127 + in { 128 + options.modules.desktop.niri-cosmic = { 129 + enable = mkOption { 130 + default = cfg.enable; 131 + example = true; 132 + description = "Whether to enable COSMIC on Niri"; 133 + type = types.bool; 134 + }; 135 + }; 136 + 137 + config = mkIf cfg.niri-cosmic.enable { 138 + boot = { 139 + plymouth.enable = true; 140 + initrd.verbose = mkDefault false; 141 + consoleLogLevel = 0; 142 + }; 143 + 144 + programs = { 145 + dconf = { 146 + enable = true; 147 + packages = [ pkgs.cosmic-session ]; 148 + }; 149 + }; 150 + 151 + environment = { 152 + pathsToLink = [ 153 + "/share/backgrounds" 154 + "/share/cosmic" 155 + "/share/cosmic-layouts" 156 + "/share/cosmic-themes" 157 + ]; 158 + systemPackages = corePackages ++ supportPackages ++ optionalPackages ++ [ 159 + cosmic-base-config 160 + cosmic-ext-alternative-startup 161 + ]; 162 + sessionVariables = { 163 + X11_BASE_RULES_XML = "${config.services.xserver.xkb.dir}/rules/base.xml"; 164 + X11_EXTRA_RULES_XML = "${config.services.xserver.xkb.dir}/rules/base.extras.xml"; 165 + 166 + GSK_RENDERER = mkDefault "ngl"; 167 + QT_QPA_PLATFORM = mkDefault "wayland;xcb"; 168 + GDK_BACKEND = mkDefault "wayland,x11,*"; 169 + SDL_VIDEODRIVER = mkDefault "wayland,x11"; 170 + NIXOS_OZONE_WL = mkDefault 1; 171 + COSMIC_DATA_CONTROL_ENABLED = mkDefault 1; 172 + }; 173 + }; 174 + 175 + hardware.system76.power-daemon.enable = mkDefault true; 176 + 177 + services = { 178 + graphical-desktop.enable = true; 179 + displayManager = { 180 + cosmic-greeter.enable = true; 181 + sessionPackages = [ cosmic-ext-niri-desktop ]; 182 + }; 183 + 184 + dbus = { 185 + enable = true; 186 + implementation = mkDefault "broker"; 187 + }; 188 + 189 + accounts-daemon.enable = true; 190 + libinput.enable = true; 191 + upower.enable = true; 192 + 193 + acpid.enable = mkDefault true; 194 + gnome.gnome-keyring.enable = mkDefault true; 195 + gvfs.enable = mkDefault true; 196 + 197 + logind.settings.Login = { 198 + powerKey = "suspend"; 199 + powerKeyLongPress = "poweroff"; 200 + lidSwitch = "suspend"; 201 + }; 202 + 203 + geoclue2 = { 204 + enable = true; 205 + enableDemoAgent = false; 206 + whitelistedAgents = [ "geoclue-demo-agent" ]; 207 + }; 208 + }; 209 + 210 + security = { 211 + polkit.enable = true; 212 + rtkit.enable = true; 213 + pam.services.cosmic-greeter = { }; 214 + }; 215 + 216 + systemd = { 217 + packages = with pkgs; [ cosmic-session niri ]; 218 + user.services = { 219 + cosmic-niri-session = let 220 + set-environment = config.system.build.setEnvironment; 221 + run-session = pkgs.writeShellScriptBin "run-cosmic-niri-session" /*sh*/'' 222 + source ${set-environment} 223 + ${getBin pkgs.dbus}/bin/dbus-update-activation-environment --systemd --all 224 + exec ${getBin pkgs.cosmic-session}/bin/cosmic-session ${getBin pkgs.niri}/bin/niri --session 225 + ''; 226 + in { 227 + bindsTo = [ "graphical-session.target" ]; 228 + serviceConfig = { 229 + Environment = [ 230 + "RUST_BACKTRACE=1" 231 + "RUST_LOG=info" 232 + ]; 233 + Type = "notify"; 234 + NotifyAccess = "all"; 235 + Slice = "session.slice"; 236 + Restart = "on-failure"; 237 + ExecStart = getExe run-session; 238 + }; 239 + }; 240 + }; 241 + }; 242 + 243 + xdg = { 244 + sounds.enable = true; 245 + icons.fallbackCursorThemes = mkDefault [ "Cosmic" ]; 246 + portal = { 247 + enable = true; 248 + xdgOpenUsePortal = true; 249 + configPackages = mkDefault [ pkgs.xdg-desktop-portal-cosmic ]; 250 + extraPortals = with pkgs; [ 251 + xdg-desktop-portal-gnome 252 + xdg-desktop-portal-cosmic 253 + xdg-desktop-portal-gtk 254 + ]; 255 + config.niri = { 256 + default = [ "gnome" "cosmic" "gtk" ]; 257 + "org.freedesktop.impl.portal.Access" = "gtk"; 258 + "org.freedesktop.impl.portal.Notification" = "gtk"; 259 + "org.freedesktop.impl.portal.Secret" = "gnome-keyring"; 260 + "org.freedesktop.impl.portal.FileChooser" = "gtk"; 261 + "org.freedesktop.impl.portal.ScreenCast" = "gnome"; 262 + "org.freedesktop.impl.portal.Screenshot" = "gnome"; 263 + }; 264 + }; 265 + }; 266 + 267 + fonts.packages = with pkgs; [ 268 + fira 269 + noto-fonts 270 + open-sans 271 + ]; 272 + }; 273 + }
-78
modules/desktop/session.nix
··· 1 - { lib, config, pkgs, user, ... } @ inputs: 2 - 3 - with lib; 4 - let 5 - inherit (import ../../lib/theme.nix inputs) cursorTheme defaultFont iconTheme gtkTheme kvantumTheme; 6 - cfg = config.modules.desktop; 7 - in { 8 - options.modules.desktop.session = { 9 - enable = mkOption { 10 - default = cfg.enable; 11 - example = true; 12 - description = "Whether to enable session and desktop environment."; 13 - type = types.bool; 14 - }; 15 - }; 16 - 17 - config = mkIf cfg.session.enable { 18 - users.users."${user}".extraGroups = [ "video" ]; 19 - 20 - boot = { 21 - plymouth.enable = true; 22 - initrd.verbose = mkDefault false; 23 - consoleLogLevel = 0; 24 - }; 25 - 26 - environment.sessionVariables = { 27 - GSK_RENDERER = mkDefault "ngl"; 28 - QT_QPA_PLATFORM = mkDefault "wayland;xcb"; 29 - GDK_BACKEND = mkDefault "wayland,x11,*"; 30 - SDL_VIDEODRIVER = mkDefault "wayland,x11"; 31 - NIXOS_OZONE_WL = mkDefault "1"; 32 - }; 33 - 34 - services = { 35 - greetd = { 36 - enable = true; 37 - settings = { 38 - terminal.vt = 1; 39 - default_session.command = let 40 - hyprConfig = pkgs.writeTextFile { 41 - name = "hyprland-greeter.conf"; 42 - text = '' 43 - source=${toString cfg.hyprland.configFile} 44 - exec-once = ${getExe config.programs.regreet.package}; hyprctl dispatch exit 45 - animations { 46 - enabled = false 47 - } 48 - ''; 49 - }; 50 - in escapeShellArgs [ 51 - "${pkgs.dbus}/bin/dbus-run-session" 52 - "${getExe pkgs.hyprland}" 53 - "-c" (toString hyprConfig) 54 - ]; 55 - }; 56 - }; 57 - upower.enable = true; 58 - gvfs.enable = true; 59 - logind.settings.Login = { 60 - powerKey = "suspend"; 61 - powerKeyLongPress = "poweroff"; 62 - lidSwitch = "suspend"; 63 - }; 64 - }; 65 - 66 - programs = { 67 - regreet = { 68 - enable = true; 69 - inherit cursorTheme iconTheme; 70 - font = defaultFont; 71 - theme = gtkTheme; 72 - settings.GTK.application_prefer_dark_theme = true; 73 - }; 74 - }; 75 - 76 - security.polkit.enable = true; 77 - }; 78 - }