From 212da586160c25fd919a308e5fbe30c9b5e565ca Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 20 Dec 2022 19:07:51 +0100 Subject: lib: add on --- lib/default.nix | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib') diff --git a/lib/default.nix b/lib/default.nix index 149b97a72..1a57df266 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -39,6 +39,8 @@ let ne = x: y: x != y; mod = x: y: x - y * (x / y); + on = b: u: x: y: b (u x) (u y); + genid = lib.genid_uint32; # TODO remove genid_uint31 = x: ((lib.genid_uint32 x) + 16777216) / 2; genid_uint32 = import ./genid.nix { inherit lib; }; -- cgit v1.3.1 From efbcfce7a78d12a5a6adebba5f1ec3bb9f602286 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 20 Dec 2022 19:08:42 +0100 Subject: lib: add uniq and uniqBy --- lib/default.nix | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'lib') diff --git a/lib/default.nix b/lib/default.nix index 1a57df266..280f04299 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -187,6 +187,30 @@ let in filter (x: x != []) ([acc.chunk] ++ acc.chunks); + # Filter adjacent duplicate elements. + uniq = uniqBy eq; + + # Filter adjacent duplicate elements determined via the given function. + uniqBy = cmp: let + f = a: s: + if length s == 0 then + [] + else let + b = head s; + in + if cmp a b then + f b (tail s) + else + [b] ++ f b (tail s); + in + s: + if length s == 0 then + [] + else let + b = head s; + in + [b] ++ f b (tail s); + warnOldVersion = oldName: newName: if compareVersions oldName newName != -1 then trace "Upstream `${oldName}' gets overridden by `${newName}'." newName -- cgit v1.3.1 From 02751cb50d2791be12476db14554a2093a52b6a0 Mon Sep 17 00:00:00 2001 From: tv Date: Tue, 20 Dec 2022 20:00:01 +0100 Subject: lib.haskell.substitutePkg: sort and dedup deps --- lib/haskell.nix | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/haskell.nix b/lib/haskell.nix index 4f0ee05ab..f87cfa761 100644 --- a/lib/haskell.nix +++ b/lib/haskell.nix @@ -39,7 +39,12 @@ rec { in if parse == null then (pkgs.writeText name s).overrideAttrs (old: { - dependencies = old.dependencies or [] ++ dependencies; + dependencies = + lib.uniq + (lib.sort (lib.on lib.lessThan (lib.getAttr "name")) + (filter + (lib.ne null) + (old.dependencies or [] ++ dependencies))); }) else -- cgit v1.3.1 From ea9dbc8caf3111f80cc94de51eb6d6dace05e3c4 Mon Sep 17 00:00:00 2001 From: lassulus Date: Tue, 27 Dec 2022 12:20:42 +0100 Subject: types host: remove cores --- kartei/krebs/default.nix | 5 ----- kartei/lass/blue.nix | 1 - kartei/lass/coaxmetal.nix | 1 - kartei/lass/daedalus.nix | 1 - kartei/lass/dishfire.nix | 1 - kartei/lass/echelon.nix | 1 - kartei/lass/green.nix | 1 - kartei/lass/hilum.nix | 1 - kartei/lass/icarus.nix | 1 - kartei/lass/lasspi.nix | 1 - kartei/lass/littleT.nix | 1 - kartei/lass/massulus.nix | 1 - kartei/lass/mors.nix | 1 - kartei/lass/prism.nix | 1 - kartei/lass/shodan.nix | 1 - kartei/lass/skynet.nix | 1 - kartei/lass/styx.nix | 1 - kartei/lass/xerxes.nix | 1 - kartei/lass/yellow.nix | 1 - kartei/makefu/default.nix | 18 ------------------ kartei/others/default.nix | 3 --- kartei/tv/default.nix | 9 --------- krebs/0tests/data/test-config.nix | 1 - krebs/5pkgs/simple/generate-secrets/default.nix | 1 - lass/2configs/default.nix | 1 - lass/5pkgs/l-gen-secrets/default.nix | 1 - lib/types.nix | 3 --- makefu/2configs/tools/init-host/default.nix | 1 - 28 files changed, 61 deletions(-) (limited to 'lib') diff --git a/kartei/krebs/default.nix b/kartei/krebs/default.nix index e5626d923..7419ba13f 100644 --- a/kartei/krebs/default.nix +++ b/kartei/krebs/default.nix @@ -15,7 +15,6 @@ with import ../../lib; "test-all-krebs-modules" ] (name: { inherit name; - cores = 1; nets = { retiolum = { ip4.addr = "10.243.73.57"; @@ -36,7 +35,6 @@ in { hosts = mapAttrs hostDefaults ({ filebitch = { ci = true; - cores = 4; nets = { shack = { ip4 = { @@ -134,7 +132,6 @@ in { ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHl5cDF9QheXyMlNYIX17ILbgd94K50fZy7w0fDLvZlo "; }; onebutton = { - cores = 1; nets = { retiolum = { ip4.addr = "10.243.0.101"; @@ -163,7 +160,6 @@ in { ssh.pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIAcZg+iLaPZ0SpLM+nANxIjZC/RIsansjyutK0+gPhIe "; }; ponte = { - cores = 1; owner = config.krebs.users.krebs; extraZones = { "krebsco.de" = /* bindzone */ '' @@ -212,7 +208,6 @@ in { }; puyak = { ci = true; - cores = 4; nets = { retiolum = { ip4.addr = "10.243.77.2"; diff --git a/kartei/lass/blue.nix b/kartei/lass/blue.nix index b26e7fba6..ddec9553d 100644 --- a/kartei/lass/blue.nix +++ b/kartei/lass/blue.nix @@ -1,6 +1,5 @@ { r6, w6, ... }: { - cores = 1; nets = { retiolum = { ip4.addr = "10.243.0.77"; diff --git a/kartei/lass/coaxmetal.nix b/kartei/lass/coaxmetal.nix index 80d49dd97..d32f279fe 100644 --- a/kartei/lass/coaxmetal.nix +++ b/kartei/lass/coaxmetal.nix @@ -1,6 +1,5 @@ { r6, w6, ... }: { - cores = 16; nets = { retiolum = { ip4.addr = "10.243.0.17"; diff --git a/kartei/lass/daedalus.nix b/kartei/lass/daedalus.nix index 3033178ae..891cbd293 100644 --- a/kartei/lass/daedalus.nix +++ b/kartei/lass/daedalus.nix @@ -1,6 +1,5 @@ { r6, w6, ... }: { - cores = 2; nets = rec { retiolum = { ip4.addr = "10.243.133.115"; diff --git a/kartei/lass/dishfire.nix b/kartei/lass/dishfire.nix index a76d76e83..548320584 100644 --- a/kartei/lass/dishfire.nix +++ b/kartei/lass/dishfire.nix @@ -1,6 +1,5 @@ { r6, w6, ... }: { - cores = 4; nets = rec { internet = { ip4 = rec { diff --git a/kartei/lass/echelon.nix b/kartei/lass/echelon.nix index cc38ccb1a..d66033ba4 100644 --- a/kartei/lass/echelon.nix +++ b/kartei/lass/echelon.nix @@ -1,6 +1,5 @@ { r6, w6, ... }: { - cores = 1; nets = { retiolum = { ip4.addr = "10.243.0.3"; diff --git a/kartei/lass/green.nix b/kartei/lass/green.nix index 7623533b5..1c5d0aead 100644 --- a/kartei/lass/green.nix +++ b/kartei/lass/green.nix @@ -1,6 +1,5 @@ { r6, w6, ... }: { - cores = 1; nets = { retiolum = { ip4.addr = "10.243.0.66"; diff --git a/kartei/lass/hilum.nix b/kartei/lass/hilum.nix index ce24a916c..27fd0620a 100644 --- a/kartei/lass/hilum.nix +++ b/kartei/lass/hilum.nix @@ -1,7 +1,6 @@ { r6, w6, ... }: { consul = false; - cores = 1; nets = { retiolum = { ip4.addr = "10.243.20.123"; diff --git a/kartei/lass/icarus.nix b/kartei/lass/icarus.nix index c9c7fc410..c19d4e15c 100644 --- a/kartei/lass/icarus.nix +++ b/kartei/lass/icarus.nix @@ -1,6 +1,5 @@ { r6, w6, ... }: { - cores = 2; nets = rec { retiolum = { ip4.addr = "10.243.133.114"; diff --git a/kartei/lass/lasspi.nix b/kartei/lass/lasspi.nix index 3461e8f34..aab44bc5e 100644 --- a/kartei/lass/lasspi.nix +++ b/kartei/lass/lasspi.nix @@ -1,7 +1,6 @@ { r6, w6, ... }: { consul = false; - cores = 1; nets = { retiolum = { ip4.addr = "10.243.1.89"; diff --git a/kartei/lass/littleT.nix b/kartei/lass/littleT.nix index 10e3a62e2..297d2dc62 100644 --- a/kartei/lass/littleT.nix +++ b/kartei/lass/littleT.nix @@ -1,6 +1,5 @@ { r6, w6, ... }: { - cores = 2; nets = { retiolum = { ip4.addr = "10.243.133.77"; diff --git a/kartei/lass/massulus.nix b/kartei/lass/massulus.nix index 39e3254f7..6876e02b9 100644 --- a/kartei/lass/massulus.nix +++ b/kartei/lass/massulus.nix @@ -1,6 +1,5 @@ { r6, w6, ... }: { - cores = 1; ci = false; nets = { retiolum = { diff --git a/kartei/lass/mors.nix b/kartei/lass/mors.nix index f912e5c02..c483fe5a3 100644 --- a/kartei/lass/mors.nix +++ b/kartei/lass/mors.nix @@ -1,6 +1,5 @@ { r6, w6, ... }: { - cores = 2; nets = { retiolum = { ip4.addr = "10.243.0.2"; diff --git a/kartei/lass/prism.nix b/kartei/lass/prism.nix index 06fbdda16..c7965debf 100644 --- a/kartei/lass/prism.nix +++ b/kartei/lass/prism.nix @@ -1,6 +1,5 @@ { config, krebs, r6, w6, ... }: rec { - cores = 4; extraZones = { "krebsco.de" = '' cache 60 IN A ${nets.internet.ip4.addr} diff --git a/kartei/lass/shodan.nix b/kartei/lass/shodan.nix index 0f6080709..50ab86e6e 100644 --- a/kartei/lass/shodan.nix +++ b/kartei/lass/shodan.nix @@ -1,6 +1,5 @@ { r6, w6, ... }: { - cores = 2; nets = { retiolum = { ip4.addr = "10.243.0.4"; diff --git a/kartei/lass/skynet.nix b/kartei/lass/skynet.nix index da7434e5e..2109d2e35 100644 --- a/kartei/lass/skynet.nix +++ b/kartei/lass/skynet.nix @@ -1,6 +1,5 @@ { r6, w6, ... }: { - cores = 2; nets = rec { retiolum = { ip4.addr = "10.243.133.116"; diff --git a/kartei/lass/styx.nix b/kartei/lass/styx.nix index 6c0b98075..0b13c1184 100644 --- a/kartei/lass/styx.nix +++ b/kartei/lass/styx.nix @@ -1,6 +1,5 @@ { r6, w6, ... }: { - cores = 1; nets = { retiolum = { ip4.addr = "10.243.11.1"; diff --git a/kartei/lass/xerxes.nix b/kartei/lass/xerxes.nix index 94fbc78d4..96f619a70 100644 --- a/kartei/lass/xerxes.nix +++ b/kartei/lass/xerxes.nix @@ -1,6 +1,5 @@ { r6, w6, ... }: { - cores = 2; consul = false; nets = rec { retiolum = { diff --git a/kartei/lass/yellow.nix b/kartei/lass/yellow.nix index 99a9eb35e..ebf824950 100644 --- a/kartei/lass/yellow.nix +++ b/kartei/lass/yellow.nix @@ -1,6 +1,5 @@ { r6, w6, ... }: { - cores = 1; nets = { retiolum = { ip4.addr = "10.243.0.14"; diff --git a/kartei/makefu/default.nix b/kartei/makefu/default.nix index ecb834bbf..bf49a1766 100644 --- a/kartei/makefu/default.nix +++ b/kartei/makefu/default.nix @@ -58,21 +58,18 @@ with import ../../lib; in { hosts = mapAttrs hostDefaults { cake = rec { - cores = 4; ci = false; nets = { retiolum.ip4.addr = "10.243.136.236"; }; }; crapi = rec { # raspi1 - cores = 1; ci = false; nets = { retiolum.ip4.addr = "10.243.136.237"; }; }; firecracker = { - cores = 4; nets = { retiolum.ip4.addr = "10.243.12.12"; }; @@ -80,28 +77,24 @@ in { studio = rec { ci = false; - cores = 4; nets = { retiolum.ip4.addr = "10.243.227.163"; }; }; fileleech = rec { ci = false; - cores = 4; nets = { retiolum.ip4.addr = "10.243.113.98"; }; }; tsp = { ci = true; - cores = 1; nets = { retiolum.ip4.addr = "10.243.0.212"; }; }; x = { ci = true; - cores = 4; syncthing.id = "OA36OF6-JEFCUJQ-OEYVTMH-DPCACQI-3AJRE5G-BFVMOUG-RPYJQE3-4ZCUWA5"; nets = { retiolum.ip4.addr = "10.243.0.91"; @@ -113,7 +106,6 @@ in { }; filepimp = rec { ci = false; - cores = 1; nets = { retiolum.ip4.addr = "10.243.153.102"; }; @@ -121,7 +113,6 @@ in { omo = rec { ci = true; - cores = 2; syncthing.id = "Y5OTK3S-JOJLAUU-KTBXKUW-M7S5UEQ-MMQPUK2-7CXO5V6-NOUDLKP-PRGAFAK"; nets = { retiolum = { @@ -139,7 +130,6 @@ in { }; wbob = rec { ci = true; - cores = 4; nets = { retiolum = { ip4.addr = "10.243.214.15"; @@ -164,7 +154,6 @@ in { latte.euer IN A ${nets.internet.ip4.addr} ''; }; - cores = 4; nets = rec { internet = { ip4.addr = "178.254.30.202"; @@ -246,7 +235,6 @@ in { music.euer IN A ${nets.internet.ip4.addr} ''; }; - cores = 8; nets = rec { internet = { ip4.addr = "142.132.189.140"; @@ -302,7 +290,6 @@ in { sdev = rec { ci = true; - cores = 1; nets = { retiolum.ip4.addr = "10.243.83.237"; }; @@ -312,7 +299,6 @@ in { # non-stockholm flap = rec { - cores = 1; extraZones = { "krebsco.de" = '' flap IN A ${nets.internet.ip4.addr} @@ -332,7 +318,6 @@ in { }; nukular = rec { - cores = 1; nets = { retiolum = { ip4.addr = "10.243.231.219"; @@ -342,17 +327,14 @@ in { shackdev = rec { # router@shack - cores = 1; nets.wiregrill.ip4.addr = "10.244.245.2"; }; rockit = rec { # router@home - cores = 1; nets.wiregrill.ip4.addr = "10.244.245.3"; }; senderechner = rec { - cores = 2; nets = { retiolum = { ip4.addr = "10.243.0.163"; diff --git a/kartei/others/default.nix b/kartei/others/default.nix index f3ea8b80c..de0bd2f7f 100644 --- a/kartei/others/default.nix +++ b/kartei/others/default.nix @@ -43,7 +43,6 @@ in { }; }; horisa = { - cores = 2; owner = config.krebs.users.ulrich; # main laptop nets = { retiolum = { @@ -57,7 +56,6 @@ in { }; }; hasegateway = { - cores = 1; owner = config.krebs.users.hase; nets = { #internet = { @@ -343,7 +341,6 @@ in { }; }; tpsw = { - cores = 2; owner = config.krebs.users.ciko; # main laptop nets = { retiolum = { diff --git a/kartei/tv/default.nix b/kartei/tv/default.nix index f7e86c598..005c26e88 100644 --- a/kartei/tv/default.nix +++ b/kartei/tv/default.nix @@ -40,7 +40,6 @@ in { hosts = mapAttrs evalHost { alnus = { ci = true; - cores = 2; nets = { retiolum = { ip4.addr = "10.243.21.1"; @@ -64,7 +63,6 @@ in { }; au = { ci = true; - cores = 4; nets = { retiolum = { ip4.addr = "10.243.13.39"; @@ -89,7 +87,6 @@ in { }; bu = { ci = true; - cores = 4; nets = { retiolum = { ip4.addr = "10.243.13.36"; @@ -138,7 +135,6 @@ in { }; mu = { ci = true; - cores = 2; nets = { retiolum = { ip4.addr = "10.243.20.1"; @@ -230,7 +226,6 @@ in { }; nomic = { ci = true; - cores = 2; nets = { retiolum = { ip4.addr = "10.243.0.110"; @@ -256,7 +251,6 @@ in { }; wu = { ci = true; - cores = 4; nets = { retiolum = { ip4.addr = "10.243.13.37"; @@ -282,7 +276,6 @@ in { }; querel = { ci = true; - cores = 2; nets = { retiolum = { ip4.addr = "10.243.22.22"; @@ -313,7 +306,6 @@ in { pubkey = "xu-1:pYRENvaxZqGeImwLA9qHmRwHV4jfKaYx4u1VcZ31x0s="; }; ci = true; - cores = 4; nets = { retiolum = { ip4.addr = "10.243.13.38"; @@ -339,7 +331,6 @@ in { }; zu = { ci = true; - cores = 4; nets = { retiolum = { ip4.addr = "10.243.13.40"; diff --git a/krebs/0tests/data/test-config.nix b/krebs/0tests/data/test-config.nix index f0927ddd9..33cb01245 100644 --- a/krebs/0tests/data/test-config.nix +++ b/krebs/0tests/data/test-config.nix @@ -8,7 +8,6 @@ ]; krebs.hosts.minimal = { - cores = 1; secure = false; }; diff --git a/krebs/5pkgs/simple/generate-secrets/default.nix b/krebs/5pkgs/simple/generate-secrets/default.nix index f9a7450f7..a3c9f67c5 100644 --- a/krebs/5pkgs/simple/generate-secrets/default.nix +++ b/krebs/5pkgs/simple/generate-secrets/default.nix @@ -23,7 +23,6 @@ pkgs.writers.writeDashBin "generate-secrets" '' cat <; ]; networking.hostName = config.krebs.build.host.name; - nix.maxJobs = config.krebs.build.host.cores; krebs = { enable = true; diff --git a/lass/5pkgs/l-gen-secrets/default.nix b/lass/5pkgs/l-gen-secrets/default.nix index d999a4334..6cb60eaa1 100644 --- a/lass/5pkgs/l-gen-secrets/default.nix +++ b/lass/5pkgs/l-gen-secrets/default.nix @@ -25,7 +25,6 @@ pkgs.writeDashBin "l-gen-secrets" '' cat < Date: Fri, 30 Dec 2022 17:51:23 +0100 Subject: lib.types.net.ip*: add prefixLength --- lib/types.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'lib') diff --git a/lib/types.nix b/lib/types.nix index 9f278c650..32b4541ae 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -146,6 +146,14 @@ rec { }.${config._module.args.name} or { default = "${ip4.config.addr}/32"; }); + prefixLength = mkOption ({ + type = uint; + } // { + retiolum.default = 16; + wiregrill.default = 16; + }.${config._module.args.name} or { + default = 32; + }); }; })); default = null; @@ -165,6 +173,14 @@ rec { }.${config._module.args.name} or { default = "${ip6.config.addr}/128"; }); + prefixLength = mkOption ({ + type = uint; + } // { + retiolum.default = 32; + wiregrill.default = 32; + }.${config._module.args.name} or { + default = 128; + }); }; })); default = null; -- cgit v1.3.1