File tree Expand file tree Collapse file tree 5 files changed +169
-51
lines changed
Expand file tree Collapse file tree 5 files changed +169
-51
lines changed Original file line number Diff line number Diff line change 1- { pkgs ? import <nixpkgs> { } } :
2- with pkgs ;
3- mkYarnPackage rec {
4- pname = "untis-ics-sync" ;
5- version = "0.5.10" ;
1+ {
2+ mkYarnPackage ,
3+ fetchYarnDeps ,
4+ makeWrapper ,
5+ lib ,
6+ nodejs ,
7+ } :
8+ mkYarnPackage rec {
9+ pname = "untis-ics-sync" ;
10+ version = "0.6.0" ;
611
7- src = ./. ;
12+ src = ./. ;
813
9- offlineCache = fetchYarnDeps {
10- yarnLock = src + "/yarn.lock" ;
11- hash = "sha256-NHghkf5Nziyz3M7E4941sV5JFqY7RYMTlZqYsQPZLpU=" ;
12- } ;
14+ offlineCache = fetchYarnDeps {
15+ yarnLock = src + "/yarn.lock" ;
16+ hash = "sha256-NHghkf5Nziyz3M7E4941sV5JFqY7RYMTlZqYsQPZLpU=" ;
17+ } ;
1318
14- packageJSON = ./package.json ;
15- yarnLock = ./yarn.lock ;
19+ nativeBuildInputs = [ makeWrapper ] ;
1620
17- buildPhase = ''
18- export HOME=$(mktemp -d)
19- yarn --offline build
20- '' ;
21+ packageJSON = ./package.json ;
22+ yarnLock = ./yarn.lock ;
2123
22- distPhase = "true" ;
23- }
24+ buildPhase = ''
25+ yarn --offline run build
26+ '' ;
27+
28+ postInstall = ''
29+ makeWrapper ${ lib . getExe nodejs } "$out/bin/untis-ics-sync" \
30+ --add-flags "$out/libexec/untis-ics-sync/deps/untis-ics-sync/dist/main.js"
31+ '' ;
32+
33+ meta = with lib ; {
34+ description = "Serves a calendar API (ICS) for events provided from Untis" ;
35+ homepage = "https://github.com/bddvlpr/untis-ics-sync" ;
36+ license = licenses . bsd3 ;
37+ maintainers = with maintainers ; [ bddvlpr ] ;
38+ mainProgram = "untis-ics-sync" ;
39+ } ;
40+ }
Original file line number Diff line number Diff line change 11{
22 inputs = {
3- nixpkgs . url = "nixpkgs/nixpkgs-unstable" ;
3+ nixpkgs . url = "github:nixos/nixpkgs/nixpkgs-unstable" ;
4+ flake-parts . url = "github:hercules-ci/flake-parts" ;
45 } ;
56
6- outputs = { nixpkgs , ...} : let
7- forAllSystems = nixpkgs . lib . genAttrs [
8- "aarch64-linux"
9- "aarch64-darwin"
10- "x86_64-darwin"
11- "x86_64-linux"
12- ] ;
13- in {
14- formatter = forAllSystems ( system : nixpkgs . legacyPackages . ${ system } . alejandra ) ;
7+ outputs = inputs @ {
8+ self ,
9+ flake-parts ,
10+ ...
11+ } :
12+ flake-parts . lib . mkFlake { inherit inputs ; } {
13+ systems = [
14+ "aarch64-linux"
15+ "aarch64-darwin"
16+ "x86_64-darwin"
17+ "x86_64-linux"
18+ ] ;
1519
16- packages = forAllSystems (
17- system : let
18- pkgs = nixpkgs . legacyPackages . ${ system } ;
19- in {
20- default = import ./default.nix { inherit pkgs ; } ;
21- }
22- ) ;
20+ perSystem = { pkgs , ...} : {
21+ formatter = pkgs . alejandra ;
2322
24- devShell = forAllSystems (
25- system : let
26- pkgs = nixpkgs . legacyPackages . ${ system } ;
27- in
28- pkgs . mkShell {
23+ packages = rec {
24+ default = pkgs . callPackage ./default.nix { } ;
25+ untis-ics-sync = default ;
26+ } ;
27+
28+ devShells . default = pkgs . mkShell {
2929 buildInputs = with pkgs ; [ nodejs yarn nest-cli ] ;
30- }
31- ) ;
32- } ;
30+ } ;
31+ } ;
32+
33+ flake = {
34+ nixosModules = rec {
35+ default = import ./module.nix self ;
36+ untis-ics-sync = default ;
37+ } ;
38+ } ;
39+ } ;
3340}
Original file line number Diff line number Diff line change 1+ self : {
2+ config ,
3+ lib ,
4+ pkgs ,
5+ ...
6+ } : let
7+ cfg = config . services . untis-ics-sync ;
8+ in {
9+ options . services . untis-ics-sync = let
10+ inherit ( lib ) mkEnableOption mkPackageOption mkOption types ;
11+ inherit ( pkgs . stdenv . hostPlatform ) system ;
12+ in {
13+ enable = mkEnableOption "Untis ICS Sync" ;
14+ package = mkPackageOption self . packages . ${ system } "default" { } ;
15+
16+ envFile = mkOption {
17+ type = types . path ;
18+ description = "The environment file with credentials." ;
19+ } ;
20+
21+ user = mkOption {
22+ type = types . str ;
23+ default = "untis-ics-sync" ;
24+ description = "The user to run untis-ics-sync under." ;
25+ } ;
26+ group = mkOption {
27+ type = types . str ;
28+ default = "untis-ics-sync" ;
29+ description = "The group to run untis-ics-sync under." ;
30+ } ;
31+ } ;
32+
33+ config = lib . mkIf cfg . enable {
34+ systemd . services . untis-ics-sync = {
35+ description = "untis-ics-sync" ;
36+ wantedBy = [ "multi-user.target" ] ;
37+ wants = [ "network-online.target" ] ;
38+ after = [ "network-online.target" ] ;
39+
40+ serviceConfig = {
41+ Restart = "on-failure" ;
42+ ExecStart = "${ lib . getExe cfg . package } " ;
43+ EnvironmentFile = cfg . envFile ;
44+ User = cfg . user ;
45+ Group = cfg . group ;
46+ } ;
47+ } ;
48+
49+ users = {
50+ users . untis-ics-sync = lib . mkIf ( cfg . user == "untis-ics-sync" ) {
51+ isSystemUser = true ;
52+ group = cfg . group ;
53+ } ;
54+ groups . untis-ics-sync = lib . mkIf ( cfg . group == "untis-ics-sync" ) { } ;
55+ } ;
56+ } ;
57+ }
Original file line number Diff line number Diff line change 11{
22 "name" : " untis-ics-sync" ,
3- "version" : " 0.5.10 " ,
3+ "version" : " 0.6.0 " ,
44 "description" : " Serves a calendar API (ICS) for events provided from Untis." ,
55 "author" : " Luna Simons <luna@bddvlpr.com> (https://bddvlpr.com)" ,
6- "bin" : " dist/main.js" ,
76 "license" : " BSD-3-Clause" ,
87 "private" : true ,
98 "scripts" : {
You can’t perform that action at this time.
0 commit comments