parent
d3b4c730a0
commit
23b11fcaf1
44
flake.nix
44
flake.nix
|
@ -10,16 +10,13 @@
|
||||||
let
|
let
|
||||||
pkgs = nixpkgs.legacyPackages."${system}";
|
pkgs = nixpkgs.legacyPackages."${system}";
|
||||||
naersk-lib = naersk.lib."${system}";
|
naersk-lib = naersk.lib."${system}";
|
||||||
srcNoTarget = dir:
|
src = ./.;
|
||||||
builtins.filterSource (path: type:
|
|
||||||
type != "directory" || builtins.baseNameOf path != "target") dir;
|
|
||||||
src = srcNoTarget ./.;
|
|
||||||
in rec {
|
in rec {
|
||||||
# `nix build`
|
# `nix build`
|
||||||
packages = rec {
|
packages = rec {
|
||||||
printerfacts-bin = naersk-lib.buildPackage {
|
printerfacts-bin = naersk-lib.buildPackage {
|
||||||
pname = "printerfacts";
|
pname = "printerfacts";
|
||||||
root = srcNoTarget ./.;
|
root = ./.;
|
||||||
};
|
};
|
||||||
printerfacts = pkgs.stdenv.mkDerivation {
|
printerfacts = pkgs.stdenv.mkDerivation {
|
||||||
inherit (printerfacts-bin) name;
|
inherit (printerfacts-bin) name;
|
||||||
|
@ -66,7 +63,7 @@
|
||||||
nodes.server = { ... }: {
|
nodes.server = { ... }: {
|
||||||
imports = [ self.nixosModules."${system}".printerfacts ];
|
imports = [ self.nixosModules."${system}".printerfacts ];
|
||||||
users.groups.within = { };
|
users.groups.within = { };
|
||||||
systemd.services.within-homedir-setup = {
|
systemd.services."within.homedir-setup" = {
|
||||||
description = "Creates homedirs for /srv/within services";
|
description = "Creates homedirs for /srv/within services";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
|
||||||
|
@ -118,25 +115,36 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
users.users.printerfacts = {
|
||||||
|
createHome = true;
|
||||||
|
description = "tulpa.dev/cadey/printerfacts";
|
||||||
|
isSystemUser = true;
|
||||||
|
group = "within";
|
||||||
|
home = "/srv/within/printerfacts";
|
||||||
|
extraGroups = [ "keys" ];
|
||||||
|
};
|
||||||
|
|
||||||
systemd.services."within.printerfacts" = {
|
systemd.services."within.printerfacts" = {
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
path = [ self.packages."${system}".printerfacts ];
|
||||||
|
after = [ "within.homedir-setup.service" ];
|
||||||
|
|
||||||
serviceConfig = {
|
serviceConfig =
|
||||||
DynamicUser = "yes";
|
let site = self.packages."${system}".printerfacts;
|
||||||
|
in {
|
||||||
|
User = "printerfacts";
|
||||||
|
Group = "within";
|
||||||
Restart = "on-failure";
|
Restart = "on-failure";
|
||||||
WorkingDirectory = "/srv/within/printerfacts";
|
WorkingDirectory = site;
|
||||||
|
ExecStart = "${site}/bin/printerfacts";
|
||||||
RestartSec = "5s";
|
RestartSec = "5s";
|
||||||
};
|
};
|
||||||
|
|
||||||
script = let site = self.packages."${system}".printerfacts;
|
environment = {
|
||||||
in ''
|
RUST_LOG = "info";
|
||||||
set -x
|
DOMAIN = cfg.domain;
|
||||||
export SOCKPATH=${cfg.sockPath}
|
SOCKPATH = cfg.sockPath;
|
||||||
export DOMAIN=${toString cfg.domain}
|
};
|
||||||
export RUST_LOG=info
|
|
||||||
cd ${site}
|
|
||||||
exec ${site}/bin/printerfacts
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
services.cfdyndns =
|
services.cfdyndns =
|
||||||
|
|
Loading…
Reference in New Issue