diff --git a/flake.lock b/flake.lock index 4447c82..f03dd3b 100644 --- a/flake.lock +++ b/flake.lock @@ -299,6 +299,25 @@ "type": "github" } }, + "home-manager-cosmic": { + "inputs": { + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1727725142, + "narHash": "sha256-VHM8iZb1y/y0gOGD6Q/4Yey0OHczLrBNp6BLBiDwWFU=", + "owner": "tristanbeedell", + "repo": "home-manager", + "rev": "ed1eed53419d49d7de94e34678e3261dbdd07dfd", + "type": "github" + }, + "original": { + "owner": "tristanbeedell", + "ref": "cosmic", + "repo": "home-manager", + "type": "github" + } + }, "home-manager_2": { "inputs": { "nixpkgs": [ @@ -387,17 +406,18 @@ }, "nixpkgs": { "locked": { - "lastModified": 1727122398, - "narHash": "sha256-o8VBeCWHBxGd4kVMceIayf5GApqTavJbTa44Xcg5Rrk=", + "lastModified": 1722185531, + "narHash": "sha256-veKR07psFoJjINLC8RK4DiLniGGMgF3QMlS4tb74S6k=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "30439d93eb8b19861ccbe3e581abf97bdc91b093", + "rev": "52ec9ac3b12395ad677e8b62106f0b98c1f8569d", "type": "github" }, "original": { - "id": "nixpkgs", + "owner": "NixOS", "ref": "nixos-unstable", - "type": "indirect" + "repo": "nixpkgs", + "type": "github" } }, "nixpkgs-stable": { @@ -433,6 +453,21 @@ } }, "nixpkgs_2": { + "locked": { + "lastModified": 1727122398, + "narHash": "sha256-o8VBeCWHBxGd4kVMceIayf5GApqTavJbTa44Xcg5Rrk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "30439d93eb8b19861ccbe3e581abf97bdc91b093", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, + "nixpkgs_3": { "locked": { "lastModified": 1725534445, "narHash": "sha256-Yd0FK9SkWy+ZPuNqUgmVPXokxDgMJoGuNpMEtkfcf84=", @@ -448,7 +483,7 @@ "type": "github" } }, - "nixpkgs_3": { + "nixpkgs_4": { "locked": { "lastModified": 1725194671, "narHash": "sha256-tLGCFEFTB5TaOKkpfw3iYT9dnk4awTP/q4w+ROpMfuw=", @@ -517,8 +552,9 @@ "root": { "inputs": { "home-manager": "home-manager", + "home-manager-cosmic": "home-manager-cosmic", "nixos-cosmic": "nixos-cosmic", - "nixpkgs": "nixpkgs", + "nixpkgs": "nixpkgs_2", "nixvim": "nixvim", "sops-nix": "sops-nix", "stylix": "stylix" @@ -547,7 +583,7 @@ }, "sops-nix": { "inputs": { - "nixpkgs": "nixpkgs_2", + "nixpkgs": "nixpkgs_3", "nixpkgs-stable": "nixpkgs-stable_2" }, "locked": { @@ -574,7 +610,7 @@ "flake-utils": "flake-utils_2", "gnome-shell": "gnome-shell", "home-manager": "home-manager_3", - "nixpkgs": "nixpkgs_3", + "nixpkgs": "nixpkgs_4", "systems": "systems_2", "tinted-foot": "tinted-foot", "tinted-kitty": "tinted-kitty", diff --git a/flake.nix b/flake.nix index 918ca2d..060f1ce 100644 --- a/flake.nix +++ b/flake.nix @@ -6,6 +6,9 @@ url = "github:nix-community/home-manager/master"; inputs.nixpkgs.follows = "nixpkgs"; }; + home-manager-cosmic = { + url = "github:tristanbeedell/home-manager/cosmic"; + }; stylix.url = "github:danth/stylix"; sops-nix.url = "github:Mic92/sops-nix"; nixos-cosmic = { diff --git a/home/desktop/cosmic/default.nix b/home/desktop/cosmic/default.nix new file mode 100644 index 0000000..d87403b --- /dev/null +++ b/home/desktop/cosmic/default.nix @@ -0,0 +1,208 @@ +{pkgs, config, ...}: let + bind = mods: key: action: { + modifiers = ["Super"] ++ mods; + inherit key action; + }; + _action = type: value: { + inherit type value; + }; + Actions = (enum [ + # Close the active window + "Close" + + # Show a debug overlay if enabled in the compositor build + "Debug" + + # Disable a default shortcut binding + "Disable" + + # Change focus to the last workspace + "LastWorkspace" + + # Maximize the active window + "Maximize" + + # Migrate the active workspace to the next output + "MigrateWorkspaceToNextOutput" + + # Migrate the active workspace to the previous output + "MigrateWorkspaceToPreviousOutput" + + # Minimize the active window + "Minimize" + + # Move a window to the last workspace + "MoveToLastWorkspace" + + # Move a window to the next output + "MoveToNextOutput" + + # Move a window to the next workspace + "MoveToNextWorkspace" + + # Move a window to the previous output + "MoveToPreviousOutput" + + # Move a window to the previous workspace + "MoveToPreviousWorkspace" + + # Change focus to the next output + "NextOutput" + + # Change focus to the next workspace + "NextWorkspace" + + # Change focus to the previous output + "PreviousOutput" + + # Change focus to the previous workspace + "PreviousWorkspace" + + # Move a window to the last workspace + "SendToLastWorkspace" + + # Move a window to the next output + "SendToNextOutput" + + # Move a window to the next workspace + "SendToNextWorkspace" + + # Move a window to the previous output + "SendToPreviousOutput" + + # Move a window to the previous workspace + "SendToPreviousWorkspace" + + # Swap positions of the active window with another + "SwapWindow" + + # Stop the compositor + "Terminate" + + # Toggle the orientation of a tiling group + "ToggleOrientation" + + # Toggle window stacking for the active window + "ToggleStacking" + + # Toggle the sticky state of the active window + "ToggleSticky" + + # Toggle tiling mode of the active workspace + "ToggleTiling" + + # Toggle between tiling and floating window states for the active window + "ToggleWindowFloating" + + ]) // { + + # Change focus to the window or workspace in the given direction + "Focus" = FocusDirection: _action "Focus" FocusDirection; + # Migrate the active workspace to the output in the given direction + "MigrateWorkspaceToOutput" = Direction: _action "MigrateWorkspaceToOutput" Direction; + # Move a window in the given direction + Move = Direction: _action "Move" Direction; + # Move a window to the given output + MoveToOutput = Direction: _action "MoveToOutput" Direction; + # Move a window to the given workspace + MoveToWorkspace = u8: _action "MoveToWorkspace" u8; + # Change the orientation of a tiling group + Orientation = Orientation: _action "Orientation" Orientation; + # Resize the active window in a given direction + Resizing = ResizeDirection: _action "Resizing" ResizeDirection; + # Move a window to the output in the given direction + SendToOutput = Direction: _action "SendToOutput" Direction; + # Move a window to the given workspace + SendToWorkspace = u8: _action "SendToWorkspace" u8; + # Move to an output in the given direction + SwitchOutput = Direction: _action "SwitchOutput" Direction; + # Perform a common system operation + System = System: _action "System" System; + # Execute a command with any given arguments + Spawn = String: _action "Spawn" String; + # Change focus to the given workspace ID + Workspace = u8: _action "Workspace" u8; + + }; + + Modifiers = enum [ + "Super" + "Ctrl" + "Alt" + "Shift" + ]; + + enum = builtins.foldl' (acc: el: {${el}=el;} // acc) {}; + +in with Modifiers; { + programs.cosmic = { + enable = true; + defaultKeybindings = false; + keybindings = [ +# Navigation + (bind [Super] "h" (Actions.Focus "Left")) + (bind [Super] "l" (Actions.Focus "Right")) + (bind [Super] "j" (Actions.Focus "Down")) + (bind [Super] "k" (Actions.Focus "Up")) + (bind [Super Shift] "h" (Actions.Move "Left")) + (bind [Super Shift] "l" (Actions.Move "Right")) + (bind [Super Shift] "j" (Actions.Move "Down")) + (bind [Super Shift] "k" (Actions.Move "Up")) + + (bind [Super] "1" (Actions.Workspace 1)) + (bind [Super] "2" (Actions.Workspace 2)) + (bind [Super] "3" (Actions.Workspace 3)) + (bind [Super] "4" (Actions.Workspace 4)) + (bind [Super] "5" (Actions.Workspace 5)) + (bind [Super Shift] "1" (Actions.MoveToWorkspace 1)) + (bind [Super Shift] "2" (Actions.MoveToWorkspace 2)) + (bind [Super Shift] "3" (Actions.MoveToWorkspace 3)) + (bind [Super Shift] "4" (Actions.MoveToWorkspace 4)) + (bind [Super Shift] "5" (Actions.MoveToWorkspace 5)) + + (bind [Super] "Space" Actions.ToggleWindowFloating) + (bind [Super] "f" Actions.Maximize) + (bind [Super] "m" Actions.Minimize) + (bind [Super Shift] "x" Actions.Close) + + (bind [Super Shift] "v" Actions.ToggleStacking) + (bind [Super Shift] "y" Actions.ToggleSticky) +# System + (bind [Super] "d" (Actions.Spawn config.programs.menu.drunCommand)) + (bind [Super] "Return" (Actions.Spawn "${pkgs.alacritty}/bin/alacritty")) + (bind [Super] "o" (Actions.System "HomeFolder")) + (bind [Super Shift] "s" (Actions.Spawn "cosmic-screenshot")) + ]; + background = { + displays = { + all = { + source = ../../../images/nier2.jpg; + }; + }; + }; + panels = { + Panel = { + applets = { + start = [ "com.system76.CosmicAppletWorkspaces" ]; + center = [ "com.system76.CosmicAppList" ]; + end = [ + "com.system76.CosmicAppletTime" + "com.system76.CosmicAppletAudio" + "com.system76.CosmicAppletNotifications" + "com.system76.CosmicAppletMinimize" + "com.system76.CosmicAppletPower" + ]; + }; + }; + }; + settings = { + "com.system76.CosmicComp".options = { + autotile = true; + active_hint = true; + focus_follows_cursor = true; + focus_follows_cursor_delay = 0; + cursor_follows_focus = true; + }; + }; + }; +} diff --git a/home/programs/lf/default.nix b/home/programs/lf/default.nix index d63dc3b..a0b3a17 100644 --- a/home/programs/lf/default.nix +++ b/home/programs/lf/default.nix @@ -37,6 +37,7 @@ in { R = "drag"; "" = ":rename"; "" = "open-with"; + "" = ":reload"; }; programs.lf.extraConfig = '' set sixel true diff --git a/nixos/programs/cosmic.nix b/nixos/programs/cosmic.nix index f343d5c..b5cbed6 100644 --- a/nixos/programs/cosmic.nix +++ b/nixos/programs/cosmic.nix @@ -1,4 +1,4 @@ -{inputs, ...}: { +{inputs, config, ...}: { imports = [ inputs.nixos-cosmic.nixosModules.default ]; @@ -8,4 +8,9 @@ }; services.desktopManager.cosmic.enable = true; services.displayManager.cosmic-greeter.enable = true; + services.system76-scheduler.enable = true; + home-manager.users.${config.user}.imports = [ + (import "${inputs.home-manager-cosmic}/modules/programs/cosmic/.") + ../../home/desktop/cosmic/. + ]; }