Merge pull request #12 from DannyDannyDanny/feat/add-nix-on-macos

Nix on MacOs 🍎
This commit is contained in:
Daniel Thoren 2025-09-08 20:49:42 +02:00 committed by GitHub
commit c8685c0f89
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 102 additions and 80 deletions

22
nixos/flake.lock generated
View file

@ -34,6 +34,27 @@
"type": "github"
}
},
"nix-darwin": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1757130842,
"narHash": "sha256-4i7KKuXesSZGUv0cLPLfxbmF1S72Gf/3aSypgvVkwuA=",
"owner": "nix-darwin",
"repo": "nix-darwin",
"rev": "15f067638e2887c58c4b6ba1bdb65a0b61dc58c5",
"type": "github"
},
"original": {
"owner": "nix-darwin",
"ref": "master",
"repo": "nix-darwin",
"type": "github"
}
},
"nixos-wsl": {
"inputs": {
"flake-compat": "flake-compat",
@ -102,6 +123,7 @@
},
"root": {
"inputs": {
"nix-darwin": "nix-darwin",
"nixos-wsl": "nixos-wsl",
"nixpkgs": "nixpkgs_2",
"vscode-server": "vscode-server"

View file

@ -3,6 +3,12 @@
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixos-wsl.url = "github:nix-community/NixOS-WSL/main";
vscode-server.url = "github:nix-community/nixos-vscode-server";
# nix-darwin for macOS
# (follows nixpkgs so both use the same channel)
nix-darwin.url = "github:nix-darwin/nix-darwin/master";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
# for later
# home-manager.url = "github:nix-community/home-manager";
# home-manager.inputs.nixpkgs.follows = "nixpkgs";
@ -12,18 +18,18 @@
nixpkgs,
nixos-wsl,
vscode-server,
nix-darwin,
self,
# home-manager,
...
}: {
nixosConfigurations = {
wsl = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
nixos-wsl.nixosModules.default
vscode-server.nixosModules.default
./hosts/wsl.nix # previously configuration.nix
./hosts/wsl.nix
./tmux.nix
./neovim.nix
./fish.nix
@ -35,17 +41,28 @@
system = "x86_64-linux";
modules = [
vscode-server.nixosModules.default
./hosts/macbookair.nix # previously configuration.nix
./hosts/macbookair.nix
./hardware-configuration.nix
./tmux.nix
./neovim.nix
./fish.nix
# home-manager.nixosModules.default
# ./configuration.nix # shouldn't this be necessary???
# ./configuration.nix
# ./uxplay.nix
];
};
};
# macOS (nix-darwin) configuration
darwinConfigurations."Daniel-Macbook-Air" = nix-darwin.lib.darwinSystem {
modules = [
./hosts/macos.nix
# TODO: nix-darwin lacks tmux options; move to Home Manager.x
# ./tmux.nix
# TODO: add neovim via homemanager, that should work the same for NixOS as Nix-Darwin
# ./neovim.nix # NOTE: Option only exists on NixOS.
./fish.nix
];
};
};
}

View file

@ -1,90 +1,74 @@
# Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page, on
# https://search.nixos.org/options and in the NixOS manual (`nixos-help`).
# NixOS-WSL specific options are documented on the NixOS-WSL repository:
# https://github.com/nix-community/NixOS-WSL
{ config, lib, pkgs, ... }:
{
networking = {
useDHCP = true;
# nameserver sources: https://dnsmap.io/articles/most-popular-dns-servers
nameservers = [ "84.200.69.80" "8.26.56.26" "1.1.1.1" "8.8.8.8" "64.6.65.6" "208.67.222.222" "209.244.0.3" ];
};
nix.settings.experimental-features = [ "nix-command" "flakes" ];
programs.nix-ld.enable = true;
# TODO: move to home manager (?)
programs = {
direnv = {
enable = true;
# enableFishIntegration = true;
nix-direnv.enable = true;
};
};
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. It's perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "25.05"; # Did you read the comment?
users.users.danny = {
isNormalUser = true;
extraGroups = [ "wheel" ];
initialPassword = "test";
};
# Apple Silicon + nix-darwin basics
nixpkgs.hostPlatform = "aarch64-darwin";
nix.enable = false; # Determinate manages Nix
nixpkgs.config.allowUnfree = true;
system.primaryUser = "danny";
# Shells & dev ergonomics
programs.fish.enable = true;
environment.shells = [ pkgs.fish ];
# If you want fish as default shell, uncomment:
# users.defaultUserShell = pkgs.fish;
programs.direnv.enable = true;
programs.direnv.nix-direnv.enable = true;
# Networking (macOS-safe)
networking = {
# Set if you want a specific hostname in macOS UI as well:
hostName = "Daniel-Macbook-Air";
knownNetworkServices = [ "Wi-Fi" "Thunderbolt Bridge" ];
};
# macOS niceties
security.pam.services.sudo_local.touchIdAuth = true;
system.defaults = {
# Keyboard
NSGlobalDomain = {
AppleShowAllExtensions = true;
ApplePressAndHoldEnabled = true;
"com.apple.mouse.tapBehavior" = 1;
"com.apple.sound.beep.volume" = 0.0;
"com.apple.sound.beep.feedback" = 0;
};
# Finder & Dock
finder.AppleShowAllExtensions = true;
dock.autohide = true;
dock.mru-spaces = false;
};
# Environment
environment.variables = {
DBT_USER = "DNTH";
};
environment.systemPackages = with pkgs; [
# tmux # activated in tmux.nix
# vim # using neovim in stead
# neovim # activated in neovim.nix
# disabled git as it comes pre-installed on macos - delete or re-enable?
# git # version control
gh # github cli tool
ripgrep # faster grep
wget # for vscode-server
busybox # useful programs e.g. tree, unzip etc
openssl # cryptography swiss army knife
xdg-utils # terminal desktop intergrations (i.e. allow terminal to open browser)
# make default.nix in python project folders instead of using a top-level python environment manager
# pyenv
# poetry
neofetch # system info
btop # resource monitor
tldr # community alternative to man
fzf # fuzzy finder
# gimp # bloat
# blender # bloat
# inkscape # bloat
gh
ripgrep
wget
# busybox #TODO: doesn't run on darwin
git
gnupg
coreutils
openssl
neofetch
btop
tldr
fzf
cowsay
lolcat
neovim
];
# services.vscode-server.enable = true;
# security.rtkit.enable = true; # realtime kit hands out realtime scheduling priority
# services.pipewire = {
# enable = true; # if not already enabled
# alsa.enable = true;
# alsa.support32Bit = true;
# pulse.enable = true;
# # If you want to use JACK applications, uncomment this
# #jack.enable = true;
# };
# Keep for darwin as well (tracks defaults across upgrades)
# current max per nix-darwin; bump only if a release notes says so
system.stateVersion = 6;
}

View file

@ -79,4 +79,3 @@
};
};
}