Skip to content

Commit

Permalink
Organize hosts and home (#75)
Browse files Browse the repository at this point in the history
* Reorganize host config

Host config got a bit mixed up, as well as having issues like
core and core-darwin having unnecessarily similar names, so
we regroup into better "bundles" by platform and purpose.

* Reorganize home config

Sort out home config into bundles for more opaque option selection
per host.

* Separate nixos-specific and darwin-specific options

Right now nixos rejects unfamiliar options and darwin may do the same. For now we separate into different bundles that are included. In the future this could potentially be further sorted out.
  • Loading branch information
NoRePercussions authored Sep 9, 2024
1 parent b79b304 commit cb26316
Show file tree
Hide file tree
Showing 51 changed files with 171 additions and 139 deletions.
24 changes: 20 additions & 4 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@
./hosts/elmira
home-manager.darwinModules.home-manager
{
home-manager.users.tuckershea = import ./home/tuckershea/elmira.nix;
home-manager.users.tuckershea.imports = [
./home/tuckershea/shell
./home/tuckershea/graphical
./home/tuckershea/darwin
./home/tuckershea/hosts/elmira
];
home-manager.extraSpecialArgs = {inherit inputs outputs;};
}
];
};
Expand All @@ -68,7 +74,10 @@
impermanence.nixosModules.impermanence
disko.nixosModules.disko
{
home-manager.users.tuckershea = import ./home/tuckershea/marlon.nix;
home-manager.users.tuckershea.imports = [
./home/tuckershea/shell
];
home-manager.extraSpecialArgs = {inherit inputs outputs;};
}
];
};
Expand All @@ -83,7 +92,10 @@
impermanence.nixosModules.impermanence
disko.nixosModules.disko
{
home-manager.users.tuckershea = import ./home/tuckershea/roland.nix;
home-manager.users.tuckershea.imports = [
./home/tuckershea/shell
];
home-manager.extraSpecialArgs = {inherit inputs outputs;};
}
];
};
Expand All @@ -96,7 +108,11 @@
sops-nix.nixosModules.sops
home-manager.nixosModules.home-manager
{
home-manager.users.tuckershea = import ./home/tuckershea/vic.nix;
home-manager.users.tuckershea.imports = [
./home/tuckershea/shell
./home/tuckershea/graphical
];
home-manager.extraSpecialArgs = {inherit inputs outputs;};
}
];
};
Expand Down
6 changes: 0 additions & 6 deletions home/tuckershea/common/core/pyenv.nix

This file was deleted.

5 changes: 5 additions & 0 deletions home/tuckershea/darwin/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
imports = [
./defaults.nix
];
}
File renamed without changes.
14 changes: 0 additions & 14 deletions home/tuckershea/elmira.nix

This file was deleted.

File renamed without changes.
6 changes: 6 additions & 0 deletions home/tuckershea/graphical/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
imports = [
./alacritty.nix
./surfingkeys
];
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
imports = [
./ssh.nix
];
}
6 changes: 6 additions & 0 deletions home/tuckershea/hosts/elmira/git.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{ ... }:
{
programs.git.extraConfig = {
"gpg \"ssh\"".program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign";
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
};

home.file.".ssh/.keep".text = "Managed by home-manager";
home.file.".ssh/id_tuckershea_elmira.pub".source = ../../../../../resources/publickeys/id_tuckershea_elmira.pub;
home.file.".ssh/id_tuckershea_elmira.pub".source = ../../../../resources/publickeys/id_tuckershea_elmira.pub;
}
5 changes: 0 additions & 5 deletions home/tuckershea/marlon.nix

This file was deleted.

5 changes: 0 additions & 5 deletions home/tuckershea/roland.nix

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
...
}: {
imports = [
inputs.nix-index-database.hmModules.nix-index

./fzf.nix
./git.nix
./neovim.nix
./pyenv.nix
./surfingkeys
./nix-index.nix
./ripgrep.nix
./thefuck.nix
./tmux
./zsh
Expand Down Expand Up @@ -41,14 +39,4 @@
tailscale
wget
];

programs.ripgrep = {
enable = true;
arguments = [
"--max-columns=150"
"--smart-case"
];
};

programs.nix-index-database.comma.enable = true;
}
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{lib, ...}: {
{
lib,
pkgs,
...
}: {
programs.git = {
enable = true;
delta.enable = true;
Expand All @@ -13,7 +17,7 @@
"**/._.DS_Store"
];
signing = {
key = lib.removeSuffix "\n" (builtins.readFile ../../../../resources/publickeys/id_norepercussions_github.pub);
key = lib.removeSuffix "\n" (builtins.readFile ../../../resources/publickeys/id_norepercussions_github.pub);
signByDefault = true;
};
userEmail = "[email protected]";
Expand All @@ -22,9 +26,6 @@
gpg.format = "ssh";
core.autocrlf = "input";
init.defaultBranch = "main";

# todo: change this for non-mac systems
"gpg \"ssh\"".program = "/Applications/1Password.app/Contents/MacOS/op-ssh-sign";
};
};
}
File renamed without changes.
8 changes: 8 additions & 0 deletions home/tuckershea/shell/nix-index.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{ inputs, ... }:
{
imports = [
inputs.nix-index-database.hmModules.nix-index
];

programs.nix-index-database.comma.enable = true;
}
9 changes: 9 additions & 0 deletions home/tuckershea/shell/ripgrep.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
programs.ripgrep = {
enable = true;
arguments = [
"--max-columns=150"
"--smart-case"
];
};
}
26 changes: 26 additions & 0 deletions home/tuckershea/shell/ssh.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{lib, ...}:
{
programs.ssh = {
enable = true;
serverAliveInterval = 30;

matchBlocks = {
famat = lib.hm.dag.entryBefore ["*"] {
hostname = "ssh.pythonanywhere.com";
user = "famat";
identitiesOnly = true;
};
andrew = lib.hm.dag.entryBefore ["*"] {
hostname = "unix.andrew.cmu.edu";
user = "tshea";
};
};

extraConfig = lib.mkMerge [
"GSSAPIAuthentication yes"
"GSSAPIDelegateCredentials yes"
];
};

home.file.".ssh/.keep".text = "Managed by home-manager";
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 0 additions & 7 deletions home/tuckershea/vic.nix

This file was deleted.

10 changes: 0 additions & 10 deletions hosts/common/core/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@
./git.nix
./locale.nix
./nix.nix
./openssh.nix
./registry.nix
./zsh.nix
];

