Skip to content

Commit

Permalink
fix(hosts/defiant): streamline host definitions, skip library approach
Browse files Browse the repository at this point in the history
In the previous configuration I used a library approach to generate
host configurations. This approach makes it more complicated to handle
different kind of host configurations and adds an unnecessary
abstraction layer.

Streamline the config defining darwin and nixos configurations directly
in the flake.
  • Loading branch information
refnode committed Nov 16, 2024
1 parent b50e9dd commit b5d3de3
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 47 deletions.
24 changes: 9 additions & 15 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -107,21 +107,15 @@

# Build darwin flake using:
# $ darwin-rebuild build --flake .#defiant

darwinConfigurations = let
system = "aarch64-darwin";
pkgs = pkgsFor.${system};
in {
defiant = import ./lib {
inherit
pkgs
nix-darwin
home-manager
system
user
flake
inputs
;
darwinConfigurations = {
defiant = nix-darwin.lib.darwinSystem {
system = "aarch64-darwin";
modules = [./hosts/defiant];
specialArgs = {
inherit flake inputs;
system = "aarch64-darwin";
pkgs = pkgsFor.aarch64-darwin;
};
};
};

Expand Down
94 changes: 94 additions & 0 deletions hosts/defiant/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
{
pkgs,
flake,
system,
inputs,
...
}: {
imports = [
inputs.home-manager.darwinModules.home-manager
];

# List packages installed in system profile. To search by name, run:
# $ nix-env -qaP | grep wget
environment = {
systemPackages = [
pkgs.coreutils
pkgs.vim
pkgs.git
];

shells = [
pkgs.bash
pkgs.zsh
];

loginShell = pkgs.zsh;
};

fonts = {
packages = [
(pkgs.nerdfonts.override {
fonts = [
"JetBrainsMono"
"Meslo"
];
})
];
};

# Auto upgrade nix package and the daemon service.
services.nix-daemon.enable = true;

nix = {
# package = pkgs.nixVersions.nix_2_16;
checkConfig = true;
configureBuildUsers = true;
settings = {
# Necessary for using flakes on this system.
experimental-features = "nix-command flakes";
allowed-users = [
"@admin"
];
# disable it, enabling leads to some symlink problems
# on macOS
auto-optimise-store = false;
cores = 6;
extra-sandbox-paths = [];
max-jobs = "auto";
require-sigs = true;
sandbox = false;
# substituters = [];
# trusted-public-keys = [];
trusted-users = [
"@admin"
];
};
};

programs.zsh.enable = true;

# TODO https://discourse.nixos.org/t/give-name-label-comment-to-generations/45355
system.configurationRevision = flake.rev or flake.dirtyRev or null;

# Used for backwards compatibility,
# please read the changelog before changing.
# $ darwin-rebuild changelog
system.stateVersion = 4;

# The platform the configuration will be used on.
nixpkgs.hostPlatform = system;

networking = {
computerName = "defiant";
hostName = "defiant";
localHostName = "defiant";
};

home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = {inherit pkgs;};
users.refnode = import ../../users/refnode;
};
}
34 changes: 2 additions & 32 deletions lib/default.nix
Original file line number Diff line number Diff line change
@@ -1,32 +1,2 @@
{
pkgs,
nix-darwin,
home-manager,
system,
user,
flake,
inputs,
...
}: let
osConfig = ../hosts/darwin-base.nix;
userHomeConfig = ../users/${user};
systemFn = nix-darwin.lib.darwinSystem;
home-manager = inputs.home-manager.darwinModules.home-manager;
in
systemFn {
modules = [
osConfig
{_module.args = {inherit flake;};}
home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.${user} = import userHomeConfig {
inherit pkgs user;
};
# Optionally, use home-manager.extraSpecialArgs to pass
# arguments to home.nix
# home-manager.extraSpecialArgs = { inherit lib; };
}
];
}
{...}: {
}

0 comments on commit b5d3de3

Please sign in to comment.