You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.2 KiB
79 lines
2.2 KiB
{ |
|
|
|
inputs = { |
|
naersk.url = "github:nmattia/naersk/master"; |
|
naersk.inputs.nixpkgs.follows = "nixpkgs"; |
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; |
|
utils.url = "github:numtide/flake-utils"; |
|
}; |
|
|
|
outputs = { self, nixpkgs, utils, naersk }: |
|
utils.lib.eachDefaultSystem (system: |
|
let |
|
pkgs = import nixpkgs { inherit system; }; |
|
naersk-lib = pkgs.callPackage naersk { }; |
|
in { |
|
|
|
defaultPackage = naersk-lib.buildPackage { |
|
src = ./.; |
|
buildInputs = with pkgs; [ pkg-config openssl ]; |
|
}; |
|
|
|
defaultApp = utils.lib.mkApp { drv = self.defaultPackage."${system}"; }; |
|
|
|
devShell = with pkgs; |
|
mkShell { |
|
buildInputs = [ |
|
# rust |
|
cargo |
|
cargo-watch |
|
rustc |
|
rust-analyzer |
|
rustfmt |
|
rustPackages.clippy |
|
|
|
# system |
|
pkg-config |
|
openssl |
|
cmake |
|
|
|
# dhall |
|
dhall |
|
dhall-json |
|
|
|
jo |
|
]; |
|
RUST_LOG = "info"; |
|
RUST_SRC_PATH = rustPlatform.rustLibSrc; |
|
}; |
|
|
|
nixosModules.bot = { config, lib, ... }: { |
|
options.within.services.mara-bot.enable = |
|
lib.mkEnableOption "enable Mara bot"; |
|
|
|
config = lib.mkIf config.within.services.mara-bot.enable { |
|
users.groups.mara-bot = { }; |
|
|
|
users.users.mara-bot = { |
|
createHome = true; |
|
isSystemUser = true; |
|
home = "/var/lib/mara-bot"; |
|
group = "mara-bot"; |
|
}; |
|
|
|
systemd.services.mara-bot = { |
|
wantedBy = [ "multi-user.target" ]; |
|
environment.RUST_LOG = "tower_http=debug,info"; |
|
unitConfig.ConditionPathExists = "/var/lib/mara-bot/config.yaml"; |
|
serviceConfig = { |
|
User = "mara-bot"; |
|
Group = "mara-bot"; |
|
Restart = "always"; |
|
WorkingDirectory = "/var/lib/mara-bot"; |
|
ExecStart = "${self.defaultPackage."${system}"}/bin/mara"; |
|
}; |
|
}; |
|
}; |
|
}; |
|
}); |
|
}
|
|
|