lib: migrate a few more things into the lib

This commit is contained in:
Aaron Bieber 2023-02-02 05:48:19 -07:00
parent 4466a77159
commit e294b2a83a
No known key found for this signature in database
4 changed files with 36 additions and 33 deletions

View File

@ -130,32 +130,6 @@
# Set our configurationRevison based on the status of our git repo.
# If the repo is dirty, disable autoUpgrade as it means we are
# testing something.
buildVer = let state = self.rev or "DIRTY";
in {
system.configurationRevision = state;
system.autoUpgrade.enable = state != "DIRTY";
};
buildShell = pkgs:
pkgs.mkShell {
shellHook = ''
PS1='\u@\h:\w; '
( . ./common.sh; start ) || true;
'';
nativeBuildInputs = with pkgs; [
deadnix
git
jq
nil
nix-diff
nix-output-monitor
shfmt
sops
ssh-to-age
ssh-to-pgp
statix
];
};
buildSys = sys: sysBase: extraMods: name:
sysBase.lib.nixosSystem {
system = sys;
@ -170,7 +144,7 @@
registry.unstable.flake = unstable;
nixPath = [ "nixpkgs=${sysBase}" ];
};
}] ++ [ buildVer (./. + "/hosts/${name}") ]
}] ++ [ (xinlib.buildVer self) (./. + "/hosts/${name}") ]
++ [{ nixpkgs.overlays = overlays; }];
};
pkgs = unstable.legacyPackages.x86_64-linux;
@ -192,8 +166,8 @@
formatter.x86_64-linux = stable.legacyPackages.x86_64-linux.nixfmt;
formatter.aarch64-darwin = stable.legacyPackages.aarch64-darwin.nixfmt;
devShells.x86_64-linux.default = buildShell pkgs;
devShells.aarch64-darwin.default = buildShell darwinPkgs;
devShells.x86_64-linux.default = xinlib.buildShell pkgs;
devShells.aarch64-darwin.default = xinlib.buildShell darwinPkgs;
nixosConfigurations = {
europa = buildSys "x86_64-linux" unstable [
@ -245,7 +219,7 @@
system = "x86_64-linux";
modules = [
buildVer
(xinlib.buildVer self)
(import (./installer.nix))
xin-secrets.nixosModules.sops
(import "${sshKnownHosts}")

View File

@ -184,7 +184,8 @@ in {
'';
};
systemd.user.services = lib.listToAttrs (builtins.map xinlib.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

@ -21,7 +21,8 @@ in {
boot.loader.efi.efiSysMountPoint = "/boot/efi";
boot.kernelPackages = pkgs.linuxPackages_latest;
systemd.user.services = lib.listToAttrs (builtins.map xinlib.jobToService jobs);
systemd.user.services =
lib.listToAttrs (builtins.map xinlib.jobToService jobs);
networking = {
hostName = "pwntie";

View File

@ -12,7 +12,34 @@ let
inherit (job) startAt path;
};
};
buildShell = pkgs:
pkgs.mkShell {
shellHook = ''
PS1='\u@\h:\w; '
( . ./common.sh; start ) || true;
'';
nativeBuildInputs = with pkgs; [
deadnix
git
jq
nil
nix-diff
nix-output-monitor
shfmt
sops
ssh-to-age
ssh-to-pgp
statix
];
};
xinlib = { inherit mkCronScript jobToService; };
buildVer = self:
let state = self.rev or "DIRTY";
in {
system.configurationRevision = state;
system.autoUpgrade.enable = state != "DIRTY";
};
xinlib = { inherit buildVer mkCronScript jobToService buildShell; };
in xinlib