This repository has no description
0

Configure Feed

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

superconfig / wrapperModules / flake-module.nix
2.8 kB 101 lines
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 flake.config.wrapLib.mkWrapper = 13 declarationArgs: 14 let 15 declaration = declarationArgs wrapperLib; 16 17 wrapperLib = { 18 types = { 19 inherit file; 20 }; 21 }; 22 file = 23 pkgs: 24 lib.types.submodule ( 25 { name, config, ... }: 26 { 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 }; 54 package = lib.mkOption { 55 type = lib.types.package; 56 description = "The base package to use."; 57 }; 58 extraPackages = lib.mkOption { 59 type = lib.types.listOf lib.types.package; 60 default = [ ]; 61 }; 62 flags = lib.mkOption { 63 type = lib.types.attrsOf lib.types.unspecified; # TODO add list handling 64 default = { }; 65 }; 66 env = lib.mkOption { 67 type = lib.types.attrsOf lib.types.str; 68 default = { }; 69 }; 70 passthru = lib.mkOption { 71 type = lib.types.attrs; 72 default = { }; 73 }; 74 }; 75 } 76 ]; 77 }; 78 in 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 }; 100 }; 101}