diff --git a/flake.nix b/flake.nix index 6c44e91..6cc9b30 100644 --- a/flake.nix +++ b/flake.nix @@ -97,6 +97,7 @@ , tsRevProx, taskobs, mcchunkie, gqrss, darwin, xin-secrets, talon, peerix , ... }@inputs: let + xinlib = import ./lib; supportedSystems = [ "x86_64-linux" ]; #[ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; forAllSystems = unstable.lib.genAttrs supportedSystems; @@ -158,7 +159,10 @@ buildSys = sys: sysBase: extraMods: name: sysBase.lib.nixosSystem { system = sys; - specialArgs = { inherit inputs; }; + specialArgs = { + inherit inputs; + inherit xinlib; + }; modules = hostBase.modules ++ extraMods ++ [{ nix = { registry.nixpkgs.flake = sysBase; diff --git a/hosts/europa/default.nix b/hosts/europa/default.nix index 663a324..159b41e 100644 --- a/hosts/europa/default.nix +++ b/hosts/europa/default.nix @@ -1,16 +1,10 @@ -{ config, pkgs, lib, modulesPath, inputs, ... }: +{ config, pkgs, lib, modulesPath, inputs, xinlib, ... }: let myEmacs = pkgs.callPackage ../../configs/emacs.nix { }; peerixUser = if builtins.hasAttr "peerix" config.users.users then config.users.users.peerix.name else "root"; - mkCronScript = name: src: '' - . /etc/profile; - set -x - # autogenreated ${name} - ${src} - ''; jobs = [ { name = "brain"; @@ -31,14 +25,6 @@ let path = [ pkgs.taskobs ] ++ pkgs.taskobs.buildInputs; } ]; - jobToService = job: { - name = "${job.name}"; - value = { - script = mkCronScript "${job.name}_script" job.script; - inherit (job) startAt; - inherit (job) path; - }; - }; in { _module.args.isUnstable = true; @@ -200,7 +186,7 @@ in { ''; }; - systemd.user.services = lib.listToAttrs (builtins.map jobToService jobs); + systemd.user.services = lib.listToAttrs (builtins.map xinlib.jobToService jobs); systemd.services."whytailscalewhy" = { description = "Tailscale restart on resume"; wantedBy = [ "post-resume.target" ]; diff --git a/hosts/pwntie/default.nix b/hosts/pwntie/default.nix index 1d372e1..15904df 100644 --- a/hosts/pwntie/default.nix +++ b/hosts/pwntie/default.nix @@ -1,32 +1,16 @@ -{ config, pkgs, lib, ... }: +{ config, pkgs, lib, xinlib, ... }: let myEmacs = pkgs.callPackage ../../configs/emacs.nix { }; pubKeys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIO7v+/xS8832iMqJHCWsxUZ8zYoMWoZhjj++e26g1fLT europa" ]; - mkCronScript = name: src: '' - . /etc/profile; - set -x - # autogenreated ${name} - ${src} - ''; - jobs = [ - { - name = "xin-ci"; - script = "cd ~/src/xin && ./ci"; - startAt = "daily"; - path = [ ]; - } - ]; - jobToService = job: { - name = "${job.name}"; - value = { - script = mkCronScript "${job.name}_script" job.script; - inherit (job) startAt; - inherit (job) path; - }; - }; + jobs = [{ + name = "xin-ci"; + script = "cd ~/src/xin && ./ci"; + startAt = "daily"; + path = [ ]; + }]; in { _module.args.isUnstable = true; imports = [ ./hardware-configuration.nix ]; @@ -37,7 +21,7 @@ in { boot.loader.efi.efiSysMountPoint = "/boot/efi"; boot.kernelPackages = pkgs.linuxPackages_latest; - systemd.user.services = lib.listToAttrs (builtins.map jobToService jobs); + systemd.user.services = lib.listToAttrs (builtins.map xinlib.jobToService jobs); networking = { hostName = "pwntie"; diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 0000000..62cc92c --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,18 @@ +let + mkCronScript = name: src: '' + . /etc/profile; + set -x + # autogenreated ${name} + ${src} + ''; + jobToService = job: { + name = "${job.name}"; + value = { + script = mkCronScript "${job.name}_script" job.script; + inherit (job) startAt path; + }; + }; + + xinlib = { inherit mkCronScript jobToService; }; + +in xinlib