lib; init with common functions

This commit is contained in:
Aaron Bieber 2023-02-02 05:35:19 -07:00
parent 9924444dcb
commit 3c2e26c98e
No known key found for this signature in database
4 changed files with 33 additions and 41 deletions

View File

@ -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;

View File

@ -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" ];

View File

@ -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";

18
lib/default.nix Normal file
View File

@ -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