Initial commit

This commit is contained in:
Nikodem Rabuliński 2023-08-03 14:54:05 +02:00
commit 9661927410
No known key found for this signature in database
GPG key ID: FF629AA9E08138DB
27 changed files with 1091 additions and 0 deletions

View file

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

View file

@ -0,0 +1,45 @@
{perInput}: {
config,
lib,
pkgs,
...
}: let
cfg = config.settei.flake-qol;
in {
_file = ./flake-qol.nix;
options.settei.flake-qol = with lib; {
enable = lib.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 = 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 = lib.mkIf cfg.reexportAsArgs {
inherit (cfg) inputs inputs-flakes inputs';
};
nix = {
registry = lib.mapAttrs (_: flake: {inherit flake;}) cfg.inputs-flakes;
nixPath = map (name: "${name}=flake:${name}") (lib.attrNames cfg.inputs-flakes);
};
};
}

View file

@ -0,0 +1,57 @@
{
lib,
config,
...
} @ args: {
_file = ./sane-defaults.nix;
options.settei.sane-defaults = {
enable = lib.mkEnableOption "Personal sane defaults";
};
config = lib.mkIf config.settei.sane-defaults.enable (let
cfg = config.settei;
inherit (cfg) username;
in {
_module.args = {
username = lib.mkDefault username;
};
hardware.enableRedistributableFirmware = true;
services.openssh.enable = true;
services.tailscale.enable = true;
programs.mosh.enable = lib.mkDefault true;
users = {
mutableUsers = false;
users.${username} = {
isNormalUser = true;
home = "/home/${username}";
group = username;
extraGroups = ["wheel"];
};
groups.${username} = {};
};
networking.hostName = lib.mkDefault (
args.configurationName
or (throw "pass configurationName to module arguments or set networking.hostName yourself")
);
time.timeZone = lib.mkDefault "Europe/Warsaw";
nix = {
settings = {
experimental-features = ["nix-command" "flakes" "repl-flake" "auto-allocate-uids"];
trusted-users = [username];
auto-allocate-uids = true;
};
};
# 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";
});
}