Migrated legion over. Started migrating hijiri
This commit is contained in:
parent
31dd42d37d
commit
f79b3d6ff7
40 changed files with 397 additions and 228 deletions
19
modules/shared/settei/default.nix
Normal file
19
modules/shared/settei/default.nix
Normal file
|
@ -0,0 +1,19 @@
|
|||
{perInput}: {
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: {
|
||||
_file = ./default.nix;
|
||||
|
||||
imports = [
|
||||
./sane-defaults.nix
|
||||
(import ./flake-qol.nix {inherit perInput;})
|
||||
./user.nix
|
||||
];
|
||||
|
||||
options.settei = with lib; {
|
||||
username = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
}
|
49
modules/shared/settei/flake-qol.nix
Normal file
49
modules/shared/settei/flake-qol.nix
Normal file
|
@ -0,0 +1,49 @@
|
|||
{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 = lib.mapAttrsToList (name: _: "${name}=flake:${name}") cfg.inputs-flakes;
|
||||
};
|
||||
};
|
||||
}
|
58
modules/shared/settei/sane-defaults.nix
Normal file
58
modules/shared/settei/sane-defaults.nix
Normal file
|
@ -0,0 +1,58 @@
|
|||
# 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
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
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;
|
||||
adminNeedsPassword = pkgs.stdenv.isLinux -> config.security.sudo.wheelNeedsPassword;
|
||||
in {
|
||||
_module.args = {
|
||||
username = lib.mkDefault username;
|
||||
};
|
||||
|
||||
services.tailscale.enable = true;
|
||||
|
||||
networking.hostName = lib.mkDefault (
|
||||
args.configurationName
|
||||
or (throw "pass configurationName to module arguments or set networking.hostName yourself")
|
||||
);
|
||||
|
||||
nix = {
|
||||
settings = {
|
||||
experimental-features = ["nix-command" "flakes" "repl-flake" "auto-allocate-uids"];
|
||||
trusted-users = lib.optionals (!adminNeedsPassword) [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"
|
||||
"https://nrabulinski.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="
|
||||
"nrabulinski.cachix.org-1:Q5FD7+1c68uH74CQK66UWNzxhanZW8xcg1LFXxGK8ic="
|
||||
];
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
55
modules/shared/settei/user.nix
Normal file
55
modules/shared/settei/user.nix
Normal file
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
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 = "22.05";
|
||||
};
|
||||
|
||||
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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue