stuff
This commit is contained in:
@@ -23,15 +23,7 @@ let
|
|||||||
pkgs = import flake.inputs.nixpkgs {
|
pkgs = import flake.inputs.nixpkgs {
|
||||||
inherit system overlays;
|
inherit system overlays;
|
||||||
};
|
};
|
||||||
# inherit (pkgs) lib;
|
|
||||||
# bySystemAttrs = [ "legacyPackages" "vacuPackages" "packages" "vaculib" "vacuConfig" "devShells" ];
|
|
||||||
# flakeThisSystem = lib.listToAttrs (map (attr: lib.nameValuePair attr flake.${attr}.${system}) bySystemAttrs);
|
|
||||||
in
|
in
|
||||||
pkgs // {
|
pkgs // {
|
||||||
nixpkgs-update = { ... }@args: import "${flake.inputs.nixpkgs}/maintainers/scripts/update.nix" ({ include-overlays = overlays; } // args);
|
nixpkgs-update = { ... }@args: import "${flake.inputs.nixpkgs}/maintainers/scripts/update.nix" ({ include-overlays = overlays; } // args);
|
||||||
}
|
}
|
||||||
# {
|
|
||||||
# inherit system flake flakeThisSystem;
|
|
||||||
# nixpkgsStable = flakeThisSystem.legacyPackages.stable;
|
|
||||||
# nixpkgsUnstable = flakeThisSystem.legacyPackages.unstable;
|
|
||||||
# } // flakeThisSystem // flakeThisSystem.vacuPackages
|
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
|
vaculib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
@@ -10,14 +11,12 @@ let
|
|||||||
prop_ips = s dnsData.propPublicV4;
|
prop_ips = s dnsData.propPublicV4;
|
||||||
solis_ips = s config.vacu.hosts.solis.primaryIp;
|
solis_ips = s config.vacu.hosts.solis.primaryIp;
|
||||||
mail_thing = s "178.128.79.152";
|
mail_thing = s "178.128.79.152";
|
||||||
allow_report_domains = [
|
# which domains to allow dmarc reports.
|
||||||
"dis8.net"
|
# ex: _dmarc.dis8.net TXT has "rua=rua-reports@shelvacu.com", reports will only be sent if shelvacu.com allows them
|
||||||
"chat.for.miras.pet"
|
# allow all domains configured in this repo, and one level of subdomain (ideally all but thats hard, this should be good enough)
|
||||||
"jean-luc.org"
|
allow_report_domains = lib.pipe config.vacu.dns [
|
||||||
"pwrhs.win"
|
lib.attrNames
|
||||||
"shelvacu.com"
|
(lib.concatMap (domain: [domain "*.${domain}"]))
|
||||||
"shelvacu.miras.pet"
|
|
||||||
"sv.mt"
|
|
||||||
];
|
];
|
||||||
# dmarc_allow = { TXT = [ "v=DMARC1" ]; };
|
# dmarc_allow = { TXT = [ "v=DMARC1" ]; };
|
||||||
in
|
in
|
||||||
@@ -98,11 +97,7 @@ in
|
|||||||
_acme-challenge.CNAME = s "17aa43aa-9295-4522-8cf2-b94ba537753d.auth.acme-dns.io.";
|
_acme-challenge.CNAME = s "17aa43aa-9295-4522-8cf2-b94ba537753d.auth.acme-dns.io.";
|
||||||
};
|
};
|
||||||
dav-experiment.A = prop_ips;
|
dav-experiment.A = prop_ips;
|
||||||
"_report._dmarc".subdomains = lib.pipe allow_report_domains [
|
"_report._dmarc".subdomains = vaculib.mapNamesToAttrsConst { TXT = s "v=DMARC1"; } allow_report_domains;
|
||||||
(lib.concatMap (domain: [domain "*.${domain}"]))
|
|
||||||
(map (domain: lib.nameValuePair domain { TXT = "v=DMARC1"; }))
|
|
||||||
(lib.listToAttrs)
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@@ -93,6 +93,7 @@
|
|||||||
lib = import "${nixpkgs}/lib";
|
lib = import "${nixpkgs}/lib";
|
||||||
overlays = import ./overlays;
|
overlays = import ./overlays;
|
||||||
vacuModules = import ./modules;
|
vacuModules = import ./modules;
|
||||||
|
vaculib = import ./vaculib { inherit lib; };
|
||||||
defaultSuffixedInputNames = [
|
defaultSuffixedInputNames = [
|
||||||
"nixvim"
|
"nixvim"
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
@@ -106,9 +107,7 @@
|
|||||||
let
|
let
|
||||||
suffix = if unstable then "-unstable" else "";
|
suffix = if unstable then "-unstable" else "";
|
||||||
inputNames = inp ++ defaultSuffixedInputNames;
|
inputNames = inp ++ defaultSuffixedInputNames;
|
||||||
thisInputsA = builtins.listToAttrs (
|
thisInputsA = vaculib.mapNamesToAttrs (name: allInputs.${name + suffix}) inputNames;
|
||||||
map (name: lib.nameValuePair name allInputs.${name + suffix}) inputNames
|
|
||||||
);
|
|
||||||
in
|
in
|
||||||
if inp == "all" then allInputs else thisInputsA // defaultInputs;
|
if inp == "all" then allInputs else thisInputsA // defaultInputs;
|
||||||
mkPkgs =
|
mkPkgs =
|
||||||
|
@@ -54,9 +54,7 @@ let
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
listToPackageSet =
|
listToPackageSet =
|
||||||
from:
|
vaculib.mapListToAttrs (
|
||||||
lib.pipe from [
|
|
||||||
(map (
|
|
||||||
val:
|
val:
|
||||||
if builtins.isString val then
|
if builtins.isString val then
|
||||||
nameToPackageSet val
|
nameToPackageSet val
|
||||||
@@ -69,15 +67,12 @@ let
|
|||||||
package = lib.mkDefault val;
|
package = lib.mkDefault val;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
))
|
);
|
||||||
builtins.listToAttrs
|
|
||||||
];
|
|
||||||
stringToPackageSet =
|
stringToPackageSet =
|
||||||
from:
|
from:
|
||||||
lib.pipe from [
|
lib.pipe from [
|
||||||
(vaculib.listOfLines { })
|
(vaculib.listOfLines { })
|
||||||
(map nameToPackageSet)
|
(vaculib.mapListToAttrs nameToPackageSet)
|
||||||
builtins.listToAttrs
|
|
||||||
];
|
];
|
||||||
listOrStringToPackageSet =
|
listOrStringToPackageSet =
|
||||||
from:
|
from:
|
||||||
|
@@ -21,8 +21,7 @@ let
|
|||||||
"sniper"
|
"sniper"
|
||||||
"spy"
|
"spy"
|
||||||
];
|
];
|
||||||
mkAttrsOf = f: list: builtins.listToAttrs (map (v: lib.nameValuePair v (f v)) list);
|
mapClassesToAttrs = f: vaculib.mapNamesToAttrs f classes;
|
||||||
mkAttrsOfClasses = f: mkAttrsOf f classes;
|
|
||||||
# key: what tf2 calls the key
|
# key: what tf2 calls the key
|
||||||
# value: other things you might want to call that key
|
# value: other things you might want to call that key
|
||||||
keyAliases = {
|
keyAliases = {
|
||||||
@@ -385,8 +384,7 @@ let
|
|||||||
{ config, ... }:
|
{ config, ... }:
|
||||||
{
|
{
|
||||||
options =
|
options =
|
||||||
(mkAttrsOf (
|
(vaculib.mapNamesToAttrsConst (
|
||||||
key:
|
|
||||||
mkOption {
|
mkOption {
|
||||||
type = types.nullOr bindCommandType;
|
type = types.nullOr bindCommandType;
|
||||||
default = null;
|
default = null;
|
||||||
@@ -442,40 +440,31 @@ in
|
|||||||
default = { };
|
default = { };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// mkAttrsOfClasses (
|
// vaculib.mapNamesToAttrsConst (mkOption {
|
||||||
classname:
|
|
||||||
mkOption {
|
|
||||||
type = types.submodule bindsModule;
|
type = types.submodule bindsModule;
|
||||||
default = { };
|
default = { };
|
||||||
}
|
}) classes;
|
||||||
);
|
|
||||||
autoexecLines = mkOption {
|
autoexecLines = mkOption {
|
||||||
type = types.lines;
|
type = types.lines;
|
||||||
default = "";
|
default = "";
|
||||||
};
|
};
|
||||||
classLines = mkAttrsOfClasses (
|
classLines = vaculib.mapNamesToAttrsConst (mkOption {
|
||||||
classname:
|
|
||||||
mkOption {
|
|
||||||
type = types.lines;
|
type = types.lines;
|
||||||
default = "";
|
default = "";
|
||||||
}
|
}) classes;
|
||||||
);
|
|
||||||
build.autoexec = mkOption {
|
build.autoexec = mkOption {
|
||||||
type = types.pkg;
|
type = types.pkg;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
};
|
};
|
||||||
build.classes = mkAttrsOfClasses (
|
build.classes = vaculib.mapNamesToAttrsConst (mkOption {
|
||||||
classname:
|
|
||||||
mkOption {
|
|
||||||
type = types.pkg;
|
type = types.pkg;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
}
|
}) classes;
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config.tf2 = {
|
config.tf2 = {
|
||||||
build.autoexec = pkgs.writeFile "autoexec.cfg" cfg.autoexecLines;
|
build.autoexec = pkgs.writeFile "autoexec.cfg" cfg.autoexecLines;
|
||||||
build.classes = mkAttrsOfClasses (classname: pkgs.writeText "${classname}.cfg" cfg.classLines.${classname});
|
build.classes = mapClassesToAttrs (classname: pkgs.writeText "${classname}.cfg" cfg.classLines.${classname});
|
||||||
autoexecLines = lib.mkMerge (
|
autoexecLines = lib.mkMerge (
|
||||||
[
|
[
|
||||||
''
|
''
|
||||||
@@ -486,7 +475,7 @@ in
|
|||||||
]
|
]
|
||||||
++ lib.optional cfg.binds.clear (lib.mkBefore ''unbindall'')
|
++ lib.optional cfg.binds.clear (lib.mkBefore ''unbindall'')
|
||||||
);
|
);
|
||||||
classLines = mkAttrsOfClasses (classname: ''
|
classLines = mapClassesToAttrs (classname: ''
|
||||||
// START keybinds from config.tf2.binds.${classname}
|
// START keybinds from config.tf2.binds.${classname}
|
||||||
${cfg.binds.${classname}._out}
|
${cfg.binds.${classname}._out}
|
||||||
// END keybinds from config.tf2.binds.${classname}
|
// END keybinds from config.tf2.binds.${classname}
|
||||||
|
@@ -106,8 +106,7 @@ let
|
|||||||
diskIds,
|
diskIds,
|
||||||
partitions,
|
partitions,
|
||||||
}:
|
}:
|
||||||
builtins.listToAttrs (
|
vaculib.mapListToAttrs (id: {
|
||||||
map (id: {
|
|
||||||
name = diskName groupName id;
|
name = diskName groupName id;
|
||||||
value = {
|
value = {
|
||||||
type = "disk";
|
type = "disk";
|
||||||
@@ -117,8 +116,7 @@ let
|
|||||||
inherit partitions;
|
inherit partitions;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}) diskIds
|
}) diskIds;
|
||||||
);
|
|
||||||
groupAttrs = {
|
groupAttrs = {
|
||||||
es14a = {
|
es14a = {
|
||||||
groupName = "es14a";
|
groupName = "es14a";
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
{ inputs, ... }:
|
{ inputs, vaculib, ... }:
|
||||||
{
|
{
|
||||||
name = "trip-megatest";
|
name = "trip-megatest";
|
||||||
|
|
||||||
@@ -6,36 +6,25 @@
|
|||||||
{ lib, config, ... }:
|
{ lib, config, ... }:
|
||||||
let
|
let
|
||||||
domains = builtins.attrNames config.security.acme.certs;
|
domains = builtins.attrNames config.security.acme.certs;
|
||||||
disableAcmes = builtins.listToAttrs (
|
disableAcmes = vaculib.mapListToAttrs (d: {
|
||||||
map (d: {
|
|
||||||
name = "acme-${d}";
|
name = "acme-${d}";
|
||||||
value = {
|
value = {
|
||||||
enable = lib.mkForce false;
|
enable = lib.mkForce false;
|
||||||
};
|
};
|
||||||
}) domains
|
}) domains;
|
||||||
);
|
reEnableSelfsigned = vaculib.mapListToAttrs (d: {
|
||||||
reEnableSelfsigned = builtins.listToAttrs (
|
|
||||||
map (d: {
|
|
||||||
name = "acme-selfsigned-${d}";
|
name = "acme-selfsigned-${d}";
|
||||||
value = {
|
value = {
|
||||||
wantedBy = [ "container@frontproxy.service" ];
|
wantedBy = [ "container@frontproxy.service" ];
|
||||||
before = [ "container@frontproxy.service" ];
|
before = [ "container@frontproxy.service" ];
|
||||||
};
|
};
|
||||||
}) domains
|
}) domains;
|
||||||
);
|
|
||||||
unitsToDisable = [
|
unitsToDisable = [
|
||||||
"container@vacustore.service"
|
"container@vacustore.service"
|
||||||
"container@nix-cache-nginx.service"
|
"container@nix-cache-nginx.service"
|
||||||
"openvpn-awootrip.service"
|
"openvpn-awootrip.service"
|
||||||
];
|
];
|
||||||
disableUnits = builtins.listToAttrs (
|
disableUnits = vaculib.mapNamesToAttrsConst { enable = lib.mkForce false; } unitsToDisable;
|
||||||
map (u: {
|
|
||||||
name = u;
|
|
||||||
value = {
|
|
||||||
enable = lib.mkForce false;
|
|
||||||
};
|
|
||||||
}) unitsToDisable
|
|
||||||
);
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
|
@@ -2,6 +2,7 @@
|
|||||||
config,
|
config,
|
||||||
pkgs,
|
pkgs,
|
||||||
lib,
|
lib,
|
||||||
|
vaculib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
@@ -31,7 +32,6 @@ let
|
|||||||
) domains;
|
) domains;
|
||||||
message = "proxiedService ${proxiedConfig.name}'s `domain` does not match any of the known domains";
|
message = "proxiedService ${proxiedConfig.name}'s `domain` does not match any of the known domains";
|
||||||
}) proxied;
|
}) proxied;
|
||||||
#networking.hosts = mapListToAttrs (c: lib.nameValuePair c.ipAddress [ c.name ]) proxied;
|
|
||||||
hosts = lib.foldl (
|
hosts = lib.foldl (
|
||||||
acc: c:
|
acc: c:
|
||||||
let
|
let
|
||||||
@@ -43,8 +43,7 @@ let
|
|||||||
else
|
else
|
||||||
acc // { ${name} = (acc.${name} or [ ]) ++ [ val ]; }
|
acc // { ${name} = (acc.${name} or [ ]) ++ [ val ]; }
|
||||||
) { } proxied;
|
) { } proxied;
|
||||||
mapListToAttrs = f: list: lib.listToAttrs (map f list);
|
certBindMounts = vaculib.mapListToAttrs (
|
||||||
certBindMounts = mapListToAttrs (
|
|
||||||
d:
|
d:
|
||||||
lib.nameValuePair "/certs/${d}" {
|
lib.nameValuePair "/certs/${d}" {
|
||||||
hostPath = config.security.acme.certs.${d}.directory;
|
hostPath = config.security.acme.certs.${d}.directory;
|
||||||
@@ -55,10 +54,7 @@ let
|
|||||||
(lib.filter (c: c.unixSocket != null))
|
(lib.filter (c: c.unixSocket != null))
|
||||||
(map (c: builtins.dirOf c.unixSocket))
|
(map (c: builtins.dirOf c.unixSocket))
|
||||||
lib.unique
|
lib.unique
|
||||||
(map (path: lib.nameValuePair path {
|
(vaculib.mapNamesToAttrsConst { isReadOnly = false; })
|
||||||
isReadOnly = false;
|
|
||||||
}))
|
|
||||||
lib.listToAttrs
|
|
||||||
];
|
];
|
||||||
bindMounts = certBindMounts // socketBindMounts;
|
bindMounts = certBindMounts // socketBindMounts;
|
||||||
in
|
in
|
||||||
@@ -75,9 +71,9 @@ in
|
|||||||
postRun = "${pkgs.nixos-container}/bin/nixos-container run frontproxy -- systemctl reload haproxy";
|
postRun = "${pkgs.nixos-container}/bin/nixos-container run frontproxy -- systemctl reload haproxy";
|
||||||
};
|
};
|
||||||
|
|
||||||
security.acme.certs = mapListToAttrs (
|
security.acme.certs = vaculib.mapNamesToAttrs (domain: {
|
||||||
domain: lib.nameValuePair domain { extraDomainNames = [ "*.${domain}" ]; }
|
extraDomainNames = [ "*.${domain}" ];
|
||||||
) domains;
|
}) domains;
|
||||||
|
|
||||||
users.groups.acme.gid = 993;
|
users.groups.acme.gid = 993;
|
||||||
|
|
||||||
|
38
vaculib/lists.nix
Normal file
38
vaculib/lists.nix
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
{ lib, ... }:
|
||||||
|
rec {
|
||||||
|
/**
|
||||||
|
# Type
|
||||||
|
|
||||||
|
```
|
||||||
|
mapListToAttrs :: (a -> { name :: String; value :: b; }) -> [a] -> { ${name} :: b; }
|
||||||
|
```
|
||||||
|
*/
|
||||||
|
mapListToAttrs =
|
||||||
|
f:
|
||||||
|
list:
|
||||||
|
lib.listToAttrs (map f list);
|
||||||
|
|
||||||
|
/**
|
||||||
|
# Type
|
||||||
|
|
||||||
|
```
|
||||||
|
mapNamesToAttrs :: (${name} -> a) -> [${name}] -> { ${name} :: a; }
|
||||||
|
```
|
||||||
|
*/
|
||||||
|
mapNamesToAttrs =
|
||||||
|
f:
|
||||||
|
list:
|
||||||
|
mapListToAttrs (name: { inherit name; value = f name; });
|
||||||
|
|
||||||
|
/**
|
||||||
|
# Type
|
||||||
|
|
||||||
|
```
|
||||||
|
mapNamesToAttrsConst :: a -> [${name}] -> { ${name} :: a; }
|
||||||
|
```
|
||||||
|
*/
|
||||||
|
mapNamesToAttrsConst =
|
||||||
|
a:
|
||||||
|
list:
|
||||||
|
mapNamesToAttrs (_: a);
|
||||||
|
}
|
Reference in New Issue
Block a user