diff options
author | Fernando Ayats <[email protected]> | 2022-05-21 12:07:55 +0200 |
---|---|---|
committer | Fernando Ayats <[email protected]> | 2022-05-21 12:07:55 +0200 |
commit | 9d89e0f08e1782ddeefa030755805387fb14dccf (patch) | |
tree | 2017d900f5cddfedd0fb381b2a4cbe8aaa0c6d9c | |
parent | b3276d32077b7883e4cede784b6598fc3ca403c0 (diff) | |
download | Hyprland-9d89e0f08e1782ddeefa030755805387fb14dccf.tar.gz Hyprland-9d89e0f08e1782ddeefa030755805387fb14dccf.zip |
nix: add nixos module
-rw-r--r-- | flake.nix | 26 | ||||
-rw-r--r-- | module.nix | 62 |
2 files changed, 80 insertions, 8 deletions
@@ -14,32 +14,42 @@ nixpkgs, ... }: let - supportedSystems = [ - "aarch64-linux" + inherit (nixpkgs) lib; + genSystems = lib.genAttrs [ "x86_64-linux" ]; - genSystems = nixpkgs.lib.genAttrs supportedSystems; pkgsFor = nixpkgs.legacyPackages; + # https://github.com/NixOS/rfcs/pull/107 + mkVersion = longDate: + lib.concatStrings [ + "0.pre" + "+date=" + (lib.concatStringsSep "-" [ + (__substring 0 4 longDate) + (__substring 4 2 longDate) + (__substring 6 2 longDate) + ]) + ]; in { packages = genSystems (system: { wlroots = pkgsFor.${system}.wlroots.overrideAttrs (prev: { - version = inputs.wlroots.lastModifiedDate; + version = mkVersion inputs.wlroots.lastModifiedDate; src = inputs.wlroots; }); default = pkgsFor.${system}.callPackage ./default.nix { - version = self.lastModifiedDate; + version = mkVersion self.lastModifiedDate; inherit (self.packages.${system}) wlroots; }; }); formatter = genSystems (system: pkgsFor.${system}.alejandra); - # TODO Provide a nixos module for easy installation and configuration - # nixosModules.default = import ./module.nix; + nixosModules.default = import ./module.nix self; # Deprecated - overlay = _: prev: { + overlays.default = _: prev: { hyprland = self.packages.${prev.system}.default; }; + overlay = self.overlays.default; }; } diff --git a/module.nix b/module.nix new file mode 100644 index 00000000..a7460b34 --- /dev/null +++ b/module.nix @@ -0,0 +1,62 @@ +# Copied from https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/programs/sway.nix +self: { + config, + lib, + pkgs, + ... +}: +with lib; let + cfg = config.programs.hyprland; +in { + options.programs.hyprland = { + enable = mkEnableOption '' + Hyprland, the dynamic tiling Wayland compositor that doesn't sacrifice on its looks. + You can manually launch Hyprland by executing "exec Hyprland" on a TTY. + A configuration file will be generated in ~/.config/hypr/hyprland.conf. + See <link xlink:href="https://github.com/vaxerski/Hyprland/wiki" /> for + more information. + ''; + + package = mkOption { + type = types.package; + default = self.packages.${pkgs.system}.default; + defaultText = literalExpression "<Hyprland flake>.packages.<system>.default"; + example = literalExpression "<Hyprland flake>.packages.<system>.default.override { }"; + description = '' + Hyprland package to use. + ''; + }; + + extraPackages = mkOption { + type = with types; listOf package; + default = with pkgs; [ + kitty + wofi + swaybg + ]; + defaultText = literalExpression '' + with pkgs; [ kitty wofi swaybg ]; + ''; + example = literalExpression '' + with pkgs; [ + alacritty wofi + ] + ''; + description = '' + Extra packages to be installed system wide. + ''; + }; + }; + + config = mkIf cfg.enable { + environment.systemPackages = [cfg.package] ++ cfg.extraPackages; + security.polkit.enable = true; + hardware.opengl.enable = mkDefault true; + fonts.enableDefaultFonts = mkDefault true; + programs.dconf.enable = mkDefault true; + services.xserver.displayManager.sessionPackages = [cfg.package]; + programs.xwayland.enable = mkDefault true; + xdg.portal.enable = mkDefault true; + xdg.portal.extraPortals = [pkgs.xdg-desktop-portal-wlr]; + }; +} |