home-manager.extraSpecialArgs = {inherit inputs outputs;};

nixpkgs = {
config = {
allowUnfree = true;
};
};
}
68 changes: 38 additions & 30 deletions hosts/common/core/nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,48 @@
options,
...
}:
lib.mkMerge [
{
nix = {
settings = {
# auto-optimise-store = true;
experimental-features = ["nix-command" "flakes"];
warn-dirty = false;
{
nix = {
settings = {
auto-optimise-store = true;
experimental-features = ["nix-command" "flakes"];
warn-dirty = false;

trusted-public-keys = [
"hydra.nixos.org-1:CNHJZBh9K4tP3EKF6FkkgeVYsS3ohTl+oS0Qa8bezVs="
"tuckershea.cachix.org-1:a9DdtLF8DyqAHFV7VHlA7YvasP6wUMHdOygVyks3JGM="
];

# Maybe make this darwin-specific?
extra-platforms = ["x86_64-darwin" "aarch64-darwin"];
substituters = [
"https://cache.nixos.org/"
"https://tuckershea.cachix.org"
];
};

trusted-public-keys = [
"hydra.nixos.org-1:CNHJZBh9K4tP3EKF6FkkgeVYsS3ohTl+oS0Qa8bezVs="
"tuckershea.cachix.org-1:a9DdtLF8DyqAHFV7VHlA7YvasP6wUMHdOygVyks3JGM="
];
gc = {
automatic = true;

substituters = [
"https://cache.nixos.org/"
"https://tuckershea.cachix.org"
];
};
# GC every Monday morning
# customized in hosts/common/darwin/nix.nix
# and hosts/common/nixos/nix.nix

gc = {
automatic = true;
# nixos and darwin have different ways to configure
# this interval, so instead we just leave it to
# the default of 3:15 daily, which is fine.
options = "--delete-older-than 7d";
# keep profile generations around for one week
options = "--delete-older-than 7d";
};

registry = {
# Lock nixpkgs so we don't need to download it
# every time we want to do nix run/develop/etc
nixpkgs = {
from = { id = "nixpkgs"; type = "indirect"; };
flake = inputs.nixpkgs;
};
};
}
};

# nix-daemon only on darwin, check option to avoid recursion
(lib.optionalAttrs (lib.hasAttr "nix-daemon" options.services) {
services.nix-daemon.enable = true;
})
]
nixpkgs = {
config = {
allowUnfree = true;
};
};
}
9 changes: 0 additions & 9 deletions hosts/common/core/registry.nix

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
imports = [
./auto-font-smoothing.nix
./font-smoothing.nix
./keyboard.nix
./nix.nix
];
}
File renamed without changes.
File renamed without changes.
10 changes: 10 additions & 0 deletions hosts/common/darwin/nix.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
nix.settings.extra-platforms = ["x86_64-darwin" "aarch64-darwin"];
services.nix-daemon.enable = true;

nix.gc.interval = [{
Hour = 3;
Minute = 15;
Weekday = 1;
}];
}
5 changes: 5 additions & 0 deletions hosts/common/graphical/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{ ... }: {
imports = [
./fonts.nix
];
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
imports = [
./auto-upgrade.nix
./network.nix
./nix.nix
./no-wait-online.nix # mitigate NetworkManager Wait-Online failure
./node-exporter.nix
./openssh.nix
./sudo-no-password.nix # don't require password for sudo
./tailscale.nix
];
Expand Down
File renamed without changes.
4 changes: 4 additions & 0 deletions hosts/common/nixos/nix.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{ ... }:
{
nix.gc.dates = "Mon *-*-* 03:15:00";
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
lib,
pkgs,
...
}: {
services.openssh = lib.optionalAttrs pkgs.stdenv.isLinux {
}:
{
services.openssh = {
enable = true;
ports = [22]; # change this later?

Expand Down
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit cb26316

Please sign in to comment.