forked from Fediversity/Fediversity
factor out settings for use in base install
This commit is contained in:
parent
682b533b49
commit
edfbc7d03a
7 changed files with 88 additions and 69 deletions
37
infra/common/nixos/base.nix
Normal file
37
infra/common/nixos/base.nix
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
# base configuration used also in the initial NixOS install,
|
||||||
|
# enabling to then push further configs.
|
||||||
|
{ lib, modulesPath, ... }:
|
||||||
|
let
|
||||||
|
inherit (lib) attrValues;
|
||||||
|
keys = import ../../../keys;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
"${modulesPath}/virtualisation/qemu-guest-agent.nix"
|
||||||
|
"${modulesPath}/virtualisation/qemu-vm.nix"
|
||||||
|
"${modulesPath}/profiles/qemu-guest.nix"
|
||||||
|
./hardware.nix
|
||||||
|
./users.nix
|
||||||
|
];
|
||||||
|
time.timeZone = "Europe/Amsterdam";
|
||||||
|
i18n.defaultLocale = "en_US.UTF-8";
|
||||||
|
system.stateVersion = "24.05"; # do not change
|
||||||
|
services.qemuGuest.enable = true;
|
||||||
|
networking.firewall.enable = true;
|
||||||
|
|
||||||
|
services.openssh = {
|
||||||
|
enable = true;
|
||||||
|
settings.PasswordAuthentication = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
## TODO Remove direct root authentication, see #24
|
||||||
|
users.users.root.openssh.authorizedKeys.keys = attrValues keys.contributors;
|
||||||
|
|
||||||
|
# FIXME un-hardcode
|
||||||
|
networking.nameservers = [
|
||||||
|
"95.215.185.6"
|
||||||
|
"95.215.185.7"
|
||||||
|
"2a00:51c0::5fd7:b906"
|
||||||
|
"2a00:51c0::5fd7:b907"
|
||||||
|
];
|
||||||
|
}
|
|
@ -1,21 +1,9 @@
|
||||||
{ lib, ... }:
|
|
||||||
|
|
||||||
let
|
|
||||||
inherit (lib) mkDefault;
|
|
||||||
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./hardware.nix
|
./base.nix
|
||||||
./networking.nix
|
./networking.nix
|
||||||
./users.nix
|
|
||||||
];
|
];
|
||||||
|
|
||||||
time.timeZone = "Europe/Amsterdam";
|
|
||||||
i18n.defaultLocale = "en_US.UTF-8";
|
|
||||||
system.stateVersion = "24.05"; # do not change
|
|
||||||
nixpkgs.hostPlatform = mkDefault "x86_64-linux";
|
|
||||||
|
|
||||||
## This is just nice to have, but it is also particularly important for the
|
## This is just nice to have, but it is also particularly important for the
|
||||||
## Forgejo CI runners because the Nix configuration in the actions is directly
|
## Forgejo CI runners because the Nix configuration in the actions is directly
|
||||||
## taken from here.
|
## taken from here.
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
{ modulesPath, ... }:
|
{ modulesPath, ... }:
|
||||||
|
let
|
||||||
|
sources = import ../../../npins;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
"${modulesPath}/profiles/qemu-guest.nix"
|
"${modulesPath}/profiles/qemu-guest.nix"
|
||||||
|
"${sources.disko}/module.nix"
|
||||||
];
|
];
|
||||||
|
|
||||||
boot = {
|
boot = {
|
||||||
|
|
|
@ -6,11 +6,6 @@ let
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
config = {
|
config = {
|
||||||
services.openssh = {
|
|
||||||
enable = true;
|
|
||||||
settings.PasswordAuthentication = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
networking = {
|
networking = {
|
||||||
hostName = config.fediversityVm.name;
|
hostName = config.fediversityVm.name;
|
||||||
domain = config.fediversityVm.domain;
|
domain = config.fediversityVm.domain;
|
||||||
|
@ -46,13 +41,6 @@ in
|
||||||
interface = "eth0";
|
interface = "eth0";
|
||||||
};
|
};
|
||||||
|
|
||||||
nameservers = [
|
|
||||||
"95.215.185.6"
|
|
||||||
"95.215.185.7"
|
|
||||||
"2a00:51c0::5fd7:b906"
|
|
||||||
"2a00:51c0::5fd7:b907"
|
|
||||||
];
|
|
||||||
|
|
||||||
firewall.enable = false;
|
firewall.enable = false;
|
||||||
nftables = {
|
nftables = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
|
@ -8,8 +8,6 @@ let
|
||||||
inherit (lib) attrValues elem mkDefault;
|
inherit (lib) attrValues elem mkDefault;
|
||||||
inherit (lib.attrsets) concatMapAttrs optionalAttrs;
|
inherit (lib.attrsets) concatMapAttrs optionalAttrs;
|
||||||
inherit (lib.strings) removeSuffix;
|
inherit (lib.strings) removeSuffix;
|
||||||
sources = import ../../npins;
|
|
||||||
inherit (sources) nixpkgs agenix disko;
|
|
||||||
|
|
||||||
secretsPrefix = ../../secrets;
|
secretsPrefix = ../../secrets;
|
||||||
secrets = import (secretsPrefix + "/secrets.nix");
|
secrets = import (secretsPrefix + "/secrets.nix");
|
||||||
|
@ -17,48 +15,27 @@ let
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [ ./options.nix ];
|
imports = [
|
||||||
|
./options.nix
|
||||||
|
./nixos
|
||||||
|
];
|
||||||
|
|
||||||
fediversityVm.hostPublicKey = mkDefault keys.systems.${config.fediversityVm.name};
|
fediversityVm.hostPublicKey = mkDefault keys.systems.${config.fediversityVm.name};
|
||||||
|
|
||||||
ssh = {
|
## Read all the secrets, filter the ones that are supposed to be readable
|
||||||
host = config.fediversityVm.ipv4.address;
|
## with this host's public key, and add them correctly to the configuration
|
||||||
hostPublicKey = config.fediversityVm.hostPublicKey;
|
## as `age.secrets.<name>.file`.
|
||||||
};
|
age.secrets = concatMapAttrs (
|
||||||
|
name: secret:
|
||||||
|
optionalAttrs (elem config.fediversityVm.hostPublicKey secret.publicKeys) {
|
||||||
|
${removeSuffix ".age" name}.file = secretsPrefix + "/${name}";
|
||||||
|
}
|
||||||
|
) secrets;
|
||||||
|
|
||||||
inherit nixpkgs;
|
## FIXME: Remove direct root authentication once the NixOps4 NixOS provider
|
||||||
|
## supports users with password-less sudo.
|
||||||
## The configuration of the machine. We strive to keep in this file only the
|
users.users.root.openssh.authorizedKeys.keys = attrValues keys.contributors ++ [
|
||||||
## options that really need to be injected from the resource. Everything else
|
# allow our panel vm access to the test machines
|
||||||
## should go into the `./nixos` subdirectory.
|
keys.panel
|
||||||
nixos.module = {
|
];
|
||||||
imports = [
|
|
||||||
(import "${agenix}/modules/age.nix")
|
|
||||||
(import "${disko}/module.nix")
|
|
||||||
./options.nix
|
|
||||||
./nixos
|
|
||||||
];
|
|
||||||
|
|
||||||
## Inject the shared options from the resource's `config` into the NixOS
|
|
||||||
## configuration.
|
|
||||||
fediversityVm = config.fediversityVm;
|
|
||||||
|
|
||||||
## Read all the secrets, filter the ones that are supposed to be readable
|
|
||||||
## with this host's public key, and add them correctly to the configuration
|
|
||||||
## as `age.secrets.<name>.file`.
|
|
||||||
age.secrets = concatMapAttrs (
|
|
||||||
name: secret:
|
|
||||||
optionalAttrs (elem config.fediversityVm.hostPublicKey secret.publicKeys) ({
|
|
||||||
${removeSuffix ".age" name}.file = secretsPrefix + "/${name}";
|
|
||||||
})
|
|
||||||
) secrets;
|
|
||||||
|
|
||||||
## FIXME: Remove direct root authentication once the NixOps4 NixOS provider
|
|
||||||
## supports users with password-less sudo.
|
|
||||||
users.users.root.openssh.authorizedKeys.keys = attrValues keys.contributors ++ [
|
|
||||||
# allow our panel vm access to the test machines
|
|
||||||
keys.panel
|
|
||||||
];
|
|
||||||
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
26
infra/common/shared.nix
Normal file
26
infra/common/shared.nix
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (config.terraform) hostname domain initialUser;
|
||||||
|
sources = import ../../npins;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
imports = [
|
||||||
|
"${sources.agenix}/modules/age.nix"
|
||||||
|
../../services/fediversity
|
||||||
|
./resource.nix
|
||||||
|
];
|
||||||
|
fediversityVm.name = hostname;
|
||||||
|
fediversity = {
|
||||||
|
inherit domain;
|
||||||
|
temp.initialUser = {
|
||||||
|
inherit (initialUser) username email displayName;
|
||||||
|
# FIXME: disgusting, but nvm, this is going to be replaced by
|
||||||
|
# proper central authentication at some point
|
||||||
|
passwordFile = pkgs.writeText "password" initialUser.password;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
|
@ -7,7 +7,7 @@
|
||||||
{
|
{
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
hostKeys ? { },
|
hostKeys ? { },
|
||||||
nixosConfiguration,
|
nixosConfiguration ? import ../infra/common/nixos/base.nix,
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
Loading…
Add table
Reference in a new issue