From 6c6556b8d65426b2744e79d2045a110dcf732718 Mon Sep 17 00:00:00 2001 From: notgne2 Date: Mon, 26 Dec 2022 22:29:11 -0700 Subject: [PATCH] update and move inputs, WIP ezpc hyprland, improve elvish module, improve locking, disable systemd initrd by default --- flake.lock | 163 ++++++++++++++++++++++--------- flake.nix | 16 +++ home-manager/common.nix | 6 +- home-manager/modules/elvish.nix | 61 ++++++------ home-manager/modules/ezpcusr.nix | 83 +++++++++++++++- modules/workstation.nix | 5 +- 6 files changed, 255 insertions(+), 79 deletions(-) diff --git a/flake.lock b/flake.lock index 6ccc147..fee5d78 100644 --- a/flake.lock +++ b/flake.lock @@ -144,32 +144,52 @@ "type": "github" } }, + "flake-utils": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "home-manager": { "inputs": { "nixpkgs": [ - "plasma-manager", "nixpkgs" + ], + "utils": [ + "flake-utils" ] }, "locked": { - "lastModified": 1654113405, - "narHash": "sha256-VpK+0QaWG2JRgB00lw77N9TjkE3ec0iMYIX1TzGpxa4=", + "lastModified": 1671966569, + "narHash": "sha256-jbLgfSnmLchARBNFRvCic63CFQ9LAyvlXnBpc2kwjQc=", "owner": "nix-community", "repo": "home-manager", - "rev": "ac2287df5a2d6f0a44bbcbd11701dbbf6ec43675", + "rev": "c55fa26ce05fee8e063db22918d05a73d430b2ea", "type": "github" }, "original": { "owner": "nix-community", - "ref": "release-22.05", "repo": "home-manager", "type": "github" } }, "home-manager-clipman": { "inputs": { - "nixpkgs": "nixpkgs", - "utils": "utils" + "nixpkgs": [ + "nixpkgs" + ], + "utils": [ + "flake-utils" + ] }, "locked": { "lastModified": 1666272074, @@ -186,23 +206,62 @@ "type": "github" } }, - "nixpkgs": { + "hyprland": { + "inputs": { + "hyprland-protocols": "hyprland-protocols", + "nixpkgs": [ + "nixpkgs" + ], + "wlroots": "wlroots", + "xdph": "xdph" + }, "locked": { - "lastModified": 1662996720, - "narHash": "sha256-XvLQ3SuXnDMJMpM1sv1ifPjBuRytiDYhB12H/BNTjgY=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "5f326e2a403e1cebaec378e72ceaf5725983376d", + "lastModified": 1671982931, + "narHash": "sha256-cRInW7YYjw9xbjDTYOQD9PGo04aPAJWWu78PQ1HPkiQ=", + "owner": "hyprwm", + "repo": "Hyprland", + "rev": "cd08fa22fd1ddbb8604e42d01043617a8eb10520", "type": "github" }, "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", + "owner": "hyprwm", + "repo": "Hyprland", "type": "github" } }, - "nixpkgs_2": { + "hyprland-protocols": { + "flake": false, + "locked": { + "lastModified": 1670703428, + "narHash": "sha256-4KUW5SKR0Y9uaYGcYwy53YJ3B/sgiprCL4fRGO+mpOA=", + "owner": "hyprwm", + "repo": "hyprland-protocols", + "rev": "d0d6db8cb5bef6d93ca3ad8fb2124964173396da", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprland-protocols", + "type": "github" + } + }, + "hyprland-protocols_2": { + "flake": false, + "locked": { + "lastModified": 1670703428, + "narHash": "sha256-4KUW5SKR0Y9uaYGcYwy53YJ3B/sgiprCL4fRGO+mpOA=", + "owner": "hyprwm", + "repo": "hyprland-protocols", + "rev": "d0d6db8cb5bef6d93ca3ad8fb2124964173396da", + "type": "github" + }, + "original": { + "owner": "hyprwm", + "repo": "hyprland-protocols", + "type": "github" + } + }, + "nixpkgs": { "locked": { "lastModified": 1670841420, "narHash": "sha256-mSEia1FzrsHbfqjorMyYiX8NXdDVeR1Pw1k55jMJlJY=", @@ -218,22 +277,6 @@ "type": "github" } }, - "nixpkgs_3": { - "locked": { - "lastModified": 1655643053, - "narHash": "sha256-8PMDEr44DwH45PbBijtQcAPyC4Ap+sOO5wK0y5lFvyY=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "5afb1b7dcf46c4ded5719525a42879b35363862c", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-22.05", - "repo": "nixpkgs", - "type": "github" - } - }, "npmlock2nix": { "flake": false, "locked": { @@ -252,8 +295,12 @@ }, "plasma-manager": { "inputs": { - "home-manager": "home-manager", - "nixpkgs": "nixpkgs_3" + "home-manager": [ + "home-manager" + ], + "nixpkgs": [ + "nixpkgs" + ] }, "locked": { "lastModified": 1664383871, @@ -280,8 +327,11 @@ "bemoji": "bemoji", "bwmenu": "bwmenu", "firenvim": "firenvim", + "flake-utils": "flake-utils", + "home-manager": "home-manager", "home-manager-clipman": "home-manager-clipman", - "nixpkgs": "nixpkgs_2", + "hyprland": "hyprland", + "nixpkgs": "nixpkgs", "npmlock2nix": "npmlock2nix", "plasma-manager": "plasma-manager", "rycee": "rycee", @@ -320,18 +370,43 @@ "type": "github" } }, - "utils": { + "wlroots": { + "flake": false, "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "host": "gitlab.freedesktop.org", + "lastModified": 1671723353, + "narHash": "sha256-G1jiI0SA7eiZusO+iJytErMRNbKbwqJJJGL+sNoBNoQ=", + "owner": "wlroots", + "repo": "wlroots", + "rev": "b28a9afd4b0b86e9a66a40f6b44b69f59947b7d6", + "type": "gitlab" + }, + "original": { + "host": "gitlab.freedesktop.org", + "owner": "wlroots", + "repo": "wlroots", + "type": "gitlab" + } + }, + "xdph": { + "inputs": { + "hyprland-protocols": "hyprland-protocols_2", + "nixpkgs": [ + "hyprland", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1671837878, + "narHash": "sha256-OmFDyktTc/l+3wHboHeFpAQgPt3r7jjqZf8MrwuUGMo=", + "owner": "hyprwm", + "repo": "xdg-desktop-portal-hyprland", + "rev": "e47f4cec698080768821b271510985ab94a37e91", "type": "github" }, "original": { - "owner": "numtide", - "repo": "flake-utils", + "owner": "hyprwm", + "repo": "xdg-desktop-portal-hyprland", "type": "github" } } diff --git a/flake.nix b/flake.nix index 20cce59..db654ba 100644 --- a/flake.nix +++ b/flake.nix @@ -2,6 +2,14 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + + home-manager = { + url = "github:nix-community/home-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.utils.follows = "flake-utils"; + }; + base16-rofi = { url = "github:tinted-theming/base16-rofi"; flake = false; @@ -44,6 +52,8 @@ }; plasma-manager = { url = "github:pjones/plasma-manager"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.home-manager.follows = "home-manager"; }; bemoji = { url = "github:marty-oehme/bemoji"; @@ -55,6 +65,12 @@ }; home-manager-clipman = { url = "github:jwygoda/home-manager/clipman"; + inputs.nixpkgs.follows = "nixpkgs"; + inputs.utils.follows = "flake-utils"; + }; + hyprland = { + url = "github:hyprwm/Hyprland"; + inputs.nixpkgs.follows = "nixpkgs"; }; }; diff --git a/home-manager/common.nix b/home-manager/common.nix index ec1243a..d80faa0 100644 --- a/home-manager/common.nix +++ b/home-manager/common.nix @@ -4,7 +4,11 @@ inputs: { pkgs, ... }: { - imports = [(import ./modules inputs) "${inputs.home-manager-clipman}/modules/services/clipman.nix"]; + imports = [ + (import ./modules inputs) + "${inputs.home-manager-clipman}/modules/services/clipman.nix" + inputs.hyprland.homeManagerModules.default + ]; programs.direnv = { enable = lib.mkDefault true; diff --git a/home-manager/modules/elvish.nix b/home-manager/modules/elvish.nix index 60042c7..78c6ee1 100644 --- a/home-manager/modules/elvish.nix +++ b/home-manager/modules/elvish.nix @@ -7,6 +7,30 @@ with lib; let cfg = config.programs.elvish; in { + options.programs.starship.elvishIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Elvish integration. + ''; + }; + + options.programs.zoxide.elvishIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Elvish integration. + ''; + }; + + options.programs.direnv.elvishIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Elvish integration. + ''; + }; + options.programs.elvish = { enable = mkEnableOption "Elvish, a friendly interactive shell and an expressive programming"; @@ -18,30 +42,6 @@ in { ''; }; - zoxide = mkOption { - type = types.bool; - default = false; - description = '' - Enable zoxide smart directory switcher - ''; - }; - - starship = mkOption { - type = types.bool; - default = false; - description = '' - Use the starship prompt - ''; - }; - - direnv = mkOption { - type = types.bool; - default = false; - description = '' - Enable direnv integration for elvish - ''; - }; - package = mkOption { type = types.package; default = pkgs.elvish; @@ -73,22 +73,21 @@ in { exec elvish ''; + # Don't do things twice if we're just passing through :) programs.starship.enableBashIntegration = mkIf cfg.defaultFromBash false; - - programs.starship.enable = mkIf cfg.starship true; - programs.zoxide.enable = mkIf cfg.zoxide true; - programs.direnv.enable = mkIf cfg.direnv true; + programs.zoxide.enableBashIntegration = mkIf cfg.defaultFromBash false; + programs.direnv.enableBashIntegration = mkIf cfg.defaultFromBash false; programs.elvish.initExtra = mkMerge [ - (mkIf cfg.starship '' + (mkIf (config.programs.starship.elvishIntegration && config.programs.starship.enable) '' if (and (not-eq $E:TERM "dumb") (or (not (has-env "INSIDE_EMACS")) (eq $E:INSIDE_EMACS "vterm"))) { eval (${config.home.profileDirectory}/bin/starship init elvish) } '') - (mkIf cfg.zoxide '' + (mkIf (config.programs.zoxide.elvishIntegration && config.programs.zoxide.enable) '' eval (${config.programs.zoxide.package}/bin/zoxide init elvish | slurp) '') - (mkIf cfg.direnv '' + (mkIf (config.programs.direnv.elvishIntegration && config.programs.direnv.enable) '' eval (${pkgs.direnv}/bin/direnv hook elvish | ${pkgs.gnused}/bin/sed 's/except/catch/' | slurp) '') ]; diff --git a/home-manager/modules/ezpcusr.nix b/home-manager/modules/ezpcusr.nix index 124de5a..1905aeb 100644 --- a/home-manager/modules/ezpcusr.nix +++ b/home-manager/modules/ezpcusr.nix @@ -91,18 +91,22 @@ in { events = [ { event = "before-sleep"; - command = "${lockCommand}"; + command = "${pkgs.systemd}/bin/loginctl lock-session"; } { event = "lock"; command = "${lockCommand}"; } + { + event = "unlock"; + command = "${pkgs.procps}/bin/pkill -USR1 swaylock"; + } ]; timeouts = [ { timeout = cfg.screensaver.lockTime; - command = "${lockCommand}"; + command = "${pkgs.systemd}/bin/loginctl lock-session"; } { timeout = cfg.screensaver.offTime; @@ -112,6 +116,81 @@ in { ]; }; + wayland.windowManager.hyprland = { + enable = false; + systemdIntegration = true; + extraConfig = let + swayConfig = config.wayland.windowManager.sway.config; + swayBindings = swayConfig.keybindings; + swayToHyprlandBinding = key: binding: let + splitKey = lib.splitString "+" key; + + isMod = m: m == "Mod4" || m == "Shift"; + convertMod = m: + if m == "Mod4" + then "SUPER" + else lib.toUpper m; + + mods = filter isMod splitKey; + modsStr = "${(lib.concatStringsSep "_" (map convertMod mods))},"; + + normalKeys = filter (m: isMod m == false) splitKey; + normalKey = lib.elemAt normalKeys 0; + + convertedKey = "${modsStr}${normalKey}"; + + convertDir = dir: lib.elemAt (lib.stringToCharacters dir) 0; + + splitBinding = lib.splitString " " binding; + bindingAction = lib.elemAt splitBinding 0; + newBinding = + if bindingAction == "exec" + then "exec, ${lib.concatStringsSep " " (lib.tail splitBinding)}" + else if bindingAction == "workspace" + then let n = lib.last splitBinding; in "workspace, ${n}" + else if bindingAction == "kill" + then "killactive," + else if bindingAction == "focus" + then let + l = lib.last splitBinding; + in + if l == "mode_toggle" + then "togglefloating," + else "movefocus,${convertDir l}" + else if bindingAction == "fullscreen" + then "fullscreen,0" + else if bindingAction == "floating" + then "togglefloating," + else if bindingAction == "move" + then let + splitMove = lib.tail splitBinding; + moveThing = lib.elemAt splitMove 0; + toThing = + if lib.length splitMove >= 3 + then lib.elemAt splitMove 2 + else null; + in + if toThing == null + then "movewindow,${convertDir moveThing}" + else if moveThing == "container" && toThing == "workspace" + then "movetoworkspacesilent,${lib.last splitMove}" + else null + else null; + in + if newBinding == null + then "# ${key} - ${binding}" + else "bind=${convertedKey}, ${newBinding}"; + convertedBindings = lib.concatStringsSep "\n" (lib.mapAttrsToList swayToHyprlandBinding swayBindings); + bindingsStr = "${convertedBindings}\n"; + in '' + monitor=,preferred,auto,auto + gestures { + workspace_swipe = on + } + ${convertedBindings} + ''; + }; + wayland.windowManager.sway = { enable = lib.mkDefault true; diff --git a/modules/workstation.nix b/modules/workstation.nix index 1bdfc02..8e9a13b 100644 --- a/modules/workstation.nix +++ b/modules/workstation.nix @@ -24,7 +24,10 @@ in { config = mkIf cfg.enable { boot.plymouth.enable = lib.mkDefault true; - boot.initrd.systemd.enable = lib.mkDefault true; + # as soon as this stops breaking _all_ my machines + boot.initrd.systemd.enable = lib.mkDefault false; + # until https://github.com/NixOS/nixpkgs/pull/199784 is merged + systemd.services.plymouth-start.restartIfChanged = false; services.avahi = { enable = lib.mkDefault true;