summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2025-02-21 08:46:20 +0100
committerMartin Fischer <martin@push-f.com>2025-02-21 08:46:44 +0100
commit370f034436112632dac273757d5d7ad5807136fc (patch)
tree2d0a176bbdfff80c021d5a7c10f5c36e063d98b7
parent583732cb08ceb5d2ad6cd0c7ac13b06096c31235 (diff)
refactor: move user config to workstation profile
-rw-r--r--nixos/hosts/hamac/default.nix14
-rw-r--r--nixos/profiles/workstation/default.nix54
2 files changed, 40 insertions, 28 deletions
diff --git a/nixos/hosts/hamac/default.nix b/nixos/hosts/hamac/default.nix
index d17b155..e768648 100644
--- a/nixos/hosts/hamac/default.nix
+++ b/nixos/hosts/hamac/default.nix
@@ -11,6 +11,8 @@
<top/shared/vpn.nix>
];
+ workstation.username = "martin";
+
# Bootloader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
@@ -35,18 +37,6 @@
LC_TIME = "en_US.UTF-8";
};
- users.users.martin = {
- isNormalUser = true;
- description = "Martin";
- extraGroups = [ "networkmanager" "wheel" ];
- packages = with pkgs; [];
- };
-
- services.getty = {
- autologinUser = "martin";
- autologinOnce = true; # only in the first tty once per boot
- };
-
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [
diff --git a/nixos/profiles/workstation/default.nix b/nixos/profiles/workstation/default.nix
index 8a77434..fee6a86 100644
--- a/nixos/profiles/workstation/default.nix
+++ b/nixos/profiles/workstation/default.nix
@@ -1,6 +1,7 @@
-{ config, pkgs, ... }:
+{ config, lib, pkgs, ... }:
let
+ cfg = config.workstation;
npins = import ../../npins;
nixGit = import (pkgs.fetchFromGitHub {
owner = "NixOS";
@@ -10,6 +11,12 @@ let
});
in
{
+ options.workstation = {
+ username = lib.mkOption {
+ type = lib.types.str;
+ };
+ };
+
imports = [
../common
<top/shared/basics-physical.nix>
@@ -18,23 +25,38 @@ in
./create.nix
];
- environment.systemPackages = [
- pkgs.npins
- (pkgs.callPackage "${npins.agenix}/pkgs/agenix.nix" {})
+ config = {
+ users.users.${cfg.username} = {
+ isNormalUser = true;
+ extraGroups = [
+ "wheel"
+ "networkmanager"
+ ];
+ };
- pkgs.unzip
- ];
+ services.getty = {
+ autologinUser = cfg.username;
+ autologinOnce = true; # only in the first tty once per boot
+ };
- environment.sessionVariables = {
- # Tell .zshrc to source zshrc-workstation.sh.
- MYNIX_PROFILE = "workstation";
- };
+ environment.systemPackages = [
+ pkgs.npins
+ (pkgs.callPackage "${npins.agenix}/pkgs/agenix.nix" {})
- # Age defaults to this anyway when openssh is enabled.
- # We're setting this here for workstations where openssh is disabled.
- age.identityPaths = ["/etc/ssh/ssh_host_ed25519_key"];
+ pkgs.unzip
+ ];
- # Using nix from git for --raw support in nix-instantiate --eval.
- # FUTURE: remove once upgrading to NixOS 25.05
- nix.package = nixGit.packages.${builtins.currentSystem}.default;
+ environment.sessionVariables = {
+ # Tell .zshrc to source zshrc-workstation.sh.
+ MYNIX_PROFILE = "workstation";
+ };
+
+ # Age defaults to this anyway when openssh is enabled.
+ # We're setting this here for workstations where openssh is disabled.
+ age.identityPaths = ["/etc/ssh/ssh_host_ed25519_key"];
+
+ # Using nix from git for --raw support in nix-instantiate --eval.
+ # FUTURE: remove once upgrading to NixOS 25.05
+ nix.package = nixGit.packages.${builtins.currentSystem}.default;
+ };
}