From 11764d5850a61cf77a5384e56015ebf2a1376cd6 Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 18 Sep 2023 17:27:54 +0200 Subject: [PATCH] feat: systemd upgrade feat: streamdeck ui config --- flake.lock | 96 ++++++++++++++-------------- modules/optional/streamdeck.nix | 58 ++++++++++++++++- statix.toml | 3 + users/common/programs/git.nix | 14 +++- users/common/programs/streamdeck.nix | 40 ++++++++++++ users/common/shells/zsh/default.nix | 2 +- users/patrick/default.nix | 1 + 7 files changed, 163 insertions(+), 51 deletions(-) create mode 100644 statix.toml create mode 100644 users/common/programs/streamdeck.nix diff --git a/flake.lock b/flake.lock index ff02378..6050029 100644 --- a/flake.lock +++ b/flake.lock @@ -11,11 +11,11 @@ ] }, "locked": { - "lastModified": 1690228878, - "narHash": "sha256-9Xe7JV0krp4RJC9W9W9WutZVlw6BlHTFMiUP/k48LQY=", + "lastModified": 1694793763, + "narHash": "sha256-y6gTE1C9mIoSkymRYyzCmv62PFgy+hbZ5j8fuiQK5KI=", "owner": "ryantm", "repo": "agenix", - "rev": "d8c973fd228949736dedf61b7f8cc1ece3236792", + "rev": "572baca9b0c592f71982fca0790db4ce311e3c75", "type": "github" }, "original": { @@ -101,11 +101,11 @@ ] }, "locked": { - "lastModified": 1693833206, - "narHash": "sha256-wHOY0nnD6gWj8u9uI85/YlsganYyWRK1hLFZulZwfmY=", + "lastModified": 1694858246, + "narHash": "sha256-zcKnlTrMspD6YUgN1VyKMKSZ5Few3LCyDyBz3wtGPJQ=", "owner": "numtide", "repo": "devshell", - "rev": "65114ea495a8d3cc1352368bf170d67ef005aa5a", + "rev": "f26c2e05cd766be3750dd3d6e276650a1eab4c61", "type": "github" }, "original": { @@ -121,11 +121,11 @@ ] }, "locked": { - "lastModified": 1694069327, - "narHash": "sha256-Si2otUNjCe8kY5nsV7tILi4PsI0odBFrdSu8cCjn/eQ=", + "lastModified": 1695039393, + "narHash": "sha256-HXvRPTSfQ/fCqxYGvWOc1duSBdXcQlrYvyno8YZbyHI=", "owner": "nix-community", "repo": "disko", - "rev": "7bee8de8e6755506c70323b864a884f9624cc23a", + "rev": "9f29cedac79d0acf07b6341f9112f46dec3abb8f", "type": "github" }, "original": { @@ -210,11 +210,11 @@ ] }, "locked": { - "lastModified": 1692799911, - "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=", + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", "owner": "numtide", "repo": "flake-utils", - "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", "type": "github" }, "original": { @@ -228,11 +228,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1692799911, - "narHash": "sha256-3eihraek4qL744EvQXsK1Ha6C3CR7nnT8X2qWap4RNk=", + "lastModified": 1694529238, + "narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=", "owner": "numtide", "repo": "flake-utils", - "rev": "f9e7cf818399d17d347f847525c5a5a8032e4e44", + "rev": "ff7b65b44d01cf9ba6a71320833626af21126384", "type": "github" }, "original": { @@ -269,11 +269,11 @@ ] }, "locked": { - "lastModified": 1694134858, - "narHash": "sha256-fG/ESauOGmiojKlpJG8gB62dJa5Wd+ZIuiDMKK/HD3g=", + "lastModified": 1694643239, + "narHash": "sha256-pv2k/5FvyirDE8g4TNehzwZ0T4UOMMmqWSQnM/luRtE=", "owner": "nix-community", "repo": "home-manager", - "rev": "19c6a4081b14443420358262f8416149bd79561a", + "rev": "d9b88b43524db1591fb3d9410a21428198d75d49", "type": "github" }, "original": { @@ -284,11 +284,11 @@ }, "impermanence": { "locked": { - "lastModified": 1690797372, - "narHash": "sha256-GImz19e33SeVcIvBB7NnhbJSbTpFFmNtWLh7Z85Y188=", + "lastModified": 1694622745, + "narHash": "sha256-z397+eDhKx9c2qNafL1xv75lC0Q4nOaFlhaU1TINqb8=", "owner": "nix-community", "repo": "impermanence", - "rev": "e3a7acd113903269a1b5c8b527e84ce7ee859851", + "rev": "e9643d08d0d193a2e074a19d4d90c67a874d932e", "type": "github" }, "original": { @@ -303,11 +303,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1693844549, - "narHash": "sha256-q37gKJEJ8H+bvcQRuZpbGTDU/GvyrpMtaejhFvS8mSc=", + "lastModified": 1694952508, + "narHash": "sha256-0KzgnYW9RvlwUnl5qYinNOg/WsV9jEJfMPVQoJL8bmI=", "owner": "nix-community", "repo": "lib-aggregate", - "rev": "80552e56920ed1acc248596a13d8f0b4932138d3", + "rev": "d44755862cce5ba5e040ec8f7df6c6b33e47c8a0", "type": "github" }, "original": { @@ -323,11 +323,11 @@ "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1694051403, - "narHash": "sha256-TbCcylrAPLhKu7s7mnjwQjkrqBMjI9/ysiysfKn5XHs=", + "lastModified": 1695000172, + "narHash": "sha256-TWPMFY29XcWAwUJFE3n+4pGqBdBbr4XsWDZwr77fTwo=", "owner": "nix-community", "repo": "nix-eval-jobs", - "rev": "9cc7944c28c2bc5de3c96c253b3fd814c1cb85dd", + "rev": "a91f3595b22037f561912cd3a9ca549933e4544d", "type": "github" }, "original": { @@ -394,11 +394,11 @@ }, "nixos-hardware": { "locked": { - "lastModified": 1693718952, - "narHash": "sha256-+nGdJlgTk0MPN7NygopipmyylVuAVi7OItIwTlwtGnw=", + "lastModified": 1695033975, + "narHash": "sha256-GIUxbgLBhVyaKRxQw/NWYFLx7/jbKW3+U0HoSsMLPAs=", "owner": "nixos", "repo": "nixos-hardware", - "rev": "793de77d9f83418b428e8ba70d1e42c6507d0d35", + "rev": "161b027169b19d3a0ad6bd0a8948edf0c0fb0f64", "type": "github" }, "original": { @@ -409,11 +409,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1693985761, - "narHash": "sha256-K5b+7j7Tt3+AqbWkcw+wMeqOAWyCD1MH26FPZyWXpdo=", + "lastModified": 1694767346, + "narHash": "sha256-5uH27SiVFUwsTsqC5rs3kS7pBoNhtoy9QfTP9BmknGk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "0bffda19b8af722f8069d09d8b6a24594c80b352", + "rev": "ace5093e36ab1e95cb9463863491bee90d5a4183", "type": "github" }, "original": { @@ -425,11 +425,11 @@ }, "nixpkgs-lib": { "locked": { - "lastModified": 1693701915, - "narHash": "sha256-waHPLdDYUOHSEtMKKabcKIMhlUOHPOOPQ9UyFeEoovs=", + "lastModified": 1694911725, + "narHash": "sha256-8YqI+YU1DGclEjHsnrrGfqsQg3Wyga1DfTbJrN3Ud0c=", "owner": "nix-community", "repo": "nixpkgs.lib", - "rev": "f5af57d3ef9947a70ac86e42695231ac1ad00c25", + "rev": "819180647f428a3826bfc917a54449da1e532ce0", "type": "github" }, "original": { @@ -464,11 +464,11 @@ ] }, "locked": { - "lastModified": 1694182450, - "narHash": "sha256-Eivl9r8Y5RKn3z4N1hAUAl6///bJhpzyHCVk7Q8u6Dw=", + "lastModified": 1695035588, + "narHash": "sha256-jhB35iAcGXVXFPPA+JAQQX2J6Uj3BqlyEGjMDZSEAD0=", "owner": "nix-community", "repo": "nixpkgs-wayland", - "rev": "1372a7ab8f8d1a4c12f4cf522cbe553c91043656", + "rev": "9613c0cb66dcbb7fa5bcdf6667e384caf53eab26", "type": "github" }, "original": { @@ -479,11 +479,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1694048283, - "narHash": "sha256-QexXMDukc4fmXq5SJsDg8WRA6+FiEOt+PB3hx+fbc8o=", + "lastModified": 1694998849, + "narHash": "sha256-A23ROwLGc+lbgUZOkHMhsJ+3IMC+5MmRXXl61iEuhhQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "308e5f73e17dc2fe43ba95ec83697999b5dd544d", + "rev": "5b859eef2e5dd7aacfd229e819f426942eed25fc", "type": "github" }, "original": { @@ -506,11 +506,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1692274144, - "narHash": "sha256-BxTQuRUANQ81u8DJznQyPmRsg63t4Yc+0kcyq6OLz8s=", + "lastModified": 1694364351, + "narHash": "sha256-oadhSCqopYXxURwIA6/Anpe5IAG11q2LhvTJNP5zE6o=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "7e3517c03d46159fdbf8c0e5c97f82d5d4b0c8fa", + "rev": "4f883a76282bc28eb952570afc3d8a1bf6f481d7", "type": "github" }, "original": { @@ -609,11 +609,11 @@ ] }, "locked": { - "lastModified": 1693817438, - "narHash": "sha256-fg3+n4Ky1gCzDtPm0MomMTFw0YkH05Y8ojy5t7bkfHg=", + "lastModified": 1694528738, + "narHash": "sha256-aWMEjib5oTqEzF9f3WXffC1cwICo6v/4dYKjwNktV8k=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "b8d3a059f5487d6767d07c3716386753e3132d9f", + "rev": "7a49c388d7a6b63bb551b1ddedfa4efab8f400d8", "type": "github" }, "original": { diff --git a/modules/optional/streamdeck.nix b/modules/optional/streamdeck.nix index 4a08858..9fc29fe 100644 --- a/modules/optional/streamdeck.nix +++ b/modules/optional/streamdeck.nix @@ -1,4 +1,60 @@ { + lib, + pkgs, + ... +}: let + inherit + (lib) + types + mkEnableOption + mkPackageOption + mkOption + mkIf + ; + settingsFormat = pkgs.formats.json {}; +in { # broken on nixpkgs currently. How fun - #programs.streamdeck-ui.enable = true; + programs.streamdeck-ui.enable = true; + + home-manager.sharedModules = [ + ({config, ...}: { + options.programs.streamdeck-ui = { + enable = mkEnableOption "streamdeck-ui"; + package = mkPackageOption pkgs "streamdeck-ui" {}; + autoStart = mkOption { + default = true; + type = types.bool; + description = "Whether streamdeck-ui should be started automatically"; + }; + settings = mkOption { + default = {}; + type = types.submodule {freeformType = settingsFormat.type;}; + description = "Configuration per streamdeck"; + }; + }; + config = mkIf config.programs.streamdeck-ui.enable { + home.sessionVariables.STREAMDECK_UI_CONFIG = "${config.xdg.configHome}/streamdeck-ui/config.json"; + xdg.configFile.streamdeck-ui = { + target = "streamdeck-ui/config.json"; + source = settingsFormat.generate "config.json" { + streamdeck_ui_version = 1; + state = config.programs.streamdeck-ui.settings; + }; + }; + systemd.user.services = mkIf config.programs.streamdeck-ui.autoStart { + streamdeck-ui = { + Unit = { + Description = "Start streamdeck-ui"; + }; + Service = { + ExecStart = "${config.programs.streamdeck-ui.package}/bin/streamdeck-ui --no-ui"; + }; + Install = { + WantedBy = ["default.target"]; + }; + }; + }; + }; + }) + ]; } diff --git a/statix.toml b/statix.toml new file mode 100644 index 0000000..31a2a5b --- /dev/null +++ b/statix.toml @@ -0,0 +1,3 @@ +disabled = [ + "repeated_keys" +] diff --git a/users/common/programs/git.nix b/users/common/programs/git.nix index bdfc3d0..045dc56 100644 --- a/users/common/programs/git.nix +++ b/users/common/programs/git.nix @@ -1,14 +1,26 @@ -{ +{pkgs, ...}: { programs.git = { enable = true; difftastic.enable = true; aliases = { cs = "commit -v -S"; + cr = "commit -v -S --edit --file \"$(git rev-parse --git-dir)\"/COMMIT_EDITMSG'"; s = "status"; a = "add"; p = "push"; + rebase = "rebase --gpg-sign"; }; extraConfig = { + core.pager = "${pkgs.delta}/bin/delta"; + delta = { + hyperlinks = true; + keep-plus-minus-markers = true; + line-numbers = true; + navigate = true; + side-by-side = true; + syntax-theme = "TwoDark"; + tabs = 4; + }; mergetool.prompt = true; merge.conflictstyle = "diff3"; init.defaultBranch = "main"; diff --git a/users/common/programs/streamdeck.nix b/users/common/programs/streamdeck.nix new file mode 100644 index 0000000..faebacb --- /dev/null +++ b/users/common/programs/streamdeck.nix @@ -0,0 +1,40 @@ +{ + programs.streamdeck-ui = { + enable = true; + settings = { + # Device ID + "AL31H1B01852" = { + buttons = { + # Page number + "0" = { + # button number + "5" = { + # keyInput to press + keys = "F7"; + # Text shown on button + text = "mute"; + # Text position + text_vertical_align = "middle-bottom"; + }; + "6" = { + keys = "F8"; + text = "deafen"; + text_vertical_align = "top"; + }; + "7" = { + # background picture + icon = "/home/patrick/ms.jpg"; + # command to execute on press + command = "echo lol"; + # background fill colour + background_color = "#000000"; + }; + }; + }; + brightness = 99; # brighness value between 0 and 99 + display_timeout = 1800; # dimmer timeout in seconds + brightness_dimmed = 10; # dimmed brighness + }; + }; + }; +} diff --git a/users/common/shells/zsh/default.nix b/users/common/shells/zsh/default.nix index 742cfba..31fc356 100644 --- a/users/common/shells/zsh/default.nix +++ b/users/common/shells/zsh/default.nix @@ -38,7 +38,7 @@ initExtra = builtins.readFile ./zshrc; # This needs to be loaded befor zsh-fast-syntax-highlighting # is sourced as that overwrites all widgets to redraw with highlighting - initExtraBeforeCompInit = '' + initExtraFirst = '' if autoload history-search-end; then zle -N history-beginning-search-backward-end history-search-end zle -N history-beginning-search-forward-end history-search-end diff --git a/users/patrick/default.nix b/users/patrick/default.nix index 468e0d1..3b454d2 100644 --- a/users/patrick/default.nix +++ b/users/patrick/default.nix @@ -41,6 +41,7 @@ ../common/programs/bottles.nix ../common/programs/gdb.nix + ../common/programs/streamdeck.nix ]; }; }