Setup nix flake to work with darwin, wsl and linux system configuration. This has ONLY been tested on Darwin so far.

This commit is contained in:
Martin Lasson 2025-01-26 00:29:25 +01:00
parent 5322764881
commit f0f8aeb7b8
15 changed files with 468 additions and 144 deletions

View file

@ -1,11 +0,0 @@
{ pkgs, ... }: {
home = {
packages = with pkgs; [
ghostty
];
file = {
".config/ghostty".source = ../ghostty;
};
};
}

View file

@ -1,61 +0,0 @@
{ pkgs, neovim-flake, ... }: {
programs = {
zsh = {
enable = true;
};
};
home = {
stateVersion = "24.05";
packages = with pkgs; [
neovim-flake.packages.${system}.neovim
fzf
bat
git
yazi
tmux
eza
curl
wget
ripgrep
fd
jq
starship
fastfetch
clang
clang-tools
nixfmt-rfc-style
luajit
zoxide
rustup
zig
zls
nil
lldb
gopls
delve
golangci-lint
cmake
cmake-language-server
cmake-format
cmake-lint
python313Packages.debugpy
pyright
lua-language-server
gnumake
ninja
];
file = {
".zshrc".source = ../zsh/.zshrc;
".config/nvim".source = ../nvim;
".config/yazi".source = ../yazi;
".config/starship.toml".source = ../starship/starship.toml;
".tmux.conf".source = ../tmux/.tmux.conf;
".config/tmux".source = ../tmux;
".config/bat".source = ../bat;
".config/ghostty".source = ../ghostty;
".config/confutils".source = ../confutils;
".config/wallpapers".source = ../wallpapers;
};
};
}

12
nix/local_home.nix Normal file
View file

@ -0,0 +1,12 @@
{ ... }:
{
# local_home.nix
# This is a template file that is committed to git with minimal changes.
# In order to use this and remain pure, each machine needs to create a local branch, i.e `machine-wsl` and set these variables
# accordingly, and then commit it.
home = {
# Stub values for demonstration. Override these in local branch.
username = "JohnDoe";
homeDirectory = "/home/johndoe";
};
}

View file

@ -1,11 +0,0 @@
{ ... }: {
# local-machine.nix
# This is a template file that is committed to git with minimal changes.
# In order to use this and remain pure, each machine needs to create a local branch, i.e `machine-wsl` and set these variables
# accordingly, and then commit it.
home = {
# Stub values for demonstration. Override these in local branch.
username = "nixos";
homeDirectory = "/home/nixos";
};
}

14
nix/local_system.nix Normal file
View file

@ -0,0 +1,14 @@
{
pkgs,
config,
self,
nix-homebrew,
...
}:
{
system = {
stateVersion = 5;
};
nix-homebrew.user = "larssonmartin1998-mac";
}

10
nix/pkgs/darwin.nix Normal file
View file

@ -0,0 +1,10 @@
{ pkgs, homebrew, ... }:
{
home = {
packages = with pkgs; [
gawk
];
file = {
};
};
}

68
nix/pkgs/home.nix Normal file
View file

@ -0,0 +1,68 @@
{
pkgs,
neovim-flake,
...
}:
{
programs = {
zsh = {
enable = true;
};
};
home = {
stateVersion = "24.05";
packages = with pkgs; [
neovim-flake.packages.${system}.neovim
fzf
bat
git
yazi
tmux
eza
curl
wget
ripgrep
fd
jq
starship
fastfetch
clang
clang-tools
nixfmt-rfc-style
luajit
zoxide
rustup
zig
zls
nil
lldb
gopls
delve
golangci-lint
cmake
cmake-language-server
cmake-format
cmake-lint
python313Packages.debugpy
pyright
lua-language-server
gnumake
ninja
tldr
nerd-fonts.caskaydia-mono
];
file = {
".zshrc".source = ../../zsh/.zshrc;
".config/nvim".source = ../../nvim;
".config/yazi".source = ../../yazi;
".config/starship.toml".source = ../../starship/starship.toml;
".tmux.conf".source = ../../tmux/.tmux.conf;
".config/tmux".source = ../../tmux;
".config/bat".source = ../../bat;
".config/ghostty".source = ../../ghostty;
".config/confutils".source = ../../confutils;
".config/wallpapers".source = ../../wallpapers;
};
};
}

58
nix/system/darwin.nix Normal file
View file

@ -0,0 +1,58 @@
{
pkgs,
config,
self,
...
}:
{
system.configurationRevision = self.rev or self.dirtyRev or null;
environment.systemPackages = with pkgs; [
home-manager
mkalias
];
homebrew = {
enable = true;
casks = [
"ghostty"
];
brews = [
"mas"
];
masApps = { };
onActivation.cleanup = "zap";
onActivation.autoUpdate = true;
onActivation.upgrade = true;
};
system.defaults = {
dock.autohide = true;
finder.FXPreferredViewStyle = "clmv";
loginwindow.GuestEnabled = false;
NSGlobalDomain.AppleICUForce24HourTime = true;
NSGlobalDomain.AppleInterfaceStyle = "Dark";
NSGlobalDomain.KeyRepeat = 2;
};
system.activationScripts.applications.text =
let
env = pkgs.buildEnv {
name = "system-applications";
paths = config.environment.systemPackages;
pathsToLink = "/Applications";
};
in
pkgs.lib.mkForce ''
# Set up applications
echo "setting up /Applications..." >&2
rm -rf /Applications/Nix\ Apps
mkdir -p /Applications/Nix\ Apps
find ${env}/Applications -maxdepth 1 -type l -exec readlink '{}' + |
while read -r src; do
app_name=$(basename "$src")
echo "copying $src" >&2
${pkgs.mkalias}/bin/mkalias "$src" "/Applications/Nix Apps/$app_name"
done
'';
}

2
nix/system/linux.nix Normal file
View file

@ -0,0 +1,2 @@
{ ... }: {
}

7
nix/system/wsl.nix Normal file
View file

@ -0,0 +1,7 @@
{ nixos-wsl, ... }: {
imports = [
nixosWSL.nixosModules.default
];
wsl.enable = true;
}