Make common modules compatible for nix-darwin

TODO: Determine why nushell config is populated twice
This commit is contained in:
Christopher Mühl 2025-08-06 23:14:38 +02:00
parent d20c9ac3bd
commit 53b8448159
33 changed files with 114 additions and 98 deletions

View file

@ -1,13 +1,16 @@
set shell := ["nu", "-c"] set shell := ["bash", "-c"]
editor := env('EDITOR') editor := env('EDITOR')
rebuild := if os() == "linux" { "nixos-rebuild" } else { "darwin-rebuild" }
default: default:
@just --list --justfile {{justfile()}} @just --list --justfile {{justfile()}}
# Runs `nixos-rebuild` # TODO: Run `pre-commit install` at some point
# Runs `nixos-rebuild` or `darwin-rebuild` depending on the OS
[group('nix')] [group('nix')]
deploy: deploy:
nixos-rebuild switch --flake . --use-remote-sudo sudo {{rebuild}} switch --flake .
europium: europium:
nixos-rebuild switch --flake .#europium --target-host europium --build-host europium --use-remote-sudo nixos-rebuild switch --flake .#europium --target-host europium --build-host europium --use-remote-sudo

View file

@ -16,8 +16,13 @@
nixos = [ nixos = [
agenix.nixosModules.default agenix.nixosModules.default
agenix-rekey.nixosModules.default agenix-rekey.nixosModules.default
./modules/common
];
darwin = [
agenix.darwinModules.default
agenix-rekey.nixosModules.default
./modules/common
]; ];
darwin = [];
}; };
# Add modules only to specific hosts # Add modules only to specific hosts
@ -41,7 +46,7 @@
// { // {
agenix-rekey = inputs.agenix-rekey.configure { agenix-rekey = inputs.agenix-rekey.configure {
userFlake = inputs.self; userFlake = inputs.self;
nixosConfigurations = inputs.self.nixosConfigurations; nixosConfigurations = inputs.self.nixosConfigurations // inputs.self.darwinConfigurations;
homeConfigurations = inputs.self.homeConfigurations; homeConfigurations = inputs.self.homeConfigurations;
}; };
}; };

View file

@ -0,0 +1,17 @@
{
pkgs,
config,
...
} @ all: {
elements.secrets = {
rekeyPath = "christopher_molybdenum";
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHl33DPxxzxrNNjM8rL4ktAj4ExzCyGiU8rKog0csxNA";
};
elements.kitty.enable = true;
home.packages = with pkgs; [
_elements.to-s3
_elements.connect-to-mercury
];
}

View file

@ -1,17 +0,0 @@
{...}: {
programs.kitty = {
enable = true;
settings = {
window_padding_width = "5 10";
font_family = "Monaspace Krypton";
paste_actions = "no-op";
};
extraConfig = ''
modify_font cell_height 7px
'';
themeFile = "Catppuccin-Frappe";
};
}

View file

@ -32,13 +32,11 @@
}; };
}; };
elements.kitty.enable = true;
home = { home = {
extraOutputsToInstall = ["doc" "devdoc"]; extraOutputsToInstall = ["doc" "devdoc"];
# Until Home Manager 24.11 releases
stateVersion = "23.11";
enableNixpkgsReleaseCheck = false;
packages = with pkgs._elements; [ packages = with pkgs._elements; [
quick-zeal quick-zeal
spawn-term spawn-term
@ -49,7 +47,5 @@
]; ];
}; };
programs.home-manager.enable = true;
# home.file.".config/Yubico/u2f_keys".text = "christopher:C7akk/T8XYov6fOk3rGo0ZW66QPMtdLnGznPuK+tTh/qmPecvECzGVMKJuh5M7nYsMoT6r/idAP88FGinf/rpw==,ydS/PgUALZriaaHYS81u3x8rRFulq727GDJRlvbJhP2yeKK7Ih+xqRceyabLR3MxRN8PT/MtC1I/Xjaxl0S2Rg==,es256,+presence"; # home.file.".config/Yubico/u2f_keys".text = "christopher:C7akk/T8XYov6fOk3rGo0ZW66QPMtdLnGznPuK+tTh/qmPecvECzGVMKJuh5M7nYsMoT6r/idAP88FGinf/rpw==,ydS/PgUALZriaaHYS81u3x8rRFulq727GDJRlvbJhP2yeKK7Ih+xqRceyabLR3MxRN8PT/MtC1I/Xjaxl0S2Rg==,es256,+presence";
} }

View file

@ -0,0 +1,23 @@
{
inputs,
pkgs,
...
}: {
# This module is common to all systems, both nixos and darwin. It is
# automatically added to all hosts via the flake configuration.
imports = [
./elements.nix
./secrets.nix
./nix.nix
./programs/home-manager.nix
];
environment.systemPackages = with pkgs; [
pre-commit
git
gitleaks
just
];
}

View file

