updated modules in flake

This commit is contained in:
Kristian Krsnik 2023-08-01 21:59:54 +02:00
parent 12a4ab7ae7
commit 28e7a2855e
3 changed files with 118 additions and 42 deletions

View File

@ -5,13 +5,14 @@
nixpkgs.url = github:nixos/nixpkgs/nixos-23.05;
};
outputs = { self, nixpkgs }:
let
outputs = {
self,
nixpkgs,
} @ inputs: let
supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
in {
# Formatter
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra);
@ -23,13 +24,12 @@
# Dev Shell
devShells = forAllSystems (system: {
default = pkgs.${system}.mkShellNoCC {
shellHook = "Welcome to your nix-powered dev environment for dyn-gandi!";
shellHook = "echo Welcome to your nix-powered dev environment for dyn-gandi!";
packages = with pkgs.${system}; [
(poetry2nix.mkPoetryEnv {projectDir = self;})
poetry
];
};
});
@ -41,6 +41,9 @@
};
});
# Home Manager Module
homeManagerModules.default = import ./nix/hm-module.nix self;
# NixOS Module
#nixosModules.default = import ./nix/module.nix inputs;
};
}

View File

@ -1,15 +1,72 @@
{ config, lib, pkgs, ... }:
let
cfg = config.dyn-gandi;
self: {
config,
lib,
pkgs,
...
}: let
cfg = config.services.dyn-gandi;
inherit (lib) mkIf mkEnableOption mkOption types;
in {
options.services.dyn-gandi = {
enable = mkEnableOption "dyn-gandi";
options.dyn-gandi = {
enable = lib.mkEnableOption null // {
description = lib.mdDoc '''';
timer = lib.mkOption {
type = lib.types.int;
default = 0;
description = lib.mdDoc ''
The time intervall in seconds the script should be repeated.
0 disables automatic starts.
'';
};
settings = mkOption {
type = with types; let
valueType = nullOr (oneOf [
bool
int
float
str
path
(attrsOf valueType)
(listOf valueType)
]);
in
valueType;
default = {api = {"example.com" = ["@" "www"];};};
example = {
General = {
disabledTrayIcon = true;
showStartupLaunchMessage = false;
};
};
description = '''';
};
};
config = lib.mkIf cfg.enable {
config = mkIf cfg.enable {
home.packages = [self.packages.x86_64-linux.default];
xdg.configFile."dyn-gandi/config.json" = {
text = builtins.toJSON cfg.settings;
};
systemd.user.services.dyn-gandi =
mkIf cfg.timer
!= 0 {
Unit = {
Description = "DNS Updater tool for Gandi.net";
After = ["graphical-session-pre.target"];
PartOf = ["graphical-session.target"];
};
};
systemd.user.timers.dyn-gandi = {
wantedBy = ["timers.target"];
timerConfig = {
OnBootSec = "0s";
OnUnitActiveSec = "${cfg.timer}s";
Unit = "dyn-gandi.service";
};
};
};
}

16
nix/module.nix Normal file
View File

@ -0,0 +1,16 @@
inputs: { config, lib, pkgs, ... }:
let
cfg = config.services.dyn-gandi;
inherit (lib) mkIf mkEnableOption;
#package = inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.default;
in {
options.services.dyn-gandi = {
enable = mkEnableOption null;
};
config = mkIf cfg.enable {
environment.systemPackages = [ cfg.package ];
}
}