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,42 +5,45 @@
nixpkgs.url = github:nixos/nixpkgs/nixos-23.05; nixpkgs.url = github:nixos/nixpkgs/nixos-23.05;
}; };
outputs = { self, nixpkgs }: outputs = {
let self,
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; nixpkgs,
forAllSystems = nixpkgs.lib.genAttrs supportedSystems; } @ inputs: let
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system}); supportedSystems = ["x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin"];
in { forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
in {
# Formatter
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra);
# Formatter # Packages
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.alejandra); packages = forAllSystems (system: {
default = pkgs.${system}.poetry2nix.mkPoetryApplication {projectDir = self;};
});
# Packages # Dev Shell
packages = forAllSystems (system: { devShells = forAllSystems (system: {
default = pkgs.${system}.poetry2nix.mkPoetryApplication { projectDir = self; }; default = pkgs.${system}.mkShellNoCC {
}); shellHook = "echo Welcome to your nix-powered dev environment for dyn-gandi!";
# Dev Shell packages = with pkgs.${system}; [
devShells = forAllSystems (system: { (poetry2nix.mkPoetryEnv {projectDir = self;})
default = pkgs.${system}.mkShellNoCC { poetry
shellHook = "Welcome to your nix-powered dev environment for dyn-gandi!"; ];
};
});
packages = with pkgs.${system}; [ # Run as apps
(poetry2nix.mkPoetryEnv { projectDir = self; }) apps = forAllSystems (system: {
poetry default = {
]; program = "${self.packages.${system}.default}/bin/dyn_gandi";
type = "app";
};
});
}; # Home Manager Module
}); homeManagerModules.default = import ./nix/hm-module.nix self;
# NixOS Module
# Run as apps #nixosModules.default = import ./nix/module.nix inputs;
apps = forAllSystems (system: { };
default = {
program = "${self.packages.${system}.default}/bin/dyn_gandi";
type = "app";
};
});
homeManagerModules.default = import ./nix/hm-module.nix self;
};
} }

View File

@ -1,15 +1,72 @@
{ config, lib, pkgs, ... }: self: {
let config,
cfg = config.dyn-gandi; lib,
pkgs,
...
}: let
cfg = config.services.dyn-gandi;
inherit (lib) mkIf mkEnableOption mkOption types;
in { in {
options.services.dyn-gandi = {
enable = mkEnableOption "dyn-gandi";
options.dyn-gandi = { timer = lib.mkOption {
enable = lib.mkEnableOption null // { type = lib.types.int;
description = lib.mdDoc ''''; 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 ];
}
}