@ -4,9 +4,6 @@
config, config,
... ...
}: { }: {
# Needed for Nix flakes
environment.systemPackages = [pkgs.git];
nix.settings = { nix.settings = {
# auto-optimize-store = true; # auto-optimize-store = true;
# builders-use-substitutes = true; # builders-use-substitutes = true;

0
modules/darwin/.keep Normal file
View file

View file

@ -1,6 +0,0 @@
{...}: {
# Use the same secrets (agenix) module for darwin as we have already configured
# for nixos as its functionality is not system-dependent.
imports = [../../nixos/secrets];
}

View file

@ -0,0 +1,13 @@
{...}: {
imports = [
./helix
./terminal
];
home = {
stateVersion = "23.11";
enableNixpkgsReleaseCheck = false;
};
programs.home-manager.enable = true;
}

View file

@ -7,8 +7,7 @@ in {
./programs ./programs
./shell/aliases.nix ./shell/aliases.nix
./shell/prompt.nix ./shell/prompt.nix
./shell/nu # ./shell/nu
./shell/zsh
]; ];
# add environment variables # add environment variables
@ -22,7 +21,6 @@ in {
TERMINAL = "kitty"; TERMINAL = "kitty";
EDITOR = "hx"; EDITOR = "hx";
TERM = "xterm-color"; TERM = "xterm-color";
# QT_QPA_PLATFORMTHEME = "qt5ct";
# auto-run programs using nix-index-database # auto-run programs using nix-index-database
NIX_AUTO_RUN = "1"; NIX_AUTO_RUN = "1";

View file

@ -72,12 +72,6 @@
} }
} }
$env.PATH = ($env.PATH |
split row (char esep) |
prepend /home/myuser/.apps |
append /usr/bin/env
)
def agx [search] { def agx [search] {
hx (ag $search | fzf | cut -d : -f 1,2) hx (ag $search | fzf | cut -d : -f 1,2)
} }
@ -90,6 +84,7 @@
| append $"($env.HOME)/code/hausgold/snippets/bin" | append $"($env.HOME)/code/hausgold/snippets/bin"
| append $"($env.HOME)/.bun/bin" | append $"($env.HOME)/.bun/bin"
| append $"($env.HOME)/.npm/bin" | append $"($env.HOME)/.npm/bin"
| append /usr/bin/env
) )
''; '';
}; };

View file

@ -0,0 +1,5 @@
{...}: {
imports = [
./kitty.nix
];
}

View file

@ -0,0 +1,34 @@
{
config,
pkgs,
lib,
...
}:
with lib; let
cfg = config.elements;
in {
options = {
elements.kitty = {
enable = mkEnableOption "kitty";
};
};
config = mkIf cfg.kitty.enable {
programs.kitty = {
enable = true;
settings = {
window_padding_width = "5 10";
font_family = "Monaspace Krypton";
paste_actions = "no-op";
};
extraConfig = ''
shell ${pkgs.nushell}/bin/nu
modify_font cell_height 7px
'';
themeFile = "Catppuccin-Frappe";
};
};
}

View file

@ -1,6 +1,4 @@
{lib, ...}: { {lib, ...}: {
documentation.dev.enable = true;
i18n = { i18n = {
defaultLocale = "en_US.UTF-8"; defaultLocale = "en_US.UTF-8";
supportedLocales = [ supportedLocales = [

View file

@ -1,19 +1,6 @@
{ {...}: {
inputs,
pkgs,
...
}: {
imports = [ imports = [
./core ./core
./core/users.nix ./core/users.nix
./core/nix.nix
./programs/home-manager.nix
./programs/zsh.nix
];
environment.systemPackages = with pkgs; [
pre-commit
gitleaks
]; ];
} }

View file

@ -1,26 +0,0 @@
{
environment.pathsToLink = ["/share/zsh"];
programs = {
less.enable = true;
zsh = {
enable = true;
autosuggestions.enable = true;
syntaxHighlighting = {
enable = true;
patterns = {
"rm -rf *" = "fg=black,bg=red";
};
styles = {
"aliases" = "fg=magenta";
};
highlighters = [
"main"
"brackets"
"pattern"
];
};
};
};
}

View file

@ -11,5 +11,6 @@
}; };
}; };
users.users.christopher = {}; # For some reason this is required for hm to work. # For some reason this is required for hm to work with nix-darwin
users.users.christopher = {};
} }

View file

@ -19,6 +19,8 @@ with lib._elements; {
./beszel-agent.nix ./beszel-agent.nix
./wayland.nix ./wayland.nix
# TODO: Add config settings like "services.shutdown.enable = true;"
"${inputs.self}/modules/nixos/common/services/shutdown.nix" "${inputs.self}/modules/nixos/common/services/shutdown.nix"
]; ];
@ -49,9 +51,6 @@ with lib._elements; {
# Set your time zone. # Set your time zone.
time.timeZone = "Europe/Berlin"; time.timeZone = "Europe/Berlin";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
console = { console = {
font = "Lat2-Terminus16"; font = "Lat2-Terminus16";
useXkbConfig = true; # use xkbOptions in tty. useXkbConfig = true; # use xkbOptions in tty.
@ -131,8 +130,6 @@ with lib._elements; {
pinentryPackage = pkgs.pinentry-gtk2; pinentryPackage = pkgs.pinentry-gtk2;
enableSSHSupport = true; enableSSHSupport = true;
}; };
zsh.enable = true;
}; };
environment = { environment = {

View file

@ -58,15 +58,11 @@ with lib._elements; {
gnumake gnumake
]; ];
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
console = { console = {
font = "Lat2-Terminus16"; font = "Lat2-Terminus16";
keyMap = lib.mkForce "de"; keyMap = lib.mkForce "de";
}; };
programs.zsh.enable = true;
programs.vim.enable = true; programs.vim.enable = true;
programs.git.enable = true; programs.git.enable = true;