Compare commits
36 Commits
check
...
update-nix
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c9e0fd6c6 | ||
|
|
0f847b4799 | ||
|
|
40a8a823b8 | ||
|
|
e3adb3fc71 | ||
|
|
a569a1d147 | ||
|
|
64718b77ca | ||
|
|
7b34c39736 | ||
|
|
4d6ab60793 | ||
|
|
35bffee544 | ||
|
|
16917fd79b | ||
|
|
895c116c01 | ||
|
|
e67151f7b9 | ||
|
|
8d26ec1760 | ||
|
|
7a9062b629 | ||
|
|
de07454a0a | ||
|
|
6fe60f61cf | ||
|
|
3fa74847e4 | ||
|
|
fc37140b52 | ||
|
|
83406c61f3 | ||
|
|
6d736e7e80 | ||
|
|
7b6cec4100 | ||
|
|
e21a6516b5 | ||
|
|
6ffe8ea5f6 | ||
|
|
0a2fefd141 | ||
|
|
0c885d05b6 | ||
|
|
58d85b117a | ||
|
|
ad58d7b6e9 | ||
|
|
7a63cb9642 | ||
|
|
196b98da36 | ||
|
|
42acbe95b8 | ||
|
|
b6b065e365 | ||
|
|
4b1955b189 | ||
|
|
ef7ef8b843 | ||
|
|
38c1367322 | ||
|
|
8e72c086fd | ||
|
|
c454b1339d |
@@ -58,51 +58,53 @@
|
|||||||
pkgs.buildPackages.xorg.lndir
|
pkgs.buildPackages.xorg.lndir
|
||||||
pkgs.glibcLocales
|
pkgs.glibcLocales
|
||||||
pkgs.kbd.out
|
pkgs.kbd.out
|
||||||
self.nixosConfigurations."test-flash-machine-${pkgs.hostPlatform.system}".pkgs.perlPackages.ConfigIniFiles
|
self.nixosConfigurations."test-flash-machine-${pkgs.stdenv.hostPlatform.system}".pkgs.perlPackages.ConfigIniFiles
|
||||||
self.nixosConfigurations."test-flash-machine-${pkgs.hostPlatform.system}".pkgs.perlPackages.FileSlurp
|
self.nixosConfigurations."test-flash-machine-${pkgs.stdenv.hostPlatform.system}".pkgs.perlPackages.FileSlurp
|
||||||
pkgs.bubblewrap
|
pkgs.bubblewrap
|
||||||
|
|
||||||
self.nixosConfigurations."test-flash-machine-${pkgs.hostPlatform.system}".config.system.build.toplevel
|
self.nixosConfigurations."test-flash-machine-${pkgs.stdenv.hostPlatform.system}".config.system.build.toplevel
|
||||||
self.nixosConfigurations."test-flash-machine-${pkgs.hostPlatform.system}".config.system.build.diskoScript
|
self.nixosConfigurations."test-flash-machine-${pkgs.stdenv.hostPlatform.system}".config.system.build.diskoScript
|
||||||
self.nixosConfigurations."test-flash-machine-${pkgs.hostPlatform.system}".config.system.build.diskoScript.drvPath
|
self.nixosConfigurations."test-flash-machine-${pkgs.stdenv.hostPlatform.system}".config.system.build.diskoScript.drvPath
|
||||||
]
|
]
|
||||||
++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs);
|
++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs);
|
||||||
closureInfo = pkgs.closureInfo { rootPaths = dependencies; };
|
closureInfo = pkgs.closureInfo { rootPaths = dependencies; };
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
# Skip flash test on aarch64-linux for now as it's too slow
|
# Skip flash test on aarch64-linux for now as it's too slow
|
||||||
checks = lib.optionalAttrs (pkgs.stdenv.isLinux && pkgs.hostPlatform.system != "aarch64-linux") {
|
checks =
|
||||||
nixos-test-flash = self.clanLib.test.baseTest {
|
lib.optionalAttrs (pkgs.stdenv.isLinux && pkgs.stdenv.hostPlatform.system != "aarch64-linux")
|
||||||
name = "flash";
|
{
|
||||||
nodes.target = {
|
nixos-test-flash = self.clanLib.test.baseTest {
|
||||||
virtualisation.emptyDiskImages = [ 4096 ];
|
name = "flash";
|
||||||
virtualisation.memorySize = 4096;
|
nodes.target = {
|
||||||
|
virtualisation.emptyDiskImages = [ 4096 ];
|
||||||
|
virtualisation.memorySize = 4096;
|
||||||
|
|
||||||
virtualisation.useNixStoreImage = true;
|
virtualisation.useNixStoreImage = true;
|
||||||
virtualisation.writableStore = true;
|
virtualisation.writableStore = true;
|
||||||
|
|
||||||
environment.systemPackages = [ self.packages.${pkgs.system}.clan-cli ];
|
environment.systemPackages = [ self.packages.${pkgs.system}.clan-cli ];
|
||||||
environment.etc."install-closure".source = "${closureInfo}/store-paths";
|
environment.etc."install-closure".source = "${closureInfo}/store-paths";
|
||||||
|
|
||||||
nix.settings = {
|
nix.settings = {
|
||||||
substituters = lib.mkForce [ ];
|
substituters = lib.mkForce [ ];
|
||||||
hashed-mirrors = null;
|
hashed-mirrors = null;
|
||||||
connect-timeout = lib.mkForce 3;
|
connect-timeout = lib.mkForce 3;
|
||||||
flake-registry = "";
|
flake-registry = "";
|
||||||
experimental-features = [
|
experimental-features = [
|
||||||
"nix-command"
|
"nix-command"
|
||||||
"flakes"
|
"flakes"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
testScript = ''
|
||||||
|
start_all()
|
||||||
|
machine.succeed("echo 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIRWUusawhlIorx7VFeQJHmMkhl9X3QpnvOdhnV/bQNG root@target' > ./test_id_ed25519.pub")
|
||||||
|
# Some distros like to automount disks with spaces
|
||||||
|
machine.succeed('mkdir -p "/mnt/with spaces" && mkfs.ext4 /dev/vdc && mount /dev/vdc "/mnt/with spaces"')
|
||||||
|
machine.succeed("clan flash write --ssh-pubkey ./test_id_ed25519.pub --keymap de --language de_DE.UTF-8 --debug --flake ${self.checks.x86_64-linux.clan-core-for-checks} --yes --disk main /dev/vdc test-flash-machine-${pkgs.stdenv.hostPlatform.system}")
|
||||||
|
'';
|
||||||
|
} { inherit pkgs self; };
|
||||||
};
|
};
|
||||||
testScript = ''
|
|
||||||
start_all()
|
|
||||||
machine.succeed("echo 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIRWUusawhlIorx7VFeQJHmMkhl9X3QpnvOdhnV/bQNG root@target' > ./test_id_ed25519.pub")
|
|
||||||
# Some distros like to automount disks with spaces
|
|
||||||
machine.succeed('mkdir -p "/mnt/with spaces" && mkfs.ext4 /dev/vdc && mount /dev/vdc "/mnt/with spaces"')
|
|
||||||
machine.succeed("clan flash write --ssh-pubkey ./test_id_ed25519.pub --keymap de --language de_DE.UTF-8 --debug --flake ${self.checks.x86_64-linux.clan-core-for-checks} --yes --disk main /dev/vdc test-flash-machine-${pkgs.hostPlatform.system}")
|
|
||||||
'';
|
|
||||||
} { inherit pkgs self; };
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,9 +160,9 @@
|
|||||||
closureInfo = pkgs.closureInfo {
|
closureInfo = pkgs.closureInfo {
|
||||||
rootPaths = [
|
rootPaths = [
|
||||||
privateInputs.clan-core-for-checks
|
privateInputs.clan-core-for-checks
|
||||||
self.nixosConfigurations."test-install-machine-${pkgs.hostPlatform.system}".config.system.build.toplevel
|
self.nixosConfigurations."test-install-machine-${pkgs.stdenv.hostPlatform.system}".config.system.build.toplevel
|
||||||
self.nixosConfigurations."test-install-machine-${pkgs.hostPlatform.system}".config.system.build.initialRamdisk
|
self.nixosConfigurations."test-install-machine-${pkgs.stdenv.hostPlatform.system}".config.system.build.initialRamdisk
|
||||||
self.nixosConfigurations."test-install-machine-${pkgs.hostPlatform.system}".config.system.build.diskoScript
|
self.nixosConfigurations."test-install-machine-${pkgs.stdenv.hostPlatform.system}".config.system.build.diskoScript
|
||||||
pkgs.stdenv.drvPath
|
pkgs.stdenv.drvPath
|
||||||
pkgs.bash.drvPath
|
pkgs.bash.drvPath
|
||||||
pkgs.buildPackages.xorg.lndir
|
pkgs.buildPackages.xorg.lndir
|
||||||
@@ -215,7 +215,7 @@
|
|||||||
# Prepare test flake and Nix store
|
# Prepare test flake and Nix store
|
||||||
flake_dir = prepare_test_flake(
|
flake_dir = prepare_test_flake(
|
||||||
temp_dir,
|
temp_dir,
|
||||||
"${self.checks.${pkgs.hostPlatform.system}.clan-core-for-checks}",
|
"${self.checks.${pkgs.stdenv.hostPlatform.system}.clan-core-for-checks}",
|
||||||
"${closureInfo}"
|
"${closureInfo}"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -296,7 +296,7 @@
|
|||||||
# Prepare test flake and Nix store
|
# Prepare test flake and Nix store
|
||||||
flake_dir = prepare_test_flake(
|
flake_dir = prepare_test_flake(
|
||||||
temp_dir,
|
temp_dir,
|
||||||
"${self.checks.${pkgs.hostPlatform.system}.clan-core-for-checks}",
|
"${self.checks.${pkgs.stdenv.hostPlatform.system}.clan-core-for-checks}",
|
||||||
"${closureInfo}"
|
"${closureInfo}"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
cli = self.packages.${pkgs.hostPlatform.system}.clan-cli-full;
|
cli = self.packages.${pkgs.stdenv.hostPlatform.system}.clan-cli-full;
|
||||||
|
|
||||||
ollama-model = pkgs.callPackage ./qwen3-4b-instruct.nix { };
|
ollama-model = pkgs.callPackage ./qwen3-4b-instruct.nix { };
|
||||||
in
|
in
|
||||||
@@ -53,7 +53,7 @@ in
|
|||||||
pytest
|
pytest
|
||||||
pytest-xdist
|
pytest-xdist
|
||||||
(cli.pythonRuntime.pkgs.toPythonModule cli)
|
(cli.pythonRuntime.pkgs.toPythonModule cli)
|
||||||
self.legacyPackages.${pkgs.hostPlatform.system}.nixosTestLib
|
self.legacyPackages.${pkgs.stdenv.hostPlatform.system}.nixosTestLib
|
||||||
]
|
]
|
||||||
))
|
))
|
||||||
];
|
];
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
cli = self.packages.${pkgs.hostPlatform.system}.clan-cli-full;
|
cli = self.packages.${pkgs.stdenv.hostPlatform.system}.clan-cli-full;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
name = "systemd-abstraction";
|
name = "systemd-abstraction";
|
||||||
|
|||||||
@@ -115,9 +115,9 @@
|
|||||||
let
|
let
|
||||||
closureInfo = pkgs.closureInfo {
|
closureInfo = pkgs.closureInfo {
|
||||||
rootPaths = [
|
rootPaths = [
|
||||||
self.packages.${pkgs.hostPlatform.system}.clan-cli
|
self.packages.${pkgs.stdenv.hostPlatform.system}.clan-cli
|
||||||
self.checks.${pkgs.hostPlatform.system}.clan-core-for-checks
|
self.checks.${pkgs.stdenv.hostPlatform.system}.clan-core-for-checks
|
||||||
self.clanInternals.machines.${pkgs.hostPlatform.system}.test-update-machine.config.system.build.toplevel
|
self.clanInternals.machines.${pkgs.stdenv.hostPlatform.system}.test-update-machine.config.system.build.toplevel
|
||||||
pkgs.stdenv.drvPath
|
pkgs.stdenv.drvPath
|
||||||
pkgs.bash.drvPath
|
pkgs.bash.drvPath
|
||||||
pkgs.buildPackages.xorg.lndir
|
pkgs.buildPackages.xorg.lndir
|
||||||
@@ -132,7 +132,7 @@
|
|||||||
imports = [ self.nixosModules.test-update-machine ];
|
imports = [ self.nixosModules.test-update-machine ];
|
||||||
};
|
};
|
||||||
extraPythonPackages = _p: [
|
extraPythonPackages = _p: [
|
||||||
self.legacyPackages.${pkgs.hostPlatform.system}.nixosTestLib
|
self.legacyPackages.${pkgs.stdenv.hostPlatform.system}.nixosTestLib
|
||||||
];
|
];
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
@@ -154,7 +154,7 @@
|
|||||||
# Prepare test flake and Nix store
|
# Prepare test flake and Nix store
|
||||||
flake_dir = prepare_test_flake(
|
flake_dir = prepare_test_flake(
|
||||||
temp_dir,
|
temp_dir,
|
||||||
"${self.checks.${pkgs.hostPlatform.system}.clan-core-for-checks}",
|
"${self.checks.${pkgs.stdenv.hostPlatform.system}.clan-core-for-checks}",
|
||||||
"${closureInfo}"
|
"${closureInfo}"
|
||||||
)
|
)
|
||||||
(flake_dir / ".clan-flake").write_text("") # Ensure .clan-flake exists
|
(flake_dir / ".clan-flake").write_text("") # Ensure .clan-flake exists
|
||||||
@@ -226,7 +226,7 @@
|
|||||||
"--to",
|
"--to",
|
||||||
"ssh://root@192.168.1.1",
|
"ssh://root@192.168.1.1",
|
||||||
"--no-check-sigs",
|
"--no-check-sigs",
|
||||||
f"${self.packages.${pkgs.hostPlatform.system}.clan-cli}",
|
f"${self.packages.${pkgs.stdenv.hostPlatform.system}.clan-cli}",
|
||||||
"--extra-experimental-features", "nix-command flakes",
|
"--extra-experimental-features", "nix-command flakes",
|
||||||
],
|
],
|
||||||
check=True,
|
check=True,
|
||||||
@@ -242,7 +242,7 @@
|
|||||||
"-o", "UserKnownHostsFile=/dev/null",
|
"-o", "UserKnownHostsFile=/dev/null",
|
||||||
"-o", "StrictHostKeyChecking=no",
|
"-o", "StrictHostKeyChecking=no",
|
||||||
f"root@192.168.1.1",
|
f"root@192.168.1.1",
|
||||||
"${self.packages.${pkgs.hostPlatform.system}.clan-cli}/bin/clan",
|
"${self.packages.${pkgs.stdenv.hostPlatform.system}.clan-cli}/bin/clan",
|
||||||
"machines",
|
"machines",
|
||||||
"update",
|
"update",
|
||||||
"--debug",
|
"--debug",
|
||||||
@@ -270,7 +270,7 @@
|
|||||||
|
|
||||||
# Run clan update command
|
# Run clan update command
|
||||||
subprocess.run([
|
subprocess.run([
|
||||||
"${self.packages.${pkgs.hostPlatform.system}.clan-cli-full}/bin/clan",
|
"${self.packages.${pkgs.stdenv.hostPlatform.system}.clan-cli-full}/bin/clan",
|
||||||
"machines",
|
"machines",
|
||||||
"update",
|
"update",
|
||||||
"--debug",
|
"--debug",
|
||||||
@@ -297,7 +297,7 @@
|
|||||||
|
|
||||||
# Run clan update command with --build-host
|
# Run clan update command with --build-host
|
||||||
subprocess.run([
|
subprocess.run([
|
||||||
"${self.packages.${pkgs.hostPlatform.system}.clan-cli-full}/bin/clan",
|
"${self.packages.${pkgs.stdenv.hostPlatform.system}.clan-cli-full}/bin/clan",
|
||||||
"machines",
|
"machines",
|
||||||
"update",
|
"update",
|
||||||
"--debug",
|
"--debug",
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
!!! Danger "Experimental"
|
||||||
|
This service is experimental and will change in the future.
|
||||||
|
|
||||||
This service sets up a certificate authority (CA) that can issue certificates to
|
This service sets up a certificate authority (CA) that can issue certificates to
|
||||||
other machines in your clan. For this the `ca` role is used.
|
other machines in your clan. For this the `ca` role is used.
|
||||||
It additionally provides a `default` role, that can be applied to all machines
|
It additionally provides a `default` role, that can be applied to all machines
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
!!! Danger "Experimental"
|
||||||
|
This service is experimental and will change in the future.
|
||||||
|
|
||||||
This module enables hosting clan-internal services easily, which can be resolved
|
This module enables hosting clan-internal services easily, which can be resolved
|
||||||
inside your VPN. This allows defining a custom top-level domain (e.g. `.clan`)
|
inside your VPN. This allows defining a custom top-level domain (e.g. `.clan`)
|
||||||
and exposing endpoints from a machine to others, which will be
|
and exposing endpoints from a machine to others, which will be
|
||||||
|
|||||||
@@ -1 +1,83 @@
|
|||||||
This a test README just to appease the eval warnings if we don't have one
|
!!! Danger "Experimental"
|
||||||
|
This service is for demonstration purpose only and may change in the future.
|
||||||
|
|
||||||
|
The Hello-World Clan Service is a minimal example showing how to build and register your own service.
|
||||||
|
|
||||||
|
It serves as a reference implementation and is used in clan-core CI tests to ensure compatibility.
|
||||||
|
|
||||||
|
## What it demonstrates
|
||||||
|
|
||||||
|
- How to define a basic Clan-compatible service.
|
||||||
|
- How to structure your service for discovery and configuration.
|
||||||
|
- How Clan services interact with nixos.
|
||||||
|
|
||||||
|
## Testing
|
||||||
|
|
||||||
|
This service demonstrates two levels of testing to ensure quality and stability across releases:
|
||||||
|
|
||||||
|
1. **Unit & Integration Testing** — via [`nix-unit`](https://github.com/nix-community/nix-unit)
|
||||||
|
2. **End-to-End Testing** — via **NixOS VM tests**, which we extended to support **container virtualization** for better performance.
|
||||||
|
|
||||||
|
We highly advocate following the [Practical Testing Pyramid](https://martinfowler.com/articles/practical-test-pyramid.html):
|
||||||
|
|
||||||
|
* Write **unit tests** for core logic and invariants.
|
||||||
|
* Add **one or two end-to-end (E2E)** tests to confirm your service starts and behaves correctly in a real NixOS environment.
|
||||||
|
|
||||||
|
NixOS is **untyped** and frequently changes; tests are the safest way to ensure long-term stability of services.
|
||||||
|
|
||||||
|
```
|
||||||
|
/ \
|
||||||
|
/ \
|
||||||
|
/ E2E \
|
||||||
|
/-------\
|
||||||
|
/ \
|
||||||
|
/Integration\
|
||||||
|
/-------------\
|
||||||
|
/ \
|
||||||
|
/ Unit Tests \
|
||||||
|
-------------------
|
||||||
|
```
|
||||||
|
|
||||||
|
### nix-unit
|
||||||
|
|
||||||
|
We highly advocate the usage of
|
||||||
|
|
||||||
|
[nix-unit](https://github.com/nix-community/nix-unit)
|
||||||
|
|
||||||
|
Example in: tests/eval-tests.nix
|
||||||
|
|
||||||
|
If you use flake-parts you can use the [native integration](https://flake.parts/options/nix-unit.html)
|
||||||
|
|
||||||
|
If nix-unit succeeds you'r nixos evaluation should be mostly correct.
|
||||||
|
|
||||||
|
!!! Tip
|
||||||
|
- Ensure most used 'settings' and variants are tested.
|
||||||
|
- Think about some important edge-cases your system should handle.
|
||||||
|
|
||||||
|
### NixOS VM / Container Test
|
||||||
|
|
||||||
|
!!! Warning "Early Vars & clanTest"
|
||||||
|
The testing system around vars is experimental
|
||||||
|
|
||||||
|
`clanTest` is still experimental and enables container virtualization by default.
|
||||||
|
This is still early and might have some limitations.
|
||||||
|
|
||||||
|
Some minimal boilerplate is needed to use `clanTest`
|
||||||
|
|
||||||
|
```nix
|
||||||
|
nixosLib = import (inputs.nixpkgs + "/nixos/lib") { }
|
||||||
|
nixosLib.runTest (
|
||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
self.modules.nixosTest.clanTest
|
||||||
|
# Example in tests/vm/default.nix
|
||||||
|
testModule
|
||||||
|
];
|
||||||
|
hostPkgs = pkgs;
|
||||||
|
|
||||||
|
# Uncomment if you don't want or cannot use containers
|
||||||
|
# test.useContainers = false;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
```
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
{
|
{
|
||||||
_class = "clan.service";
|
_class = "clan.service";
|
||||||
manifest.name = "clan-core/hello-word";
|
manifest.name = "clan-core/hello-word";
|
||||||
manifest.description = "This is a test";
|
manifest.description = "Minimal example clan service that greets the world";
|
||||||
manifest.readme = builtins.readFile ./README.md;
|
manifest.readme = builtins.readFile ./README.md;
|
||||||
|
|
||||||
# This service provides two roles: "morning" and "evening". Roles can be
|
# This service provides two roles: "morning" and "evening". Roles can be
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ in
|
|||||||
# The hello-world service being tested
|
# The hello-world service being tested
|
||||||
../../clanServices/hello-world
|
../../clanServices/hello-world
|
||||||
# Required modules
|
# Required modules
|
||||||
../../nixosModules/clanCore
|
../../nixosModules
|
||||||
];
|
];
|
||||||
testName = "hello-world";
|
testName = "hello-world";
|
||||||
tests = ./tests/eval-tests.nix;
|
tests = ./tests/eval-tests.nix;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
testFlake = clanLib.clan {
|
testClan = clanLib.clan {
|
||||||
self = { };
|
self = { };
|
||||||
# Point to the folder of the module
|
# Point to the folder of the module
|
||||||
# TODO: make this optional
|
# TODO: make this optional
|
||||||
@@ -33,10 +33,20 @@ let
|
|||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
test_simple = {
|
/**
|
||||||
config = testFlake.config;
|
We highly advocate the usage of:
|
||||||
|
https://github.com/nix-community/nix-unit
|
||||||
|
|
||||||
expr = { };
|
If you use flake-parts you can use the native integration: https://flake.parts/options/nix-unit.html
|
||||||
expected = { };
|
*/
|
||||||
|
test_simple = {
|
||||||
|
# Allows inspection via the nix-repl
|
||||||
|
# Ignored by nix-unit; it only looks at 'expr' and 'expected'
|
||||||
|
inherit testClan;
|
||||||
|
|
||||||
|
# Assert that jon has the
|
||||||
|
# configured greeting in 'environment.etc.hello.text'
|
||||||
|
expr = testClan.config.nixosConfigurations.jon.config.environment.etc."hello".text;
|
||||||
|
expected = "Good evening World!";
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
🚧🚧🚧 Experimental 🚧🚧🚧
|
!!! Danger "Experimental"
|
||||||
|
This service is experimental and will change in the future.
|
||||||
Use at your own risk.
|
|
||||||
|
|
||||||
We are still refining its interfaces, instability and breakages are expected.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,6 @@
|
|||||||
|
!!! Danger "Experimental"
|
||||||
|
This service is experimental and will change in the future.
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
🚧🚧🚧 Experimental 🚧🚧🚧
|
!!! Danger "Experimental"
|
||||||
|
This service is experimental and will change in the future.
|
||||||
Use at your own risk.
|
|
||||||
|
|
||||||
We are still refining its interfaces, instability and breakages are expected.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
🚧🚧🚧 Experimental 🚧🚧🚧
|
!!! Danger "Experimental"
|
||||||
|
This service is experimental and will change in the future.
|
||||||
Use at your own risk.
|
|
||||||
|
|
||||||
We are still refining its interfaces, instability and breakages are expected.
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
This module sets up [yggdrasil](https://yggdrasil-network.github.io/) across your clan.
|
This module sets up [yggdrasil](https://yggdrasil-network.github.io/) across your clan.
|
||||||
|
|
||||||
Yggdrasil is designed to be a future-proof and decentralised alternative to the
|
Yggdrasil is designed to be a future-proof and decentralised alternative to the
|
||||||
structured routing protocols commonly used today on the internet. Inside your
|
structured routing protocols commonly used today on the internet. Inside your
|
||||||
|
|||||||
6
devFlake/flake.lock
generated
6
devFlake/flake.lock
generated
@@ -105,11 +105,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs-dev": {
|
"nixpkgs-dev": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1761748483,
|
"lastModified": 1762080734,
|
||||||
"narHash": "sha256-v7fttCB5lJ22Ok7+N7ZbLhDeM89QIz9YWtQP4XN7xgA=",
|
"narHash": "sha256-fFunzA7ITlPHRr7dECaFGTBucNiWYEVDNPBw/9gFmII=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "061c55856b29b8b9360e14231a0986c7f85f1130",
|
"rev": "bc7f6fa86de9b208edf4ea7bbf40bcd8cc7d70a5",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ Make sure you have the following:
|
|||||||
**Note:** This creates a new directory in your current location
|
**Note:** This creates a new directory in your current location
|
||||||
|
|
||||||
```shellSession
|
```shellSession
|
||||||
nix run https://git.clan.lol/clan/clan-core/archive/main.tar.gz#clan-cli --refresh -- flakes create
|
nix run "https://git.clan.lol/clan/clan-core/archive/main.tar.gz#clan-cli" --refresh -- flakes create
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Enter a **name** in the prompt:
|
3. Enter a **name** in the prompt:
|
||||||
|
|||||||
24
flake.lock
generated
24
flake.lock
generated
@@ -31,11 +31,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1760701190,
|
"lastModified": 1761899396,
|
||||||
"narHash": "sha256-y7UhnWlER8r776JsySqsbTUh2Txf7K30smfHlqdaIQw=",
|
"narHash": "sha256-XOpKBp6HLzzMCbzW50TEuXN35zN5WGQREC7n34DcNMM=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "disko",
|
"repo": "disko",
|
||||||
"rev": "3a9450b26e69dcb6f8de6e2b07b3fc1c288d85f5",
|
"rev": "6f4cf5abbe318e4cd1e879506f6eeafd83f7b998",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -51,11 +51,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1760948891,
|
"lastModified": 1762040540,
|
||||||
"narHash": "sha256-TmWcdiUUaWk8J4lpjzu4gCGxWY6/Ok7mOK4fIFfBuU4=",
|
"narHash": "sha256-z5PlZ47j50VNF3R+IMS9LmzI5fYRGY/Z5O5tol1c9I4=",
|
||||||
"owner": "hercules-ci",
|
"owner": "hercules-ci",
|
||||||
"repo": "flake-parts",
|
"repo": "flake-parts",
|
||||||
"rev": "864599284fc7c0ba6357ed89ed5e2cd5040f0c04",
|
"rev": "0010412d62a25d959151790968765a70c436598b",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -71,11 +71,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1761339987,
|
"lastModified": 1762039661,
|
||||||
"narHash": "sha256-IUaawVwItZKi64IA6kF6wQCLCzpXbk2R46dHn8sHkig=",
|
"narHash": "sha256-oM5BwAGE78IBLZn+AqxwH/saqwq3e926rNq5HmOulkc=",
|
||||||
"owner": "nix-darwin",
|
"owner": "nix-darwin",
|
||||||
"repo": "nix-darwin",
|
"repo": "nix-darwin",
|
||||||
"rev": "7cd9aac79ee2924a85c211d21fafd394b06a38de",
|
"rev": "c3c8c9f2a5ed43175ac4dc030308756620e6e4e4",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -115,10 +115,10 @@
|
|||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 315532800,
|
"lastModified": 315532800,
|
||||||
"narHash": "sha256-yDxtm0PESdgNetiJN5+MFxgubBcLDTiuSjjrJiyvsvM=",
|
"narHash": "sha256-LDT9wuUZtjPfmviCcVWif5+7j4kBI2mWaZwjNNeg4eg=",
|
||||||
"rev": "d7f52a7a640bc54c7bb414cca603835bf8dd4b10",
|
"rev": "a7fc11be66bdfb5cdde611ee5ce381c183da8386",
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://releases.nixos.org/nixpkgs/nixpkgs-25.11pre871443.d7f52a7a640b/nixexprs.tar.xz"
|
"url": "https://releases.nixos.org/nixpkgs/nixpkgs-25.11pre887438.a7fc11be66bd/nixexprs.tar.xz"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
|
|||||||
@@ -40,9 +40,6 @@ lib.fix (
|
|||||||
# TODO: Flatten our lib functions like this:
|
# TODO: Flatten our lib functions like this:
|
||||||
resolveModule = clanLib.callLib ./resolve-module { };
|
resolveModule = clanLib.callLib ./resolve-module { };
|
||||||
|
|
||||||
# Functions to help define exports
|
|
||||||
exports = clanLib.callLib ./exports.nix { };
|
|
||||||
|
|
||||||
fs = {
|
fs = {
|
||||||
inherit (builtins) pathExists readDir;
|
inherit (builtins) pathExists readDir;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,88 +0,0 @@
|
|||||||
{ lib }:
|
|
||||||
let
|
|
||||||
/**
|
|
||||||
Creates a scope string for global exports
|
|
||||||
|
|
||||||
At least one of serviceName or machineName must be set.
|
|
||||||
|
|
||||||
The scope string has the format:
|
|
||||||
|
|
||||||
"/SERVICE/INSTANCE/ROLE/MACHINE"
|
|
||||||
|
|
||||||
If the parameter is not set, the corresponding part is left empty.
|
|
||||||
Semantically this means "all".
|
|
||||||
|
|
||||||
Examples:
|
|
||||||
mkScope { serviceName = "A"; }
|
|
||||||
-> "/A///"
|
|
||||||
|
|
||||||
mkScope { machineName = "jon"; }
|
|
||||||
-> "///jon"
|
|
||||||
|
|
||||||
mkScope { serviceName = "A"; instanceName = "i1"; roleName = "peer"; machineName = "jon"; }
|
|
||||||
-> "/A/i1/peer/jon"
|
|
||||||
*/
|
|
||||||
mkScope =
|
|
||||||
{
|
|
||||||
serviceName ? "",
|
|
||||||
instanceName ? "",
|
|
||||||
roleName ? "",
|
|
||||||
machineName ? "",
|
|
||||||
}:
|
|
||||||
let
|
|
||||||
parts = [
|
|
||||||
serviceName
|
|
||||||
instanceName
|
|
||||||
roleName
|
|
||||||
machineName
|
|
||||||
];
|
|
||||||
checkedParts = lib.map (
|
|
||||||
part:
|
|
||||||
lib.throwIf (builtins.match ".?/.?" part != null) ''
|
|
||||||
clanLib.exports.mkScope: ${part} cannot contain the "/" character
|
|
||||||
''
|
|
||||||
) parts;
|
|
||||||
in
|
|
||||||
lib.throwIf ((serviceName == "" && machineName == "")) ''
|
|
||||||
clanLib.exports.mkScope requires at least 'serviceName' or 'machineName' to be set
|
|
||||||
|
|
||||||
In case your use case requires neither
|
|
||||||
'' (lib.join "/" checkedParts);
|
|
||||||
|
|
||||||
/**
|
|
||||||
Parses a scope string into its components
|
|
||||||
|
|
||||||
Returns an attribute set with the keys:
|
|
||||||
- serviceName
|
|
||||||
- instanceName
|
|
||||||
- roleName
|
|
||||||
- machineName
|
|
||||||
|
|
||||||
Example:
|
|
||||||
parseScope "A/i1/peer/jon"
|
|
||||||
->
|
|
||||||
{
|
|
||||||
serviceName = "A";
|
|
||||||
instanceName = "i1";
|
|
||||||
roleName = "peer";
|
|
||||||
machineName = "jon";
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
parseScope =
|
|
||||||
scopeStr:
|
|
||||||
let
|
|
||||||
parts = lib.splitString "/" scopeStr;
|
|
||||||
checkedParts = lib.throwIf (lib.length parts != 4) ''
|
|
||||||
clanLib.exports.parseScope: invalid scope string format, expected 4 parts separated by 3 "/"
|
|
||||||
'' (parts);
|
|
||||||
in
|
|
||||||
{
|
|
||||||
serviceName = lib.elemAt 0 checkedParts;
|
|
||||||
instanceName = lib.elemAt 1 checkedParts;
|
|
||||||
roleName = lib.elemAt 2 checkedParts;
|
|
||||||
machineName = lib.elemAt 3 checkedParts;
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
inherit mkScope parseScope;
|
|
||||||
}
|
|
||||||
@@ -103,11 +103,6 @@ rec {
|
|||||||
inherit lib;
|
inherit lib;
|
||||||
clan-core = self;
|
clan-core = self;
|
||||||
};
|
};
|
||||||
# Run: nix-unit --extra-experimental-features flakes --flake .#legacyPackages.x86_64-linux.evalTests-build-clan
|
|
||||||
legacyPackages.eval-exports = import ./new_exports.nix {
|
|
||||||
inherit lib;
|
|
||||||
clan-core = self;
|
|
||||||
};
|
|
||||||
checks = {
|
checks = {
|
||||||
eval-lib-build-clan = pkgs.runCommand "tests" { nativeBuildInputs = [ pkgs.nix-unit ]; } ''
|
eval-lib-build-clan = pkgs.runCommand "tests" { nativeBuildInputs = [ pkgs.nix-unit ]; } ''
|
||||||
export HOME="$(realpath .)"
|
export HOME="$(realpath .)"
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
{
|
{
|
||||||
# TODO: consume directly from clan.config
|
# TODO: consume directly from clan.config
|
||||||
directory,
|
directory,
|
||||||
exports,
|
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
lib,
|
lib,
|
||||||
@@ -18,10 +17,10 @@ in
|
|||||||
{
|
{
|
||||||
# TODO: merge these options into clan options
|
# TODO: merge these options into clan options
|
||||||
options = {
|
options = {
|
||||||
# exportsModule = mkOption {
|
exportsModule = mkOption {
|
||||||
# type = types.deferredModule;
|
type = types.deferredModule;
|
||||||
# readOnly = true;
|
readOnly = true;
|
||||||
# };
|
};
|
||||||
mappedServices = mkOption {
|
mappedServices = mkOption {
|
||||||
visible = false;
|
visible = false;
|
||||||
type = attrsWith {
|
type = attrsWith {
|
||||||
@@ -29,11 +28,9 @@ in
|
|||||||
elemType = submoduleWith {
|
elemType = submoduleWith {
|
||||||
class = "clan.service";
|
class = "clan.service";
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
|
directory = directory;
|
||||||
clanLib = specialArgs.clanLib;
|
clanLib = specialArgs.clanLib;
|
||||||
inherit
|
exports = config.exports;
|
||||||
exports
|
|
||||||
directory
|
|
||||||
;
|
|
||||||
};
|
};
|
||||||
modules = [
|
modules = [
|
||||||
(
|
(
|
||||||
@@ -54,13 +51,34 @@ in
|
|||||||
default = { };
|
default = { };
|
||||||
};
|
};
|
||||||
exports = mkOption {
|
exports = mkOption {
|
||||||
type = types.lazyAttrsOf types.deferredModule;
|
type = submoduleWith {
|
||||||
|
modules = [
|
||||||
# collect exports from all services
|
{
|
||||||
# zipAttrs is needed until we use the record type.
|
options = {
|
||||||
default = lib.zipAttrsWith (_name: values: { imports = values; }) (
|
instances = lib.mkOption {
|
||||||
lib.mapAttrsToList (_name: service: service.exports) config.mappedServices
|
default = { };
|
||||||
);
|
# instances.<instanceName>...
|
||||||
|
type = types.attrsOf (submoduleWith {
|
||||||
|
modules = [
|
||||||
|
config.exportsModule
|
||||||
|
];
|
||||||
|
});
|
||||||
|
};
|
||||||
|
# instances.<machineName>...
|
||||||
|
machines = lib.mkOption {
|
||||||
|
default = { };
|
||||||
|
type = types.attrsOf (submoduleWith {
|
||||||
|
modules = [
|
||||||
|
config.exportsModule
|
||||||
|
];
|
||||||
|
});
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
]
|
||||||
|
++ lib.mapAttrsToList (_: service: service.exports) config.mappedServices;
|
||||||
|
};
|
||||||
|
default = { };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -504,7 +504,7 @@ in
|
|||||||
staticModules = [
|
staticModules = [
|
||||||
({
|
({
|
||||||
options.exports = mkOption {
|
options.exports = mkOption {
|
||||||
type = types.lazyAttrsOf types.deferredModule;
|
type = types.deferredModule;
|
||||||
default = { };
|
default = { };
|
||||||
description = ''
|
description = ''
|
||||||
!!! Danger "Experimental Feature"
|
!!! Danger "Experimental Feature"
|
||||||
@@ -634,16 +634,8 @@ in
|
|||||||
type = types.deferredModuleWith {
|
type = types.deferredModuleWith {
|
||||||
staticModules = [
|
staticModules = [
|
||||||
({
|
({
|
||||||
# exports."///".generator.name = { _file ... import = []; _type = }
|
|
||||||
# exports."///".networking = { _file ... import = []; }
|
|
||||||
|
|
||||||
# generators."///".name = { name, ...}: { _file ... import = [];}
|
|
||||||
# networks."///" = { _file ... import = []; }
|
|
||||||
|
|
||||||
# { _file ... import = []; }
|
|
||||||
# { _file ... import = []; }
|
|
||||||
options.exports = mkOption {
|
options.exports = mkOption {
|
||||||
type = types.lazyAttrsOf types.deferredModule;
|
type = types.deferredModule;
|
||||||
default = { };
|
default = { };
|
||||||
description = ''
|
description = ''
|
||||||
!!! Danger "Experimental Feature"
|
!!! Danger "Experimental Feature"
|
||||||
@@ -775,38 +767,79 @@ in
|
|||||||
```
|
```
|
||||||
'';
|
'';
|
||||||
default = { };
|
default = { };
|
||||||
type = types.lazyAttrsOf (
|
type = types.submoduleWith {
|
||||||
types.deferredModuleWith {
|
# Static modules
|
||||||
# staticModules = [];
|
modules = [
|
||||||
# lib.concatLists (
|
{
|
||||||
# lib.concatLists (
|
options.instances = mkOption {
|
||||||
# lib.mapAttrsToList (
|
type = types.attrsOf types.deferredModule;
|
||||||
# _roleName: role:
|
description = ''
|
||||||
# lib.mapAttrsToList (
|
export modules defined in 'perInstance'
|
||||||
# _instanceName: instance: lib.mapAttrsToList (_machineName: v: v.exports) instance.allMachines
|
mapped to their instance name
|
||||||
# ) role.allInstances
|
|
||||||
# ) config.result.allRoles
|
Example
|
||||||
# )
|
|
||||||
# )
|
with instances:
|
||||||
# ++
|
|
||||||
}
|
```nix
|
||||||
);
|
instances.A = { ... };
|
||||||
# # Lazy default via imports
|
instances.B= { ... };
|
||||||
# # should probably be moved to deferredModuleWith { staticModules = [ ]; }
|
|
||||||
# imports =
|
roles.peer.perInstance = { instanceName, machine, ... }:
|
||||||
# if config._docs_rendering then
|
{
|
||||||
# [ ]
|
exports.foo = 1;
|
||||||
# else
|
}
|
||||||
# lib.mapAttrsToList (_roleName: role: {
|
|
||||||
# instances = lib.mapAttrs (_instanceName: instance: {
|
This yields all other services can access these exports
|
||||||
# imports = lib.mapAttrsToList (_machineName: v: v.exports) instance.allMachines;
|
=>
|
||||||
# }) role.allInstances;
|
exports.instances.A.foo = 1;
|
||||||
# }) config.result.allRoles
|
exports.instances.B.foo = 1;
|
||||||
# ++ lib.mapAttrsToList (machineName: machine: {
|
```
|
||||||
# machines.${machineName} = machine.exports;
|
'';
|
||||||
# }) config.result.allMachines;
|
};
|
||||||
# }
|
options.machines = mkOption {
|
||||||
# ];
|
type = types.attrsOf types.deferredModule;
|
||||||
|
description = ''
|
||||||
|
export modules defined in 'perMachine'
|
||||||
|
mapped to their machine name
|
||||||
|
|
||||||
|
Example
|
||||||
|
|
||||||
|
with machines:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
instances.A = { roles.peer.machines.jon = ... };
|
||||||
|
instances.B = { roles.peer.machines.jon = ... };
|
||||||
|
|
||||||
|
perMachine = { machine, ... }:
|
||||||
|
{
|
||||||
|
exports.foo = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
This yields all other services can access these exports
|
||||||
|
=>
|
||||||
|
exports.machines.jon.foo = 1;
|
||||||
|
exports.machines.sara.foo = 1;
|
||||||
|
```
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
# Lazy default via imports
|
||||||
|
# should probably be moved to deferredModuleWith { staticModules = [ ]; }
|
||||||
|
imports =
|
||||||
|
if config._docs_rendering then
|
||||||
|
[ ]
|
||||||
|
else
|
||||||
|
lib.mapAttrsToList (_roleName: role: {
|
||||||
|
instances = lib.mapAttrs (_instanceName: instance: {
|
||||||
|
imports = lib.mapAttrsToList (_machineName: v: v.exports) instance.allMachines;
|
||||||
|
}) role.allInstances;
|
||||||
|
}) config.result.allRoles
|
||||||
|
++ lib.mapAttrsToList (machineName: machine: {
|
||||||
|
machines.${machineName} = machine.exports;
|
||||||
|
}) config.result.allMachines;
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
# ---
|
# ---
|
||||||
# Place the result in _module.result to mark them as "internal" and discourage usage/overrides
|
# Place the result in _module.result to mark them as "internal" and discourage usage/overrides
|
||||||
@@ -991,39 +1024,5 @@ in
|
|||||||
}
|
}
|
||||||
) config.result.allMachines;
|
) config.result.allMachines;
|
||||||
};
|
};
|
||||||
|
|
||||||
debug = mkOption {
|
|
||||||
default = lib.zipAttrsWith (_name: values: { imports = values; }) (
|
|
||||||
lib.mapAttrsToList (_machineName: machine: machine.exports) config.result.allMachines
|
|
||||||
);
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
imports = [
|
|
||||||
{
|
|
||||||
# collect exports from all machines
|
|
||||||
# zipAttrs is needed until we use the record type.
|
|
||||||
exports = lib.zipAttrsWith (_name: values: { imports = values; }) (
|
|
||||||
lib.mapAttrsToList (_machineName: machine: machine.exports) config.result.allMachines
|
|
||||||
);
|
|
||||||
|
|
||||||
}
|
|
||||||
{
|
|
||||||
# collect exports from all instances, roles and machines
|
|
||||||
# zipAttrs is needed until we use the record type.
|
|
||||||
exports = lib.zipAttrsWith (_name: values: { imports = values; }) (
|
|
||||||
lib.concatLists (
|
|
||||||
lib.concatLists (
|
|
||||||
lib.mapAttrsToList (
|
|
||||||
_roleName: role:
|
|
||||||
lib.mapAttrsToList (
|
|
||||||
_instanceName: instance: lib.mapAttrsToList (_machineName: v: v.exports) instance.allMachines
|
|
||||||
) role.allInstances
|
|
||||||
) config.result.allRoles
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,221 +0,0 @@
|
|||||||
{
|
|
||||||
clan-core,
|
|
||||||
lib,
|
|
||||||
}:
|
|
||||||
# TODO: TEST: define a clan without machines
|
|
||||||
{
|
|
||||||
test_simple =
|
|
||||||
let
|
|
||||||
eval = clan-core.clanLib.clan {
|
|
||||||
exports."///".foo = lib.mkForce eval.config.exports."///".bar;
|
|
||||||
|
|
||||||
directory = ./.;
|
|
||||||
self = {
|
|
||||||
clan = eval.config;
|
|
||||||
inputs = { };
|
|
||||||
};
|
|
||||||
|
|
||||||
machines.jon = { };
|
|
||||||
machines.sara = { };
|
|
||||||
|
|
||||||
exportsModule =
|
|
||||||
{ lib, ... }:
|
|
||||||
{
|
|
||||||
options.foo = lib.mkOption {
|
|
||||||
type = lib.types.number;
|
|
||||||
default = 0;
|
|
||||||
};
|
|
||||||
options.bar = lib.mkOption {
|
|
||||||
type = lib.types.number;
|
|
||||||
default = 0;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
####### Service module "A"
|
|
||||||
modules.service-A =
|
|
||||||
{ ... }:
|
|
||||||
{
|
|
||||||
# config.exports
|
|
||||||
manifest.name = "A";
|
|
||||||
|
|
||||||
roles.default = {
|
|
||||||
# TODO: Remove automapping
|
|
||||||
# Currently exports are automapped
|
|
||||||
# scopes "/service=A/instance=hello/role=default/machine=jon"
|
|
||||||
# perInstance.exports.foo = 7;
|
|
||||||
|
|
||||||
# New style:
|
|
||||||
# Explizit scope
|
|
||||||
# perInstance.exports."service=A/instance=hello/role=default/machine=jon".foo = 7;
|
|
||||||
perInstance =
|
|
||||||
{ instanceName, machine, exports, ... }:
|
|
||||||
{
|
|
||||||
exports."A/${instanceName}/default/${machine.name}" = {
|
|
||||||
foo = 7;
|
|
||||||
# define export depending on B
|
|
||||||
bar = exports."B/B/default/${machine.name}".foo + 35;
|
|
||||||
};
|
|
||||||
# exports."A/${instanceName}/default/${machine.name}".
|
|
||||||
|
|
||||||
# default behavior
|
|
||||||
# exports = scope.mkExports { foo = 7; };
|
|
||||||
|
|
||||||
# We want to export things for different scopes from this scope;
|
|
||||||
# If this scope is used.
|
|
||||||
#
|
|
||||||
# Explicit scope; different from the function scope above
|
|
||||||
# exports = clanLib.scopedExport {
|
|
||||||
# # Different role export
|
|
||||||
# role = "peer";
|
|
||||||
# serviceName = config.manifest.name;
|
|
||||||
# inherit instanceName machineName;
|
|
||||||
# } { foo = 7; };
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
perMachine =
|
|
||||||
{ ... }:
|
|
||||||
{
|
|
||||||
#
|
|
||||||
# exports = scope.mkExports { foo = 7; };
|
|
||||||
# exports."A///${machine.name}".foo = 42;
|
|
||||||
# exports."B///".foo = 42;
|
|
||||||
};
|
|
||||||
|
|
||||||
# scope "/service=A/instance=??/role=??/machine=jon"
|
|
||||||
# perMachine.exports.foo = 42;
|
|
||||||
|
|
||||||
# scope "/service=A/instance=??/role=??/machine=??"
|
|
||||||
# exports."///".foo = 10;
|
|
||||||
};
|
|
||||||
####### Service module "A"
|
|
||||||
modules.service-B =
|
|
||||||
{ exports, ... }:
|
|
||||||
{
|
|
||||||
# config.exports
|
|
||||||
manifest.name = "B";
|
|
||||||
|
|
||||||
roles.default = {
|
|
||||||
# TODO: Remove automapping
|
|
||||||
# Currently exports are automapped
|
|
||||||
# scopes "/service=A/instance=hello/role=default/machine=jon"
|
|
||||||
# perInstance.exports.foo = 7;
|
|
||||||
|
|
||||||
# New style:
|
|
||||||
# Explizit scope
|
|
||||||
# perInstance.exports."service=A/instance=hello/role=default/machine=jon".foo = 7;
|
|
||||||
perInstance =
|
|
||||||
{ instanceName, machine, ... }:
|
|
||||||
{
|
|
||||||
# TODO: Test non-existing scope
|
|
||||||
# define export depending on A
|
|
||||||
exports."B/${instanceName}/default/${machine.name}".foo = exports."///".foo + exports."A/A/default/${machine.name}".foo;
|
|
||||||
# exports."B/B/default/jon".foo = exports."A/A/default/jon".foo;
|
|
||||||
|
|
||||||
# default behavior
|
|
||||||
# exports = scope.mkExports { foo = 7; };
|
|
||||||
|
|
||||||
# We want to export things for different scopes from this scope;
|
|
||||||
# If this scope is used.
|
|
||||||
#
|
|
||||||
# Explicit scope; different from the function scope above
|
|
||||||
# exports = clanLib.scopedExport {
|
|
||||||
# # Different role export
|
|
||||||
# role = "peer";
|
|
||||||
# serviceName = config.manifest.name;
|
|
||||||
# inherit instanceName machineName;
|
|
||||||
# } { foo = 7; };
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
perMachine =
|
|
||||||
{ ... }:
|
|
||||||
{
|
|
||||||
# exports = scope.mkExports { foo = 7; };
|
|
||||||
# exports."A///${machine.name}".foo = 42;
|
|
||||||
# exports."B///".foo = 42;
|
|
||||||
};
|
|
||||||
|
|
||||||
# scope "/service=A/instance=??/role=??/machine=jon"
|
|
||||||
# perMachine.exports.foo = 42;
|
|
||||||
|
|
||||||
# scope "/service=A/instance=??/role=??/machine=??"
|
|
||||||
exports."///".foo = 10;
|
|
||||||
};
|
|
||||||
#######
|
|
||||||
|
|
||||||
inventory = {
|
|
||||||
instances.A = {
|
|
||||||
module.name = "service-A";
|
|
||||||
module.input = "self";
|
|
||||||
roles.default.tags = [ "all" ];
|
|
||||||
};
|
|
||||||
instances.B = {
|
|
||||||
module.name = "service-B";
|
|
||||||
module.input = "self";
|
|
||||||
roles.default.tags = [ "all" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
# <- inventory
|
|
||||||
#
|
|
||||||
# -> exports
|
|
||||||
/**
|
|
||||||
Current state
|
|
||||||
{
|
|
||||||
instances = {
|
|
||||||
hello = { networking = null; };
|
|
||||||
};
|
|
||||||
machines = {
|
|
||||||
jon = { networking = null; };
|
|
||||||
};
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
Target state: (Flat attribute set)
|
|
||||||
|
|
||||||
tdlr;
|
|
||||||
|
|
||||||
# roles / instance level definitions may not exist on their own
|
|
||||||
# role and instance names are completely arbitrary.
|
|
||||||
# For example what does it mean: this is a export for all "peer" roles of all service-instances? That would be magic on the roleName.
|
|
||||||
# Or exports for all instances with name "ifoo" ? That would be magic on the instanceName.
|
|
||||||
|
|
||||||
# Practical combinations
|
|
||||||
# always include either the service name or the machine name
|
|
||||||
|
|
||||||
exports = {
|
|
||||||
# Clan level (1)
|
|
||||||
"///" networks generators
|
|
||||||
|
|
||||||
# Service anchored (8) : min 1 instance is needed ; machines may not exist
|
|
||||||
"A///" <- service specific
|
|
||||||
"A/instance//" <- instance of a service
|
|
||||||
"A//peer/" <- role of a service
|
|
||||||
"A/instance/peer/" <- instance+role of a service
|
|
||||||
"A///machine" <- machine of a service
|
|
||||||
"A/instance//machine" <- machine + instance of a service
|
|
||||||
"A//role/machine" <- machine + role of a service
|
|
||||||
"A/instance/role/machine" <- machine + role + instance of a service
|
|
||||||
|
|
||||||
# Machine anchored (1 or 2)
|
|
||||||
"///jon" <- this machine
|
|
||||||
"A///jon" <- role on a machine (dupped with service anchored)
|
|
||||||
|
|
||||||
# Unpractical; probably not needed (5)
|
|
||||||
"//peer/jon" <- role on a machine
|
|
||||||
"/instance//jon" <- role on a machine
|
|
||||||
"/instance//" <- instance: All "foo" instances everywhere?
|
|
||||||
"//role/" <- role: All "peer" roles everywhere?
|
|
||||||
"/instance/role/" <- instance role: Applies to all services, whose instance name has "ifoo" and role is "peer" (double magic)
|
|
||||||
|
|
||||||
# TODO: lazyattrs poc
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
inherit eval;
|
|
||||||
expr = eval;
|
|
||||||
expected = 42;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,21 +1,4 @@
|
|||||||
{ lib, ... }:
|
{ lib, ... }:
|
||||||
let
|
|
||||||
inherit (lib)
|
|
||||||
mapAttrs
|
|
||||||
attrNames
|
|
||||||
showOption
|
|
||||||
setDefaultModuleLocation
|
|
||||||
mkOptionType
|
|
||||||
isAttrs
|
|
||||||
filterAttrs
|
|
||||||
intersectAttrs
|
|
||||||
mapAttrsToList
|
|
||||||
mkOptionDefault
|
|
||||||
zipAttrsWith
|
|
||||||
seq
|
|
||||||
fix
|
|
||||||
;
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
A custom type for deferred modules that guarantee to be JSON serializable.
|
A custom type for deferred modules that guarantee to be JSON serializable.
|
||||||
@@ -29,7 +12,7 @@ in
|
|||||||
- Enforces that the definition is JSON serializable
|
- Enforces that the definition is JSON serializable
|
||||||
- Disallows nested imports
|
- Disallows nested imports
|
||||||
*/
|
*/
|
||||||
uniqueDeferredSerializableModule = fix (
|
uniqueDeferredSerializableModule = lib.fix (
|
||||||
self:
|
self:
|
||||||
let
|
let
|
||||||
checkDef =
|
checkDef =
|
||||||
@@ -40,18 +23,19 @@ in
|
|||||||
def;
|
def;
|
||||||
in
|
in
|
||||||
# Essentially the "raw" type, but with a custom name and check
|
# Essentially the "raw" type, but with a custom name and check
|
||||||
mkOptionType {
|
lib.mkOptionType {
|
||||||
name = "deferredModule";
|
name = "deferredModule";
|
||||||
description = "deferred custom module. Must be JSON serializable.";
|
description = "deferred custom module. Must be JSON serializable.";
|
||||||
descriptionClass = "noun";
|
descriptionClass = "noun";
|
||||||
# Unfortunately, tryEval doesn't catch JSON errors
|
# Unfortunately, tryEval doesn't catch JSON errors
|
||||||
check = value: seq (builtins.toJSON value) (isAttrs value);
|
check = value: lib.seq (builtins.toJSON value) (lib.isAttrs value);
|
||||||
merge = lib.options.mergeUniqueOption {
|
merge = lib.options.mergeUniqueOption {
|
||||||
message = "------";
|
message = "------";
|
||||||
merge = loc: defs: {
|
merge = loc: defs: {
|
||||||
imports = map (
|
imports = map (
|
||||||
def:
|
def:
|
||||||
seq (checkDef loc def) setDefaultModuleLocation "${def.file}, via option ${showOption loc}"
|
lib.seq (checkDef loc def) lib.setDefaultModuleLocation
|
||||||
|
"${def.file}, via option ${lib.showOption loc}"
|
||||||
def.value
|
def.value
|
||||||
) defs;
|
) defs;
|
||||||
};
|
};
|
||||||
@@ -64,113 +48,4 @@ in
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
|
||||||
New submodule type that allows merging at the attribute level.
|
|
||||||
|
|
||||||
:::note
|
|
||||||
'record' type adopted from https://github.com/NixOS/nixpkgs/pull/334680
|
|
||||||
:::
|
|
||||||
|
|
||||||
It applies additional constraints to immediate child options:
|
|
||||||
|
|
||||||
- No support for 'readOnly'
|
|
||||||
- No support for 'apply'
|
|
||||||
- No support for type-merging: That means the modules options must be pre-declared directly.
|
|
||||||
*/
|
|
||||||
record =
|
|
||||||
{
|
|
||||||
optional ? { },
|
|
||||||
required ? { },
|
|
||||||
wildcardType ? null,
|
|
||||||
}:
|
|
||||||
mkOptionType {
|
|
||||||
name = "record";
|
|
||||||
description =
|
|
||||||
if wildcardType == null then "record" else "open record of ${wildcardType.description}";
|
|
||||||
descriptionClass = if wildcardType == null then "noun" else "composite";
|
|
||||||
check = isAttrs;
|
|
||||||
merge.v2 =
|
|
||||||
{ loc, defs }:
|
|
||||||
let
|
|
||||||
pushPositions = map (
|
|
||||||
def:
|
|
||||||
mapAttrs (_n: v: {
|
|
||||||
inherit (def) file;
|
|
||||||
value = v;
|
|
||||||
}) def.value
|
|
||||||
);
|
|
||||||
|
|
||||||
# Checks
|
|
||||||
intersection = intersectAttrs optional required;
|
|
||||||
optionalDefault = filterAttrs (_: opt: opt ? default) optional;
|
|
||||||
|
|
||||||
# Definitions + option defaults
|
|
||||||
allDefs =
|
|
||||||
defs
|
|
||||||
++ (mapAttrsToList (name: opt: {
|
|
||||||
file = (builtins.unsafeGetAttrPos name required).file or "<unknown-file>";
|
|
||||||
value = {
|
|
||||||
${name} = mkOptionDefault opt.default;
|
|
||||||
};
|
|
||||||
}) (filterAttrs (_n: opt: opt ? default) required));
|
|
||||||
|
|
||||||
merged = zipAttrsWith (
|
|
||||||
name: defs:
|
|
||||||
let
|
|
||||||
elemType = optional.${name}.type or required.${name}.type or wildcardType;
|
|
||||||
in
|
|
||||||
lib.modules.mergeDefinitions (loc ++ [ name ]) elemType defs
|
|
||||||
) (pushPositions allDefs);
|
|
||||||
in
|
|
||||||
{
|
|
||||||
headError =
|
|
||||||
if intersection != { } then
|
|
||||||
{
|
|
||||||
message = "The following attributes of '${showOption loc}' are both declared in 'optional' and in 'required': ${lib.concatStringsSep ", " (attrNames intersection)}";
|
|
||||||
}
|
|
||||||
else if optionalDefault != { } then
|
|
||||||
{
|
|
||||||
message = "The following attributes of '${showOption loc}' are declared in 'optional' cannot have a default value: ${lib.concatStringsSep ", " (attrNames optionalDefault)}";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
null;
|
|
||||||
# TODO: expose fields, fieldValues and extraValues
|
|
||||||
valueMeta = {
|
|
||||||
attrs = mapAttrs (_n: v: v.checkedAndMerged.valueMeta) merged;
|
|
||||||
};
|
|
||||||
value = mapAttrs (
|
|
||||||
name: v:
|
|
||||||
let
|
|
||||||
elemType = optional.${name}.type or required.${name}.type or wildcardType;
|
|
||||||
in
|
|
||||||
if required ? ${name} then
|
|
||||||
# Non-optional, lazy ?
|
|
||||||
v.mergedValue
|
|
||||||
else
|
|
||||||
# Optional, lazy
|
|
||||||
v.optionalValue.value or elemType.emptyValue.value or v.mergedValue
|
|
||||||
) merged;
|
|
||||||
};
|
|
||||||
nestedTypes = lib.optionalAttrs (wildcardType != null) {
|
|
||||||
inherit wildcardType;
|
|
||||||
};
|
|
||||||
getSubOptions =
|
|
||||||
prefix:
|
|
||||||
# Since this type doesn't support type merging, we can safely use the original attrs to display documentation.
|
|
||||||
mapAttrs (
|
|
||||||
name: opt:
|
|
||||||
(
|
|
||||||
opt
|
|
||||||
// {
|
|
||||||
loc = prefix ++ [ name ];
|
|
||||||
inherit name;
|
|
||||||
declarations = [
|
|
||||||
(builtins.unsafeGetAttrPos name optional).file or (builtins.unsafeGetAttrPos name required).file
|
|
||||||
or "<unknown-file>"
|
|
||||||
];
|
|
||||||
}
|
|
||||||
)
|
|
||||||
) (optional // required);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
{ lib, clanLib, ... }:
|
|
||||||
let
|
|
||||||
inherit (lib) evalModules mkOption;
|
|
||||||
inherit (clanLib.types) record;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
test_simple =
|
|
||||||
let
|
|
||||||
eval = evalModules {
|
|
||||||
modules = [
|
|
||||||
{
|
|
||||||
options.foo = mkOption {
|
|
||||||
type = record { };
|
|
||||||
default = { };
|
|
||||||
};
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
inherit eval;
|
|
||||||
expr = eval.config.foo;
|
|
||||||
expected = { };
|
|
||||||
};
|
|
||||||
|
|
||||||
test_wildcard =
|
|
||||||
let
|
|
||||||
eval = evalModules {
|
|
||||||
modules = [
|
|
||||||
{
|
|
||||||
options.foo = mkOption {
|
|
||||||
type = record { };
|
|
||||||
default = { };
|
|
||||||
};
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
inherit eval;
|
|
||||||
expr = eval.config.foo;
|
|
||||||
expected = { };
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,92 @@
|
|||||||
{ lib, clanLib, ... }:
|
{ lib, clanLib, ... }:
|
||||||
|
let
|
||||||
|
evalSettingsModule =
|
||||||
|
m:
|
||||||
|
lib.evalModules {
|
||||||
|
modules = [
|
||||||
|
{
|
||||||
|
options.foo = lib.mkOption {
|
||||||
|
type = clanLib.types.uniqueDeferredSerializableModule;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
m
|
||||||
|
];
|
||||||
|
};
|
||||||
|
in
|
||||||
{
|
{
|
||||||
unique = import ./unique_tests.nix { inherit lib clanLib; };
|
test_simple =
|
||||||
record = import ./record_tests.nix { inherit lib clanLib; };
|
let
|
||||||
|
eval = evalSettingsModule {
|
||||||
|
foo = { };
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
inherit eval;
|
||||||
|
expr = eval.config.foo;
|
||||||
|
expected = {
|
||||||
|
# Foo has imports
|
||||||
|
# This can only ever be one module due to the type of foo
|
||||||
|
imports = [
|
||||||
|
{
|
||||||
|
# This is the result of 'setDefaultModuleLocation'
|
||||||
|
# Which also returns exactly one module
|
||||||
|
_file = "<unknown-file>, via option foo";
|
||||||
|
imports = [
|
||||||
|
{ }
|
||||||
|
];
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
test_no_nested_imports =
|
||||||
|
let
|
||||||
|
eval = evalSettingsModule {
|
||||||
|
foo = {
|
||||||
|
imports = [ ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
inherit eval;
|
||||||
|
expr = eval.config.foo;
|
||||||
|
expectedError = {
|
||||||
|
type = "ThrownError";
|
||||||
|
message = "*nested imports";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
test_no_function_modules =
|
||||||
|
let
|
||||||
|
eval = evalSettingsModule {
|
||||||
|
foo =
|
||||||
|
{ ... }:
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
inherit eval;
|
||||||
|
expr = eval.config.foo;
|
||||||
|
expectedError = {
|
||||||
|
type = "TypeError";
|
||||||
|
message = "cannot convert a function to JSON";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
test_non_attrs_module =
|
||||||
|
let
|
||||||
|
eval = evalSettingsModule {
|
||||||
|
foo = "foo.nix";
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
inherit eval;
|
||||||
|
expr = eval.config.foo;
|
||||||
|
expectedError = {
|
||||||
|
type = "ThrownError";
|
||||||
|
message = ".*foo.* is not of type";
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,92 +0,0 @@
|
|||||||
{ lib, clanLib, ... }:
|
|
||||||
let
|
|
||||||
evalSettingsModule =
|
|
||||||
m:
|
|
||||||
lib.evalModules {
|
|
||||||
modules = [
|
|
||||||
{
|
|
||||||
options.foo = lib.mkOption {
|
|
||||||
type = clanLib.types.uniqueDeferredSerializableModule;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
m
|
|
||||||
];
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
test_not_defined =
|
|
||||||
let
|
|
||||||
eval = evalSettingsModule {
|
|
||||||
foo = { };
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
inherit eval;
|
|
||||||
expr = eval.config.foo;
|
|
||||||
expected = {
|
|
||||||
# Foo has imports
|
|
||||||
# This can only ever be one module due to the type of foo
|
|
||||||
imports = [
|
|
||||||
{
|
|
||||||
# This is the result of 'setDefaultModuleLocation'
|
|
||||||
# Which also returns exactly one module
|
|
||||||
_file = "<unknown-file>, via option foo";
|
|
||||||
imports = [
|
|
||||||
{ }
|
|
||||||
];
|
|
||||||
}
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
test_no_nested_imports =
|
|
||||||
let
|
|
||||||
eval = evalSettingsModule {
|
|
||||||
foo = {
|
|
||||||
imports = [ ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
inherit eval;
|
|
||||||
expr = eval.config.foo;
|
|
||||||
expectedError = {
|
|
||||||
type = "ThrownError";
|
|
||||||
message = "*nested imports";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
test_no_function_modules =
|
|
||||||
let
|
|
||||||
eval = evalSettingsModule {
|
|
||||||
foo =
|
|
||||||
{ ... }:
|
|
||||||
{
|
|
||||||
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
inherit eval;
|
|
||||||
expr = eval.config.foo;
|
|
||||||
expectedError = {
|
|
||||||
type = "TypeError";
|
|
||||||
message = "cannot convert a function to JSON";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
test_non_attrs_module =
|
|
||||||
let
|
|
||||||
eval = evalSettingsModule {
|
|
||||||
foo = "foo.nix";
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
inherit eval;
|
|
||||||
expr = eval.config.foo;
|
|
||||||
expectedError = {
|
|
||||||
type = "ThrownError";
|
|
||||||
message = ".*foo.* is not of type";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -111,11 +111,11 @@ in
|
|||||||
};
|
};
|
||||||
modules = [
|
modules = [
|
||||||
(import ../../lib/inventory/distributed-service/all-services-wrapper.nix {
|
(import ../../lib/inventory/distributed-service/all-services-wrapper.nix {
|
||||||
inherit (clanConfig) directory exports;
|
inherit (clanConfig) directory;
|
||||||
})
|
})
|
||||||
# Dependencies
|
# Dependencies
|
||||||
{
|
{
|
||||||
# exportsModule = clanConfig.exportsModule;
|
exportsModule = clanConfig.exportsModule;
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
# TODO: Rename to "allServices"
|
# TODO: Rename to "allServices"
|
||||||
|
|||||||
@@ -110,7 +110,9 @@ in
|
|||||||
|
|
||||||
# TODO: make this writable by moving the options from inventoryClass into clan.
|
# TODO: make this writable by moving the options from inventoryClass into clan.
|
||||||
exports = lib.mkOption {
|
exports = lib.mkOption {
|
||||||
type = types.lazyAttrsOf (types.submoduleWith { modules = [ config.exportsModule ]; });
|
readOnly = true;
|
||||||
|
visible = false;
|
||||||
|
internal = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
exportsModule = lib.mkOption {
|
exportsModule = lib.mkOption {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ let
|
|||||||
inputs.data-mesher.nixosModules.data-mesher
|
inputs.data-mesher.nixosModules.data-mesher
|
||||||
];
|
];
|
||||||
config = {
|
config = {
|
||||||
clan.core.clanPkgs = lib.mkDefault self.packages.${pkgs.hostPlatform.system};
|
clan.core.clanPkgs = lib.mkDefault self.packages.${pkgs.stdenv.hostPlatform.system};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
|
|||||||
@@ -30,5 +30,5 @@ let
|
|||||||
in
|
in
|
||||||
{
|
{
|
||||||
# Note this might jump back and worth as kernel get added or removed.
|
# Note this might jump back and worth as kernel get added or removed.
|
||||||
boot.kernelPackages = lib.mkIf (lib.meta.availableOn pkgs.hostPlatform pkgs.zfs) latestKernelPackage;
|
boot.kernelPackages = lib.mkIf (lib.meta.availableOn pkgs.stdenv.hostPlatform pkgs.zfs) latestKernelPackage;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ class SecretStore(StoreBase):
|
|||||||
output_dir / "activation" / generator.name / file.name
|
output_dir / "activation" / generator.name / file.name
|
||||||
)
|
)
|
||||||
out_file.parent.mkdir(parents=True, exist_ok=True)
|
out_file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
out_file.write_bytes(self.get(generator, file.name))
|
out_file.write_bytes(file.value)
|
||||||
if "partitioning" in phases:
|
if "partitioning" in phases:
|
||||||
for generator in vars_generators:
|
for generator in vars_generators:
|
||||||
for file in generator.files:
|
for file in generator.files:
|
||||||
@@ -254,7 +254,7 @@ class SecretStore(StoreBase):
|
|||||||
output_dir / "partitioning" / generator.name / file.name
|
output_dir / "partitioning" / generator.name / file.name
|
||||||
)
|
)
|
||||||
out_file.parent.mkdir(parents=True, exist_ok=True)
|
out_file.parent.mkdir(parents=True, exist_ok=True)
|
||||||
out_file.write_bytes(self.get(generator, file.name))
|
out_file.write_bytes(file.value)
|
||||||
|
|
||||||
hash_data = self.generate_hash(machine)
|
hash_data = self.generate_hash(machine)
|
||||||
if hash_data:
|
if hash_data:
|
||||||
|
|||||||
@@ -246,7 +246,7 @@ class SecretStore(StoreBase):
|
|||||||
)
|
)
|
||||||
# chmod after in case it doesn't have u+w
|
# chmod after in case it doesn't have u+w
|
||||||
target_path.touch(mode=0o600)
|
target_path.touch(mode=0o600)
|
||||||
target_path.write_bytes(self.get(generator, file.name))
|
target_path.write_bytes(file.value)
|
||||||
target_path.chmod(file.mode)
|
target_path.chmod(file.mode)
|
||||||
|
|
||||||
if "partitioning" in phases:
|
if "partitioning" in phases:
|
||||||
@@ -260,7 +260,7 @@ class SecretStore(StoreBase):
|
|||||||
)
|
)
|
||||||
# chmod after in case it doesn't have u+w
|
# chmod after in case it doesn't have u+w
|
||||||
target_path.touch(mode=0o600)
|
target_path.touch(mode=0o600)
|
||||||
target_path.write_bytes(self.get(generator, file.name))
|
target_path.write_bytes(file.value)
|
||||||
target_path.chmod(file.mode)
|
target_path.chmod(file.mode)
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -211,7 +211,7 @@ class ClanSelectError(ClanError):
|
|||||||
|
|
||||||
def __str__(self) -> str:
|
def __str__(self) -> str:
|
||||||
if self.description:
|
if self.description:
|
||||||
return f"{self.msg} Reason: {self.description}"
|
return f"{self.msg} Reason: {self.description}. Use flag '--debug' to see full nix trace."
|
||||||
return self.msg
|
return self.msg
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
|
|||||||
Reference in New Issue
Block a user