This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

wrapperModules: migrate to github:lassulus/wrappers

+74 -505
+22 -1
flake.lock
··· 530 530 "rogue-talk": "rogue-talk", 531 531 "spora": "spora", 532 532 "stockholm": "stockholm", 533 - "treefmt-nix": "treefmt-nix_6" 533 + "treefmt-nix": "treefmt-nix_6", 534 + "wrappers": "wrappers" 534 535 } 535 536 }, 536 537 "sops-nix": { ··· 780 781 "original": { 781 782 "owner": "numtide", 782 783 "repo": "treefmt-nix", 784 + "type": "github" 785 + } 786 + }, 787 + "wrappers": { 788 + "inputs": { 789 + "nixpkgs": [ 790 + "nixpkgs" 791 + ] 792 + }, 793 + "locked": { 794 + "lastModified": 1771363153, 795 + "narHash": "sha256-YKa4ay96+0r+85akn/99t8ab1/iRUdWC/TRAKc+aAnE=", 796 + "owner": "lassulus", 797 + "repo": "wrappers", 798 + "rev": "8cc78f6c3b4fd3875c5ac36954ca1d4cb64bce24", 799 + "type": "github" 800 + }, 801 + "original": { 802 + "owner": "lassulus", 803 + "repo": "wrappers", 783 804 "type": "github" 784 805 } 785 806 }
+4 -1
flake.nix
··· 65 65 66 66 rogue-talk.url = "github:rogue-talk/rogue-talk"; 67 67 rogue-talk.inputs.nixpkgs.follows = "nixpkgs"; 68 + 69 + wrappers.url = "github:lassulus/wrappers"; 70 + # wrappers.url = "git+file:/home/lass/src/wrappers"; 71 + wrappers.inputs.nixpkgs.follows = "nixpkgs"; 68 72 }; 69 73 70 74 outputs = ··· 178 182 ./formatter.nix 179 183 ./5pkgs/flake-module.nix 180 184 ./keys/flake-module.nix 181 - ./wrapperModules/flake-module.nix 182 185 ./skills/flake-module.nix 183 186 ./games/flake-module.nix 184 187 ./machines/pixel8/flake-module.nix
-379
wrapperModules/flake-module.nix
··· 1 - { self, lib, ... }: 2 - { 3 - imports = [ 4 - ./mpv/default.nix 5 - ./notmuch/default.nix 6 - ]; 7 - flake.options.wrapperModules = lib.mkOption { 8 - type = lib.types.attrsOf (lib.types.attrsOf lib.types.unspecified); 9 - default = { }; 10 - description = "Wrapper modules"; 11 - }; 12 - /** 13 - A function to create a wrapper module. 14 - returns an attribute set with options and apply function. 15 - 16 - Example usage: 17 - helloWrapper = mkWrapper (wlib: { config, ... }: { 18 - options.greeting = lib.mkOption { 19 - type = lib.types.str; 20 - default = "hello"; 21 - }; 22 - config.package = config.pkgs.hello; 23 - config.flags = { 24 - "--greeting" = config.greeting; 25 - }; 26 - }; 27 - 28 - helloWrapper.apply { 29 - pkgs = pkgs; 30 - greeting = "hi"; 31 - }; 32 - 33 - # This will return a derivation that wraps the hello package with the --greeting flag set to "hi". 34 - */ 35 - flake.config.wrapLib.mkWrapper = 36 - declarationArgs: 37 - let 38 - declaration = declarationArgs wrapperLib; 39 - 40 - wrapperLib = { 41 - types = { 42 - inherit file; 43 - }; 44 - }; 45 - file = 46 - # we need to pass pkgs here, because writeText is in pkgs 47 - pkgs: 48 - lib.types.submodule ( 49 - { name, config, ... }: 50 - { 51 - options = { 52 - content = lib.mkOption { 53 - type = lib.types.lines; 54 - description = '' 55 - content of file 56 - ''; 57 - }; 58 - path = lib.mkOption { 59 - type = lib.types.path; 60 - description = '' 61 - the path to the file 62 - ''; 63 - default = pkgs.writeText name config.content; 64 - defaultText = "pkgs.writeText name <content>"; 65 - }; 66 - }; 67 - } 68 - ); 69 - evalArgs = cfg: { 70 - modules = [ 71 - declaration 72 - cfg 73 - { 74 - options = { 75 - pkgs = lib.mkOption { 76 - description = '' 77 - The nixpkgs pkgs instance to use. 78 - We want to have this, so wrapper modules can be system agnostic. 79 - ''; 80 - }; 81 - package = lib.mkOption { 82 - type = lib.types.package; 83 - description = '' 84 - The base package to wrap. 85 - This means we inherit all other files from this package 86 - (like man page, /share, ...) 87 - ''; 88 - }; 89 - extraPackages = lib.mkOption { 90 - type = lib.types.listOf lib.types.package; 91 - default = [ ]; 92 - description = '' 93 - Additional packages to add to the wrapper's runtime dependencies. 94 - This is useful if the wrapped program needs additional libraries or tools to function correctly. 95 - These packages will be added to the wrapper's runtime dependencies, ensuring they are available when the wrapped program is executed. 96 - ''; 97 - }; 98 - flags = lib.mkOption { 99 - type = lib.types.attrsOf lib.types.unspecified; # TODO add list handling 100 - default = { }; 101 - description = '' 102 - Flags to pass to the wrapper. 103 - The key is the flag name, the value is the flag value. 104 - If the value is true, the flag will be passed without a value. 105 - If the value is false or null, the flag will not be passed. 106 - If the value is a list, the flag will be passed multiple times with each value. 107 - ''; 108 - }; 109 - env = lib.mkOption { 110 - type = lib.types.attrsOf lib.types.str; 111 - default = { }; 112 - description = '' 113 - Environment variables to set in the wrapper. 114 - ''; 115 - }; 116 - passthru = lib.mkOption { 117 - type = lib.types.attrs; 118 - default = { }; 119 - description = '' 120 - Additional attributes to add to the resulting derivation's passthru. 121 - This can be used to add additional metadata or functionality to the wrapped package. 122 - This will always contain options, config and settings, so these are reserved names and cannot be used here. 123 - ''; 124 - }; 125 - }; 126 - } 127 - ]; 128 - }; 129 - in 130 - { 131 - # expose options to generate documentation of available modules 132 - options = (lib.evalModules (evalArgs { })).options; 133 - apply = 134 - settings: 135 - let 136 - eval = lib.evalModules (evalArgs { 137 - config = settings; 138 - }); 139 - options = eval.options; 140 - config = eval.config; 141 - in 142 - self.wrapLib.makeWrapper { 143 - pkgs = config.pkgs; 144 - package = config.package; 145 - runtimeInputs = config.extraPackages; 146 - flagSeparator = "="; 147 - flags = config.flags; 148 - env = config.env; 149 - passthru = { 150 - inherit options config settings; 151 - } 152 - // config.passthru; 153 - }; 154 - }; 155 - 156 - /** 157 - Create a wrapped application that preserves all original outputs (man pages, completions, etc.) 158 - 159 - # Arguments 160 - 161 - - `pkgs`: The nixpkgs pkgs instance to use 162 - - `package`: The package to wrap 163 - - `runtimeInputs`: List of packages to add to PATH (optional) 164 - - `env`: Attribute set of environment variables to export (optional) 165 - - `flags`: Attribute set of command-line flags to add (optional) 166 - - `flagSeparator`: Separator between flag names and values (optional, defaults to " ") 167 - - `preHook`: Shell script to run before executing the command (optional) 168 - - `passthru`: Attribute set to pass through to the wrapped derivation (optional) 169 - - `aliases`: List of additional names to symlink to the wrapped executable (optional) 170 - - `wrapper`: Custom wrapper function (optional, defaults to exec'ing the original binary with flags) 171 - - Called with { env, flags, envString, flagsString, exePath, preHook } 172 - 173 - # Example 174 - 175 - ```nix 176 - makeWrapper { 177 - pkgs = pkgs; 178 - package = pkgs.curl; 179 - runtimeInputs = [ pkgs.jq ]; 180 - env = { 181 - CURL_CA_BUNDLE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"; 182 - }; 183 - flags = { 184 - "--silent" = { }; # becomes --silent 185 - "--connect-timeout" = "30"; # becomes --connect-timeout 30 186 - }; 187 - preHook = '' 188 - echo "Making request..." >&2 189 - ''; 190 - } 191 - 192 - # Or with custom wrapper: 193 - makeWrapper pkgs.someProgram { 194 - wrapper = { exePath, flagsString, envString, preHook, ... }: '' 195 - ${envString} 196 - ${preHook} 197 - echo "Custom logic here" 198 - exec ${exePath} ${flagsString} "$@" 199 - ''; 200 - } 201 - ``` 202 - */ 203 - flake.config.wrapLib.makeWrapper = 204 - { 205 - pkgs, 206 - package, 207 - runtimeInputs ? [ ], 208 - env ? { }, 209 - flags ? { }, 210 - flagSeparator ? " ", # " " for "--flag value" or "=" for "--flag=value" 211 - preHook ? "", 212 - passthru ? { }, 213 - aliases ? [ ], 214 - wrapper ? ( 215 - { 216 - exePath, 217 - flagsString, 218 - envString, 219 - preHook, 220 - ... 221 - }: 222 - '' 223 - ${envString} 224 - ${preHook} 225 - exec ${exePath}${flagsString} "$@" 226 - '' 227 - ), 228 - }: 229 - let 230 - # Extract binary name from the exe path 231 - exePath = lib.getExe package; 232 - binName = baseNameOf exePath; 233 - 234 - # Generate environment variable exports 235 - envString = 236 - if env == { } then 237 - "" 238 - else 239 - lib.concatStringsSep "\n" ( 240 - lib.mapAttrsToList (name: value: ''export ${name}="${toString value}"'') env 241 - ) 242 - + "\n"; 243 - 244 - # Generate flag arguments with proper line breaks and indentation 245 - flagsString = 246 - if flags == { } then 247 - "" 248 - else 249 - " \\\n " 250 - + lib.concatStringsSep " \\\n " ( 251 - lib.mapAttrsToList ( 252 - name: value: 253 - if value == { } then "${name}" else "${name}${flagSeparator}${lib.escapeShellArg (toString value)}" 254 - ) flags 255 - ); 256 - 257 - finalWrapper = wrapper { 258 - inherit 259 - env 260 - flags 261 - envString 262 - flagsString 263 - exePath 264 - preHook 265 - ; 266 - }; 267 - 268 - # Multi-output aware symlink join function 269 - multiOutputSymlinkJoin = 270 - { 271 - name, 272 - paths, 273 - outputs ? [ "out" ], 274 - originalOutputs ? { }, 275 - passthru ? { }, 276 - meta ? { }, 277 - aliases ? [ ], 278 - binName ? null, 279 - ... 280 - }@args: 281 - pkgs.stdenv.mkDerivation ( 282 - { 283 - inherit name outputs; 284 - 285 - buildCommand = '' 286 - # Symlink all paths to the main output 287 - mkdir -p $out 288 - for path in ${lib.concatStringsSep " " (map toString paths)}; do 289 - ${pkgs.lndir}/bin/lndir -silent "$path" $out 290 - done 291 - 292 - # Create symlinks for aliases 293 - ${lib.optionalString (aliases != [ ] && binName != null) '' 294 - mkdir -p $out/bin 295 - for alias in ${lib.concatStringsSep " " (map lib.escapeShellArg aliases)}; do 296 - ln -sf ${lib.escapeShellArg binName} $out/bin/$alias 297 - done 298 - ''} 299 - 300 - # Handle additional outputs by symlinking from the original package's outputs 301 - ${lib.concatMapStringsSep "\n" ( 302 - output: 303 - if output != "out" && originalOutputs ? ${output} && originalOutputs.${output} != null then 304 - '' 305 - if [[ -n "''${${output}:-}" ]]; then 306 - mkdir -p ${"$" + output} 307 - # Only symlink from the original package's corresponding output 308 - ${pkgs.lndir}/bin/lndir -silent "${originalOutputs.${output}}" ${"$" + output} 309 - fi 310 - '' 311 - else 312 - "" 313 - ) outputs} 314 - ''; 315 - 316 - inherit passthru meta; 317 - } 318 - // (removeAttrs args [ 319 - "name" 320 - "paths" 321 - "outputs" 322 - "originalOutputs" 323 - "passthru" 324 - "meta" 325 - "aliases" 326 - "binName" 327 - ]) 328 - ); 329 - 330 - # Get original package outputs for symlinking 331 - originalOutputs = 332 - if package ? outputs then 333 - lib.listToAttrs ( 334 - map (output: { 335 - name = output; 336 - value = if package ? ${output} then package.${output} else null; 337 - }) package.outputs 338 - ) 339 - else 340 - { }; 341 - 342 - # Create the wrapper derivation using our multi-output aware symlink join 343 - wrappedPackage = multiOutputSymlinkJoin ( 344 - { 345 - name = package.pname or package.name; 346 - paths = [ 347 - (pkgs.writeShellApplication { 348 - name = binName; 349 - runtimeInputs = runtimeInputs; 350 - text = finalWrapper; 351 - }) 352 - package 353 - ]; 354 - outputs = if package ? outputs then package.outputs else [ "out" ]; 355 - inherit originalOutputs aliases binName; 356 - passthru = 357 - (package.passthru or { }) 358 - // passthru 359 - // { 360 - inherit 361 - env 362 - flags 363 - preHook 364 - aliases 365 - ; 366 - }; 367 - # Pass through original attributes 368 - meta = package.meta or { }; 369 - } 370 - // lib.optionalAttrs (package ? version) { 371 - inherit (package) version; 372 - } 373 - // lib.optionalAttrs (package ? pname) { 374 - inherit (package) pname; 375 - } 376 - ); 377 - in 378 - wrappedPackage; 379 - }
+2 -2
tools/claude/flake-module.nix
··· 1 - { self, ... }: 1 + { self, inputs, ... }: 2 2 { 3 3 perSystem = 4 4 { pkgs, system, ... }: ··· 11 11 claudeMd = ./CLAUDE.md; 12 12 in 13 13 { 14 - packages.claude = self.wrapLib.makeWrapper { 14 + packages.claude = inputs.wrappers.lib.wrapPackage { 15 15 pkgs = pkgs; 16 16 package = (self.lib.halalify pkgs.claude-code); 17 17 wrapper =
+6 -6
tools/mpv/flake-module.nix
··· 1 - { self, ... }: 1 + { self, inputs, ... }: 2 2 { 3 3 perSystem = 4 4 { pkgs, ... }: ··· 46 46 ''; 47 47 48 48 in 49 - self.wrapperModules.mpv.apply { 49 + (inputs.wrappers.wrapperModules.mpv.apply { 50 50 pkgs = pkgs; 51 51 scripts = with pkgs.mpvScripts; [ 52 52 sponsorblock ··· 54 54 vr-reversal 55 55 visualizer 56 56 ]; 57 - extraFlags = { 57 + flags = { 58 58 "--ytdl-format" = "bestvideo[height<=1080]+bestaudio/best"; 59 59 "--script-opts" = "ytdl_hook-ytdl_path=${pkgs.yt-dlp}/bin/yt-dlp"; 60 60 "--script-opts-append" = "sponsorblock-local_database=no"; 61 61 "--audio-channels" = "2"; 62 - "--script" = autosub; 62 + "--script" = "${autosub}"; 63 63 }; 64 - "mpv.input".content = '' 64 + "input.conf".content = '' 65 65 : script-binding console/enable 66 66 x add audio-delay -0.050 67 67 X add audio-delay 0.050 ··· 71 71 "mpv.conf".content = '' 72 72 osd-font-size=20 73 73 ''; 74 - }; 74 + }).wrapper; 75 75 76 76 # Separate package for subtitle downloader 77 77 packages.mpv-dl-subs =
+3 -3
tools/muchsync/flake-module.nix
··· 1 - { self, ... }: 1 + { self, inputs, ... }: 2 2 { 3 3 perSystem = 4 4 { ··· 7 7 ... 8 8 }: 9 9 { 10 - packages.muchsync = self.wrapLib.makeWrapper { 10 + packages.muchsync = inputs.wrappers.lib.wrapPackage { 11 11 pkgs = pkgs; 12 12 package = pkgs.muchsync; 13 13 runtimeInputs = [ pkgs.notmuch ] ++ lib.optionals pkgs.stdenv.isLinux [ pkgs.iputils ]; 14 14 env = { 15 - NOTMUCH_CONFIG = self.packages.${pkgs.system}.notmuch.passthru.config.configFile.path; 15 + NOTMUCH_CONFIG = self.packages.${pkgs.system}.notmuch.passthru.configuration.configFile.path; 16 16 }; 17 17 wrapper = 18 18 { exePath, envString, ... }:
+4 -4
tools/mutt/flake-module.nix
··· 1 - { self, ... }: 1 + { self, inputs, ... }: 2 2 { 3 3 perSystem = 4 4 { ··· 11 11 packages.mutt = 12 12 let 13 13 # Mailboxes configuration from mail.nix 14 - mailboxes = self.packages.${system}.notmuch.mailboxes; 15 - notmuchConfig = self.packages.${system}.notmuch.passthru.config.configFile.path; 14 + mailboxes = self.packages.${system}.notmuch.passthru.mailboxes; 15 + notmuchConfig = self.packages.${system}.notmuch.passthru.configuration.configFile.path; 16 16 17 17 mailcap = pkgs.writeText "mailcap" '' 18 18 text/html; ${pkgs.elinks}/bin/elinks -dump ; copiousoutput; ··· 302 302 ''; 303 303 304 304 in 305 - (self.wrapLib.makeWrapper { 305 + (inputs.wrappers.lib.wrapPackage { 306 306 pkgs = pkgs; 307 307 package = pkgs.neomutt; 308 308 aliases = [ "mutt" ];
+22 -21
tools/notmuch/flake-module.nix
··· 1 - { self, ... }: 1 + { self, inputs, ... }: 2 2 { 3 3 perSystem = 4 4 { ··· 74 74 ]; 75 75 }; 76 76 77 + notmuchConfig = inputs.wrappers.wrapperModules.notmuch.apply { 78 + pkgs = pkgs; 79 + settings = { 80 + database = { 81 + path = "Maildir"; 82 + mail_root = "Maildir"; 83 + }; 84 + new.tags = "unread;inbox;"; 85 + search.exclude_tags = "deleted;spam;"; 86 + maildir.synchronize_flags = true; 87 + user = { 88 + name = "lassulus"; 89 + primary_email = "lassulus@lassul.us"; 90 + other_email = lib.concatStringsSep ";" (lib.flatten (lib.attrValues mailboxes)); 91 + }; 92 + }; 93 + passthru = { 94 + mailboxes = mailboxes; 95 + }; 96 + }; 77 97 in 78 - self.wrapperModules.notmuch.apply { 79 - pkgs = pkgs; 80 - config = { 81 - database = { 82 - path = "Maildir"; 83 - mail_root = "Maildir"; 84 - }; 85 - new.tags = "unread;inbox;"; 86 - search.exclude_tags = "deleted;spam;"; 87 - maildir.synchronize_flags = true; 88 - user = { 89 - name = "lassulus"; 90 - primary_email = "lassulus@lassul.us"; 91 - other_email = lib.concatStringsSep ";" (lib.flatten (lib.attrValues mailboxes)); 92 - }; 93 - }; 94 - passthru = { 95 - mailboxes = mailboxes; 96 - }; 97 - }; 98 + notmuchConfig.wrapper; 98 99 }; 99 100 }
+2 -2
tools/pass/flake-module.nix
··· 1 - { self, ... }: 1 + { self, inputs, ... }: 2 2 { 3 3 perSystem = 4 4 { ··· 7 7 ... 8 8 }: 9 9 { 10 - packages.pass = self.wrapLib.makeWrapper { 10 + packages.pass = inputs.wrappers.lib.wrapPackage { 11 11 pkgs = pkgs; 12 12 package = pkgs.passage; 13 13 runtimeInputs = [
+2 -2
tools/pi/flake-module.nix
··· 1 - { self, ... }: 1 + { self, inputs, ... }: 2 2 { 3 3 perSystem = 4 4 { pkgs, system, ... }: ··· 52 52 ''; 53 53 in 54 54 { 55 - packages.pi = self.wrapLib.makeWrapper { 55 + packages.pi = inputs.wrappers.lib.wrapPackage { 56 56 pkgs = pkgs; 57 57 package = piPkg; 58 58 runtimeInputs = [ pkgs.nodejs ];
+2 -2
tools/ssh-yubikey/flake-module.nix
··· 1 - { self, ... }: 1 + { self, inputs, ... }: 2 2 { 3 3 perSystem = 4 4 { pkgs, ... }: 5 5 { 6 - packages.ssh-yubikey = self.wrapLib.makeWrapper { 6 + packages.ssh-yubikey = inputs.wrappers.lib.wrapPackage { 7 7 pkgs = pkgs; 8 8 package = pkgs.openssh; 9 9 env = {
+3 -3
tools/tmux/flake-module.nix
··· 1 - { self, ... }: 1 + { self, inputs, ... }: 2 2 { 3 3 perSystem = 4 4 { pkgs, ... }: ··· 18 18 in 19 19 { 20 20 packages.tmux = 21 - (self.wrapLib.makeWrapper { 21 + (inputs.wrappers.lib.wrapPackage { 22 22 pkgs = pkgs; 23 23 package = pkgs.tmux; 24 24 flags = { 25 - "-f" = tmuxConfigFile; 25 + "-f" = "${tmuxConfigFile}"; 26 26 }; 27 27 }).overrideAttrs 28 28 (old: {
+2 -2
tools/zsh/flake-module.nix
··· 1 - { self, ... }: 1 + { self, inputs, ... }: 2 2 { 3 3 perSystem = 4 4 { pkgs, ... }: ··· 343 343 in 344 344 { 345 345 packages.zsh = 346 - (self.wrapLib.makeWrapper { 346 + (inputs.wrappers.lib.wrapPackage { 347 347 pkgs = pkgs; 348 348 package = pkgs.zsh; 349 349 runtimeInputs = with pkgs; [
-43
wrapperModules/mpv/default.nix
··· 1 - { 2 - self, 3 - lib, 4 - ... 5 - }: 6 - { 7 - flake.wrapperModules.mpv = self.wrapLib.mkWrapper ( 8 - wlib: 9 - { config, ... }: 10 - { 11 - options = { 12 - scripts = lib.mkOption { 13 - type = lib.types.listOf lib.types.package; 14 - default = [ ]; 15 - description = "Scripts to add to mpv via override."; 16 - }; 17 - "mpv.input" = lib.mkOption { 18 - type = wlib.types.file config.pkgs; 19 - default.content = ""; 20 - }; 21 - "mpv.conf" = lib.mkOption { 22 - type = wlib.types.file config.pkgs; 23 - default.content = ""; 24 - }; 25 - extraFlags = lib.mkOption { 26 - type = lib.types.attrsOf lib.types.unspecified; # TODO add list handling 27 - default = { }; 28 - description = "Extra flags to pass to mpv."; 29 - }; 30 - }; 31 - config.flags = { 32 - "--input-conf" = config."mpv.input".path; 33 - "--include" = config."mpv.conf".path; 34 - } 35 - // config.extraFlags; 36 - config.package = lib.mkDefault ( 37 - config.pkgs.mpv.override { 38 - scripts = config.scripts; 39 - } 40 - ); 41 - } 42 - ); 43 - }
-34
wrapperModules/notmuch/default.nix
··· 1 - { 2 - self, 3 - lib, 4 - ... 5 - }: 6 - { 7 - flake.wrapperModules.notmuch = self.wrapLib.mkWrapper ( 8 - wlib: 9 - { config, ... }: 10 - let 11 - iniFmt = config.pkgs.formats.ini { }; 12 - writeNotmuchConfig = cfg: iniFmt.generate "notmuch.ini" cfg; 13 - in 14 - { 15 - options = { 16 - config = lib.mkOption { 17 - type = iniFmt.type; 18 - default = { 19 - database = { 20 - path = "Maildir"; 21 - mail_root = "Maildir"; 22 - }; 23 - }; 24 - }; 25 - configFile = lib.mkOption { 26 - type = wlib.types.file config.pkgs; 27 - default.path = toString (writeNotmuchConfig config.config); 28 - }; 29 - }; 30 - config.package = config.pkgs.notmuch; 31 - config.env.NOTMUCH_CONFIG = config.configFile.path; 32 - } 33 - ); 34 - }