Fix module
This commit is contained in:
12
flake.nix
12
flake.nix
@@ -13,13 +13,17 @@
|
||||
flake-utils,
|
||||
}:
|
||||
flake-utils.lib.eachDefaultSystem (system: let
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
pkgs = import nixpkgs {inherit system;};
|
||||
in {
|
||||
packages = rec {
|
||||
tauron-scrapper = pkgs.callPackage ./package.nix {};
|
||||
default = tauron-scrapper;
|
||||
};
|
||||
|
||||
nixosModules.tauron-scrapper = pkgs.callPackage ./module.nix {inherit self;};
|
||||
});
|
||||
})
|
||||
// {
|
||||
nixosModules = rec {
|
||||
tauron-scrapper = import ./module.nix self;
|
||||
default = tauron-scrapper;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
29
module.nix
29
module.nix
@@ -1,23 +1,36 @@
|
||||
{
|
||||
self: {
|
||||
config,
|
||||
coreutils-full,
|
||||
formats,
|
||||
pkgs,
|
||||
system,
|
||||
utils,
|
||||
lib,
|
||||
self,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
inherit (utils.systemdUtils.unitOptions) unitOption;
|
||||
inherit (pkgs) coreutils-full formats;
|
||||
inherit (lib.utils.systemdUtils.unitOptions) unitOption;
|
||||
cfg = config.services.tauron-scrapper;
|
||||
yamlConfig = (formats.yaml {}).generate "tauron-scrapper-config.yaml" cfg.config;
|
||||
in {
|
||||
options.services.tauron-scrapper = {
|
||||
enable = mkEnableOption "tauron-scrapper";
|
||||
|
||||
cliArgs = mkOption {
|
||||
type = types.attrs;
|
||||
description = "List of CLI arguments. Do not put '-c' argument here as it will be automatically appended basing on the 'config' option.";
|
||||
|
||||
example = {
|
||||
date = "$(date -d '5 days ago' '+%Y-%m-%d')";
|
||||
to = "$(date -d 'yesterday' '+%Y-%m-%d')";
|
||||
};
|
||||
|
||||
default = {
|
||||
date = "$(date -d '5 days ago' '+%Y-%m-%d')";
|
||||
to = "$(date -d 'yesterday' '+%Y-%m-%d')";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkOption {
|
||||
type = types.attr;
|
||||
type = types.attrs;
|
||||
description = "The configuration of tauron-scrapper command";
|
||||
example = {
|
||||
timezone = "Europe/Warsaw";
|
||||
@@ -93,7 +106,7 @@ in {
|
||||
path = [self.packages.${system}.tauron-scrapper coreutils-full];
|
||||
|
||||
script = ''
|
||||
tauron-scrapper -c ${yamlConfig} -d "$(date -d "yesterday" '+%Y-%m-%d')"
|
||||
tauron-scrapper -c ${yamlConfig} ${lib.cli.toGNUCommandLineShell {} cfg.cliArgs}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user