The world's most clever kitty cat

Improve NixOS module

bwc9876.dev 7634c9fd 95483770

verified
+90 -13
+76 -2
Cargo.lock
··· 1004 1004 "once_cell", 1005 1005 "socket2", 1006 1006 "tracing", 1007 - "windows-sys 0.52.0", 1007 + "windows-sys 0.60.2", 1008 1008 ] 1009 1009 1010 1010 [[package]] ··· 2050 2050 2051 2051 [[package]] 2052 2052 name = "windows-sys" 2053 + version = "0.60.2" 2054 + source = "registry+https://github.com/rust-lang/crates.io-index" 2055 + checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb" 2056 + dependencies = [ 2057 + "windows-targets 0.53.5", 2058 + ] 2059 + 2060 + [[package]] 2061 + name = "windows-sys" 2053 2062 version = "0.61.2" 2054 2063 source = "registry+https://github.com/rust-lang/crates.io-index" 2055 2064 checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" ··· 2081 2090 "windows_aarch64_gnullvm 0.52.6", 2082 2091 "windows_aarch64_msvc 0.52.6", 2083 2092 "windows_i686_gnu 0.52.6", 2084 - "windows_i686_gnullvm", 2093 + "windows_i686_gnullvm 0.52.6", 2085 2094 "windows_i686_msvc 0.52.6", 2086 2095 "windows_x86_64_gnu 0.52.6", 2087 2096 "windows_x86_64_gnullvm 0.52.6", ··· 2089 2098 ] 2090 2099 2091 2100 [[package]] 2101 + name = "windows-targets" 2102 + version = "0.53.5" 2103 + source = "registry+https://github.com/rust-lang/crates.io-index" 2104 + checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3" 2105 + dependencies = [ 2106 + "windows-link", 2107 + "windows_aarch64_gnullvm 0.53.1", 2108 + "windows_aarch64_msvc 0.53.1", 2109 + "windows_i686_gnu 0.53.1", 2110 + "windows_i686_gnullvm 0.53.1", 2111 + "windows_i686_msvc 0.53.1", 2112 + "windows_x86_64_gnu 0.53.1", 2113 + "windows_x86_64_gnullvm 0.53.1", 2114 + "windows_x86_64_msvc 0.53.1", 2115 + ] 2116 + 2117 + [[package]] 2092 2118 name = "windows_aarch64_gnullvm" 2093 2119 version = "0.42.2" 2094 2120 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 2101 2127 checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" 2102 2128 2103 2129 [[package]] 2130 + name = "windows_aarch64_gnullvm" 2131 + version = "0.53.1" 2132 + source = "registry+https://github.com/rust-lang/crates.io-index" 2133 + checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53" 2134 + 2135 + [[package]] 2104 2136 name = "windows_aarch64_msvc" 2105 2137 version = "0.42.2" 2106 2138 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 2113 2145 checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" 2114 2146 2115 2147 [[package]] 2148 + name = "windows_aarch64_msvc" 2149 + version = "0.53.1" 2150 + source = "registry+https://github.com/rust-lang/crates.io-index" 2151 + checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006" 2152 + 2153 + [[package]] 2116 2154 name = "windows_i686_gnu" 2117 2155 version = "0.42.2" 2118 2156 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 2125 2163 checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" 2126 2164 2127 2165 [[package]] 2166 + name = "windows_i686_gnu" 2167 + version = "0.53.1" 2168 + source = "registry+https://github.com/rust-lang/crates.io-index" 2169 + checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3" 2170 + 2171 + [[package]] 2128 2172 name = "windows_i686_gnullvm" 2129 2173 version = "0.52.6" 2130 2174 source = "registry+https://github.com/rust-lang/crates.io-index" 2131 2175 checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" 2132 2176 2133 2177 [[package]] 2178 + name = "windows_i686_gnullvm" 2179 + version = "0.53.1" 2180 + source = "registry+https://github.com/rust-lang/crates.io-index" 2181 + checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c" 2182 + 2183 + [[package]] 2134 2184 name = "windows_i686_msvc" 2135 2185 version = "0.42.2" 2136 2186 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 2143 2193 checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" 2144 2194 2145 2195 [[package]] 2196 + name = "windows_i686_msvc" 2197 + version = "0.53.1" 2198 + source = "registry+https://github.com/rust-lang/crates.io-index" 2199 + checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2" 2200 + 2201 + [[package]] 2146 2202 name = "windows_x86_64_gnu" 2147 2203 version = "0.42.2" 2148 2204 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 2155 2211 checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" 2156 2212 2157 2213 [[package]] 2214 + name = "windows_x86_64_gnu" 2215 + version = "0.53.1" 2216 + source = "registry+https://github.com/rust-lang/crates.io-index" 2217 + checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499" 2218 + 2219 + [[package]] 2158 2220 name = "windows_x86_64_gnullvm" 2159 2221 version = "0.42.2" 2160 2222 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 2167 2229 checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" 2168 2230 2169 2231 [[package]] 2232 + name = "windows_x86_64_gnullvm" 2233 + version = "0.53.1" 2234 + source = "registry+https://github.com/rust-lang/crates.io-index" 2235 + checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1" 2236 + 2237 + [[package]] 2170 2238 name = "windows_x86_64_msvc" 2171 2239 version = "0.42.2" 2172 2240 source = "registry+https://github.com/rust-lang/crates.io-index" ··· 2177 2245 version = "0.52.6" 2178 2246 source = "registry+https://github.com/rust-lang/crates.io-index" 2179 2247 checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" 2248 + 2249 + [[package]] 2250 + name = "windows_x86_64_msvc" 2251 + version = "0.53.1" 2252 + source = "registry+https://github.com/rust-lang/crates.io-index" 2253 + checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" 2180 2254 2181 2255 [[package]] 2182 2256 name = "wit-bindgen"
+7 -4
flake.nix
··· 30 30 selectToolchain = pkgs: pkgs.fenix.default; 31 31 mkCrane = pkgs: (crane.mkLib pkgs).overrideToolchain (selectToolchain pkgs).toolchain; 32 32 mkCraneStuff = pkgs: let 33 - src = ./.; 33 + craneLib = mkCrane pkgs; 34 34 commonArgs = { 35 - src = (mkCrane pkgs).cleanCargoSource src; 35 + src = craneLib.cleanCargoSource ./.; 36 36 strictDeps = true; 37 37 }; 38 - craneLib = mkCrane pkgs; 39 38 cargoArtifacts = craneLib.buildDepsOnly commonArgs; 40 39 in { 41 40 inherit 42 - src 43 41 commonArgs 44 42 craneLib 45 43 cargoArtifacts ··· 61 59 }; 62 60 }; 63 61 devShell = pkgs: (mkCrane pkgs).devShell {}; 62 + nixosModule = {lib, ...}: { 63 + imports = ["./nixosModule.nix"]; 64 + 65 + services.bingus-bot.package = lib.mkDefault self.packages.default; 66 + }; 64 67 package = { 65 68 rustPlatform, 66 69 lib,
+7 -7
nix/nixosModule.nix nixosModule.nix
··· 1 1 { 2 - pkgs, 3 2 lib, 4 3 config, 5 4 ... ··· 7 6 cfg = config.services.bingus-bot; 8 7 in { 9 8 options.services.bingus-bot = { 10 - enable = lib.mkOption { 11 - type = lib.types.bool; 12 - default = false; 13 - example = true; 14 - description = "Whether to enable Bingus, a Discord bot that uses Markov Chains"; 9 + enable = lib.mkEnableOption "Bingus, a Discord bot that uses Markov Chains"; 10 + 11 + package = lib.mkOption { 12 + description = "Package to use for bingus"; 13 + type = lib.types.package; 15 14 }; 16 15 17 16 tokenFile = lib.mkOption { ··· 48 47 }; 49 48 50 49 serviceConfig = { 51 - ExecStart = lib.getExe pkgs.bingus; 50 + ExecStart = lib.getExe cfg.package; 52 51 Restart = "always"; 52 + RestartSec = "5s"; 53 53 StateDirectory = "bingus"; 54 54 StateDirectoryMode = "0755"; 55 55 LoadCredential = "token:${cfg.tokenFile}";