From 15771a522decc865aeaf62af346ccb356f1bdd69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Krop=C3=A1=C4=8Dek?= Date: Wed, 18 Dec 2024 23:14:56 +0100 Subject: [PATCH] added more config --- flake.lock | 8 ++--- flake.nix | 5 +++- hosts/base.nix | 19 ++++++++++++ lib.nix | 2 +- nixosModules/default.nix | 8 ++++- nixosModules/locale/default.nix | 52 +++++++++++++++++++++++++++++++++ nixosModules/users/default.nix | 27 +++++++++++++++++ 7 files changed, 114 insertions(+), 7 deletions(-) create mode 100644 hosts/base.nix create mode 100644 nixosModules/locale/default.nix create mode 100644 nixosModules/users/default.nix diff --git a/flake.lock b/flake.lock index 2505e3a..39860ef 100644 --- a/flake.lock +++ b/flake.lock @@ -22,16 +22,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1734119587, - "narHash": "sha256-AKU6qqskl0yf2+JdRdD0cfxX4b9x3KKV5RqA6wijmPM=", + "lastModified": 1734536697, + "narHash": "sha256-G/HnRTtU+ob8x967kjzMRqjNFbAdllrcjYc+IcaR15Y=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "3566ab7246670a43abd2ffa913cc62dad9cdf7d5", + "rev": "9c40bef08a5bdc0ccc3207f4282a1ded83e77a7a", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-unstable", + "ref": "nixos-unstable-small", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index 3dc5c15..33b30b8 100644 --- a/flake.nix +++ b/flake.nix @@ -13,7 +13,10 @@ outputs = inputs@{ self, nixpkgs, ... }: let - kclib = (import ./lib.nix); + kclib = import ./lib.nix { + nixpkgs = inputs.nixpkgs; + inputs = inputs; + }; in { nixosConfigurations = { diff --git a/hosts/base.nix b/hosts/base.nix new file mode 100644 index 0000000..ba59127 --- /dev/null +++ b/hosts/base.nix @@ -0,0 +1,19 @@ +{ + ... +}: +{ + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + kropcloud = { + admin = { + user = "krop"; + sshKeys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIJl0Rdo2kHliBeIiPuiO4kYO5M0VZFNXw4siepV1p6Pj krop@wenar-nix" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOUnlAjPnMwJYgZb7YuholdTxifOEFnAyXVqI+xFlHw6 krop@lenar" + ]; + }; + }; + + system.stateVersion = "24.11"; +} diff --git a/lib.nix b/lib.nix index 8618f1c..b763a87 100644 --- a/lib.nix +++ b/lib.nix @@ -1,6 +1,5 @@ { nixpkgs, - lib, inputs, }: { @@ -8,6 +7,7 @@ nixpkgs.lib.nixosSystem = { system = arch; modules = [ + ./hosts/base.nix ./hosts/${name}.nix ./nixosModules ]; diff --git a/nixosModules/default.nix b/nixosModules/default.nix index b021e28..7335a40 100644 --- a/nixosModules/default.nix +++ b/nixosModules/default.nix @@ -1 +1,7 @@ -{ }: { } +{ }: +{ + imports = [ + ./users + ./locale + ]; +} diff --git a/nixosModules/locale/default.nix b/nixosModules/locale/default.nix new file mode 100644 index 0000000..881be9e --- /dev/null +++ b/nixosModules/locale/default.nix @@ -0,0 +1,52 @@ +{ config, lib, ... }: +let + cfg = config.kropcloud.locale; +in +{ + options.kropcloud.locale = { + timeZone = lib.mkOption { + type = lib.types.str; + default = "Europe/Prague"; + description = "The timezone for the system."; + }; + keyMap = lib.mkOption { + type = lib.types.str; + default = "cz-lat2"; + description = "The keymap to use for console input."; + }; + defaultLocale = lib.mkOption { + type = lib.types.str; + default = "en_GB.UTF-8"; + description = "The default locale for the system."; + }; + extraLocale = lib.mkOption { + type = lib.types.str; + default = "cs_CZ.UTF-8"; + description = "The locale to apply uniformly to all LC_* categories."; + }; + }; + + config = { + # Set the system timezone. + time.timeZone = cfg.timeZone; + + # Set the default locale. + i18n.defaultLocale = cfg.defaultLocale; + + # Apply the same locale to all LC_* categories. + i18n.extraLocaleSettings = lib.genAttrs [ + "LC_ADDRESS" + "LC_IDENTIFICATION" + "LC_MEASUREMENT" + "LC_MONETARY" + "LC_NAME" + "LC_NUMERIC" + "LC_PAPER" + "LC_TELEPHONE" + "LC_TIME" + ] (_: cfg.extraLocale); + + # Set the console keymap. + console.keyMap = cfg.keyMap; + }; +} diff --git a/nixosModules/users/default.nix b/nixosModules/users/default.nix new file mode 100644 index 0000000..ffb152c --- /dev/null +++ b/nixosModules/users/default.nix @@ -0,0 +1,27 @@ +{ config, lib, ... }: +let + cfg = config.kropcloud.admin; +in +{ + options.kropcloud.admin = { + user = lib.mkOption { + type = lib.types.str; + default = "krop"; + description = "Name of the admin user to be created."; + }; + sshKeys = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; + description = "List of SSH public keys to authorize for the admin user."; + }; + }; + + config = { + # Define the admin user + users.users.${cfg.user} = { + isNormalUser = true; + extraGroups = [ "wheel" ]; + openssh.authorizedKeys.keys = cfg.sshKeys; + }; + }; +}