Compare commits

...

10 commits

13 changed files with 124 additions and 27 deletions

View file

@ -14,3 +14,10 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: nix build .#checks.x86_64-linux.pre-commit -L
check-website:
runs-on: native
steps:
- uses: actions/checkout@v4
- run: cd website && nix-build -A tests
- run: cd website && nix-build -A build

View file

@ -16,15 +16,19 @@ in
HTTP_ADDR = "127.0.0.1";
LANDING_PAGE = "explore";
};
mailer = {
ENABLED = true;
SMTP_ADDR = "mail.protagio.nl";
SMTP_PORT = "587";
FROM = "git@fediversity.eu";
USER = "git@fediversity.eu";
};
};
mailerPasswordFile = "/var/lib/forgejo/data/keys/forgejo-mailpw";
settings.service.ENABLE_NOTIFY_MAIL = true;
settings.mailer = {
ENABLED = true;
PROTOCOL = "smtp+starttls";
SMTP_ADDR = "mail.protagio.nl";
SMTP_PORT = "587";
FROM = "git@fediversity.eu";
USER = "git@fediversity.eu";
};
secrets.mailer.PASSWD = "/var/lib/forgejo/data/keys/forgejo-mailpw";
database = {
type = "mysql";
socket = "/run/mysqld/mysqld.sock";

View file

@ -7,7 +7,7 @@
{ pkgs, ... }:
{
checks = {
mastodon-garage = import ./tests/mastodon-garage.nix { inherit self pkgs; };
mastodon = import ./tests/mastodon.nix { inherit self pkgs; };
pixelfed-garage = import ./tests/pixelfed-garage.nix { inherit self pkgs; };
};
};

View file

@ -0,0 +1,23 @@
{ config, lib, ... }:
{
collections.events.entry = { link, ... }: {
title = "NixOS 24.11 ZHF hackathon";
name = "zhf-24-11";
description = "NixOS 24.11 ZHF hackathon in Zürich";
start-date = "2024-11-23";
end-date = "2024-11-24";
start-time = "10:00";
end-time = "17:00";
location = "OST Campus Rapperswil";
body = ''
The biannual [Zürich NixOS ZHF hackathon](https://zurich.nix.ug/) has become somewhat of an institution for maintaining the tradition of preparing the upcoming NixOS release.
The main goal of the two-day gathering is to bring down the number of build failures on the [continuous integration system Hydra](https://status.nixos.org/) before the release: ZHF stands for *Zero Hydra Failures*.
It also presents a great opportunity to learn Nix, squash bugs together, get to know each other, discuss current events, and make plans for the future.
This is the greatest event in the series so far, with more than 40 participants from all over Europe, including many high-profile contributors and maintainers in the Nix ecosystem.
[Fediversity engineers attended](${link config.collections.news.by-name.zhf-24-11}) to present prototypes and exchange ideas with other developers.
'';
};
}

View file

@ -0,0 +1,22 @@
{ config, lib, ... }:
{
collections.news.entry = { link, ... }: rec {
name = "zhf-24-11";
title = "NixOS 24.11 release hackathon and workshop";
description = "Fediversity engineers met in Zürich at a NixOS 24.11 ZHF hackathon";
date = "2024-11-28";
author = "Valentin Gagarin";
summary = ''
Fediversity engineers met in Zürich at a [NixOS 24.11 ZHF hackathon](${link config.collections.events.by-name.zhf-24-11}) to present prototypes and exchange ideas with the Nix community.
'';
body = ''
${summary}
Robert held a lightning talk on the design of [NixOps4](https://github.com/nixops4/nixops4), which is currently in the prototype stage of development.
Before that, Nicolas had already shown an internal demonstration that NixOps4 is capable of deploying multiple NixOS services in the Fediversity test environment.
In the afternoon, Robert, Valentin, and Koen got together with Eli from [Thymis](https://thymis.io) and Johannes from [Clan](https://clan.lol/) to walk each other through the architecture of their respective systems.
This was an extraordinarily fruitful encounter that helped us to identify overlaps and potential for future collaboration!
'';
};
}

View file

@ -61,8 +61,32 @@ rec {
];
};
tests = with pkgs; with lib; runCommand "run-tests" { } ''
touch $out
${getExe nix-unit} ${./tests.nix} "$@"
'';
inherit sources pkgs;
tests = with pkgs; with lib;
let
source = fileset.toSource {
root = ./.;
fileset = fileset.unions [
./default.nix
./tests.nix
./lib.nix
./npins
];
};
in
runCommand "run-tests"
{
buildInputs = [ pkgs.nix ];
}
''
export HOME="$(realpath .)"
# HACK: nix-unit initialises its own entire Nix, so it needs a store to operate on,
# but since we're in a derivation, we can't fetch sources, so copy Nixpkgs manually here.
# `''${sources.nixpkgs}` resolves to `<hash>-source`,
# adding it verbatim will result in <hash'>-<hash>-source, so rename it first
cp -r ${sources.nixpkgs} source
nix-store --add --store "$HOME" source
${getExe nix-unit} --gc-roots-dir "$HOME" --store "$HOME" ${source}/tests.nix "$@"
touch $out
'';
}

View file

@ -99,20 +99,22 @@ rec {
relativePath = path1': path2':
let
inherit (lib.path) subpath;
inherit (lib) lists;
inherit (lib) lists length take drop min max;
path1 = subpath.components path1';
prefix1 = with lib; take (length path1 - 1) path1;
prefix1 = take (length path1 - 1) path1;
path2 = subpath.components path2';
prefix2 = with lib; take (length path2 - 1) path2;
prefix2 = take (length path2 - 1) path2;
commonPrefixLength = with lists;
findFirstIndex (i: i.fst != i.snd)
(length prefix1)
(min (length prefix1) (length prefix2))
(zipLists prefix1 prefix2);
depth = max 0 (length prefix1 - commonPrefixLength);
relativeComponents = with lists;
[ "." ] ++ (replicate (length prefix1 - commonPrefixLength) "..") ++ (drop commonPrefixLength path2);
[ "." ] ++ (replicate depth "..") ++ (drop commonPrefixLength path2);
in
join "/" relativeComponents;

View file

@ -14,11 +14,11 @@
'')
(
(crossLists (name: file: weight: { inherit name file weight; })
[ [ "Signika " ] [ "signika-extended.woff2" "signika.woff2" ] [ 500 700 ] ]
[ [ "Signika" ] [ "signika-extended.woff2" "signika.woff2" ] [ 500 700 ] ]
)
++
(crossLists (name: file: weight: { inherit name file weight; })
[ [ "Heebo " ] [ "heebo-extended.woff2" "heebo.woff2" ] [ 400 600 ] ]
[ [ "Heebo" ] [ "heebo-extended.woff2" "heebo.woff2" ] [ 400 600 ] ]
)
)
));

View file

@ -25,7 +25,7 @@ in
default = null;
};
};
config.name = lib.slug config.title;
config.name = with lib; mkDefault (slug config.title);
config.outputs.html = lib.mkForce
((cfg.templates.html.page config).override (final: prev: {
html = {

View file

@ -52,12 +52,17 @@ in
};
entry = mkOption {
description = "An entry in the collection";
type = types.collection (types.submodule ({
type = with types; collection (submodule ({
imports = [ config.type ];
_module.args.collection = config;
process-locations = ls: with lib; concatMap (l: map (p: "${p}/${l}") config.prefixes) ls;
}));
};
by-name = mkOption {
description = "Entries accessible by symbolic name";
type = with types; attrsOf attrs;
default = with lib; listToAttrs (map (e: { name = e.name; value = e; }) config.entry);
};
};
}));
};

View file

@ -39,7 +39,7 @@ in
type = with types; str;
};
};
config.name = lib.slug config.title;
config.name = with lib; mkDefault (slug config.title);
config.summary = lib.mkDefault config.description;
config.outputs.html = lib.mkForce
((cfg.templates.html.page config).override (final: prev: {

View file

@ -4,8 +4,18 @@ let
inherit (import ./. { }) lib;
in
{
test-relativePath = {
expr = with lib; relativePath "bar" "baz";
expected = "./baz";
};
test-relativePath = with lib;
let
testData = [
{ from = "bar"; to = "baz"; expected = "./baz"; }
{ from = "foo/bar"; to = "foo/baz"; expected = "./baz"; }
{ from = "foo"; to = "bar/baz"; expected = "./bar/baz"; }
{ from = "foo/bar"; to = "baz"; expected = "./../baz"; }
{ from = "foo/bar/baz"; to = "foo"; expected = "./../../foo"; }
];
in
{
expr = map (case: relativePath case.from case.to) testData;
expected = map (case: case.expected) testData;
};
}