Skip to content

Commit

Permalink
nixos 23.11 -> 24.05
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickvP committed Oct 13, 2024
1 parent c8a18b9 commit 0b064d6
Show file tree
Hide file tree
Showing 10 changed files with 481 additions and 476 deletions.
82 changes: 24 additions & 58 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
extra-substituters = "https://kninfra.cachix.org";
};
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.11";
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
flake-utils.url = "github:numtide/flake-utils";
poetry2nix = {
inputs.nixpkgs.follows = "nixpkgs";
Expand Down
15 changes: 0 additions & 15 deletions kn/base/templates/base/bare.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,6 @@
var csrf_token = "{{ csrf_token }}";
var leden_api_url = "{% url "leden-api" %}";
</script>
<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="/matomo/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', '1']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="/matomo/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->
{% endblock %}
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion nix/devshell.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ packages = [
#"python2",
"python3-with-grpcio",
"fd",
"nixfmt",
"nixfmt-classic",
"nixos-rebuild",
"gettext",
"mongodb",
Expand Down
10 changes: 5 additions & 5 deletions nix/infra.nix
Original file line number Diff line number Diff line change
Expand Up @@ -228,17 +228,20 @@ in rec {
path = "/root/vm-host.key";
type = "ed25519";
}];
systemd.services."acme-mail.local".enable = false;
kn.settings.ALLOWED_HOSTS = [ "localhost" "localhost:8080" "vipassana.kn.cx" ];
age.secrets.kn-env.file = ../secrets/vm.age;
age.secrets.mailman-rest.file = ../secrets/mailman-rest-vm.age;
kn.settings.DOMAINNAME = "vipassana.kn.cx";
kn.shared.initialDB = true;
virtualisation.memorySize = 2048;
# install the vm-ssh.key.pub for ssh access
users.users.root.openssh.authorizedKeys.keyFiles = [ ./vm-ssh.key.pub ];
};

# virtualized system, used for development
vm = { modulesPath, pkgs, ... }: {
imports = [ virtualized "${modulesPath}/virtualisation/qemu-vm.nix" ];
# install the vm-ssh.key.pub for ssh access
users.users.root.openssh.authorizedKeys.keyFiles = [ ./vm-ssh.key.pub ];
services.getty = {
autologinUser = "root";
helpLine = ''
Expand All @@ -254,13 +257,10 @@ in rec {
};
kn.django.package = "/kninfra-pub";
kn.mailserver.hostname = "mail.local";
kn.settings.ALLOWED_HOSTS = [ "localhost" "localhost:8080" ];
systemd.services."acme-mail.local".enable = false;
programs.bash.shellAliases."vm.stop" = "poweroff";
system.fsPackages = [ pkgs.bindfs ];
# qemu settings:
virtualisation = {
memorySize = 2048;
diskSize = 1024;
# set up serial console
graphics = false;
Expand Down
2 changes: 1 addition & 1 deletion nix/packages/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ final: prev: {
mkdir -p $out/bin
makeWrapper ${nodejs}/bin/node $out/bin/kn-puppet \
--add-flags ${../puppet.js} \
--set NODE_PATH ${puppeteer-cli.node_modules} \
--set NODE_PATH ${puppeteer-cli}/lib/node_modules/puppeteer-cli/node_modules \
--set PUPPETEER_EXECUTABLE_PATH ${chromium}/bin/chromium
'') {
nodejs = final.nodejs-slim_latest;
Expand Down
18 changes: 12 additions & 6 deletions nix/puppet.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,36 @@ async function getAccData(page) {
})
}

async function go_to(page, url) {
const url_str = url.toString()
console.log("Navigating to", url_str);
return page.goto(url_str);
}

async function toWiki(page) {
const wiki_url = new URL("/wiki/Hoofdpagina", page.url())
if (page.url() != wiki_url.toString()) {
return page.goto(wiki_url.toString())
return go_to(page, wiki_url)
}
}

async function getWikiUser(page) {
await toWiki(page)
return page.evaluate(() => {
return document.getElementById('pt-userpage')?.textContent
return document.getElementById('pt-userpage')?.textContent?.trim()
})
}

async function getWikiHeading(page) {
await toWiki(page)
return page.evaluate(() => {
return document.getElementById("firstHeading").textContent
return document.getElementById("firstHeading").textContent?.trim()
})
}

async function testKNWebsite(browser, PARAM) {
const page = await browser.newPage();
await page.goto(PARAM.host);
await go_to(page, PARAM.host);
await Promise.all([
page.waitForNavigation(),
page.evaluate((PARAM) => {
Expand All @@ -47,11 +53,11 @@ async function testKNWebsite(browser, PARAM) {
const accData = await getAccData(page)
assert.ok(accData.valid, "api.valid")
assert.equal(accData.name, PARAM.user, "api.name")
assert.equal(accData.email, PARAM.user + "@localhost", "api.email")
assert.equal(accData.email, PARAM.user + "@vipassana.kn.cx", "api.email")
// todo: assert.equal(accData.email, PARAM.user + "@karpenoktem.nl", "api.email")
assert.equal(await getWikiUser(page), PARAM.user[0].toUpperCase() + PARAM.user.slice(1), "wiki user")
assert.equal(await getWikiHeading(page), "Hoofdpagina", "wiki page name")
await page.goto(PARAM.host + "/accounts/logout")
await go_to(page, PARAM.host + "/accounts/logout")
assert.ok(!(await getAccData(page)).valid, "api logged out")
assert.ok(!await getWikiUser(page), "wiki logged out")
assert.equal(await getWikiHeading(page), "Fouten in rechten", "wiki loggedout permissions")
Expand Down
16 changes: 13 additions & 3 deletions nix/services/kn/shared.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
{ config, lib, pkgs, ... }:
let
cfg = config.kn.shared;
# generate a json file with configuration for uwsgi
kn_env = config.kn.shared.env;
in {
options.kn.shared = with lib; {
enable = mkEnableOption "KN DB";
Expand All @@ -32,7 +30,7 @@ in {
environment.systemPackages = [(
pkgs.runCommandNoCC "knshell" { buildInputs = [ pkgs.makeWrapper ]; } ''
makeWrapper ${pkgs.kninfra}/bin/shell $out/bin/knshell \
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: ''--set "${n}" "${v}"'') kn_env)}
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: ''--set "${n}" "${v}"'') cfg.env)}
''
)];
systemd.services = lib.mkIf cfg.initialDB {
Expand Down Expand Up @@ -65,6 +63,18 @@ in {
fi
'';
};
kn_initial_sync = rec {
requires = [ "giedo.service" "hans.service" "daan.service" ];
after = requires;
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
EnvironmentFile = config.age.secrets.kn-env.path;
ExecStart = "${pkgs.kninfra}/utils/giedo-sync.py";
};
environment = cfg.env;
};
};
};
}
Loading

0 comments on commit 0b064d6

Please sign in to comment.