Compare commits

..

2 commits

Author SHA1 Message Date
fd1d55df5f
move shell from flake 2025-07-01 10:22:58 +02:00
0c23115cff allow configuring network interface (#413)
Reviewed-on: Fediversity/Fediversity#413
Reviewed-by: Valentin Gagarin <valentin.gagarin@tweag.io>
Co-authored-by: Kiara Grouwstra <kiara@procolix.eu>
Co-committed-by: Kiara Grouwstra <kiara@procolix.eu>
2025-06-30 19:23:51 +02:00
4 changed files with 68 additions and 61 deletions

View file

@ -58,6 +58,11 @@ in
in in
[ [
pkgs.npins pkgs.npins
pkgs.nil
pkgs.agenix-cli
pkgs.openssh
pkgs.httpie
pkgs.jq
pkgs.nix-unit pkgs.nix-unit
test-loop test-loop
nixops4.packages.${system}.default nixops4.packages.${system}.default

View file

@ -11,7 +11,7 @@
let let
sources = import ./npins; sources = import ./npins;
inherit (import sources.flake-inputs) import-flake; inherit (import sources.flake-inputs) import-flake;
inherit (sources) git-hooks agenix; inherit (sources) git-hooks;
# XXX(@fricklerhandwerk): this atrocity is required to splice in a foreign Nixpkgs via flake-parts # XXX(@fricklerhandwerk): this atrocity is required to splice in a foreign Nixpkgs via flake-parts
# XXX - this is just importing a flake # XXX - this is just importing a flake
nixpkgs = import-flake { src = sources.nixpkgs; }; nixpkgs = import-flake { src = sources.nixpkgs; };
@ -54,7 +54,6 @@
{ {
pkgs, pkgs,
lib, lib,
inputs',
... ...
}: }:
{ {
@ -73,21 +72,6 @@
trim-trailing-whitespace.enable = true; trim-trailing-whitespace.enable = true;
shellcheck.enable = true; shellcheck.enable = true;
}; };
devShells.default = pkgs.mkShell {
packages = [
pkgs.npins
pkgs.nil
(pkgs.callPackage "${agenix}/pkgs/agenix.nix" { })
pkgs.openssh
pkgs.httpie
pkgs.jq
# exposing this env var as a hack to pass info in from form
(inputs'.nixops4.packages.default.overrideAttrs {
impureEnvVars = [ "DEPLOYMENT" ];
})
];
};
}; };
} }
); );

View file

@ -1,7 +1,7 @@
{ config, lib, ... }: { config, lib, ... }:
let let
inherit (lib) mkDefault; inherit (lib) mkDefault mkIf mkMerge;
in in
{ {
@ -13,41 +13,14 @@ in
settings.PasswordAuthentication = false; settings.PasswordAuthentication = false;
}; };
networking = { networking = mkMerge [
{
hostName = config.fediversityVm.name; hostName = config.fediversityVm.name;
domain = config.fediversityVm.domain; domain = config.fediversityVm.domain;
## REVIEW: Do we actually need that, considering that we have static IPs? ## REVIEW: Do we actually need that, considering that we have static IPs?
useDHCP = mkDefault true; useDHCP = mkDefault true;
interfaces = {
eth0 = {
ipv4 = {
addresses = [
{
inherit (config.fediversityVm.ipv4) address prefixLength;
}
];
};
ipv6 = {
addresses = [
{
inherit (config.fediversityVm.ipv6) address prefixLength;
}
];
};
};
};
defaultGateway = {
address = config.fediversityVm.ipv4.gateway;
interface = "eth0";
};
defaultGateway6 = {
address = config.fediversityVm.ipv6.gateway;
interface = "eth0";
};
nameservers = [ nameservers = [
"95.215.185.6" "95.215.185.6"
"95.215.185.7" "95.215.185.7"
@ -60,6 +33,29 @@ in
enable = true; enable = true;
rulesetFile = ./nftables-ruleset.nft; rulesetFile = ./nftables-ruleset.nft;
}; };
}
## IPv4
(mkIf config.fediversityVm.ipv4.enable {
interfaces.${config.fediversityVm.ipv4.interface}.ipv4.addresses = [
{ inherit (config.fediversityVm.ipv4) address prefixLength; }
];
defaultGateway = {
address = config.fediversityVm.ipv4.gateway;
interface = config.fediversityVm.ipv4.interface;
}; };
})
## IPv6
(mkIf config.fediversityVm.ipv6.enable {
interfaces.${config.fediversityVm.ipv6.interface}.ipv6.addresses = [
{ inherit (config.fediversityVm.ipv6) address prefixLength; }
];
defaultGateway6 = {
address = config.fediversityVm.ipv6.gateway;
interface = config.fediversityVm.ipv6.interface;
};
})
];
}; };
} }

View file

@ -91,6 +91,17 @@ in
}; };
ipv4 = { ipv4 = {
enable = mkOption {
default = true;
};
interface = mkOption {
description = ''
The interface that carries the machine's IPv4 network.
'';
default = "eth0";
};
address = mkOption { address = mkOption {
description = '' description = ''
The IP address of the machine, version 4. It will be injected as a The IP address of the machine, version 4. It will be injected as a
@ -116,6 +127,17 @@ in
}; };
ipv6 = { ipv6 = {
enable = mkOption {
default = true;
};
interface = mkOption {
description = ''
The interface that carries the machine's IPv6 network.
'';
default = "eth0";
};
address = mkOption { address = mkOption {
description = '' description = ''
The IP address of the machine, version 6. It will be injected as a The IP address of the machine, version 6. It will be injected as a