Skip to content

Commit

Permalink
refactor: phase1 modularizing the host config for workplace
Browse files Browse the repository at this point in the history
Following the great example of gh/Misterio77, I start to split out the
host configuration of the workplace into a `common/core` part, present on
all systems and a `common/optional` part, to include only on selected
modules. In difference to Misterio77 repo, I do not only manage Linux
systems, but darwin as well. Therefore this repo will also have a
`common/darwin` folder.
  • Loading branch information
refnode committed Dec 26, 2024
1 parent 326b2ae commit 45daf94
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 63 deletions.
34 changes: 34 additions & 0 deletions hosts/common/core/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
pkgs,
inputs,
...
}: {
imports = [
./nix.nix
./fonts.nix
];

environment = {
systemPackages = [
pkgs.coreutils
pkgs.neovim-unwrapped
pkgs.git
];

shells = [
pkgs.bash
pkgs.zsh
];
};

programs.zsh = {
enable = true;
enableCompletion = true;
};

home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = {
inherit pkgs inputs;
};
}
12 changes: 12 additions & 0 deletions hosts/common/core/fonts.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{pkgs, ...}: {
fonts = {
packages = [
(pkgs.nerdfonts.override {
fonts = [
"JetBrainsMono"
"Meslo"
];
})
];
};
}
33 changes: 33 additions & 0 deletions hosts/common/core/nix.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{...}: {
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"
];
};
};

# Auto upgrade nix package and the daemon service.
services.nix-daemon.enable = true;
}
3 changes: 3 additions & 0 deletions hosts/common/darwin/core/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{...}: {
environment.systemPath = ["/opt/homebrew/bin"];
}
3 changes: 3 additions & 0 deletions hosts/common/users/refnode/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{config, ...}: {
home-manager.users.refnode = import ../../../../users/refnode/default.nix;
}
67 changes: 4 additions & 63 deletions hosts/defiant/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,65 +7,11 @@
}: {
imports = [
inputs.home-manager.darwinModules.home-manager
../common/core
../common/darwin/core
../common/users/refnode
];

# 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
];
};

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;

Expand All @@ -83,10 +29,5 @@
localHostName = "defiant";
};

home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = {inherit pkgs;};
users.refnode = import ../../users/refnode;
};
# home-manager.users.refnode = import ../../users/refnode;
}

0 comments on commit 45daf94

Please sign in to comment.