move admin config to top-level
This commit is contained in:
parent
81c9ecd6dc
commit
a055f4fa40
8 changed files with 77 additions and 49 deletions
8
admins.nix
Normal file
8
admins.nix
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
dadada = {
|
||||||
|
shell = "zsh";
|
||||||
|
keys = [
|
||||||
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJyTgdVPPxQeL5KZo9frZQlDIv2QkelJw3gNGoGtUMfw tim@metis"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
|
@ -1 +0,0 @@
|
||||||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJyTgdVPPxQeL5KZo9frZQlDIv2QkelJw3gNGoGtUMfw tim@metis
|
|
|
@ -1,4 +1,5 @@
|
||||||
{ self
|
{ self
|
||||||
|
, admins
|
||||||
, nixpkgs
|
, nixpkgs
|
||||||
, nixosSystem
|
, nixosSystem
|
||||||
, home-manager
|
, home-manager
|
||||||
|
@ -8,15 +9,20 @@
|
||||||
, scripts
|
, scripts
|
||||||
, recipemd
|
, recipemd
|
||||||
}:
|
}:
|
||||||
let adapterModule = system: {
|
let
|
||||||
nixpkgs.config.allowUnfreePredicate = (pkg: true);
|
adapterModule = system: {
|
||||||
nixpkgs.overlays = (nixpkgs.lib.attrValues self.overlays) ++ [
|
nixpkgs.config.allowUnfreePredicate = (pkg: true);
|
||||||
(final: prev: { homePage = homePage.defaultPackage.${system}; })
|
nixpkgs.overlays = (nixpkgs.lib.attrValues self.overlays) ++ [
|
||||||
(final: prev: { s = scripts; })
|
(final: prev: { homePage = homePage.defaultPackage.${system}; })
|
||||||
(final: prev: { n = nvd; })
|
(final: prev: { s = scripts; })
|
||||||
(final: prev: { recipemd = recipemd.defaultPackage.${system}; })
|
(final: prev: { n = nvd; })
|
||||||
];
|
(final: prev: { recipemd = recipemd.defaultPackage.${system}; })
|
||||||
};
|
];
|
||||||
|
};
|
||||||
|
lib = nixpkgs.lib;
|
||||||
|
adminConfig = users: {
|
||||||
|
dadada.admin.users = lib.getAttrs users admins;
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
gorgon = nixosSystem rec {
|
gorgon = nixosSystem rec {
|
||||||
|
@ -40,6 +46,7 @@ in
|
||||||
ifrit = nixosSystem rec {
|
ifrit = nixosSystem rec {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
modules = (nixpkgs.lib.attrValues self.nixosModules) ++ [
|
modules = (nixpkgs.lib.attrValues self.nixosModules) ++ [
|
||||||
|
(adminConfig [ "dadada" ])
|
||||||
(adapterModule system)
|
(adapterModule system)
|
||||||
./modules/profiles/server.nix
|
./modules/profiles/server.nix
|
||||||
./ifrit/configuration.nix
|
./ifrit/configuration.nix
|
||||||
|
@ -49,6 +56,7 @@ in
|
||||||
surgat = nixosSystem rec {
|
surgat = nixosSystem rec {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
modules = (nixpkgs.lib.attrValues self.nixosModules) ++ [
|
modules = (nixpkgs.lib.attrValues self.nixosModules) ++ [
|
||||||
|
(adminConfig [ "dadada" ])
|
||||||
(adapterModule system)
|
(adapterModule system)
|
||||||
./modules/profiles/server.nix
|
./modules/profiles/server.nix
|
||||||
./surgat/configuration.nix
|
./surgat/configuration.nix
|
||||||
|
@ -57,6 +65,7 @@ in
|
||||||
pruflas = nixosSystem rec {
|
pruflas = nixosSystem rec {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
modules = (nixpkgs.lib.attrValues self.nixosModules) ++ [
|
modules = (nixpkgs.lib.attrValues self.nixosModules) ++ [
|
||||||
|
(adminConfig [ "dadada" ])
|
||||||
(adapterModule system)
|
(adapterModule system)
|
||||||
./modules/profiles/laptop.nix
|
./modules/profiles/laptop.nix
|
||||||
./pruflas/configuration.nix
|
./pruflas/configuration.nix
|
||||||
|
@ -66,6 +75,7 @@ in
|
||||||
agares = nixosSystem rec {
|
agares = nixosSystem rec {
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
modules = (nixpkgs.lib.attrValues self.nixosModules) ++ [
|
modules = (nixpkgs.lib.attrValues self.nixosModules) ++ [
|
||||||
|
(adminConfig [ "dadada" ])
|
||||||
(adapterModule system)
|
(adapterModule system)
|
||||||
./modules/profiles/server.nix
|
./modules/profiles/server.nix
|
||||||
./agares/configuration.nix
|
./agares/configuration.nix
|
||||||
|
|
|
@ -3,6 +3,38 @@
|
||||||
with lib;
|
with lib;
|
||||||
let
|
let
|
||||||
cfg = config.dadada.admin;
|
cfg = config.dadada.admin;
|
||||||
|
extraGroups = [ "wheel" "libvirtd" ];
|
||||||
|
|
||||||
|
shells = {
|
||||||
|
"bash" = pkgs.bashInteractive;
|
||||||
|
"zsh" = pkgs.zsh;
|
||||||
|
"fish" = pkgs.fish;
|
||||||
|
};
|
||||||
|
|
||||||
|
shellNames = builtins.attrNames shells;
|
||||||
|
|
||||||
|
adminOpts = { name, config, ... }: {
|
||||||
|
options = {
|
||||||
|
keys = mkOption {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
default = [ ];
|
||||||
|
apply = x: assert (builtins.length x > 0 || abort "Please specify at least one key to be able to log in"); x;
|
||||||
|
description = ''
|
||||||
|
The keys that should be able to access the account.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
shell = mkOption {
|
||||||
|
type = types.nullOr types.str;
|
||||||
|
apply = x: assert (builtins.elem x shellNames || abort "Please specify one of ${builtins.toString shellNames}"); x;
|
||||||
|
default = "zsh";
|
||||||
|
defaultText = literalExpression "zsh";
|
||||||
|
example = literalExpression "bash";
|
||||||
|
description = ''
|
||||||
|
One of ${builtins.toString shellNames}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
|
@ -10,12 +42,12 @@ in
|
||||||
enable = mkEnableOption "Enable admin access";
|
enable = mkEnableOption "Enable admin access";
|
||||||
|
|
||||||
users = mkOption {
|
users = mkOption {
|
||||||
type = with types; attrsOf (listOf path);
|
type = with types; attrsOf (submodule adminOpts);
|
||||||
default = [ ];
|
default = { };
|
||||||
description = ''
|
description = ''
|
||||||
List of admin users with root access to all the machine.
|
Admin users with root access machine.
|
||||||
'';
|
'';
|
||||||
example = literalExample "\"user1\" = [ /path/to/key1 /path/to/key2 ]";
|
example = literalExample "\"user1\" = { shell = pkgs.bashInteractive; keys = [ 'ssh-rsa 123456789' ]; }";
|
||||||
};
|
};
|
||||||
|
|
||||||
rat = mkOption {
|
rat = mkOption {
|
||||||
|
@ -29,28 +61,27 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
programs.zsh.enable = mkDefault true;
|
||||||
|
|
||||||
services.sshd.enable = true;
|
services.sshd.enable = true;
|
||||||
services.openssh.passwordAuthentication = false;
|
services.openssh.passwordAuthentication = false;
|
||||||
security.sudo.wheelNeedsPassword = false;
|
security.sudo.wheelNeedsPassword = false;
|
||||||
|
services.openssh.openFirewall = true;
|
||||||
|
|
||||||
users.users = mapAttrs
|
users.users = mapAttrs
|
||||||
(user: keys: (
|
(user: keys: (
|
||||||
{
|
{
|
||||||
extraGroups = [
|
shell = shells."${keys.shell}";
|
||||||
"wheel"
|
extraGroups = extraGroups;
|
||||||
"libvirtd"
|
isNormalUser = true;
|
||||||
];
|
openssh.authorizedKeys.keys = keys.keys;
|
||||||
isNormalUser = true;
|
}))
|
||||||
openssh.authorizedKeys.keyFiles = keys;
|
|
||||||
}))
|
|
||||||
cfg.users;
|
cfg.users;
|
||||||
|
|
||||||
nix.trustedUsers = builtins.attrNames cfg.users;
|
nix.trustedUsers = builtins.attrNames cfg.users;
|
||||||
|
|
||||||
users.mutableUsers = mkDefault false;
|
users.mutableUsers = mkDefault false;
|
||||||
|
|
||||||
networking.firewall.allowedTCPPorts = [ 22 ];
|
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
vim
|
vim
|
||||||
tmux
|
tmux
|
||||||
|
|
|
@ -1,17 +1,11 @@
|
||||||
{ config, pkgs, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
with lib;
|
with lib;
|
||||||
let
|
{
|
||||||
keys = [ ../../../keys/dadada.pub ];
|
|
||||||
in {
|
|
||||||
networking.domain = mkDefault "dadada.li";
|
networking.domain = mkDefault "dadada.li";
|
||||||
networking.tempAddresses = "disabled";
|
networking.tempAddresses = "disabled";
|
||||||
|
|
||||||
dadada.admin.users = {
|
dadada.admin.enable = true;
|
||||||
"dadada" = keys;
|
|
||||||
};
|
|
||||||
|
|
||||||
dadada.networking.localResolver.enable = true;
|
dadada.networking.localResolver.enable = true;
|
||||||
|
|
||||||
dadada.autoUpgrade.enable = mkDefault true;
|
dadada.autoUpgrade.enable = mkDefault true;
|
||||||
|
|
||||||
environment.noXlibs = mkDefault true;
|
environment.noXlibs = mkDefault true;
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
{ config, pkgs, lib, ... }:
|
{ config, pkgs, lib, ... }:
|
||||||
with lib;
|
with lib;
|
||||||
let
|
{
|
||||||
keys = [ ../../keys/dadada.pub ];
|
|
||||||
in {
|
|
||||||
imports = [ ./hardware-configuration.nix ];
|
imports = [ ./hardware-configuration.nix ];
|
||||||
|
|
||||||
networking.hostName = "pruflas";
|
networking.hostName = "pruflas";
|
||||||
|
@ -103,10 +101,6 @@ in {
|
||||||
|
|
||||||
networking.domain = "dadada.li";
|
networking.domain = "dadada.li";
|
||||||
|
|
||||||
dadada.admin.users = {
|
|
||||||
"dadada" = keys;
|
|
||||||
};
|
|
||||||
|
|
||||||
users.mutableUsers = true;
|
users.mutableUsers = true;
|
||||||
|
|
||||||
dadada.networking.localResolver.enable = true;
|
dadada.networking.localResolver.enable = true;
|
||||||
|
|
|
@ -35,13 +35,6 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
dadada.admin = {
|
|
||||||
enable = true;
|
|
||||||
users = {
|
|
||||||
"dadada" = [ ../../keys/dadada.pub ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
dadada.element.enable = true;
|
dadada.element.enable = true;
|
||||||
dadada.gitea.enable = true;
|
dadada.gitea.enable = true;
|
||||||
dadada.networking.vpnExtension = "4";
|
dadada.networking.vpnExtension = "4";
|
||||||
|
|
|
@ -58,12 +58,11 @@
|
||||||
hmModules = import ./home/modules inputs;
|
hmModules = import ./home/modules inputs;
|
||||||
nixosConfigurations = import ./nixos/configurations.nix {
|
nixosConfigurations = import ./nixos/configurations.nix {
|
||||||
nixosSystem = nixpkgs.lib.nixosSystem;
|
nixosSystem = nixpkgs.lib.nixosSystem;
|
||||||
|
admins = import ./admins.nix;
|
||||||
inherit self nixpkgs home-manager nixos-hardware nvd scripts homePage recipemd;
|
inherit self nixpkgs home-manager nixos-hardware nvd scripts homePage recipemd;
|
||||||
};
|
};
|
||||||
nixosModules = import ./nixos/modules inputs;
|
nixosModules = import ./nixos/modules inputs;
|
||||||
overlays = import ./overlays;
|
overlays = import ./overlays;
|
||||||
keys = ./keys;
|
|
||||||
|
|
||||||
hydraJobs = (
|
hydraJobs = (
|
||||||
nixpkgs.lib.mapAttrs'
|
nixpkgs.lib.mapAttrs'
|
||||||
(name: config: nixpkgs.lib.nameValuePair name config.config.system.build.toplevel)
|
(name: config: nixpkgs.lib.nameValuePair name config.config.system.build.toplevel)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue