Skip to content

Commit

Permalink
convert host module parameter into proper options
Browse files Browse the repository at this point in the history
Also remote Wootility module as this exists already in nixpkgs.
  • Loading branch information
hfxbse committed Jan 23, 2025
1 parent 84405cf commit 1267d2b
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 212 deletions.
24 changes: 7 additions & 17 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@

outputs = { self, cups-brother-hl3172cdw, disko, nixpkgs, nixvim }@attrs:
let
fullName = {
user.fullName = "Fabian Haas";
};

defaultModules = [
fullName
# Nixvim needs to be an top level import
# Will fail due to infinit recursion otherwise
nixvim.nixosModules.nixvim
Expand All @@ -32,19 +37,13 @@
./modules/text-processing.nix
./modules/workplace-compliance.nix
./modules/printing.nix
./modules/hardware/Wooting/wootility.nix
./modules/development.nix
];
in
{
nixosConfigurations.home-pc = nixpkgs.lib.nixosSystem {
specialArgs = with attrs; {
cups-brother-hl3172cdw = cups-brother-hl3172cdw.packages.x86_64-linux.default;
host = {
user.name = "fxbse";
user.description = "Fabian Haas";
name = "ice-cube";
};
};

system = "x86_64-linux";
Expand All @@ -54,11 +53,6 @@
nixosConfigurations.nt-laptop = nixpkgs.lib.nixosSystem {
specialArgs = with attrs; {
cups-brother-hl3172cdw = cups-brother-hl3172cdw.packages.x86_64-linux.default;
host = rec {
user.name = "fhs";
user.description = "Fabian Haas";
name = "nt-${user.name}";
};
};

system = "x86_64-linux";
Expand All @@ -67,27 +61,23 @@

nixosConfigurations.iso = nixpkgs.lib.nixosSystem {
specialArgs = with attrs; {
host.user.description = "Fabian Haas";

# TODO add your WiFi credentials
# wifi.ssid
# wifi.psk
};

modules = [
fullName
nixvim.nixosModules.nixvim
./modules/text-processing.nix
./hosts/iso/configuration.nix
];
};

nixosConfigurations.server = nixpkgs.lib.nixosSystem {
specialArgs = with attrs; {
host.user.description = "Fabian Haas";
};

system = "x86_64-linux";
modules = [
fullName
nixvim.nixosModules.nixvim
disko.nixosModules.disko
./modules/text-processing.nix
Expand Down
13 changes: 11 additions & 2 deletions hosts/home-pc/configuration.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{ config, pkgs, host, ... }:
{ config, pkgs, ... }:
let
user = config.user;
in
{
imports = [ ./hardware-configuration.nix ];

Expand All @@ -23,12 +26,18 @@
cpuFreqGovernor = "schedutil";
};

# Setup user and machine naming.
networking.hostName = "ice-cube";
user.name = "fxbse";

# Desktop setup.
desktop = {
enable = true;
login = "auto"; # No need to login againt to reach the desktop after LUKS decryption
};

hardware.wooting.enable = true;

# Development setup.
development = {
container.enable = true;
Expand All @@ -41,7 +50,7 @@
programs.dconf.enable = true;

# Define a user account. Don't forget to set a password with ‘passwd’.
users.users.${host.user.name} = {
users.users.${user.name} = {
isNormalUser = true;
extraGroups = [
"networkmanager"
Expand Down
11 changes: 9 additions & 2 deletions hosts/nt-laptop/configuration.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Laptop model: Lenovo Thinkpad P15 Gen 1

{ config, pkgs, host, ... }:
{ config, pkgs, ... }:
let
user = config.user;
in
{
imports = [
./hardware-configuration.nix
Expand All @@ -24,6 +27,10 @@

services.logind.lidSwitch = "lock";

# Setup user and machine naming.
networking.hostName = "nt-${user.name}";
user.name = "fhs";

# Workplace compliance.
workplaceCompliance = {
enable = true;
Expand All @@ -48,7 +55,7 @@
programs.dconf.enable = true;

# Define a user account. Don't forget to set a password with ‘passwd’.
users.users.${host.user.name} = {
users.users.${user.name} = {
isNormalUser = true;
extraGroups = [
"networkmanager"
Expand Down
14 changes: 9 additions & 5 deletions modules/desktop/desktop.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{ config, host, lib, pkgs, ... }:
{ config, lib, pkgs, ... }:
let
cfg = config.desktop;
hostname = host.name;
username = host.user.name;
user = config.user;
in
{
imports = [ ./gnome.nix ];
Expand All @@ -29,8 +28,12 @@ in
};
};

options.user.name = lib.mkOption {
description = "The username of the user of the maschine";
type = lib.types.str;
};

config = lib.mkIf cfg.enable {
networking.hostName = lib.mkDefault hostname;
networking.networkmanager.enable = lib.mkDefault true;

# not to sure why this is done, but this is what the installer set up
Expand All @@ -52,12 +55,13 @@ in
};

services.libinput.enable = lib.mkDefault cfg.touchpad.enable;
users.groups.input.members = lib.optional config.hardware.wooting.enable user.name;

services.printing.enable = true;

# Enable automatic login for the user.
services.displayManager.autoLogin.enable = cfg.login == "auto";
services.displayManager.autoLogin.user = lib.mkDefault username;
services.displayManager.autoLogin.user = lib.mkDefault user.name;

boot.supportedFilesystems = [ "ntfs" ];
# Support mounting MTP devices
Expand Down
4 changes: 2 additions & 2 deletions modules/development.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{ config, lib, pkgs, host, ... }:
{ config, lib, pkgs, ... }:
let
cfg = config.development;
username = host.user.name;
username = config.user.name;
in
{
options.development = {
Expand Down
97 changes: 0 additions & 97 deletions modules/hardware/Wooting/wootility-udev.rules

This file was deleted.

12 changes: 0 additions & 12 deletions modules/hardware/Wooting/wootility.nix

This file was deleted.

Loading

0 comments on commit 1267d2b

Please sign in to comment.