Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions dev/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,39 @@
};

devShells.default = config.pre-commit.devShell;

checks = inputs.nixpkgs.lib.optionalAttrs (system == "x86_64-linux") {
service-defs =
let
checkPkgs = import inputs.nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
config.allowUnfree = true;
};

nixos = inputs.nixpkgs.lib.nixosSystem {
inherit system;
modules = [
self.nixosModules.default
../tests/service-defs/test-module.nix
];
};

topology = import self {
pkgs = checkPkgs;
modules = [ { nixosConfigurations.test-services = nixos; } ];
};
in
checkPkgs.runCommand "check-service-defs"
{
topologyOutput = topology.config.output;
nixosToplevel = nixos.config.system.build.toplevel;
}
''
echo "Topology output: $topologyOutput"
ls -la "$topologyOutput"
touch $out
'';
};
};
}
18 changes: 9 additions & 9 deletions dev/flake.lock

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

81 changes: 81 additions & 0 deletions examples/oci-containers/flake.nix
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently this fails to build using nix build <flake>#docs because flake-utils is not a flake input. I would simply omit using it here

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, omited it, it was a leftover from before flake-utils were removed from the project

Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nix-topology.url = "github:oddlama/nix-topology";
nix-topology.inputs.nixpkgs.follows = "nixpkgs";
};

outputs =
{
self,
nixpkgs,
nix-topology,
...
}:
{
nixosConfigurations.host1 = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
(
{ config, ... }:
{
networking.hostName = "host1";

# Network interfaces from systemd are detected automatically:
systemd.network.enable = true;
systemd.network.networks.eth0 = {
matchConfig.Name = "eth0";
};

# This node hosts a Jellyfin container
virtualisation.oci-containers.containers.jellyfin = {
image = "lscr.io/linuxserver/jellyfin:10.10.3";
labels = {
"traefik.http.routers.jellyfin.rule" = "Host(`jellyfin.example.com`)";
};
};

# Use a built-in function to extract the host information from the container labels
topology.extractors.oci-container.infoFn =
config.topology.extractors.oci-container.lib.traefikHostInfoFn;

# Define a custom details function to extract and show additional information
topology.extractors.oci-container.detailsFn = c: { image.text = c.image; };
}
)
nix-topology.nixosModules.default
];
};
}
// (
let
forAllSystems = nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed;
in
{
topology = forAllSystems (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ nix-topology.overlays.default ];
};
in
import nix-topology {
inherit pkgs;
modules = [
(
{ config, ... }:
let
inherit (config.lib.topology) mkInternet mkConnection;
in
{
inherit (self) nixosConfigurations;
nodes.internet = mkInternet { connections = mkConnection "host1" "eth0"; };
}
)
];
}
);
}
);
}
Loading