use standard module system over specialArgs

This commit is contained in:
seth 2024-05-01 18:00:23 -04:00
parent 6835947061
commit f295553095
Failed to generate hash of commit
9 changed files with 53 additions and 43 deletions

View file

@ -44,34 +44,52 @@
# the specialArgs are used to pass the inputs to the system configuration and home-manager configuration # the specialArgs are used to pass the inputs to the system configuration and home-manager configuration
specialArgs = { specialArgs = {
inherit inputs username hostname; inherit inputs;
}; };
in in
{ {
# it is important that you use darwin.lib.darwinSystem as this is the builder that allow # it is important that you use darwin.lib.darwinSystem as this is the builder that allow
# for the configuration of the darwin system # for the configuration of the darwin system
darwinConfigurations.${hostname} = darwin.lib.darwinSystem { darwinConfigurations.${hostname} = darwin.lib.darwinSystem {
inherit system;
# The specialArgs are used to pass the inputs to the system configuration # The specialArgs are used to pass the inputs to the system configuration
inherit specialArgs; inherit specialArgs;
modules = [ modules = [
./core.nix
./homebrew.nix ./homebrew.nix
./users.nix ./system.nix
# The home-manager module is used to configure home-manager # The home-manager module is used to configure home-manager
# to read more about this please see ../home-manager # to read more about this please see ../home-manager
home-manager.darwinModules.home-manager home-manager.darwinModules.home-manager
{ (
home-manager.useGlobalPkgs = true; { config, ... }:
home-manager.useUserPackages = true; {
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
# extraSpecialArgs is used to pass the inputs to the home-manager configuration # extraSpecialArgs is used to pass the inputs to the home-manager configuration
home-manager.extraSpecialArgs = specialArgs; home-manager.extraSpecialArgs = specialArgs;
# Here we have assume that the use is called "axel" but you can change that to your needs # Here we can create our user
home-manager.users.${username} = import ./home.nix; uses.users.${username} = {
} home = "/Users/${username}";
};
# And a home-manager configuration for them
home-manager.users.${username} = {
imports = [ ./home.nix ];
home.username = username;
};
# Here we set our (networking) host name and computer name. They should usually be the same
networking.hostName = hostname;
networking.computerName = config.networking.hostName;
}
)
]; ];
}; };
}; };

View file

@ -1,11 +1,10 @@
{ username, ... }: { config, ... }:
{ {
# Home Manager needs a bit of information about you and the # Home Manager needs a bit of information about you and the
# paths it should manage. # paths it should manage.
home = { home = {
# remember we set this in our flake.nix file # remember we set this in our flake.nix file
username = username; homeDirectory = "/Users/${config.home.username}";
homeDirectory = "/Users/${username}";
# This value determines the Home Manager release that your # This value determines the Home Manager release that your
# configuration is compatible with. This helps avoid breakage # configuration is compatible with. This helps avoid breakage

View file

@ -1,3 +1,4 @@
{ config, ... }:
{ {
config = { config = {
environment = { environment = {

View file

@ -2,6 +2,9 @@
# see <https://daiderd.com/nix-darwin/manual/index.html#sec-options> for more options # see <https://daiderd.com/nix-darwin/manual/index.html#sec-options> for more options
{ {
system = { system = {
# remember to set the hostname in the kernel command line
defaults.smb.NetBIOSName = config.networking.hostName;
# Add ability to used TouchID for sudo authentication # Add ability to used TouchID for sudo authentication
security.pam.enableSudoTouchIdAuth = true; security.pam.enableSudoTouchIdAuth = true;

View file

@ -1,9 +0,0 @@
{ username, hostname, ... }:
{
# remember to set the hostname in the kernel command line
networking.hostName = hostname;
networking.computerName = hostname;
system.defaults.smb.NetBIOSName = hostname;
users.users."${username}".home = "/Users/${username}";
}

View file

@ -16,7 +16,7 @@
}; };
outputs = outputs =
{ nixpkgs, home-manager, ... }: inputs@{ nixpkgs, home-manager, ... }:
let let
system = "x86_64-linux"; system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
@ -28,13 +28,17 @@
# Specify your home configuration modules here, for example, # Specify your home configuration modules here, for example,
# the path to your home.nix. # the path to your home.nix.
modules = [ ./home.nix ]; modules = [
./home.nix
{ home.username = username; }
];
extraSpecialArgs = {
inherit username pkgs; # We inherit pkgs
};
# Optionally use extraSpecialArgs # Optionally use extraSpecialArgs
# to pass through arguments to home.nix # to pass through arguments to home.nix
extraSpecialArgs = {
inherit inputs;
};
}; };
}; };
} }

View file

@ -1,15 +1,9 @@
{ { config, pkgs, ... }:
config,
pkgs,
username,
...
}:
{ {
# Home Manager needs a bit of information about you and the paths it should # Home Manager needs a bit of information about you and the paths it should
# manage. # manage.
home = { home = {
inherit username; homeDirectory = "/home/${config.home.username}";
homeDirectory = "/home/${username}";
# This value determines the Home Manager release that your configuration is # This value determines the Home Manager release that your configuration is
# compatible with. This helps avoid breakage when a new Home Manager release # compatible with. This helps avoid breakage when a new Home Manager release

View file

@ -2,8 +2,6 @@
config, config,
lib, lib,
pkgs, pkgs,
username,
hostName,
... ...
}: }:
@ -17,7 +15,6 @@
boot.loader.systemd-boot.enable = true; boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true; boot.loader.efi.canTouchEfiVariables = true;
networking.hostName = hostName; # Define your hostname.
# Pick only one of the below networking options. # Pick only one of the below networking options.
# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant.
# networking.networkmanager.enable = true; # Easiest to use and most distros use this by default. # networking.networkmanager.enable = true; # Easiest to use and most distros use this by default.
@ -59,7 +56,7 @@
# services.xserver.libinput.enable = true; # services.xserver.libinput.enable = true;
# Define a user account. Don't forget to set a password with passwd. # Define a user account. Don't forget to set a password with passwd.
users.users.${username} = { users.users.axol = {
isNormalUser = true; isNormalUser = true;
extraGroups = [ "wheel" ]; # Enable sudo for the user. extraGroups = [ "wheel" ]; # Enable sudo for the user.
packages = with pkgs; [ firefox ]; packages = with pkgs; [ firefox ];

View file

@ -4,17 +4,20 @@
inputs.nixpkgs.url = "github:auxolotl/nixpkgs/nixpkgs-unstable"; inputs.nixpkgs.url = "github:auxolotl/nixpkgs/nixpkgs-unstable";
outputs = outputs =
{ nixpkgs, ... }: inputs@{ nixpkgs, ... }:
let let
system = "x86_64-linux"; system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system};
hostName = builtins.abort "You need to fill in your hostName"; # Set this variable equal to your hostName hostName = builtins.abort "You need to fill in your hostName"; # Set this variable equal to your hostName
username = builtins.abort "You need to fill in your username"; # Set this variable equal to your username
in in
{ {
nixosConfigurations.${hostName} = nixpkgs.lib.nixosSystem { nixosConfigurations.${hostName} = nixpkgs.lib.nixosSystem {
inherit system; inherit system;
modules = [ ./configuration.nix ]; modules = [
./configuration.nix
{ networking.hostName = hostName; }
];
specialArgs = { specialArgs = {
inherit inputs; inherit inputs;
}; };