From 0879b52630a809d74d813c92d9f853b4d60641a3 Mon Sep 17 00:00:00 2001 From: reo101 Date: Sun, 12 Feb 2023 01:32:13 +0200 Subject: [PATCH] feat!(flake): update `homix` Add more & generalize flake outputs: - templates: just a `default.nix` (TODO: add a `Haskell` template) - packages & devShells: create and use `forEachPkgs` Add more `Wayland` things for `homix`: - `swww` - custom package + custom systemd service (TODO: abstract away) - `wired` - from flake + `home-manager` module Add default `imports` and `nixokgs.overlays` for `reo101@homix` -- TODO: don't handwire it, somehow *auto-import* from `mkNixosHost` in `flake.nix` --- flake.lock | 76 ++++++ flake.nix | 39 ++- .../x86_64-linux/__template__}/home.nix | 0 .../__template__}/configuration.nix | 0 .../__template__}/hardware-configuration.nix | 0 .../x86_64-linux/homix/{ => configs}/river | 0 .../x86_64-linux/homix/configs/wired.ron | 239 ++++++++++++++++++ .../nixos/x86_64-linux/homix/home/reo101.nix | 80 ++++-- modules/nixos/jellyfin.nix | 60 +++++ overlays/default.nix | 1 + pkgs/default.nix | 1 + pkgs/swww/default.nix | 32 +++ templates/default.nix | 6 + 13 files changed, 499 insertions(+), 35 deletions(-) rename {templates/home-manager/djam => machines/home-manager/x86_64-linux/__template__}/home.nix (100%) rename {templates/nixos/arthur => machines/nixos/x86_64-linux/__template__}/configuration.nix (100%) rename {templates/nixos/arthur => machines/nixos/x86_64-linux/__template__}/hardware-configuration.nix (100%) rename machines/nixos/x86_64-linux/homix/{ => configs}/river (100%) create mode 100644 machines/nixos/x86_64-linux/homix/configs/wired.ron create mode 100644 modules/nixos/jellyfin.nix create mode 100644 pkgs/swww/default.nix create mode 100644 templates/default.nix diff --git a/flake.lock b/flake.lock index ecc9cd0..b0e18c9 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,27 @@ { "nodes": { + "alejandra": { + "inputs": { + "flakeCompat": "flakeCompat", + "nixpkgs": [ + "wired", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1652974241, + "narHash": "sha256-0AolxQtKj3Oek0WSbODDpPVO5Ih8PXHOA3qXEKPB4dQ=", + "owner": "kamadorueda", + "repo": "alejandra", + "rev": "0be1462419fc73270a5dc0f84f8092603890b029", + "type": "github" + }, + "original": { + "owner": "kamadorueda", + "repo": "alejandra", + "type": "github" + } + }, "flake-compat": { "flake": false, "locked": { @@ -108,6 +130,22 @@ "type": "github" } }, + "flakeCompat": { + "flake": false, + "locked": { + "lastModified": 1648199409, + "narHash": "sha256-JwPKdC2PoVBkG6E+eWw3j6BMR6sL3COpYWfif7RVb8Y=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "64a525ee38886ab9028e6f61790de0832aa3ef03", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, "gitignore": { "inputs": { "nixpkgs": [ @@ -385,6 +423,7 @@ "nix-darwin": "nix-darwin", "nix-on-droid": "nix-on-droid", "nixpkgs": "nixpkgs_2", + "wired": "wired", "zig-overlay": "zig-overlay", "zls-overlay": "zls-overlay" } @@ -420,6 +459,43 @@ "type": "github" } }, + "utils_2": { + "locked": { + "lastModified": 1652776076, + "narHash": "sha256-gzTw/v1vj4dOVbpBSJX4J0DwUR6LIyXo7/SuuTJp1kM=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "04c1b180862888302ddfb2e3ad9eaa63afc60cf8", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "wired": { + "inputs": { + "alejandra": "alejandra", + "nixpkgs": [ + "nixpkgs" + ], + "utils": "utils_2" + }, + "locked": { + "lastModified": 1671338321, + "narHash": "sha256-Nm/DarDGFYP+ocPcoEYh4guKXH+jndREtMl0VKMSYF8=", + "owner": "Toqozz", + "repo": "wired-notify", + "rev": "f4300acba8180f8fc6babc1a118f9b3753a2b052", + "type": "github" + }, + "original": { + "owner": "Toqozz", + "repo": "wired-notify", + "type": "github" + } + }, "zig-overlay": { "inputs": { "flake-compat": "flake-compat_2", diff --git a/flake.nix b/flake.nix index 8ed8451..5e422fc 100644 --- a/flake.nix +++ b/flake.nix @@ -51,6 +51,11 @@ url = "github:zigtools/zls"; inputs.nixpkgs.follows = "nixpkgs"; }; + + wired = { + url = "github:Toqozz/wired-notify"; + inputs.nixpkgs.follows = "nixpkgs"; + }; }; outputs = @@ -64,32 +69,47 @@ , neovim-nightly-overlay , zig-overlay , zls-overlay + , wired , ... } @ inputs: let inherit (self) outputs; helpers = (import ./lib/helpers.nix) { lib = nixpkgs.lib; }; inherit (helpers) recurseDir hasFiles hasDirectories; - forAllSystems = nixpkgs.lib.genAttrs [ + forEachSystem = nixpkgs.lib.genAttrs [ "aarch64-linux" "i686-linux" "x86_64-linux" "aarch64-darwin" "x86_64-darwin" ]; + forEachPkgs = f: forEachSystem (system': f nixpkgs.legacyPackages.${system'}); in rec { - packages = forAllSystems (system: - let pkgs = nixpkgs.legacyPackages.${system}; - in import ./pkgs { inherit pkgs; } + # Packages (`nix build`) + packages = forEachPkgs (pkgs: + import ./pkgs { inherit pkgs; } ); - devShells = forAllSystems (system: - let pkgs = nixpkgs.legacyPackages.${system}; - in import ./shell.nix { inherit pkgs; } + # Apps (`nix run`) + apps = {}; + apps.default = null; + + # Dev Shells (`nix develop`) + devShells = forEachPkgs (pkgs: + import ./shell.nix { inherit pkgs; } ); - overlays = import ./overlays; + # Formatter + formatter = forEachPkgs (pkgs: + pkgs.nixpkgs-fmt + ); + + # Templates + templates = import ./templates; + + # Overlays + overlays = import ./overlays { inherit inputs outputs; }; # Modules nixosModules = import ./modules/nixos; @@ -118,9 +138,6 @@ users = nixpkgs.lib.attrsets.genAttrs users (user: import ./machines/nixos/${system}/${hostname}/home/${user}.nix); - # (user: args: - # let home = import ./machines/nixos/${system}/${hostname}/home/${user}.nix args; - # in home // { imports = (home.imports or []) ++ homeManagerModules; }); extraSpecialArgs = { inherit inputs outputs; diff --git a/templates/home-manager/djam/home.nix b/machines/home-manager/x86_64-linux/__template__/home.nix similarity index 100% rename from templates/home-manager/djam/home.nix rename to machines/home-manager/x86_64-linux/__template__/home.nix diff --git a/templates/nixos/arthur/configuration.nix b/machines/nixos/x86_64-linux/__template__/configuration.nix similarity index 100% rename from templates/nixos/arthur/configuration.nix rename to machines/nixos/x86_64-linux/__template__/configuration.nix diff --git a/templates/nixos/arthur/hardware-configuration.nix b/machines/nixos/x86_64-linux/__template__/hardware-configuration.nix similarity index 100% rename from templates/nixos/arthur/hardware-configuration.nix rename to machines/nixos/x86_64-linux/__template__/hardware-configuration.nix diff --git a/machines/nixos/x86_64-linux/homix/river b/machines/nixos/x86_64-linux/homix/configs/river similarity index 100% rename from machines/nixos/x86_64-linux/homix/river rename to machines/nixos/x86_64-linux/homix/configs/river diff --git a/machines/nixos/x86_64-linux/homix/configs/wired.ron b/machines/nixos/x86_64-linux/homix/configs/wired.ron new file mode 100644 index 0000000..fd22091 --- /dev/null +++ b/machines/nixos/x86_64-linux/homix/configs/wired.ron @@ -0,0 +1,239 @@ +( + shortcuts: ( + notification_interact: 1, + notification_close: 2, + notification_closeall: 3, + ), + + poll_interval: 16, + max_notifications: 8, + history_length: 100, + replacing_enabled: true, + replacing_resets_timeout: true, + + timeout: 5000, // 3 sec timeout + idle_threshold: 600, // 600 sec = 10 min + unpause_on_input: true, + + // min_window_width: 0, + // min_window_height: 0, + + debug: false, + debug_color: Color(r: 0.0, g: 1.0, b: 0.0, a: 1.0), + debug_color_alt: Color(r: 1.0, g: 0.0, b: 0.0, a: 1.0), + + layout_blocks: [ + ( + name: "notif_root", + parent: "", + hook: (parent_anchor: TR, self_anchor: TR), + offset: (x: -10, y: 39), + params: NotificationBlock(( + monitor: 0, + border_width: 2.0, + border_rounding: 0.0, + gap: (x: 0.0, y: 10.0), + background_color: (hex: "#0E1013"), + border_color: (hex: "#61AFEF"), + border_color_low: (hex: "#A0A8B7"), + border_color_critical: (hex: "#E55561"), + notification_hook: (parent_anchor: BL, self_anchor: TL), + )), + ), + + ( + name: "notif_summary", + parent: "notif_root", + offset: (x: 0, y: 0), + hook: (parent_anchor: TL, self_anchor: TR), + params: TextBlock(( + text: "%s", + padding: (left: 12.0, right: 12.0, top: 12.0, bottom: 7.0), + font: "JetBrainsMono Nerd Font 11", + color: (hex: "#A0A8B7"), + dimensions: ( + width: (min: 300, max: 300), + height: (min: 0, max: 0), + ), + dimensions_image_hint: ( + width: (min: 233, max: 238), + height: (min: 0, max: 0) + ), + dimensions_image_app: ( + width: (min: 233, max: 238), + height: (min: 0, max: 0) + ), + )), + ), + + ( + name: "notif_body", + parent: "notif_summary", + offset: (x: 0, y: 0), + hook: (parent_anchor: BL, self_anchor: TL), + render_criteria: [ Body ], + render_anti_criteria: [ AppName("progress") ], + params: TextBlock(( + text: "%b", + padding: (left: 12.0, right: 5.0, top: 5.0, bottom: 12.0), + font: "JetBrainsMono Nerd Font 10", + color: (hex: "#A0A8B7"), + dimensions: ( + width: (min: 300, max: 300), + height: (min: 0, max: 100), + ), + dimensions_image_hint: ( + width: (min: 240, max: 240), + height: (min: 0, max: 100) + ), + dimensions_image_app: ( + width: (min: 240, max: 240), + height: (min: 0, max: 100) + ), + )), + ), + + ( + name: "notif_image", + parent: "notif_summary", + hook: (parent_anchor: TL, self_anchor: TR), + offset: (x: 0, y: 0), + render_criteria: [ AppImage, HintImage ], + params: ImageBlock(( + image_type: HintThenApp, + padding: (left: 12.0, right: 5.0, top: 12.0, bottom: 10.0), + rounding: 5.0, + scale_width: 50, + scale_height: 50, + filter_mode: Lanczos3, + )), + ), + + ( + name: "notif_progress", + parent: "notif_summary", + offset: (x: 0, y: 0), + hook: (parent_anchor: BL, self_anchor: TL), + render_criteria: [ Progress ], + render_anti_criteria: [ Body ], + params: ProgressBlock(( + padding: (left: 12.0, right: 12.0, top: 8.5, bottom: 12.5), + border_width: 2.0, + border_rounding: 5.0, + fill_rounding: 5.0, + border_color: (hex: "#30363F"), + background_color: (hex: "#0E1013"), + fill_color: (hex: "#BF68D9"), + width: -1.0, + height: 14.0, + )), + ), + + ( + name: "notif_buttonbox", + parent: "notif_body", + offset: (x: 12, y: 0), + hook: (parent_anchor: BL, self_anchor: TL), + render_criteria: [ ActionOther(0) ], + params: TextBlock(( + text: "", + padding: (left: 0.0, right: 0.0, top: 0.0, bottom: 0.0), + font: "JetBrainsMono Nerd Font 11", + color: (hex: "#A0A8B7"), + dimensions: ( + width: (min: 288, max: 288), + height: (min: 38, max: 38), + ), + dimensions_image_hint: ( + width: (min: 221, max: 221), + height: (min: 38, max: 38), + ), + dimensions_image_app: ( + width: (min: 221, max: 221), + height: (min: 38, max: 38), + ), + )), + ), + + ( + name: "notif_button1", + parent: "notif_buttonbox", + offset: (x: 0, y: 0), + hook: (parent_anchor: TL, self_anchor: TL), + render_criteria: [ ActionOther(0) ], + params: ButtonBlock(( + text: "%a", + font: "JetBrainsMono Nerd Font 10", + action: OtherAction(0), + padding: (left: 8.0, right: 8.0, top: 4.0, bottom: 4.0), + border_width: 2.0, + border_rounding: 0.0, + fill_rounding: 0.0, + text_color: (hex: "#A0A8B7"), + text_color_hovered: (hex: "#FFFFFF"), + border_color: (hex: "#30363F"), + border_color_hovered: (hex: "#585b70"), + background_color: (hex: "#282C34"), + fill_color: (hex: "#FFFFFF"), + dimensions: ( + width: (min: -1, max: -1), + height: (min: 0, max: 0) + ), + )), + ), + + ( + name: "notif_button2", + parent: "notif_button1", + offset: (x: 10, y: 0), + hook: (parent_anchor: TR, self_anchor: TL), + render_criteria: [ ActionOther(1) ], + params: ButtonBlock(( + text: "%a", + font: "JetBrainsMono Nerd Font 10", + action: OtherAction(1), + padding: (left: 8.0, right: 8.0, top: 4.0, bottom: 4.0), + border_width: 2.0, + border_rounding: 0.0, + fill_rounding: 0.0, + text_color: (hex: "#A0A8B7"), + text_color_hovered: (hex: "#FFFFFF"), + border_color: (hex: "#30363F"), + border_color_hovered: (hex: "#585b70"), + background_color: (hex: "#282C34"), + fill_color: (hex: "#FFFFFF"), + dimensions: ( + width: (min: -1, max: -1), + height: (min: 0, max: 0) + ), + )), + ), + + ( + name: "notif_button3", + parent: "notif_button2", + offset: (x: 10, y: 0), + hook: (parent_anchor: TR, self_anchor: TL), + render_criteria: [ ActionOther(2) ], + params: ButtonBlock(( + text: "%a", + font: "JetBrainsMono Nerd Font 10", + action: OtherAction(2), + padding: (left: 8.0, right: 8.0, top: 4.0, bottom: 4.0), + border_width: 2.0, + border_rounding: 0.0, + fill_rounding: 0.0, + text_color: (hex: "#A0A8B7"), + text_color_hovered: (hex: "#FFFFFF"), + border_color: (hex: "#30363F"), + border_color_hovered: (hex: "#585b70"), + background_color: (hex: "#282C34"), + fill_color: (hex: "#FFFFFF"), + dimensions: ( + width: (min: -1, max: -1), + height: (min: 0, max: 0) + ), + )), + ), + ], +) diff --git a/machines/nixos/x86_64-linux/homix/home/reo101.nix b/machines/nixos/x86_64-linux/homix/home/reo101.nix index 247e6c3..c267646 100644 --- a/machines/nixos/x86_64-linux/homix/home/reo101.nix +++ b/machines/nixos/x86_64-linux/homix/home/reo101.nix @@ -1,7 +1,19 @@ { inputs, outputs, lib, config, pkgs, ... }: { - imports = builtins.attrValues outputs.homeManagerModules; + imports = builtins.attrValues outputs.homeManagerModules ++ [ + inputs.wired.homeManagerModules.default + ]; + + nixpkgs = { + overlays = builtins.attrValues outputs.overlays ++ [ + # inputs.neovim-nightly-overlay.overlay + inputs.zig-overlay.overlays.default + inputs.wired.overlays.default + ]; + + config.allowUnfree = true; + }; home = { username = "reo101"; @@ -13,52 +25,50 @@ programs.home-manager.enable = true; home.packages = with pkgs; [ - # WM - river + ## WM + river # window manager + swww # wallpaper deamon + # wired-notify # dunst on wayland - # Terminals + ## Terminals wezterm foot - # Core + ## Core neovim git firefox discord vifm - # Shell + ## Shell zsh starship zoxide + ripgrep - # Dhall + ## Dhall dhall dhall-lsp-server - # Nix + ## Nix rnix-lsp nil direnv - # Torrents + ## Torrents tremc - # Zig + ## Rust + rustc + cargo + + ## Zig # zigpkgs."0.10.1" zigpkgs.master # inputs.zls-overlay.packages.x86_64-linux.default ]; - nixpkgs = { - overlays = [ - # inputs.neovim-nightly-overlay.overlay - inputs.zig-overlay.overlays.default - ]; - - config.allowUnfree = true; - }; - # Enable the GPG Agent daemon. services.gpg-agent = { enable = true; @@ -70,16 +80,38 @@ enable = true; userName = "reo101"; userEmail = "pavel.atanasov2001@gmail.com"; - # signing = { - # signByDefault = true; - # key = "0x52F3E1D376F692C0"; - # }; }; reo101.shell = { enable = true; }; + systemd.user.services."swww" = { + Unit = { + Description = "Swww Daemon"; + PartOf = "graphical-session.target"; + }; + Service = { + ExecStart = "${pkgs.swww}/bin/swww init"; + ExecStop = "${pkgs.swww}/bin/swww kill"; + Type = "simple"; + Restart = "always"; + RestartSec = 5; + }; + Install = { + WantedBy = ["graphical-session.target"]; + }; + }; + + # services.swww = { + # enabled = true; + # }; + + services.wired = { + enable = true; + config = ../configs/wired.ron; + }; + home.file = { ".config/nvim" = { source = config.lib.file.mkOutOfStoreSymlink "${config.home.homeDirectory}/.local/src/reovim"; @@ -88,7 +120,7 @@ home.file.".config/river/init" = { executable = true; - source = ./../river; + source = ../configs/river; }; # home.file.".stack/config.yaml".text = lib.generators.toYAML {} { diff --git a/modules/nixos/jellyfin.nix b/modules/nixos/jellyfin.nix new file mode 100644 index 0000000..db79b13 --- /dev/null +++ b/modules/nixos/jellyfin.nix @@ -0,0 +1,60 @@ +{ config, nixpkgs, ... }: + +### Jellyfin +# nixpkgs.config.packageOverrides = pkgs: { +# arc = import (builtins.fetchTarball { +# url = "https://github.com/arcnmx/nixexprs/archive/1a2ca1935e243383dfc8dc89f88f55678d33fcd4.tar.gz"; +# sha256 = "sha256:0zjy3916sxxk7ds763dmmbzfdc46wdlw10m5dg6kkpqi2i81109f"; +# }) { +# inherit pkgs; +# }; +# vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; }; +# }; + +# hardware.nvidia.package = pkgs.arc.packages.nvidia-patch.override { +# nvidia_x11 = config.boot.kernelPackages.nvidiaPackages.stable; +# }; + +# hardware.opengl = { +# enable = true; +# extraPackages = with pkgs; [ +# intel-media-driver +# vaapiIntel +# vaapiVdpau +# libvdpau-va-gl +# intel-compute-runtime # OpenCL filter support (hardware tonemapping and subtitle burn-in) +# ]; +# }; + +virtualisation.oci-containers.containers."jellyfin" = { + autoStart = true; + image = "docker.io/jellyfin/jellyfin:latest"; + volumes = [ + "/var/cache/jellyfin/config:/config" + "/var/cache/jellyfin/cache:/cache" + "/var/log/jellyfin:/log" + "/media:/media:ro" + ]; + ports = [ "8096:8096" ]; + environment = { + JELLYFIN_LOG_DIR = "/log"; + }; +}; + +## services.jellyfin.enable = true; + +## systemd.services."jellyfin".serviceConfig = { +## DeviceAllow = pkgs.lib.mkForce [ +## "char-drm rw" +## "char-nvidia-frontend rw" +## "char-nvidia-uvm rw" +## ]; +## PrivateDevices = pkgs.lib.mkForce true; +## RestrictAddressFamilies = pkgs.lib.mkForce [ +## "AF_UNIX" +## "AF_NETLINK" +## "AF_INET" +## "AF_INET6" +## ]; +## }; + diff --git a/overlays/default.nix b/overlays/default.nix index b2653c9..f24acb1 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,4 +1,5 @@ # This file defines overlays +{ inputs, outputs, ... }: { # This one brings our custom packages from the 'pkgs' directory additions = final: _prev: import ../pkgs { pkgs = final; }; diff --git a/pkgs/default.nix b/pkgs/default.nix index 8c5e910..309da9c 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -3,4 +3,5 @@ { pkgs ? (import ../nixpkgs.nix) { } }: { # example = pkgs.callPackage ./example { }; + swww = pkgs.callPackage ./swww { }; } diff --git a/pkgs/swww/default.nix b/pkgs/swww/default.nix new file mode 100644 index 0000000..bdc4734 --- /dev/null +++ b/pkgs/swww/default.nix @@ -0,0 +1,32 @@ +{ lib, fetchFromGitHub, rustPlatform, pkg-config, libxkbcommon }: + +rustPlatform.buildRustPackage rec { + pname = "swww"; + version = "v0.7.1"; + + src = fetchFromGitHub { + owner = "Horus645"; + repo = pname; + rev = version; + sha256 = "sha256-Z90Zwjqcu0hbtJwKPUNV996mtdgX//ZWWm+Dya/JV9A="; + }; + + cargoSha256 = "sha256-f6++5DazCqJjRuZquiJ5hdf9l+q6sOBZOL/vyQy1hA0"; + + nativeBuildInputs = [ + pkg-config + ]; + + buildInputs = [ + libxkbcommon + ]; + + doCheck = false; + + meta = with lib; { + description = "A Solution to your Wayland Wallpaper Woes"; + homepage = "https://github.com/Horus645/swww"; + license = licenses.gpl3; + maintainers = [ maintainers.reo101 ]; + }; +} diff --git a/templates/default.nix b/templates/default.nix new file mode 100644 index 0000000..4ee71bb --- /dev/null +++ b/templates/default.nix @@ -0,0 +1,6 @@ +{ + haskell = { + description = "Haskell environment (stack + hls)"; + path = ./haskell; + }; +}