Migrated legion over. Started migrating hijiri

This commit is contained in:
Nikodem Rabuliński 2023-09-20 09:47:17 +02:00
parent 31dd42d37d
commit f79b3d6ff7
No known key found for this signature in database
GPG key ID: FF629AA9E08138DB
40 changed files with 397 additions and 228 deletions

View file

@ -1,6 +1,5 @@
{
config,
pkgs,
lib,
...
}: {
@ -8,19 +7,26 @@
options.common.hercules.enable = lib.mkEnableOption "Enables hercules-ci-agent with my configuration";
config = lib.mkIf config.common.hercules.enable {
age.secrets.hercules-token = {
file = ../../secrets/hercules-token.age;
owner = config.systemd.services.hercules-ci-agent.serviceConfig.User;
};
config = let
herculesUser = config.systemd.services.hercules-ci-agent.serviceConfig.User;
in
lib.mkIf config.common.hercules.enable {
age.secrets.hercules-token = {
file = ../../../secrets/hercules-token.age;
owner = herculesUser;
};
age.secrets.hercules-cache = {
file = ../../../secrets/hercules-cache.age;
owner = herculesUser;
};
services.hercules-ci-agent = {
enable = true;
settings = {
clusterJoinTokenPath = config.age.secrets.hercules-token.path;
concurrentTasks = lib.mkDefault 4;
binaryCachesPath = pkgs.writeText "empty-caches.json" "{}";
services.hercules-ci-agent = {
enable = true;
settings = {
clusterJoinTokenPath = config.age.secrets.hercules-token.path;
concurrentTasks = lib.mkDefault 4;
binaryCachesPath = config.age.secrets.hercules-cache.path;
};
};
};
};
}

View file

@ -1,19 +1,6 @@
{perInput}: {
lib,
config,
...
}: {
_file = ./default.nix;
imports = [
(import ../../shared/settei {inherit perInput;})
./sane-defaults.nix
(import ./flake-qol.nix {inherit perInput;})
./user.nix
];
options.settei = with lib; {
username = mkOption {
type = types.str;
};
};
}

View file

@ -1,49 +0,0 @@
{perInput}: {
config,
lib,
pkgs,
...
}: let
cfg = config.settei.flake-qol;
in {
_file = ./flake-qol.nix;
options.settei.flake-qol = with lib; {
enable = mkEnableOption "QoL defaults when using flakes";
reexportAsArgs = mkOption {
type = types.bool;
default = true;
};
inputs = mkOption {
type = types.unspecified;
};
inputs-flakes = mkOption {
type = types.attrs;
readOnly = true;
};
inputs' = mkOption {
type = types.attrs;
readOnly = true;
};
};
config = let
reexportedArgs = lib.mkIf cfg.reexportAsArgs {
inherit (cfg) inputs inputs-flakes inputs';
};
in
lib.mkIf cfg.enable {
settei.flake-qol = {
inputs-flakes = lib.filterAttrs (_: input: input ? flake -> input.flake) cfg.inputs;
inputs' = lib.mapAttrs (_: perInput pkgs.stdenv.system) cfg.inputs-flakes;
};
_module.args = reexportedArgs;
settei.user.extraArgs = reexportedArgs;
nix = {
registry = lib.mapAttrs (_: flake: {inherit flake;}) cfg.inputs-flakes;
nixPath = map (name: "${name}=flake:${name}") (lib.attrNames cfg.inputs-flakes);
};
};
}

View file

@ -1,39 +1,19 @@
# This module is supposed to be a reusable set of options you probably would want to set anyway
#
# Other default options which don't necessairly make sense for other people go into hosts/default.nix
# For sane-default options shared between NixOS and darwin, see modules/shared/settei/sane-defaults.nix
{
lib,
config,
username,
lib,
...
} @ args: {
_file = ./sane-defaults.nix;
options.settei.sane-defaults = with lib; {
enable = mkEnableOption "Personal sane defaults (but they should make sense for anyone)";
allSshKeys = mkOption {
type = types.attrsOf types.singleLineStr;
default = {};
};
};
config = lib.mkIf config.settei.sane-defaults.enable (let
cfg = config.settei;
inherit (cfg) username;
configName = optionName:
args.configurationName
or (throw "pass configurationName to module arguments or set ${optionName} yourself");
in {
_module.args = {
username = lib.mkDefault username;
};
} @ args: let
cfg = config.settei.sane-defaults;
in {
config = lib.mkIf cfg.enable {
# https://github.com/NixOS/nixpkgs/issues/254807
boot.swraid.enable = false;
hardware.enableRedistributableFirmware = true;
services.openssh.enable = true;
services.tailscale.enable = true;
programs.mosh.enable = lib.mkDefault true;
users = {
@ -45,41 +25,21 @@
extraGroups = ["wheel"];
openssh.authorizedKeys.keys = let
filteredKeys = let
configName' = configName "users.users.${username}.openssh.authorizedKeys";
configName' =
args.configurationName
or (throw "pass configurationName to module arguments or set users.users.${username}.openssh.authorizedKeys yourself");
in
lib.filterAttrs (name: _: name != configName') cfg.sane-defaults.allSshKeys;
lib.filterAttrs (name: _: name != configName') cfg.allSshKeys;
in
lib.mkDefault (lib.attrValues filteredKeys);
};
groups.${username} = {};
};
networking.hostName = lib.mkDefault (configName "networking.hostName");
nix = {
settings = {
experimental-features = ["nix-command" "flakes" "repl-flake" "auto-allocate-uids"];
trusted-users = lib.optionals (!config.security.sudo.wheelNeedsPassword) [username];
auto-allocate-uids = true;
extra-substituters = [
"https://hyprland.cachix.org"
"https://cache.garnix.io"
"https://nix-community.cachix.org"
"https://hercules-ci.cachix.org"
];
trusted-public-keys = [
"hyprland.cachix.org-1:a7pgxzMz7+chwVL3/pzj6jIBMioiJM7ypFP8PwtkuGc="
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
"hercules-ci.cachix.org-1:ZZeDl9Va+xe9j+KqdzoBZMFJHVQ42Uu/c/1/KMC5Lw0="
];
};
};
# TODO: Actually this should be extraRules which makes wheel users without any password set
# be able to use sudo with no password
security.sudo.wheelNeedsPassword = false;
system.stateVersion = "22.05";
});
};
}

View file

@ -1,55 +0,0 @@
{
config,
options,
lib,
...
}: let
hasHomeManager = options ? home-manager;
cfg = config.settei.user;
inherit (config.settei) username;
in {
_file = ./user.nix;
options.settei.user = with lib; {
enable = mkEnableOption "User-specific configuration";
config = mkOption {
type = types.deferredModule;
default = {};
};
extraArgs = mkOption {
type = types.attrs;
default = {};
};
};
config = let
hmConfig = lib.optionalAttrs hasHomeManager {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = cfg.extraArgs;
home-manager.users.${username} = {
_file = ./user.nix;
imports = [cfg.config];
home = {
inherit username;
homeDirectory = config.users.users.${username}.home;
stateVersion = config.system.stateVersion;
};
programs.home-manager.enable = true;
};
};
in
lib.mkIf cfg.enable ({
assertions = [
{
assertion = hasHomeManager;
message = "Home-manager module has to be imported before enabling settei.user";
}
];
}
// hmConfig);
}