From 3b10b2f7f2e5b42a3932286e19c76adbddbdf983 Mon Sep 17 00:00:00 2001 From: John Ogle Date: Sat, 10 Jan 2026 11:00:44 -0800 Subject: [PATCH] Extract shared NixOS/Darwin base config into roles/common.nix Create roles/common.nix containing shared configuration between NixOS and Darwin: timezone, base packages (git, glances, pciutils, tree, usbutils, vim), nix settings (experimental-features, max-jobs, trusted-users), gc config, and allowUnfree setting. Both roles/default.nix and roles/darwin.nix now import common.nix and only contain platform-specific configuration. --- roles/common.nix | 35 +++++++++++++++++++++++++++++++++++ roles/darwin.nix | 45 +++++---------------------------------------- roles/default.nix | 41 +++-------------------------------------- 3 files changed, 43 insertions(+), 78 deletions(-) create mode 100644 roles/common.nix diff --git a/roles/common.nix b/roles/common.nix new file mode 100644 index 0000000..c8908d2 --- /dev/null +++ b/roles/common.nix @@ -0,0 +1,35 @@ +# Common configuration shared between NixOS and Darwin +{ lib, pkgs, ... }: + +{ + config = { + time.timeZone = "America/Los_Angeles"; + + environment.systemPackages = with pkgs; [ + git + glances + pciutils + tree + usbutils + vim + ]; + + nix = { + package = pkgs.nix; + settings = { + experimental-features = [ "nix-command" "flakes" ]; + max-jobs = "auto"; + trusted-users = [ "johno" ]; + substituters = [ + ]; + }; + + gc = { + automatic = true; + options = "--delete-older-than 10d"; + }; + }; + + nixpkgs.config.allowUnfree = true; + }; +} diff --git a/roles/darwin.nix b/roles/darwin.nix index 8f88135..d2880e7 100644 --- a/roles/darwin.nix +++ b/roles/darwin.nix @@ -7,6 +7,10 @@ let setEnvironmentPath = "${config.system.build.setEnvironment}"; in { + imports = [ + ./common.nix + ]; + config = { # Salt manages /etc/bashrc, /etc/zshrc, /etc/zshenv # nix-darwin writes to .local variants for nix-specific configuration @@ -43,8 +47,6 @@ in fi ''; - time.timeZone = "America/Los_Angeles"; - # System preferences system.defaults = { # Custom keyboard shortcuts @@ -79,42 +81,5 @@ in }; }; }; - - environment.systemPackages = with pkgs; [ - git - glances - pciutils - tree - usbutils - vim - ]; - - nix = { - package = pkgs.nix; - # distributedBuilds = true; - # buildMachines = [{ - # hostName = "z790prors.oglehome"; - # system = "x86_64-linux"; - # protocol = "ssh-ng"; - # sshUser = "johno"; - # sshKey = "/root/.ssh/id_ed25519"; - # maxJobs = 3; - # speedFactor = 2; - # }]; - settings = { - experimental-features = [ "nix-command" "flakes" ]; - max-jobs = "auto"; - trusted-users = [ "johno" ]; - substituters = [ - ]; - }; - - gc = { - automatic = true; - options = "--delete-older-than 10d"; - }; - }; - - nixpkgs.config.allowUnfree = true; }; -} \ No newline at end of file +} diff --git a/roles/default.nix b/roles/default.nix index a2bd665..ceddcc7 100644 --- a/roles/default.nix +++ b/roles/default.nix @@ -4,6 +4,7 @@ with lib; { imports = [ + ./common.nix ./audio ./bluetooth ./btrfs @@ -31,7 +32,6 @@ with lib; LC_TELEPHONE = "en_US.UTF-8"; LC_TIME = "en_US.UTF-8"; }; - time.timeZone = "America/Los_Angeles"; services.xserver.xkb = { layout = "us"; @@ -49,42 +49,7 @@ with lib; # Enable the OpenSSH daemon. services.openssh.enable = true; - environment.systemPackages = with pkgs; [ - git - glances - pciutils - tree - usbutils - vim - ]; - - nix = { - package = pkgs.nix; - # distributedBuilds = true; - # buildMachines = [{ - # hostName = "z790prors.oglehome"; - # system = "x86_64-linux"; - # protocol = "ssh-ng"; - # sshUser = "johno"; - # sshKey = "/root/.ssh/id_ed25519"; - # maxJobs = 3; - # speedFactor = 2; - # }]; - settings = { - experimental-features = [ "nix-command" "flakes" ]; - max-jobs = "auto"; - trusted-users = [ "johno" ]; - substituters = [ - ]; - }; - - gc = { - automatic = true; - randomizedDelaySec = "14m"; - options = "--delete-older-than 10d"; - }; - }; - - nixpkgs.config.allowUnfree = true; + # NixOS-specific gc option (not available on Darwin) + nix.gc.randomizedDelaySec = "14m"; }; }