mirror of
https://git.pvv.ntnu.no/Drift/pvv-nixos-config.git
synced 2025-12-15 06:37:14 +01:00
Compare commits
30 Commits
add-bluema
...
53040bada1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
53040bada1 | ||
|
|
2030d4de39 | ||
|
|
c7797bdd04 | ||
| 615b5fc1f1 | |||
|
|
a0a837e26d | ||
|
|
8f3013dc00 | ||
|
|
78caceddce | ||
|
|
868764e0cd | ||
|
|
7c3ff2068d | ||
|
|
9d3f1381bf | ||
|
|
f3a29429aa | ||
|
|
1591fdb7cc | ||
|
|
ed28ba28f3 | ||
|
|
52b46667b1 | ||
|
|
d0f63b2fc8 | ||
|
|
0301691b1c | ||
|
|
946555e408 | ||
|
|
e02062417a | ||
|
|
b2806d78af | ||
|
|
de2c7ea6f1 | ||
|
|
106081c967 | ||
|
|
ca2deed668 | ||
|
|
bb2f7899db | ||
|
|
c2b35a7ae4 | ||
|
|
c88c3f87e0 | ||
| c5bad75edc | |||
| 71479d5ca0 | |||
| cf01792269 | |||
|
|
afae0da0b6 | ||
| 35d745b156 |
@@ -10,7 +10,6 @@ keys:
|
||||
- &host_ildkule age1x28hmzvuv6f2n66c0jtqcca3h9rput8d7j5uek6jcpx8n9egd52sqpejq0
|
||||
- &host_bekkalokk age12nj59tguy9wg882updc2vjdusx5srnxmjyfaqve4zx6jnnsaw3qsyjq6zd
|
||||
- &host_bicep age1sl43gc9cw939z5tgha2lpwf0xxxgcnlw7w4xem4sqgmt2pt264vq0dmwx2
|
||||
- &host_buskerud age1tmn5qahlyf0e579e4camckdyxrexjzffv54hdzdnrw7lzqs7kyqq0f2fr3
|
||||
|
||||
creation_rules:
|
||||
# Global secrets
|
||||
@@ -61,10 +60,3 @@ creation_rules:
|
||||
- *user_felixalb
|
||||
pgp:
|
||||
- *user_oysteikt
|
||||
|
||||
- path_regex: secrets/buskerud/[^/]+\.yaml$
|
||||
key_groups:
|
||||
- age:
|
||||
- *host_buskerud
|
||||
- *user_danio
|
||||
- *user_eirikwit
|
||||
|
||||
50
flake.lock
generated
50
flake.lock
generated
@@ -7,11 +7,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1716431128,
|
||||
"narHash": "sha256-t3T8HlX3udO6f4ilLcN+j5eC3m2gqsouzSGiriKK6vk=",
|
||||
"lastModified": 1715445235,
|
||||
"narHash": "sha256-SUu+oIWn+xqQIOlwfwNfS9Sek4i1HKsrLJchsDReXwA=",
|
||||
"owner": "nix-community",
|
||||
"repo": "disko",
|
||||
"rev": "7ffc4354dfeb37c8c725ae1465f04a9b45ec8606",
|
||||
"rev": "159d87ea5b95bbdea46f0288a33c5e1570272725",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -67,11 +67,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1716065905,
|
||||
"narHash": "sha256-08uhxBzfakfhl/ooc+gMzDupWKYvTeyQZwuvB1SBS7A=",
|
||||
"lastModified": 1715364232,
|
||||
"narHash": "sha256-ZJC3SkanEgbV7p+LFhP+85CviRWOXJNHzZwR/Stb7hE=",
|
||||
"owner": "Programvareverkstedet",
|
||||
"repo": "grzegorz",
|
||||
"rev": "0481aef6553ae9aee86e4edb4ca0ed4f2eba2058",
|
||||
"rev": "3841cda1cdcac470440b06838d56a2eb2256378c",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -87,11 +87,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1716115695,
|
||||
"narHash": "sha256-aI65l4x+U5v3i/nfn6N3eW5IZodmf4pyAByE7vTJh8I=",
|
||||
"lastModified": 1715384651,
|
||||
"narHash": "sha256-7RhckgUTjqeCjWkhiCc1iB+5CBx9fl80d/3O4Jh+5kM=",
|
||||
"owner": "Programvareverkstedet",
|
||||
"repo": "grzegorz-clients",
|
||||
"rev": "b9444658fbb39cd1bf1c61ee5a1d5f0641c49abe",
|
||||
"rev": "738a4f3dd887f7c3612e4e772b83cbfa3cde5693",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -143,11 +143,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1716586607,
|
||||
"narHash": "sha256-PzpeC/xi0+YTGJS5rdbcOqVgIryuWHkimMVXoCIidgA=",
|
||||
"lastModified": 1719520878,
|
||||
"narHash": "sha256-5BXzNOl2RVHcfS/oxaZDKOi7gVuTyWPibQG0DHd5sSc=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "03309929e115bba1339308814f8b6e63f250fedf",
|
||||
"rev": "a44bedbb48c367f0476e6a3a27bf28f6330faf23",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -158,11 +158,11 @@
|
||||
},
|
||||
"nixpkgs-stable": {
|
||||
"locked": {
|
||||
"lastModified": 1716061101,
|
||||
"narHash": "sha256-H0eCta7ahEgloGIwE/ihkyGstOGu+kQwAiHvwVoXaA0=",
|
||||
"lastModified": 1714858427,
|
||||
"narHash": "sha256-tCxeDP4C1pWe2rYY3IIhdA40Ujz32Ufd4tcrHPSKx2M=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "e7cc61784ddf51c81487637b3031a6dd2d6673a2",
|
||||
"rev": "b980b91038fc4b09067ef97bbe5ad07eecca1e76",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -174,11 +174,11 @@
|
||||
},
|
||||
"nixpkgs-unstable": {
|
||||
"locked": {
|
||||
"lastModified": 1716660083,
|
||||
"narHash": "sha256-QO7cdjtDhx72KEw6m0NOtuE5FS4asaRExZ65uFR/q8g=",
|
||||
"lastModified": 1715435713,
|
||||
"narHash": "sha256-lb2HqDQGfTdnCCpc1pgF6fkdgIOuBQ0nP8jjVSfLFqg=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "6de51d98ec2ae46730f11845e221aab9d2470a8a",
|
||||
"rev": "52b40f6c4be12742b1504ca2eb4527e597bf2526",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
@@ -214,11 +214,11 @@
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1716150352,
|
||||
"narHash": "sha256-c13lzYbLmbrcbEdPTYZYtlX2Qsz1W+2sLsIMGShPgwo=",
|
||||
"lastModified": 1722722932,
|
||||
"narHash": "sha256-K81a2GQpY2kRX+C9ek9r91THlZB674CqRTSMMb5IO7E=",
|
||||
"ref": "refs/heads/master",
|
||||
"rev": "2cab4df4b119e08a1f90ea1c944652cd78b4d478",
|
||||
"revCount": 459,
|
||||
"rev": "6580cfe546c902cdf11e17b0b8aa30b3c412bb34",
|
||||
"revCount": 465,
|
||||
"type": "git",
|
||||
"url": "https://git.pvv.ntnu.no/Projects/nettsiden.git"
|
||||
},
|
||||
@@ -249,11 +249,11 @@
|
||||
"nixpkgs-stable": "nixpkgs-stable"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1716400300,
|
||||
"narHash": "sha256-0lMkIk9h3AzOHs1dCL9RXvvN4PM8VBKb+cyGsqOKa4c=",
|
||||
"lastModified": 1715244550,
|
||||
"narHash": "sha256-ffOZL3eaZz5Y1nQ9muC36wBCWwS1hSRLhUzlA9hV2oI=",
|
||||
"owner": "Mic92",
|
||||
"repo": "sops-nix",
|
||||
"rev": "b549832718b8946e875c016a4785d204fcfc2e53",
|
||||
"rev": "0dc50257c00ee3c65fef3a255f6564cfbfe6eb7f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
grzegorz-clients.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, nixpkgs-unstable, pvv-nettsiden, sops-nix, disko, ... }@inputs:
|
||||
outputs = { self, nixpkgs, nixpkgs-unstable, sops-nix, disko, ... }@inputs:
|
||||
let
|
||||
nixlib = nixpkgs.lib;
|
||||
systems = [
|
||||
|
||||
@@ -6,13 +6,14 @@
|
||||
../../base.nix
|
||||
../../misc/metrics-exporters.nix
|
||||
|
||||
./services/website
|
||||
./services/nginx.nix
|
||||
./services/gitea/default.nix
|
||||
./services/kerberos
|
||||
./services/webmail
|
||||
./services/mediawiki
|
||||
./services/idp-simplesamlphp
|
||||
./services/kerberos
|
||||
./services/mediawiki
|
||||
./services/nginx.nix
|
||||
./services/vaultwarden.nix
|
||||
./services/webmail
|
||||
./services/website
|
||||
];
|
||||
|
||||
sops.defaultSopsFile = ../../secrets/bekkalokk/bekkalokk.yaml;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{ config, values, pkgs, ... }:
|
||||
{ config, values, pkgs, lib, ... }:
|
||||
let
|
||||
cfg = config.services.gitea;
|
||||
domain = "git.pvv.ntnu.no";
|
||||
@@ -22,7 +22,6 @@ in {
|
||||
|
||||
services.gitea = {
|
||||
enable = true;
|
||||
stateDir = "/data/gitea";
|
||||
appName = "PVV Git";
|
||||
|
||||
database = {
|
||||
@@ -35,6 +34,7 @@ in {
|
||||
|
||||
mailerPasswordFile = config.sops.secrets."gitea/email-password".path;
|
||||
|
||||
# https://docs.gitea.com/administration/config-cheat-sheet
|
||||
settings = {
|
||||
server = {
|
||||
DOMAIN = domain;
|
||||
@@ -42,6 +42,8 @@ in {
|
||||
PROTOCOL = "http+unix";
|
||||
SSH_PORT = sshPort;
|
||||
START_SSH_SERVER = true;
|
||||
START_LFS_SERVER = true;
|
||||
LANDING_PAGE = "explore";
|
||||
};
|
||||
mailer = {
|
||||
ENABLED = true;
|
||||
@@ -50,11 +52,46 @@ in {
|
||||
SMTP_ADDR = "smtp.pvv.ntnu.no";
|
||||
SMTP_PORT = 587;
|
||||
USER = "gitea@pvv.ntnu.no";
|
||||
SUBJECT_PREFIX = "[pvv-git]";
|
||||
};
|
||||
indexer.REPO_INDEXER_ENABLED = true;
|
||||
service.DISABLE_REGISTRATION = true;
|
||||
service = {
|
||||
DISABLE_REGISTRATION = true;
|
||||
ENABLE_NOTIFY_MAIL = true;
|
||||
};
|
||||
admin.DEFAULT_EMAIL_NOTIFICATIONS = "onmention";
|
||||
session.COOKIE_SECURE = true;
|
||||
database.LOG_SQL = false;
|
||||
repository = {
|
||||
PREFERRED_LICENSES = lib.concatStringsSep "," [
|
||||
"AGPL-3.0-only"
|
||||
"AGPL-3.0-or-later"
|
||||
"Apache-2.0"
|
||||
"BSD-3-Clause"
|
||||
"CC-BY-4.0"
|
||||
"CC-BY-NC-4.0"
|
||||
"CC-BY-NC-ND-4.0"
|
||||
"CC-BY-NC-SA-4.0"
|
||||
"CC-BY-ND-4.0"
|
||||
"CC-BY-SA-4.0"
|
||||
"CC0-1.0"
|
||||
"GPL-2.0-only"
|
||||
"GPL-3.0-only"
|
||||
"GPL-3.0-or-later"
|
||||
"LGPL-3.0-linking-exception"
|
||||
"LGPL-3.0-only"
|
||||
"LGPL-3.0-or-later"
|
||||
"MIT"
|
||||
"MPL-2.0"
|
||||
"Unlicense"
|
||||
];
|
||||
DEFAULT_REPO_UNITS = lib.concatStringsSep "," [
|
||||
"repo.code"
|
||||
"repo.issues"
|
||||
"repo.pulls"
|
||||
"repo.releases"
|
||||
];
|
||||
};
|
||||
picture = {
|
||||
DISABLE_GRAVATAR = true;
|
||||
ENABLE_FEDERATED_AVATAR = false;
|
||||
@@ -99,9 +136,9 @@ in {
|
||||
logo-svg = ../../../../assets/logo_blue_regular.svg;
|
||||
logo-png = ../../../../assets/logo_blue_regular.png;
|
||||
in ''
|
||||
install -Dm444 ${logo-svg} ${cfg.customDir}/public/img/logo.svg
|
||||
install -Dm444 ${logo-png} ${cfg.customDir}/public/img/logo.png
|
||||
install -Dm444 ${./loading.apng} ${cfg.customDir}/public/img/loading.png
|
||||
install -Dm444 ${logo-svg} ${cfg.customDir}/public/assets/img/logo.svg
|
||||
install -Dm444 ${logo-png} ${cfg.customDir}/public/assets/img/logo.png
|
||||
install -Dm444 ${./loading.apng} ${cfg.customDir}/public/assets/img/loading.png
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
||||
@@ -84,16 +84,16 @@ let
|
||||
cp ${./config.php} "$out"
|
||||
|
||||
substituteInPlace "$out" \
|
||||
--replace '$SAML_COOKIE_SECURE' 'true' \
|
||||
--replace '$SAML_COOKIE_SALT' 'file_get_contents("${config.sops.secrets."idp/cookie_salt".path}")' \
|
||||
--replace '$SAML_ADMIN_NAME' '"Drift"' \
|
||||
--replace '$SAML_ADMIN_EMAIL' '"drift@pvv.ntnu.no"' \
|
||||
--replace '$SAML_ADMIN_PASSWORD' 'file_get_contents("${config.sops.secrets."idp/admin_password".path}")' \
|
||||
--replace '$SAML_TRUSTED_DOMAINS' 'array( "idp.pvv.ntnu.no" )' \
|
||||
--replace '$SAML_DATABASE_DSN' '"pgsql:host=postgres.pvv.ntnu.no;port=5432;dbname=idp"' \
|
||||
--replace '$SAML_DATABASE_USERNAME' '"idp"' \
|
||||
--replace '$SAML_DATABASE_PASSWORD' 'file_get_contents("${config.sops.secrets."idp/postgres_password".path}")' \
|
||||
--replace '$CACHE_DIRECTORY' '/var/cache/idp'
|
||||
--replace-warn '$SAML_COOKIE_SECURE' 'true' \
|
||||
--replace-warn '$SAML_COOKIE_SALT' 'file_get_contents("${config.sops.secrets."idp/cookie_salt".path}")' \
|
||||
--replace-warn '$SAML_ADMIN_NAME' '"Drift"' \
|
||||
--replace-warn '$SAML_ADMIN_EMAIL' '"drift@pvv.ntnu.no"' \
|
||||
--replace-warn '$SAML_ADMIN_PASSWORD' 'file_get_contents("${config.sops.secrets."idp/admin_password".path}")' \
|
||||
--replace-warn '$SAML_TRUSTED_DOMAINS' 'array( "idp.pvv.ntnu.no" )' \
|
||||
--replace-warn '$SAML_DATABASE_DSN' '"pgsql:host=postgres.pvv.ntnu.no;port=5432;dbname=idp"' \
|
||||
--replace-warn '$SAML_DATABASE_USERNAME' '"idp"' \
|
||||
--replace-warn '$SAML_DATABASE_PASSWORD' 'file_get_contents("${config.sops.secrets."idp/postgres_password".path}")' \
|
||||
--replace-warn '$CACHE_DIRECTORY' '/var/cache/idp'
|
||||
'';
|
||||
|
||||
"modules/authpwauth/src/Auth/Source/PwAuth.php" = ./authpwauth.php;
|
||||
|
||||
@@ -1,18 +1,5 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
{
|
||||
#######################
|
||||
# TODO: remove these once nixos 24.05 gets released
|
||||
#######################
|
||||
# imports = [
|
||||
# ./krb5.nix
|
||||
# ./pam.nix
|
||||
# ];
|
||||
# disabledModules = [
|
||||
# "config/krb5/default.nix"
|
||||
# "security/pam.nix"
|
||||
# ];
|
||||
#######################
|
||||
|
||||
security.krb5 = {
|
||||
enable = true;
|
||||
settings = {
|
||||
|
||||
88
hosts/bekkalokk/services/kerberos/krb5-conf-format.nix
Normal file
88
hosts/bekkalokk/services/kerberos/krb5-conf-format.nix
Normal file
@@ -0,0 +1,88 @@
|
||||
{ pkgs, lib, ... }:
|
||||
|
||||
# Based on
|
||||
# - https://web.mit.edu/kerberos/krb5-1.12/doc/admin/conf_files/krb5_conf.html
|
||||
# - https://manpages.debian.org/unstable/heimdal-docs/krb5.conf.5heimdal.en.html
|
||||
|
||||
let
|
||||
inherit (lib) boolToString concatMapStringsSep concatStringsSep filter
|
||||
isAttrs isBool isList mapAttrsToList mdDoc mkOption singleton splitString;
|
||||
inherit (lib.types) attrsOf bool coercedTo either int listOf oneOf path
|
||||
str submodule;
|
||||
in
|
||||
{ }: {
|
||||
type = let
|
||||
section = attrsOf relation;
|
||||
relation = either (attrsOf value) value;
|
||||
value = either (listOf atom) atom;
|
||||
atom = oneOf [int str bool];
|
||||
in submodule {
|
||||
freeformType = attrsOf section;
|
||||
options = {
|
||||
include = mkOption {
|
||||
default = [ ];
|
||||
description = mdDoc ''
|
||||
Files to include in the Kerberos configuration.
|
||||
'';
|
||||
type = coercedTo path singleton (listOf path);
|
||||
};
|
||||
includedir = mkOption {
|
||||
default = [ ];
|
||||
description = mdDoc ''
|
||||
Directories containing files to include in the Kerberos configuration.
|
||||
'';
|
||||
type = coercedTo path singleton (listOf path);
|
||||
};
|
||||
module = mkOption {
|
||||
default = [ ];
|
||||
description = mdDoc ''
|
||||
Modules to obtain Kerberos configuration from.
|
||||
'';
|
||||
type = coercedTo path singleton (listOf path);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
generate = let
|
||||
indent = str: concatMapStringsSep "\n" (line: " " + line) (splitString "\n" str);
|
||||
|
||||
formatToplevel = args @ {
|
||||
include ? [ ],
|
||||
includedir ? [ ],
|
||||
module ? [ ],
|
||||
...
|
||||
}: let
|
||||
sections = removeAttrs args [ "include" "includedir" "module" ];
|
||||
in concatStringsSep "\n" (filter (x: x != "") [
|
||||
(concatStringsSep "\n" (mapAttrsToList formatSection sections))
|
||||
(concatMapStringsSep "\n" (m: "module ${m}") module)
|
||||
(concatMapStringsSep "\n" (i: "include ${i}") include)
|
||||
(concatMapStringsSep "\n" (i: "includedir ${i}") includedir)
|
||||
]);
|
||||
|
||||
formatSection = name: section: ''
|
||||
[${name}]
|
||||
${indent (concatStringsSep "\n" (mapAttrsToList formatRelation section))}
|
||||
'';
|
||||
|
||||
formatRelation = name: relation:
|
||||
if isAttrs relation
|
||||
then ''
|
||||
${name} = {
|
||||
${indent (concatStringsSep "\n" (mapAttrsToList formatValue relation))}
|
||||
}''
|
||||
else formatValue name relation;
|
||||
|
||||
formatValue = name: value:
|
||||
if isList value
|
||||
then concatMapStringsSep "\n" (formatAtom name) value
|
||||
else formatAtom name value;
|
||||
|
||||
formatAtom = name: atom: let
|
||||
v = if isBool atom then boolToString atom else toString atom;
|
||||
in "${name} = ${v}";
|
||||
in
|
||||
name: value: pkgs.writeText name ''
|
||||
${formatToplevel value}
|
||||
'';
|
||||
}
|
||||
90
hosts/bekkalokk/services/kerberos/krb5.nix
Normal file
90
hosts/bekkalokk/services/kerberos/krb5.nix
Normal file
@@ -0,0 +1,90 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
let
|
||||
inherit (lib) mdDoc mkIf mkOption mkPackageOption mkRemovedOptionModule;
|
||||
inherit (lib.types) bool;
|
||||
|
||||
mkRemovedOptionModule' = name: reason: mkRemovedOptionModule ["krb5" name] reason;
|
||||
mkRemovedOptionModuleCfg = name: mkRemovedOptionModule' name ''
|
||||
The option `krb5.${name}' has been removed. Use
|
||||
`security.krb5.settings.${name}' for structured configuration.
|
||||
'';
|
||||
|
||||
cfg = config.security.krb5;
|
||||
format = import ./krb5-conf-format.nix { inherit pkgs lib; } { };
|
||||
in {
|
||||
imports = [
|
||||
(mkRemovedOptionModuleCfg "libdefaults")
|
||||
(mkRemovedOptionModuleCfg "realms")
|
||||
(mkRemovedOptionModuleCfg "domain_realm")
|
||||
(mkRemovedOptionModuleCfg "capaths")
|
||||
(mkRemovedOptionModuleCfg "appdefaults")
|
||||
(mkRemovedOptionModuleCfg "plugins")
|
||||
(mkRemovedOptionModuleCfg "config")
|
||||
(mkRemovedOptionModuleCfg "extraConfig")
|
||||
(mkRemovedOptionModule' "kerberos" ''
|
||||
The option `krb5.kerberos' has been moved to `security.krb5.package'.
|
||||
'')
|
||||
];
|
||||
|
||||
options = {
|
||||
security.krb5 = {
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
description = mdDoc "Enable and configure Kerberos utilities";
|
||||
type = bool;
|
||||
};
|
||||
|
||||
package = mkPackageOption pkgs "krb5" {
|
||||
example = "heimdal";
|
||||
};
|
||||
|
||||
settings = mkOption {
|
||||
default = { };
|
||||
type = format.type;
|
||||
description = mdDoc ''
|
||||
Structured contents of the {file}`krb5.conf` file. See
|
||||
{manpage}`krb5.conf(5)` for details about configuration.
|
||||
'';
|
||||
example = {
|
||||
include = [ "/run/secrets/secret-krb5.conf" ];
|
||||
includedir = [ "/run/secrets/secret-krb5.conf.d" ];
|
||||
|
||||
libdefaults = {
|
||||
default_realm = "ATHENA.MIT.EDU";
|
||||
};
|
||||
|
||||
realms = {
|
||||
"ATHENA.MIT.EDU" = {
|
||||
admin_server = "athena.mit.edu";
|
||||
kdc = [
|
||||
"athena01.mit.edu"
|
||||
"athena02.mit.edu"
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
domain_realm = {
|
||||
"mit.edu" = "ATHENA.MIT.EDU";
|
||||
};
|
||||
|
||||
logging = {
|
||||
kdc = "SYSLOG:NOTICE";
|
||||
admin_server = "SYSLOG:NOTICE";
|
||||
default = "SYSLOG:NOTICE";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
environment = {
|
||||
systemPackages = [ cfg.package ];
|
||||
etc."krb5.conf".source = format.generate "krb5.conf" cfg.settings;
|
||||
};
|
||||
};
|
||||
|
||||
meta.maintainers = builtins.attrValues {
|
||||
inherit (lib.maintainers) dblsaiko h7x4;
|
||||
};
|
||||
}
|
||||
1543
hosts/bekkalokk/services/kerberos/pam.nix
Normal file
1543
hosts/bekkalokk/services/kerberos/pam.nix
Normal file
File diff suppressed because it is too large
Load Diff
@@ -17,16 +17,16 @@
|
||||
cp ${./simplesaml-config.php} "$out"
|
||||
|
||||
substituteInPlace "$out" \
|
||||
--replace '$SAML_COOKIE_SECURE' 'true' \
|
||||
--replace '$SAML_COOKIE_SALT' 'file_get_contents("${config.sops.secrets."mediawiki/simplesamlphp/cookie_salt".path}")' \
|
||||
--replace '$SAML_ADMIN_NAME' '"Drift"' \
|
||||
--replace '$SAML_ADMIN_EMAIL' '"drift@pvv.ntnu.no"' \
|
||||
--replace '$SAML_ADMIN_PASSWORD' 'file_get_contents("${config.sops.secrets."mediawiki/simplesamlphp/admin_password".path}")' \
|
||||
--replace '$SAML_TRUSTED_DOMAINS' 'array( "wiki.pvv.ntnu.no" )' \
|
||||
--replace '$SAML_DATABASE_DSN' '"pgsql:host=postgres.pvv.ntnu.no;port=5432;dbname=mediawiki_simplesamlphp"' \
|
||||
--replace '$SAML_DATABASE_USERNAME' '"mediawiki_simplesamlphp"' \
|
||||
--replace '$SAML_DATABASE_PASSWORD' 'file_get_contents("${config.sops.secrets."mediawiki/simplesamlphp/postgres_password".path}")' \
|
||||
--replace '$CACHE_DIRECTORY' '/var/cache/mediawiki/idp'
|
||||
--replace-warn '$SAML_COOKIE_SECURE' 'true' \
|
||||
--replace-warn '$SAML_COOKIE_SALT' 'file_get_contents("${config.sops.secrets."mediawiki/simplesamlphp/cookie_salt".path}")' \
|
||||
--replace-warn '$SAML_ADMIN_NAME' '"Drift"' \
|
||||
--replace-warn '$SAML_ADMIN_EMAIL' '"drift@pvv.ntnu.no"' \
|
||||
--replace-warn '$SAML_ADMIN_PASSWORD' 'file_get_contents("${config.sops.secrets."mediawiki/simplesamlphp/admin_password".path}")' \
|
||||
--replace-warn '$SAML_TRUSTED_DOMAINS' 'array( "wiki.pvv.ntnu.no" )' \
|
||||
--replace-warn '$SAML_DATABASE_DSN' '"pgsql:host=postgres.pvv.ntnu.no;port=5432;dbname=mediawiki_simplesamlphp"' \
|
||||
--replace-warn '$SAML_DATABASE_USERNAME' '"mediawiki_simplesamlphp"' \
|
||||
--replace-warn '$SAML_DATABASE_PASSWORD' 'file_get_contents("${config.sops.secrets."mediawiki/simplesamlphp/postgres_password".path}")' \
|
||||
--replace-warn '$CACHE_DIRECTORY' '/var/cache/mediawiki/idp'
|
||||
'';
|
||||
};
|
||||
};
|
||||
@@ -86,7 +86,20 @@ in {
|
||||
};
|
||||
|
||||
extensions = {
|
||||
inherit (pkgs.mediawiki-extensions) DeleteBatch UserMerge PluggableAuth SimpleSAMLphp VisualEditor;
|
||||
inherit (pkgs.mediawiki-extensions)
|
||||
CodeEditor
|
||||
CodeMirror
|
||||
DeleteBatch
|
||||
PluggableAuth
|
||||
Popups
|
||||
Scribunto
|
||||
SimpleSAMLphp
|
||||
TemplateData
|
||||
TemplateStyles
|
||||
UserMerge
|
||||
VisualEditor
|
||||
WikiEditor
|
||||
;
|
||||
};
|
||||
|
||||
extraConfig = ''
|
||||
@@ -120,13 +133,27 @@ in {
|
||||
|
||||
# Misc
|
||||
$wgEmergencyContact = "${cfg.passwordSender}";
|
||||
$wgShowIPinHeader = false;
|
||||
$wgUseTeX = false;
|
||||
$wgLocalInterwiki = $wgSitename;
|
||||
# Fix https://github.com/NixOS/nixpkgs/issues/183097
|
||||
$wgDBserver = "${toString cfg.database.host}";
|
||||
$wgAllowCopyUploads = true;
|
||||
|
||||
# SimpleSAML
|
||||
# Misc program paths
|
||||
$wgFFmpegLocation = '${pkgs.ffmpeg}/bin/ffmpeg';
|
||||
$wgExiftool = '${pkgs.exiftool}/bin/exiftool';
|
||||
$wgExiv2Command = '${pkgs.exiv2}/bin/exiv2';
|
||||
# See https://gist.github.com/sergejmueller/088dce028b6dd120a16e
|
||||
$wgJpegTran = '${pkgs.mozjpeg}/bin/jpegtran';
|
||||
$wgGitBin = '${pkgs.git}/bin/git';
|
||||
|
||||
# Debugging
|
||||
$wgShowExceptionDetails = false;
|
||||
$wgShowIPinHeader = false;
|
||||
|
||||
# EXT:{SimpleSAML,PluggableAuth}
|
||||
$wgSimpleSAMLphp_InstallDir = "${simplesamlphp}/share/php/simplesamlphp/";
|
||||
$wgPluggableAuth_Config['Log in using my SAML'] = [
|
||||
$wgPluggableAuth_Config['Log in using SAML'] = [
|
||||
'plugin' => 'SimpleSAMLphp',
|
||||
'data' => [
|
||||
'authSourceId' => 'default-sp',
|
||||
@@ -136,8 +163,12 @@ in {
|
||||
]
|
||||
];
|
||||
|
||||
# Fix https://github.com/NixOS/nixpkgs/issues/183097
|
||||
$wgDBserver = "${toString cfg.database.host}";
|
||||
# EXT:Scribunto
|
||||
$wgScribuntoDefaultEngine = 'luastandalone';
|
||||
$wgScribuntoEngineConf['luastandalone']['luaPath'] = '${pkgs.lua}/bin';
|
||||
|
||||
# EXT:WikiEditor
|
||||
$wgWikiEditorRealtimePreview = true;
|
||||
'';
|
||||
};
|
||||
|
||||
|
||||
68
hosts/bekkalokk/services/vaultwarden.nix
Normal file
68
hosts/bekkalokk/services/vaultwarden.nix
Normal file
@@ -0,0 +1,68 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
let
|
||||
cfg = config.services.vaultwarden;
|
||||
domain = "pw.pvv.ntnu.no";
|
||||
address = "127.0.1.2";
|
||||
port = 3011;
|
||||
wsPort = 3012;
|
||||
in {
|
||||
sops.secrets."vaultwarden/environ" = {
|
||||
owner = "vaultwarden";
|
||||
group = "vaultwarden";
|
||||
};
|
||||
|
||||
services.vaultwarden = {
|
||||
enable = true;
|
||||
dbBackend = "postgresql";
|
||||
environmentFile = config.sops.secrets."vaultwarden/environ".path;
|
||||
config = {
|
||||
domain = "https://${domain}";
|
||||
|
||||
rocketAddress = address;
|
||||
rocketPort = port;
|
||||
|
||||
websocketEnabled = true;
|
||||
websocketAddress = address;
|
||||
websocketPort = wsPort;
|
||||
|
||||
signupsAllowed = true;
|
||||
signupsVerify = true;
|
||||
signupsDomainsWhitelist = "pvv.ntnu.no";
|
||||
|
||||
smtpFrom = "vaultwarden@pvv.ntnu.no";
|
||||
smtpFromName = "VaultWarden PVV";
|
||||
|
||||
smtpHost = "smtp.pvv.ntnu.no";
|
||||
smtpUsername = "vaultwarden";
|
||||
smtpSecurity = "force_tls";
|
||||
smtpAuthMechanism = "Login";
|
||||
|
||||
# Configured in environ:
|
||||
# databaseUrl = "postgresql://vaultwarden@/vaultwarden";
|
||||
# smtpPassword = hemli
|
||||
};
|
||||
};
|
||||
|
||||
services.nginx.virtualHosts."${domain}" = {
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
kTLS = true;
|
||||
|
||||
extraConfig = ''
|
||||
client_max_body_size 128M;
|
||||
'';
|
||||
|
||||
locations."/" = {
|
||||
proxyPass = "http://${address}:${toString port}";
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
locations."/notifications/hub" = {
|
||||
proxyPass = "http://${address}:${toString wsPort}";
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
locations."/notifications/hub/negotiate" = {
|
||||
proxyPass = "http://${address}:${toString port}";
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -4,14 +4,10 @@
|
||||
./hardware-configuration.nix
|
||||
../../base.nix
|
||||
../../misc/metrics-exporters.nix
|
||||
|
||||
./services/libvirt.nix
|
||||
];
|
||||
|
||||
sops.defaultSopsFile = ../../secrets/buskerud/buskerud.yaml;
|
||||
sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
|
||||
sops.age.keyFile = "/var/lib/sops-nix/key.txt";
|
||||
sops.age.generateKey = true;
|
||||
|
||||
|
||||
# buskerud does not support efi?
|
||||
# boot.loader.systemd-boot.enable = true;
|
||||
# boot.loader.efi.canTouchEfiVariables = true;
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
{config, ...}:
|
||||
{
|
||||
|
||||
sops.secrets."bluemap_ssh_key" = {
|
||||
owner = "root";
|
||||
mode = "0400";
|
||||
};
|
||||
|
||||
services.bluemap = {
|
||||
enable = true;
|
||||
eula = true;
|
||||
defaultWorld = "/var/lib/bluemap/vanilla";
|
||||
host = "minecraft.pvv.ntnu.no";
|
||||
};
|
||||
|
||||
systemd.services."render-bluemap-maps".preStart = ''
|
||||
rsync -e 'ssh -i ${config.sops.secrets."bluemap_ssh_key".path} -o "StrictHostKeyChecking accept-new"' \
|
||||
root@innovation.pvv.ntnu.no:/var/backups/minecraft/current/ \
|
||||
/var/lib/bluemap/vanilla"
|
||||
'';
|
||||
}
|
||||
10
hosts/buskerud/services/libvirt.nix
Normal file
10
hosts/buskerud/services/libvirt.nix
Normal file
@@ -0,0 +1,10 @@
|
||||
{ config, pkgs, lib, ... }:
|
||||
{
|
||||
virtualisation.libvirtd.enable = true;
|
||||
programs.dconf.enable = true;
|
||||
boot.kernelModules = [ "kvm-intel" ];
|
||||
|
||||
# On a gui-enabled machine, connect with:
|
||||
# $ virt-manager --connect "qemu+ssh://buskerud/system?socket=/var/run/libvirt/libvirt-sock"
|
||||
}
|
||||
|
||||
@@ -20,10 +20,26 @@
|
||||
zramSwap.enable = true;
|
||||
|
||||
networking.hostName = "ildkule"; # Define your hostname.
|
||||
systemd.network.networks."30-all" = values.defaultNetworkConfig // {
|
||||
matchConfig.Name = "en*";
|
||||
DHCP = "yes";
|
||||
gateway = [ ];
|
||||
|
||||
# Main connection, using the global/floatig IP, for communications with the world
|
||||
systemd.network.networks."30-ntnu-global" = values.openstackGlobalNetworkConfig // {
|
||||
matchConfig.Name = "ens4";
|
||||
|
||||
# Add the global addresses in addition to the local address learned from DHCP
|
||||
addresses = [
|
||||
{ addressConfig.Address = "${values.hosts.ildkule.ipv4_global}/32"; }
|
||||
{ addressConfig.Address = "${values.hosts.ildkule.ipv6_global}/128"; }
|
||||
];
|
||||
};
|
||||
|
||||
# Secondary connection only for use within the university network
|
||||
systemd.network.networks."40-ntnu-internal" = values.openstackLocalNetworkConfig // {
|
||||
matchConfig.Name = "ens3";
|
||||
# Add the ntnu-internal addresses in addition to the local address learned from DHCP
|
||||
addresses = [
|
||||
{ addressConfig.Address = "${values.hosts.ildkule.ipv4}/32"; }
|
||||
{ addressConfig.Address = "${values.hosts.ildkule.ipv6}/128"; }
|
||||
];
|
||||
};
|
||||
|
||||
# List packages installed in system profile
|
||||
|
||||
@@ -50,7 +50,6 @@ in {
|
||||
boltdb_shipper = {
|
||||
active_index_directory = "/var/lib/loki/boltdb-shipper-index";
|
||||
cache_location = "/var/lib/loki/boltdb-shipper-cache";
|
||||
# shared_store = "filesystem";
|
||||
cache_ttl = "24h";
|
||||
};
|
||||
filesystem = {
|
||||
@@ -59,15 +58,13 @@ in {
|
||||
};
|
||||
|
||||
limits_config = {
|
||||
allow_structured_metadata = false;
|
||||
# enforce_metric_name = false;
|
||||
allow_structured_metadata = false;
|
||||
reject_old_samples = true;
|
||||
reject_old_samples_max_age = "72h";
|
||||
};
|
||||
|
||||
compactor = {
|
||||
working_directory = "/var/lib/loki/compactor";
|
||||
# shared_store = "filesystem";
|
||||
};
|
||||
|
||||
# ruler = {
|
||||
|
||||
@@ -1,8 +1,95 @@
|
||||
{ pkgs, lib }:
|
||||
{
|
||||
DeleteBatch = pkgs.callPackage ./delete-batch { };
|
||||
PluggableAuth = pkgs.callPackage ./pluggable-auth { };
|
||||
SimpleSAMLphp = pkgs.callPackage ./simple-saml-php { };
|
||||
UserMerge = pkgs.callPackage ./user-merge { };
|
||||
VisualEditor = pkgs.callPackage ./visual-editor { };
|
||||
}
|
||||
let
|
||||
kebab-case-name = project-name: lib.pipe project-name [
|
||||
(builtins.replaceStrings
|
||||
lib.upperChars
|
||||
(map (x: "-${x}") lib.lowerChars)
|
||||
)
|
||||
(lib.removePrefix "-")
|
||||
];
|
||||
|
||||
mw-ext = {
|
||||
name
|
||||
, commit
|
||||
, hash
|
||||
, tracking-branch ? "REL1_41"
|
||||
, kebab-name ? kebab-case-name name
|
||||
, fetchgit ? pkgs.fetchgit
|
||||
}:
|
||||
{
|
||||
${name} = (fetchgit {
|
||||
name = "mediawiki-${kebab-name}-source";
|
||||
url = "https://gerrit.wikimedia.org/r/mediawiki/extensions/${name}";
|
||||
rev = commit;
|
||||
inherit hash;
|
||||
}).overrideAttrs (_: {
|
||||
passthru = { inherit name kebab-name tracking-branch; };
|
||||
});
|
||||
};
|
||||
in
|
||||
# NOTE: to add another extension, you can add an mw-ext expression
|
||||
# with an empty (or even wrong) commit and empty hash, and
|
||||
# run the update script
|
||||
lib.mergeAttrsList [
|
||||
(mw-ext {
|
||||
name = "CodeEditor";
|
||||
commit = "7d8447035e381d76387e38b92e4d1e2b8d373a01";
|
||||
hash = "sha256-v2AlbP0vZma3qZyEAWGjZ/rLcvOpIMroyc1EixKjlAU=";
|
||||
})
|
||||
(mw-ext {
|
||||
name = "CodeMirror";
|
||||
commit = "a7b4541089f9b88a0b722d9d790e4cf0f13aa328";
|
||||
hash = "sha256-clyzN3v3+J4GjdyhrCsytBrH7VR1tq5yd0rB+32eWCg=";
|
||||
})
|
||||
(mw-ext {
|
||||
name = "DeleteBatch";
|
||||
commit = "cad869fbd95637902673f744581b29e0f3e3f61a";
|
||||
hash = "sha256-M1ek1WdO1/uTjeYlrk3Tz+nlb/fFZH+O0Ok7b10iKak=";
|
||||
})
|
||||
(mw-ext {
|
||||
name = "PluggableAuth";
|
||||
commit = "4111a57c34e25bde579cce5d14ea094021e450c8";
|
||||
hash = "sha256-aPtN8A9gDxLlq2+EloRZBO0DfHtE0E5kbV/adk82jvM=";
|
||||
})
|
||||
(mw-ext {
|
||||
name = "Popups";
|
||||
commit = "f1bcadbd8b868f32ed189feff232c47966c2c49e";
|
||||
hash = "sha256-PQAjq/X4ZYwnnZ6ADCp3uGWMIucJy0ZXxsTTbAyxlSE=";
|
||||
})
|
||||
(mw-ext {
|
||||
name = "Scribunto";
|
||||
commit = "7b99c95f588b06635ee3c487080d6cb04617d4b5";
|
||||
hash = "sha256-pviueRHQAsSlv4AtnUpo2Cjci7CbJ5aM75taEXY+WrI=";
|
||||
})
|
||||
(mw-ext {
|
||||
name = "SimpleSAMLphp";
|
||||
kebab-name = "simple-saml-php";
|
||||
commit = "ecb47191fecd1e0dc4c9d8b90a9118e393d82c23";
|
||||
hash = "sha256-gKu+O49XrAVt6hXdt36Ru7snjsKX6g2CYJ0kk/d+CI8=";
|
||||
})
|
||||
(mw-ext {
|
||||
name = "TemplateData";
|
||||
commit = "1ec66ce80f8a4322138efa56864502d0ee069bad";
|
||||
hash = "sha256-Lv3Lq9dYAtdgWcwelveTuOhkP38MTu0m5kmW8+ltRis=";
|
||||
})
|
||||
(mw-ext {
|
||||
name = "TemplateStyles";
|
||||
commit = "581180e898d6a942e2a65c8f13435a5d50fffa67";
|
||||
hash = "sha256-zW8O0mzG4jYfQoKi2KzsP+8iwRCLnWgH7qfmDE2R+HU=";
|
||||
})
|
||||
(mw-ext {
|
||||
name = "UserMerge";
|
||||
commit = "c17c919bdb9b67bb69f80df43e9ee9d33b1ecf1b";
|
||||
hash = "sha256-+mkzTCo8RVlGoFyfCrSb5YMh4J6Pbi1PZLFu5ps8bWY=";
|
||||
})
|
||||
(mw-ext {
|
||||
name = "VisualEditor";
|
||||
commit = "90bb3d455892e25317029ffd4bda93159e8faac8";
|
||||
hash = "sha256-SZAVELQUKZtwSM6NVlxvIHdFPodko8fhZ/uwB0LCFDA=";
|
||||
})
|
||||
(mw-ext {
|
||||
name = "WikiEditor";
|
||||
commit = "8dba5b13246d7ae09193f87e6273432b3264de5f";
|
||||
hash = "sha256-vF9PBuM+VfOIs/a2X1JcPn6WH4GqP/vUJDFkfXzWyFU=";
|
||||
})
|
||||
]
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
{ fetchzip }:
|
||||
let
|
||||
commit = "a53af3b8269ed19ede3cf1fa811e7ec8cb00af92";
|
||||
project-name = "UserMerge";
|
||||
tracking-branch = "REL1_41";
|
||||
in
|
||||
fetchzip {
|
||||
name = "mediawiki-delete-batch";
|
||||
url = "https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/${project-name}/+archive/${commit}.tar.gz";
|
||||
hash = "sha256-0ofCZhhv4aVTGq469Fdu7k0oVQu3kG3HFa8zaBbUr/M=";
|
||||
stripRoot = false;
|
||||
passthru = { inherit project-name tracking-branch; };
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
{ fetchzip }:
|
||||
let
|
||||
commit = "d5b3ad8f03b65d3746e025cdd7fe3254ad6e4026";
|
||||
project-name = "PluggableAuth";
|
||||
tracking-branch = "REL1_41";
|
||||
in
|
||||
fetchzip {
|
||||
name = "mediawiki-pluggable-auth-source";
|
||||
url = "https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/${project-name}/+archive/${commit}.tar.gz";
|
||||
hash = "sha256-mLepavgeaNUGYxrrCKVpybGO2ecjc3B5IU8q+gZTx2U=";
|
||||
stripRoot = false;
|
||||
passthru = { inherit project-name tracking-branch; };
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
{ fetchzip }:
|
||||
let
|
||||
commit = "9ae0678d77a9175285a1cfadd5adf28379dbdb3d";
|
||||
project-name = "SimpleSAMLphp";
|
||||
tracking-branch = "REL1_41";
|
||||
in
|
||||
fetchzip {
|
||||
name = "mediawiki-simple-saml-php-source";
|
||||
url = "https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/${project-name}/+archive/${commit}.tar.gz";
|
||||
hash = "sha256-s6Uw1fNzGBF0HEMl0LIRLhJkOHugrCE0aTnqawYi/pE=";
|
||||
stripRoot = false;
|
||||
passthru = { inherit project-name tracking-branch; };
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i python3 -p "python3.withPackages(ps: with ps; [ beautifulsoup4 requests ])"
|
||||
#!nix-shell -i python3 -p "python3.withPackages(ps: with ps; [ beautifulsoup4 requests ])" nix-prefetch-git
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
@@ -8,99 +8,148 @@ import subprocess
|
||||
from collections import defaultdict
|
||||
from pprint import pprint
|
||||
from dataclasses import dataclass
|
||||
from functools import cache
|
||||
import json
|
||||
|
||||
import bs4
|
||||
import requests
|
||||
|
||||
BASE_URL = "https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions"
|
||||
|
||||
BASE_WEB_URL = "https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions"
|
||||
BASE_GIT_URL = "https://gerrit.wikimedia.org/r/mediawiki/extensions/"
|
||||
|
||||
|
||||
@dataclass
|
||||
class PluginMetadata:
|
||||
project_name: str
|
||||
tracking_branch: str
|
||||
tracking_branch: str | None
|
||||
commit: str
|
||||
hash_: str
|
||||
|
||||
|
||||
def get_metadata(file_content: str) -> dict[str,str] | None:
|
||||
commit_search = re.search(f'commit = "([^"]*?)";', file_content)
|
||||
tracking_branch_search = re.search(f'tracking-branch = "([^"]+?)";', file_content)
|
||||
project_name_search = re.search(f'project-name = "([^"]+?)";', file_content)
|
||||
if commit_search is None:
|
||||
print("Could not find commit in file:")
|
||||
print(file_content)
|
||||
return None
|
||||
if tracking_branch_search is None:
|
||||
print("Could not find tracking branch in file:")
|
||||
print(file_content)
|
||||
return None
|
||||
@cache
|
||||
def get_package_listing_path():
|
||||
return Path(__file__).parent / "default.nix"
|
||||
|
||||
|
||||
@cache
|
||||
def get_global_tracking_branch() -> str:
|
||||
with open(get_package_listing_path()) as file:
|
||||
file_content = file.read()
|
||||
return re.search(r'\btracking-branch\b \? "([^"]+?)"', file_content).group(1)
|
||||
|
||||
|
||||
def get_metadata(package_expression: str) -> PluginMetadata | None:
|
||||
project_name_search = re.search(r'\bname\b = "([^"]+?)";', package_expression)
|
||||
tracking_branch_search = re.search(r'\btracking-branch\b = "([^"]+?)";', package_expression)
|
||||
commit_search = re.search(r'\bcommit\b = "([^"]*?)";', package_expression)
|
||||
hash_search = re.search(r'\bhash\b = "([^"]*?)";', package_expression)
|
||||
|
||||
if project_name_search is None:
|
||||
print("Could not find project name in file:")
|
||||
print(file_content)
|
||||
print("Could not find project name in package:")
|
||||
print(package_expression)
|
||||
return None
|
||||
|
||||
tracking_branch = None;
|
||||
if tracking_branch_search is not None:
|
||||
tracking_branch = tracking_branch_search.group(1)
|
||||
|
||||
if commit_search is None:
|
||||
print("Could not find commit in package:")
|
||||
print(package_expression)
|
||||
return None
|
||||
|
||||
if hash_search is None:
|
||||
print("Could not find hash in package:")
|
||||
print(package_expression)
|
||||
return None
|
||||
|
||||
return PluginMetadata(
|
||||
commit = commit_search.group(1),
|
||||
tracking_branch = tracking_branch_search.group(1),
|
||||
tracking_branch = tracking_branch,
|
||||
project_name = project_name_search.group(1),
|
||||
hash_ = hash_search.group(1),
|
||||
)
|
||||
|
||||
|
||||
def update_metadata(package_expression: str, metadata: PluginMetadata) -> str:
|
||||
result = package_expression
|
||||
result = re.sub(r'\bcommit\b = "[^"]*";', f'commit = "{metadata.commit}";', result)
|
||||
result = re.sub(r'\bhash\b = "[^"]*";', f'hash = "{metadata.hash_}";', result)
|
||||
return result
|
||||
|
||||
|
||||
def get_newest_commit(project_name: str, tracking_branch: str) -> str:
|
||||
content = requests.get(f"{BASE_URL}/{project_name}/+log/refs/heads/{tracking_branch}/").text
|
||||
content = requests.get(f"{BASE_WEB_URL}/{project_name}/+log/refs/heads/{tracking_branch}/").text
|
||||
soup = bs4.BeautifulSoup(content, features="html.parser")
|
||||
a = soup.find('li').findChild('a')
|
||||
commit_sha = a['href'].split('/')[-1]
|
||||
try:
|
||||
a = soup.find('li').findChild('a')
|
||||
commit_sha = a['href'].split('/')[-1]
|
||||
except AttributeError:
|
||||
print(f"ERROR: Could not parse page for {project_name}:")
|
||||
print(soup.prettify())
|
||||
exit(1)
|
||||
return commit_sha
|
||||
|
||||
|
||||
def get_nix_hash(tar_gz_url: str) -> str:
|
||||
def get_nix_hash(url: str, commit: str) -> str:
|
||||
out, err = subprocess.Popen(
|
||||
["nix-prefetch-url", "--unpack", "--type", "sha256", tar_gz_url],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE
|
||||
).communicate()
|
||||
out, err = subprocess.Popen(
|
||||
["nix", "hash", "to-sri", "--type", "sha256", out.decode().strip()],
|
||||
["nix-prefetch-git", "--url", url, "--rev", commit, "--fetch-submodules", "--quiet"],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE
|
||||
).communicate()
|
||||
|
||||
return out.decode().strip()
|
||||
return json.loads(out.decode().strip())['hash']
|
||||
|
||||
|
||||
def set_commit_and_hash(file_content: str, commit: str, sha256: str) -> str:
|
||||
result = file_content
|
||||
result = re.sub('commit = "[^"]*";', f'commit = "{commit}";', result)
|
||||
result = re.sub('hash = "[^"]*";', f'hash = "{sha256}";', result)
|
||||
return result
|
||||
def update_expression(package_expression: str) -> str:
|
||||
old_metadata = get_metadata(package_expression)
|
||||
if old_metadata is None:
|
||||
print("ERROR: could not find metadata for expression:")
|
||||
print(package_expression)
|
||||
return
|
||||
|
||||
def update(package_file: Path) -> None:
|
||||
with open(package_file) as file:
|
||||
if old_metadata.commit == "":
|
||||
old_metadata.commit = "<none>"
|
||||
if old_metadata.hash_ == "":
|
||||
old_metadata.hash_ = "<none>"
|
||||
|
||||
tracking_branch = old_metadata.tracking_branch
|
||||
if tracking_branch is None:
|
||||
tracking_branch = get_global_tracking_branch()
|
||||
|
||||
new_commit = get_newest_commit(old_metadata.project_name, tracking_branch)
|
||||
new_hash = get_nix_hash(f"{BASE_GIT_URL}/{old_metadata.project_name}", new_commit)
|
||||
if new_hash is None or new_hash == "":
|
||||
print(f"ERROR: could not fetch hash for {old_metadata.project_name}")
|
||||
exit(1)
|
||||
|
||||
print(f"Updating {old_metadata.project_name}[{tracking_branch}]: {old_metadata.commit} -> {new_commit}")
|
||||
|
||||
new_metadata = PluginMetadata(
|
||||
project_name = old_metadata.project_name,
|
||||
tracking_branch = old_metadata.tracking_branch,
|
||||
commit = new_commit,
|
||||
hash_ = new_hash,
|
||||
)
|
||||
|
||||
return update_metadata(package_expression, new_metadata)
|
||||
|
||||
|
||||
def update_all_expressions_in_default_nix() -> None:
|
||||
with open(get_package_listing_path()) as file:
|
||||
file_content = file.read()
|
||||
|
||||
metadata = get_metadata(file_content)
|
||||
if metadata is None:
|
||||
return
|
||||
if metadata.commit == "":
|
||||
metadata.commit = "<none>"
|
||||
new_file_content = re.sub(
|
||||
r"\(mw-ext\s*\{(?:.|\n)+?\}\)",
|
||||
lambda m: update_expression(m.group(0)),
|
||||
file_content,
|
||||
flags = re.MULTILINE,
|
||||
)
|
||||
|
||||
new_commit = get_newest_commit(metadata.project_name, metadata.tracking_branch)
|
||||
if new_commit == metadata.commit:
|
||||
return
|
||||
|
||||
new_url = f"{BASE_URL}/{metadata.project_name}/+archive/{new_commit}.tar.gz"
|
||||
new_hash = get_nix_hash(new_url)
|
||||
|
||||
print(f"Updating {metadata.project_name}: {metadata.commit} -> {new_commit}")
|
||||
|
||||
new_file_content = set_commit_and_hash(file_content, new_commit, new_hash)
|
||||
|
||||
with open(package_file, 'w') as file:
|
||||
with open(get_package_listing_path(), 'w') as file:
|
||||
file.write(new_file_content)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
for direntry in os.scandir(Path(__file__).parent):
|
||||
if direntry.is_dir():
|
||||
package_file = Path(direntry) / "default.nix"
|
||||
assert package_file.is_file()
|
||||
update(package_file)
|
||||
update_all_expressions_in_default_nix()
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
{ fetchzip }:
|
||||
let
|
||||
commit = "a53af3b8269ed19ede3cf1fa811e7ec8cb00af92";
|
||||
project-name = "UserMerge";
|
||||
tracking-branch = "REL1_41";
|
||||
in
|
||||
fetchzip {
|
||||
name = "mediawiki-user-merge-source";
|
||||
url = "https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/${project-name}/+archive/${commit}.tar.gz";
|
||||
hash = "sha256-0ofCZhhv4aVTGq469Fdu7k0oVQu3kG3HFa8zaBbUr/M=";
|
||||
stripRoot = false;
|
||||
passthru = { inherit project-name tracking-branch; };
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
{ fetchzip }:
|
||||
let
|
||||
commit = "bb92d4b0bb81cebd73a3dbabfb497213dac349f2";
|
||||
project-name = "VisualEditor";
|
||||
tracking-branch = "REL1_40";
|
||||
in
|
||||
fetchzip {
|
||||
name = "mediawiki-visual-editor-source";
|
||||
url = "https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/extensions/${project-name}/+archive/${commit}.tar.gz";
|
||||
hash = "sha256-lShpSoR+NLfdd5i7soM6J40pq+MzCMG0M1tSYsS+jAg=";
|
||||
stripRoot = false;
|
||||
passthru = { inherit project-name tracking-branch; };
|
||||
}
|
||||
@@ -28,6 +28,8 @@ nettsiden:
|
||||
postgres_password: ENC[AES256_GCM,data:SvbrdHF4vQ94DgoEfy67QS5oziAsMT8H,iv:LOHBqMecA6mgV3NMfmfTh3zDGiDve+t3+uaO53dIxt4=,tag:9ffz84ozIqytNdGB1COMhA==,type:str]
|
||||
cookie_salt: ENC[AES256_GCM,data:VmODSLOP1YDBrpHdk/49qx9BS+aveEYDQ1D24d4zCi06kZsCENCr+vdPAnTeM1pw98RTr3yZAEQTh4s90b6v8Q==,iv:vRClu6neyYPFdtD63kjnvK2iNOIHMbh+9qEGph7CI60=,tag:66fgppVxY0egs4+9XfDBPA==,type:str]
|
||||
admin_password: ENC[AES256_GCM,data:SADr/zN3F0tW339kSK1nD9Pb38rw7hz8,iv:s5jgl1djXd5JKwx1WG/w2Q4STMMpjJP91qxOwAoNcL0=,tag:N8bKnO9N0ei06HDkSGt6XQ==,type:str]
|
||||
vaultwarden:
|
||||
environ: ENC[AES256_GCM,data:CST5I8x8qAkrTy/wbMLL6aFSPDPIU7aWsD1L1MnIATRmk7fcUhfTSFds7quJmIpb2znsIT/WxNI/V/7UW+9ZdPKI64hfPR8MtvrJcbOhU5Fe2IiytFymFbhcOgWAXjbGzs7knQmpfMxSl98sU71oLkRuFdkousdnh4VQFZhUCYM=,iv:Is6xQ7DGdcAQgrrXCS9NbJk67O2uR82rbKOXBTzZHWw=,tag:XVEjCEM5t8qJl6jL89zrkw==,type:str]
|
||||
sops:
|
||||
kms: []
|
||||
gcp_kms: []
|
||||
@@ -61,8 +63,8 @@ sops:
|
||||
akVjeTNTeGorZjJQOVlMeCtPRUVYL3MK+VMvGxrbzGz4Q3sdaDDWjal+OiK+JYKX
|
||||
GHiMXVHQJZu/RrlxMjHKN6V3iaqxZpuvLAEJ2Lzy5EOHPtuiiRyeHQ==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
lastmodified: "2024-05-12T00:24:29Z"
|
||||
mac: ENC[AES256_GCM,data:/fh5yc09YTLT62oWVsz2CwW/mhEUI7uRh5fDRgLNeeBc/4bvM3z83xmy9veehmQhhCWjju2/CtYhaihm3bUPN4hu3wVzviIxvrS9lTcBUG+F/AH4SnF5Z1CGWb94Gqi/6OhQRIpA6azjISyv8lTAQ4TCqcOC4fz/c9KjqQ/CiGY=,iv:HjzzMRFz3+kZ4iDLn9kI80BwMDALkRX5gyOHARZSgDA=,tag:1ez7NiIavshfp4CTZNkW/Q==,type:str]
|
||||
lastmodified: "2024-05-26T02:07:41Z"
|
||||
mac: ENC[AES256_GCM,data:CRaJefV1zcJc6eyzyjTLgd0+Wv46VT8o4iz2YAGU+c2b/Cr97Tj290LoEO6UXTI3uFwVfzii2yZ2l+4FK3nVVriD4Cx1O/9qWcnLa5gfK30U0zof6AsJx8qtGu1t6oiPlGUCF7sT0BW9Wp8cPumrY6cZp9QbhmIDV0o0aJNUNN4=,iv:8OSYV1eG6kYlJD4ovZZhcD1GaYnmy7vHPa/+7egM1nE=,tag:OPI13rpDh2l1ViFj8TBFWg==,type:str]
|
||||
pgp:
|
||||
- created_at: "2023-05-21T00:28:40Z"
|
||||
enc: |
|
||||
@@ -86,3 +88,4 @@ sops:
|
||||
fp: F7D37890228A907440E1FD4846B9228E814A2AAC
|
||||
unencrypted_suffix: _unencrypted
|
||||
version: 3.8.1
|
||||
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
bluemap_ssh_key: ENC[AES256_GCM,data:2kv/cDEEQMHJdwTmmTxtyxOZz8duggaT61U69IuiOJ2yuwqkujOHZ2gkCtGa1VyFPn6wg4OTiSA/Loz+QmTSKz+8HqvY/Lybks+offDZ1mukL5NiWLUVmNZdfdHaMeEyiZsxiMoWEgFtMiKvgmdMMPa/BCHZCMCxMWFAcuiZgbhGyGukdo0wQd5RcEDaY4JZ7q95ndAn4K7gi9q1K7MLOvI5t2hGibj8DrqriXqg9mahsiFZdKWxjf3tBX0MzS85wAtleQWXmH5FRvECmdOj3OSp92JMqU/WDlQih3xjnw1Ci3L/hdwgGLHZTf/RzuPpGh2OD26A7gUjOFh+M5z2dVVtZ40F8tQFxpQxkkJBsqTNbDKuw7/KPpZUJkn4UYBkhzraG/62md/9sS9+GjTHBhfYQYHbDU8ZbPO5ZSoZfshRDUuP0qYXiQw7cxA5BQIhwYdn26uy2ghiHsP713Tz91ESVjlCZLLduGySWEQNAxSdzFu9yEyp4xdl8l9udlnxVV2/5Xm5kQEdiUMwiBpUhrghdEl6lOzome5h,iv:uiYaQgOnhFvWze/oHGSpAu8+m89l4tGCgRauDzU3ZqE=,tag:eCYgCH+e8hNYpBIFWFOTbA==,type:str]
|
||||
sops:
|
||||
kms: []
|
||||
gcp_kms: []
|
||||
azure_kv: []
|
||||
hc_vault: []
|
||||
age:
|
||||
- recipient: age1tmn5qahlyf0e579e4camckdyxrexjzffv54hdzdnrw7lzqs7kyqq0f2fr3
|
||||
enc: |
|
||||
-----BEGIN AGE ENCRYPTED FILE-----
|
||||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSAvL2dqdHFwWURFSWJEUkVl
|
||||
eXR2cTQyTXpzUEFra0drdUgzRUNmSXA4eGc0CmRoWnp5UUUyQy9kK0dHVjF3WkFp
|
||||
M0loS1RXeWxHSGNTQUljS05jaDBxMDQKLS0tIDhyUGdvcE1iMWxJeWhYb3JFTi9q
|
||||
Y0RrVHNhcVU3WFd2NitlQ3l4Ry9JTkEKALBawjOt7hChok/cHRa38HkB0KVEKvik
|
||||
r2jO26j9AUU5mqjR/dIko3jvfcXoNUNRYrMwaBfRa6AFnNBoN3g0ng==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
- recipient: age17tagmpwqjk3mdy45rfesrfey6h863x8wfq38wh33tkrlrywxducs0k6tpq
|
||||
enc: |
|
||||
-----BEGIN AGE ENCRYPTED FILE-----
|
||||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBzV1R0cWxoTXNKNnpsUjE5
|
||||
c01Oc3J5M2F2cDVKOTNma0J3eFVwa0pXQmpjCkdxRjJZTlFWSlh2UFR2emx4OVVY
|
||||
T3gzSWdXNTlyS0VJSXRnTXZweER6V00KLS0tIGdFU3oxZ3lzQTBjU0hyYjV5M2cr
|
||||
VnUvcGZDbEZuZitQS1g1NmRtb3JnNDAKV6otQlYUSF5ScyYL6LlstPU1pkLMY8r0
|
||||
/NEuN9A7l2m9Wy8iItx+ZhwGp9pEPsgdsQLJQtJFfaA6lNuFhbgqfg==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
- recipient: age1ju7rd26llahz3g8tz7cy5ld52swj8gsmg0flrmrxngc0nj0avq3ssh0sn5
|
||||
enc: |
|
||||
-----BEGIN AGE ENCRYPTED FILE-----
|
||||
YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBNbmpMaWhpQTQzR05Cd0cw
|
||||
b3dJRXVoUmFzZGxMeC9tVk9acndMemlrTHhzCkVtMHJ1bE94T25wRmpTZnpHbUdq
|
||||
NzQ4T0pLZW56TEV2emQ5RHVXTDAvdmsKLS0tIFJ0OWxNYkIxOVBVV1hmZDdoeEhm
|
||||
blB3M2JIMmk3Tmh6WjIzQjlHSW9GNDAKB3gdJL9AlF4fsCMujd/6HnieDwhCZnex
|
||||
QDU87yTePHAppnqLp+ZuVdSbqcsnQclmbm92M3S6LuKpoDhGxeHrEw==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
lastmodified: "2024-06-08T23:34:34Z"
|
||||
mac: ENC[AES256_GCM,data:CLsz6UgS1LO/5SArmT7utald3TzQUWwEiSRw3dF1RaCwyb0Fc16/5DxJSk0KGLiJRlDXses/ynSjoyaBdTagijJPKQZCpx3fHZFqEJk6Wne4zQ4EoFbY1SpPrkhGVGMYaUg/H/NapoAEiq619YudR9W6GqF8ZkauXE76wls63FM=,iv:I09LFoSkeMAWHmvXtIF4+FURZ4tOQGCXQqbNrKz5t7s=,tag:xauT9sah+26A9pRrwXlsiQ==,type:str]
|
||||
pgp: []
|
||||
unencrypted_suffix: _unencrypted
|
||||
version: 3.8.1
|
||||
@@ -1,8 +1,12 @@
|
||||
{ pkgs, ... }:
|
||||
{ pkgs, lib, config, ... }:
|
||||
{
|
||||
users.users.felixalb = {
|
||||
isNormalUser = true;
|
||||
extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
|
||||
extraGroups = [
|
||||
"wheel"
|
||||
] ++ lib.optionals ( config.users.groups ? "libvirtd" ) [
|
||||
"libvirtd"
|
||||
];
|
||||
shell = pkgs.zsh;
|
||||
openssh.authorizedKeys.keys = [
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDKzPICGew7uN0cmvRmbwkwTCodTBUgEhkoftQnZuO4Q felixalbrigtsen@gmail.com"
|
||||
|
||||
21
values.nix
21
values.nix
@@ -73,4 +73,25 @@ in rec {
|
||||
DHCP = "no";
|
||||
};
|
||||
|
||||
openstackGlobalNetworkConfig = {
|
||||
networkConfig.IPv6AcceptRA = "yes";
|
||||
dns = [ "129.241.0.200" "129.241.0.201" ];
|
||||
domains = [ "pvv.ntnu.no" "pvv.org" ];
|
||||
DHCP = "yes";
|
||||
};
|
||||
|
||||
openstackLocalNetworkConfig = {
|
||||
networkConfig.IPv6AcceptRA = "no";
|
||||
dns = [ "129.241.0.200" "129.241.0.201" ];
|
||||
domains = [ "pvv.ntnu.no" "pvv.org" ];
|
||||
DHCP = "yes";
|
||||
|
||||
# Only use this network for link-local networking, not global/default routes
|
||||
dhcpV4Config.UseRoutes = "no";
|
||||
routes = [
|
||||
{ routeConfig = { Destination = "10.0.0.0/8"; Gateway = "_dhcp4"; }; }
|
||||
];
|
||||
|
||||
linkConfig.RequiredForOnline = "no";
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user