This repository has no description
0

Configure Feed

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

wrapperModules: make more pure, add option export, implement notmuch

+152 -111
+64 -39
wrapperModules/flake-module.nix
··· 2 2 { 3 3 imports = [ 4 4 ./mpv/default.nix 5 + ./notmuch/default.nix 5 6 ]; 6 - flake.wrapLib.mkWrapper = 7 - argsFun: settings: 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 + flake.config.wrapLib.mkWrapper = 13 + declarationArgs: 8 14 let 9 - args = argsFun wrapperLib; 10 - pkgs = args.pkgs; 11 - module = args.module; 15 + declaration = declarationArgs wrapperLib; 12 16 13 17 wrapperLib = { 14 18 types = { 15 19 inherit file; 16 20 }; 17 21 }; 18 - file = lib.types.submodule ( 19 - { name, config, ... }: 20 - { 21 - options = { 22 - content = lib.mkOption { 23 - type = lib.types.lines; 24 - description = '' 25 - content of file 26 - ''; 27 - }; 28 - path = lib.mkOption { 29 - type = lib.types.path; 30 - description = '' 31 - the path to the file 32 - ''; 33 - default = pkgs.writeText name config.content; 34 - }; 35 - }; 36 - } 37 - ); 38 - eval = lib.evalModules { 39 - modules = [ 40 - module 22 + file = 23 + pkgs: 24 + lib.types.submodule ( 25 + { name, config, ... }: 41 26 { 42 27 options = { 28 + content = lib.mkOption { 29 + type = lib.types.lines; 30 + description = '' 31 + content of file 32 + ''; 33 + }; 34 + path = lib.mkOption { 35 + type = lib.types.path; 36 + description = '' 37 + the path to the file 38 + ''; 39 + default = pkgs.writeText name config.content; 40 + defaultText = "pkgs.writeText name <content>"; 41 + }; 42 + }; 43 + } 44 + ); 45 + evalArgs = cfg: { 46 + modules = [ 47 + declaration 48 + cfg 49 + { 50 + options = { 51 + pkgs = lib.mkOption { 52 + description = "The pkgs to use."; 53 + }; 43 54 package = lib.mkOption { 44 55 type = lib.types.package; 45 56 description = "The base package to use."; ··· 52 63 type = lib.types.attrsOf lib.types.unspecified; # TODO add list handling 53 64 default = { }; 54 65 }; 66 + env = lib.mkOption { 67 + type = lib.types.attrsOf lib.types.str; 68 + default = { }; 69 + }; 55 70 passthru = lib.mkOption { 56 71 type = lib.types.attrs; 57 72 default = { }; 58 73 }; 59 74 }; 60 - config = settings; 61 75 } 62 76 ]; 63 77 }; 64 - config = eval.config; 65 - options = eval.options; 66 78 in 67 - self.libWithPkgs.${pkgs.system}.makeWrapper config.package { 68 - runtimeInputs = config.extraPackages; 69 - flagSeparator = "="; 70 - flags = config.flags; 71 - passthru = { 72 - inherit options config settings; 73 - } 74 - // config.passthru; 79 + { 80 + options = (lib.evalModules (evalArgs { })).options; 81 + apply = 82 + settings: 83 + let 84 + eval = lib.evalModules (evalArgs { 85 + config = settings; 86 + }); 87 + options = eval.options; 88 + config = eval.config; 89 + in 90 + self.libWithPkgs.${config.pkgs.system}.makeWrapper config.package { 91 + runtimeInputs = config.extraPackages; 92 + flagSeparator = "="; 93 + flags = config.flags; 94 + env = config.env; 95 + passthru = { 96 + inherit options config settings; 97 + } 98 + // config.passthru; 99 + }; 75 100 }; 76 101 }
+3 -2
tools/mpv/flake-module.nix
··· 1 1 { self, ... }: 2 2 { 3 3 perSystem = 4 - { self', pkgs, ... }: 4 + { pkgs, ... }: 5 5 { 6 6 packages.mpv = 7 7 let ··· 46 46 ''; 47 47 48 48 in 49 - self'.legacyPackages.wrappers.mpv { 49 + self.wrapperModules.mpv.apply { 50 + pkgs = pkgs; 50 51 scripts = with pkgs.mpvScripts; [ 51 52 sponsorblock 52 53 quality-menu
+16 -27
tools/notmuch/flake-module.nix
··· 2 2 { 3 3 perSystem = 4 4 { 5 - pkgs, 6 5 lib, 7 - system, 6 + pkgs, 8 7 ... 9 8 }: 10 9 { ··· 75 74 ]; 76 75 }; 77 76 78 - notmuchConfig = '' 79 - [database] 80 - path=Maildir 81 - mail_root=Maildir 82 - 83 - [user] 84 - name=lassulus 85 - primary_email=lassulus@lassul.us 86 - other_email=lass@mors.r;${lib.concatStringsSep ";" (lib.flatten (lib.attrValues mailboxes))} 87 - 88 - [new] 89 - tags=unread;inbox; 90 - ignore= 91 - 92 - [search] 93 - exclude_tags=deleted;spam; 94 - 95 - [maildir] 96 - synchronize_flags=true 97 - ''; 98 - 99 77 in 100 - self.libWithPkgs.${pkgs.system}.makeWrapper pkgs.notmuch { 101 - env = { 102 - NOTMUCH_CONFIG = "${pkgs.writeText "notmuch-config" notmuchConfig}"; 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 + }; 103 93 }; 104 94 passthru = { 105 - notmuchConfig = notmuchConfig; 106 95 mailboxes = mailboxes; 107 96 }; 108 97 };
+35 -43
wrapperModules/mpv/default.nix
··· 4 4 ... 5 5 }: 6 6 { 7 - perSystem = 8 - { pkgs, ... }: 7 + flake.wrapperModules.mpv = self.wrapLib.mkWrapper ( 8 + wlib: 9 + { config, ... }: 9 10 { 10 - legacyPackages.wrappers.mpv = self.wrapLib.mkWrapper (wlib: { 11 - inherit pkgs; 12 - module = 13 - { config, ... }: 14 - { 15 - options = { 16 - scripts = lib.mkOption { 17 - type = lib.types.listOf lib.types.package; 18 - default = [ ]; 19 - description = "Scripts to add to mpv via override."; 20 - }; 21 - "mpv.input" = lib.mkOption { 22 - type = wlib.types.file; 23 - default.content = ""; 24 - }; 25 - "mpv.conf" = lib.mkOption { 26 - type = wlib.types.file; 27 - default.content = '' 28 - osd-font-size=20 29 - ''; 30 - }; 31 - extraFlags = lib.mkOption { 32 - type = lib.types.attrsOf lib.types.unspecified; # TODO add list handling 33 - default = { }; 34 - description = "Extra flags to pass to mpv."; 35 - }; 36 - }; 37 - config.flags = { 38 - "--no-config" = { }; 39 - "--input-conf" = config."mpv.input".path; 40 - "--include" = config."mpv.conf".path; 41 - } 42 - // config.extraFlags; 43 - config.package = lib.mkDefault ( 44 - pkgs.mpv.override { 45 - scripts = config.scripts; 46 - } 47 - ); 48 - }; 49 - }); 50 - }; 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 + ); 51 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 + }