Compare commits
22
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d6c2f8abfb | ||
|
|
d76299b2cd | ||
|
|
51e413434b | ||
|
|
000eadb231 | ||
|
|
7f5c0626a0 | ||
|
|
df8ea00254 | ||
|
|
1fef4404de | ||
|
|
1c8bcd7dc2 | ||
|
|
743cb019f7 | ||
|
|
536f951efb | ||
|
|
c0138494df | ||
|
|
294d18da17 | ||
|
|
181aed266c | ||
|
|
c8c41964f6 | ||
|
|
75b99daa12 | ||
|
|
bff5d2372d | ||
|
|
2456ff5c95 | ||
|
|
fd99ca1ba1 | ||
|
|
146e370d17 | ||
|
|
92fcecc800 | ||
|
|
74ecd01d2c | ||
|
|
75fe61011c |
@@ -3,10 +3,10 @@ on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- nix-darwin-25.05
|
||||
|
||||
env:
|
||||
NIXPKGS_BRANCH: nixpkgs-unstable
|
||||
NIXPKGS_BRANCH: nixpkgs-25.05-darwin
|
||||
NIX_VERSION: 2.24.11
|
||||
|
||||
jobs:
|
||||
|
||||
@@ -1,239 +1,3 @@
|
||||
[<img src="https://github.com/user-attachments/assets/0e1a77ac-6739-4153-bd24-abd3a5e143f5" width="200px" alt="logo" />](https://github.com/nix-darwin/nix-darwin)
|
||||
|
||||
# nix-darwin
|
||||
|
||||
[](https://github.com/nix-darwin/nix-darwin/actions/workflows/test.yml)
|
||||
|
||||
Nix modules for darwin, `/etc/nixos/configuration.nix` for macOS.
|
||||
|
||||
This project aims to bring the convenience of a declarative system approach to macOS.
|
||||
nix-darwin is built up around [Nixpkgs](https://github.com/NixOS/nixpkgs), quite similar to [NixOS](https://nixos.org/).
|
||||
|
||||
## Prerequisites
|
||||
|
||||
The only prerequisite is a Nix implementation; both Nix and Lix are supported.
|
||||
|
||||
As the official Nix installer does not include an automated uninstaller, and manual uninstallation on macOS is a complex process, we recommend using one of the following installers instead:
|
||||
|
||||
* The [Nix installer from Determinate Systems](https://github.com/DeterminateSystems/nix-installer?tab=readme-ov-file#determinate-nix-installer) is only recommended for use with flake-based setups.
|
||||
It can install one of two distributions of Nix:
|
||||
|
||||
* To install the **recommended** vanilla upstream [Nix](https://nixos.org), you will need to explicitly say `no` when prompted to install `Determinate Nix`.
|
||||
|
||||
* When run with the `--determinate` flag, it will install the [Determinate](https://docs.determinate.systems/) distribution.
|
||||
As Determinate manages the Nix installation itself, you will need to set `nix.enable = false;` in your configuration to disable nix-darwin’s own Nix management.
|
||||
Some nix-darwin functionality that relies on managing the Nix installation, like the `nix.*` options to adjust Nix settings or configure a Linux builder, will be unavailable.
|
||||
|
||||
* The [Lix installer](https://lix.systems/install/#on-any-other-linuxmacos-system) supports both flake-based and channel-based setups.
|
||||
|
||||
|
||||
|
||||
## Getting started
|
||||
|
||||
Despite being an experimental feature in Nix currently, nix-darwin recommends that beginners use flakes to manage their nix-darwin configurations.
|
||||
|
||||
<details>
|
||||
<summary>Flakes (Recommended for beginners)</summary>
|
||||
|
||||
### Step 1. Creating `flake.nix`
|
||||
|
||||
<details>
|
||||
<summary>Getting started from scratch</summary>
|
||||
<p></p>
|
||||
|
||||
If you don't have an existing `configuration.nix`, you can run the following commands to generate a basic `flake.nix` inside `/etc/nix-darwin`:
|
||||
|
||||
```bash
|
||||
sudo mkdir -p /etc/nix-darwin
|
||||
sudo chown $(id -nu):$(id -ng) /etc/nix-darwin
|
||||
cd /etc/nix-darwin
|
||||
|
||||
# To use Nixpkgs unstable:
|
||||
nix flake init -t nix-darwin/master
|
||||
# To use Nixpkgs 24.11:
|
||||
nix flake init -t nix-darwin/nix-darwin-24.11
|
||||
|
||||
sed -i '' "s/simple/$(scutil --get LocalHostName)/" flake.nix
|
||||
```
|
||||
|
||||
Make sure to change `nixpkgs.hostPlatform` to `aarch64-darwin` if you are using Apple Silicon.
|
||||
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Migrating from an existing configuration.nix</summary>
|
||||
<p></p>
|
||||
|
||||
Add the following to `flake.nix` in the same folder as `configuration.nix`:
|
||||
|
||||
```nix
|
||||
{
|
||||
description = "John's darwin system";
|
||||
|
||||
inputs = {
|
||||
# Use `github:NixOS/nixpkgs/nixpkgs-24.11-darwin` to use Nixpkgs 24.11.
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
# Use `github:nix-darwin/nix-darwin/nix-darwin-24.11` to use Nixpkgs 24.11.
|
||||
nix-darwin.url = "github:nix-darwin/nix-darwin/master";
|
||||
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
outputs = inputs@{ self, nix-darwin, nixpkgs }: {
|
||||
darwinConfigurations."Johns-MacBook" = nix-darwin.lib.darwinSystem {
|
||||
modules = [ ./configuration.nix ];
|
||||
};
|
||||
};
|
||||
}
|
||||
```
|
||||
|
||||
Make sure to replace `Johns-MacBook` with your hostname which you can find by running `scutil --get LocalHostName`.
|
||||
|
||||
Make sure to set `nixpkgs.hostPlatform` in your `configuration.nix` to either `x86_64-darwin` (Intel) or `aarch64-darwin` (Apple Silicon).
|
||||
|
||||
</details>
|
||||
|
||||
### Step 2. Installing `nix-darwin`
|
||||
|
||||
Unlike NixOS, `nix-darwin` does not have an installer, you can just run `darwin-rebuild switch` to install nix-darwin. As `darwin-rebuild` won't be installed in your `PATH` yet, you can use the following command:
|
||||
|
||||
```bash
|
||||
# To use Nixpkgs unstable:
|
||||
sudo nix run nix-darwin/master#darwin-rebuild -- switch
|
||||
# To use Nixpkgs 24.11:
|
||||
sudo nix run nix-darwin/nix-darwin-24.11#darwin-rebuild -- switch
|
||||
```
|
||||
|
||||
### Step 3. Using `nix-darwin`
|
||||
|
||||
After installing, you can run `darwin-rebuild` to apply changes to your system:
|
||||
|
||||
```bash
|
||||
sudo darwin-rebuild switch
|
||||
```
|
||||
|
||||
#### Using flake inputs
|
||||
|
||||
Inputs from the flake can also be passed into `darwinSystem`. These inputs are then
|
||||
accessible as an argument `inputs`, similar to `pkgs` and `lib`, inside the configuration.
|
||||
|
||||
```nix
|
||||
# in flake.nix
|
||||
nix-darwin.lib.darwinSystem {
|
||||
modules = [ ./configuration.nix ];
|
||||
specialArgs = { inherit inputs; };
|
||||
}
|
||||
```
|
||||
|
||||
```nix
|
||||
# in configuration.nix
|
||||
{ pkgs, lib, inputs }:
|
||||
# inputs.self, inputs.nix-darwin, and inputs.nixpkgs can be accessed here
|
||||
```
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Channels</summary>
|
||||
|
||||
### Step 1. Creating `configuration.nix`
|
||||
|
||||
Copy the [simple](./modules/examples/simple.nix) example to `/etc/nix-darwin/configuration.nix`.
|
||||
|
||||
### Step 2. Adding `nix-darwin` channel
|
||||
|
||||
```bash
|
||||
# If you use Nixpkgs unstable (the default):
|
||||
sudo nix-channel --add https://github.com/nix-darwin/nix-darwin/archive/master.tar.gz darwin
|
||||
# If you use Nixpkgs 24.11:
|
||||
sudo nix-channel --add https://github.com/nix-darwin/nix-darwin/archive/nix-darwin-24.11.tar.gz darwin
|
||||
|
||||
sudo nix-channel --update
|
||||
```
|
||||
|
||||
### Step 3. Installing `nix-darwin`
|
||||
|
||||
To install `nix-darwin`, you can just run `darwin-rebuild switch` to install nix-darwin. As `darwin-rebuild` won't be installed in your `PATH` yet, you can use the following command:
|
||||
|
||||
```bash
|
||||
nix-build '<darwin>' -A darwin-rebuild
|
||||
sudo ./result/bin/darwin-rebuild switch -I darwin-config=/etc/nix-darwin/configuration.nix
|
||||
```
|
||||
|
||||
### Step 4. Using `nix-darwin`
|
||||
|
||||
After installing, you can run `darwin-rebuild` to apply changes to your system:
|
||||
|
||||
```bash
|
||||
sudo darwin-rebuild switch
|
||||
```
|
||||
|
||||
### Step 5. Updating `nix-darwin`
|
||||
|
||||
You can update Nixpkgs and `nix-darwin` using the following command:
|
||||
|
||||
```bash
|
||||
sudo nix-channel --update
|
||||
```
|
||||
</details>
|
||||
|
||||
## Documentation
|
||||
|
||||
`darwin-help` will open up a local copy of the reference documentation, it can also be found online [here](https://nix-darwin.github.io/nix-darwin/manual/index.html).
|
||||
|
||||
The documentation is also available as manpages by running `man 5 configuration.nix`.
|
||||
|
||||
## Uninstalling
|
||||
|
||||
To run the latest version of the uninstaller, you can run the following command:
|
||||
|
||||
```
|
||||
sudo nix --extra-experimental-features "nix-command flakes" run nix-darwin#darwin-uninstaller
|
||||
```
|
||||
|
||||
If that command doesn't work for you, you can try the locally installed uninstaller:
|
||||
|
||||
```
|
||||
sudo darwin-uninstaller
|
||||
```
|
||||
|
||||
## Tests
|
||||
|
||||
There are basic tests that run sanity checks for some of the modules,
|
||||
you can run them like this:
|
||||
|
||||
```bash
|
||||
# run all tests
|
||||
nix-build release.nix -A tests
|
||||
# or just a subset
|
||||
nix-build release.nix -A tests.environment-path
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
Let's make Nix on macOS awesome!
|
||||
|
||||
Don't hesitate to contribute modules or open an issue.
|
||||
|
||||
To build your configuration with local changes you can run this. This
|
||||
flag can also be used to override darwin-config or nixpkgs, for more
|
||||
information on the `-I` flag look at the nix-build [manpage](https://nixos.org/manual/nix/stable/command-ref/nix-build.html).
|
||||
|
||||
```bash
|
||||
sudo darwin-rebuild switch -I darwin=.
|
||||
```
|
||||
|
||||
If you're adding a module, please add yourself to `meta.maintainers`, for example
|
||||
|
||||
```nix
|
||||
meta.maintainers = [
|
||||
lib.maintainers.alice or "alice"
|
||||
];
|
||||
|
||||
options.services.alicebot = # ...
|
||||
```
|
||||
|
||||
The `or` operator takes care of graceful degradation when `lib` from Nixpkgs
|
||||
goes out of sync.
|
||||
|
||||
Feel free to contact us on Matrix if you have questions:
|
||||
* **User support:** [#macos:nixos.org](https://matrix.to/#/#macos:nixos.org)
|
||||
* **Development discussion:** [#nix-darwin-dev:nixos.org](https://matrix.to/#/#nix-darwin-dev:nixos.org)
|
||||
This is the 25.05 release branch of nix-darwin. See [the main readme](https://github.com/nix-darwin/nix-darwin#readme) for documentation.
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
|
||||
# Nix
|
||||
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
|
||||
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
|
||||
fi
|
||||
# End Nix
|
||||
|
||||
|
||||
# System-wide profile for interactive zsh(1) shells.
|
||||
|
||||
# Setup user specific overrides for this in ~/.zshrc. See zshbuiltins(1)
|
||||
# and zshoptions(1) for more details.
|
||||
|
||||
# Correctly display UTF-8 with combining characters. We'll assume UTF-8 if the
|
||||
# locale(1) binary is missing entirely.
|
||||
if [[ ! -x /usr/bin/locale ]] || [[ "$(locale LC_CTYPE)" == "UTF-8" ]]; then
|
||||
setopt COMBINING_CHARS
|
||||
fi
|
||||
|
||||
# Disable the log builtin, so we don't conflict with /usr/bin/log
|
||||
disable log
|
||||
|
||||
# Save command history
|
||||
HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history
|
||||
HISTSIZE=2000
|
||||
SAVEHIST=1000
|
||||
|
||||
# Beep on error
|
||||
setopt BEEP
|
||||
|
||||
# Use keycodes (generated via zkbd) if present, otherwise fallback on
|
||||
# values from terminfo
|
||||
if [[ -r ${ZDOTDIR:-$HOME}/.zkbd/${TERM}-${VENDOR} ]] ; then
|
||||
source ${ZDOTDIR:-$HOME}/.zkbd/${TERM}-${VENDOR}
|
||||
else
|
||||
typeset -g -A key
|
||||
|
||||
[[ -n "$terminfo[kf1]" ]] && key[F1]=$terminfo[kf1]
|
||||
[[ -n "$terminfo[kf2]" ]] && key[F2]=$terminfo[kf2]
|
||||
[[ -n "$terminfo[kf3]" ]] && key[F3]=$terminfo[kf3]
|
||||
[[ -n "$terminfo[kf4]" ]] && key[F4]=$terminfo[kf4]
|
||||
[[ -n "$terminfo[kf5]" ]] && key[F5]=$terminfo[kf5]
|
||||
[[ -n "$terminfo[kf6]" ]] && key[F6]=$terminfo[kf6]
|
||||
[[ -n "$terminfo[kf7]" ]] && key[F7]=$terminfo[kf7]
|
||||
[[ -n "$terminfo[kf8]" ]] && key[F8]=$terminfo[kf8]
|
||||
[[ -n "$terminfo[kf9]" ]] && key[F9]=$terminfo[kf9]
|
||||
[[ -n "$terminfo[kf10]" ]] && key[F10]=$terminfo[kf10]
|
||||
[[ -n "$terminfo[kf11]" ]] && key[F11]=$terminfo[kf11]
|
||||
[[ -n "$terminfo[kf12]" ]] && key[F12]=$terminfo[kf12]
|
||||
[[ -n "$terminfo[kf13]" ]] && key[F13]=$terminfo[kf13]
|
||||
[[ -n "$terminfo[kf14]" ]] && key[F14]=$terminfo[kf14]
|
||||
[[ -n "$terminfo[kf15]" ]] && key[F15]=$terminfo[kf15]
|
||||
[[ -n "$terminfo[kf16]" ]] && key[F16]=$terminfo[kf16]
|
||||
[[ -n "$terminfo[kf17]" ]] && key[F17]=$terminfo[kf17]
|
||||
[[ -n "$terminfo[kf18]" ]] && key[F18]=$terminfo[kf18]
|
||||
[[ -n "$terminfo[kf19]" ]] && key[F19]=$terminfo[kf19]
|
||||
[[ -n "$terminfo[kf20]" ]] && key[F20]=$terminfo[kf20]
|
||||
[[ -n "$terminfo[kbs]" ]] && key[Backspace]=$terminfo[kbs]
|
||||
[[ -n "$terminfo[kich1]" ]] && key[Insert]=$terminfo[kich1]
|
||||
[[ -n "$terminfo[kdch1]" ]] && key[Delete]=$terminfo[kdch1]
|
||||
[[ -n "$terminfo[khome]" ]] && key[Home]=$terminfo[khome]
|
||||
[[ -n "$terminfo[kend]" ]] && key[End]=$terminfo[kend]
|
||||
[[ -n "$terminfo[kpp]" ]] && key[PageUp]=$terminfo[kpp]
|
||||
[[ -n "$terminfo[knp]" ]] && key[PageDown]=$terminfo[knp]
|
||||
[[ -n "$terminfo[kcuu1]" ]] && key[Up]=$terminfo[kcuu1]
|
||||
[[ -n "$terminfo[kcub1]" ]] && key[Left]=$terminfo[kcub1]
|
||||
[[ -n "$terminfo[kcud1]" ]] && key[Down]=$terminfo[kcud1]
|
||||
[[ -n "$terminfo[kcuf1]" ]] && key[Right]=$terminfo[kcuf1]
|
||||
fi
|
||||
|
||||
# Default key bindings
|
||||
[[ -n ${key[Delete]} ]] && bindkey "${key[Delete]}" delete-char
|
||||
[[ -n ${key[Home]} ]] && bindkey "${key[Home]}" beginning-of-line
|
||||
[[ -n ${key[End]} ]] && bindkey "${key[End]}" end-of-line
|
||||
[[ -n ${key[Up]} ]] && bindkey "${key[Up]}" up-line-or-search
|
||||
[[ -n ${key[Down]} ]] && bindkey "${key[Down]}" down-line-or-search
|
||||
|
||||
# Default prompt
|
||||
PS1="%n@%m %1~ %# "
|
||||
|
||||
# Useful support for interacting with Terminal.app or other terminal programs
|
||||
[ -r "/etc/zshrc_$TERM_PROGRAM" ] && . "/etc/zshrc_$TERM_PROGRAM"
|
||||
@@ -0,0 +1,74 @@
|
||||
# System-wide profile for interactive zsh(1) shells.
|
||||
|
||||
# Setup user specific overrides for this in ~/.zshrc. See zshbuiltins(1)
|
||||
# and zshoptions(1) for more details.
|
||||
|
||||
# Correctly display UTF-8 with combining characters. We'll assume UTF-8 if the
|
||||
# locale(1) binary is missing entirely.
|
||||
if [[ ! -x /usr/bin/locale ]] || [[ "$(locale LC_CTYPE)" == "UTF-8" ]]; then
|
||||
setopt COMBINING_CHARS
|
||||
fi
|
||||
|
||||
# Disable the log builtin, so we don't conflict with /usr/bin/log
|
||||
disable log
|
||||
|
||||
# Save command history
|
||||
HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history
|
||||
HISTSIZE=2000
|
||||
SAVEHIST=1000
|
||||
|
||||
# Beep on error
|
||||
setopt BEEP
|
||||
|
||||
# Use keycodes (generated via zkbd) if present, otherwise fallback on
|
||||
# values from terminfo
|
||||
if [[ -r ${ZDOTDIR:-$HOME}/.zkbd/${TERM}-${VENDOR} ]] ; then
|
||||
source ${ZDOTDIR:-$HOME}/.zkbd/${TERM}-${VENDOR}
|
||||
else
|
||||
typeset -g -A key
|
||||
|
||||
[[ -n "$terminfo[kf1]" ]] && key[F1]=$terminfo[kf1]
|
||||
[[ -n "$terminfo[kf2]" ]] && key[F2]=$terminfo[kf2]
|
||||
[[ -n "$terminfo[kf3]" ]] && key[F3]=$terminfo[kf3]
|
||||
[[ -n "$terminfo[kf4]" ]] && key[F4]=$terminfo[kf4]
|
||||
[[ -n "$terminfo[kf5]" ]] && key[F5]=$terminfo[kf5]
|
||||
[[ -n "$terminfo[kf6]" ]] && key[F6]=$terminfo[kf6]
|
||||
[[ -n "$terminfo[kf7]" ]] && key[F7]=$terminfo[kf7]
|
||||
[[ -n "$terminfo[kf8]" ]] && key[F8]=$terminfo[kf8]
|
||||
[[ -n "$terminfo[kf9]" ]] && key[F9]=$terminfo[kf9]
|
||||
[[ -n "$terminfo[kf10]" ]] && key[F10]=$terminfo[kf10]
|
||||
[[ -n "$terminfo[kf11]" ]] && key[F11]=$terminfo[kf11]
|
||||
[[ -n "$terminfo[kf12]" ]] && key[F12]=$terminfo[kf12]
|
||||
[[ -n "$terminfo[kf13]" ]] && key[F13]=$terminfo[kf13]
|
||||
[[ -n "$terminfo[kf14]" ]] && key[F14]=$terminfo[kf14]
|
||||
[[ -n "$terminfo[kf15]" ]] && key[F15]=$terminfo[kf15]
|
||||
[[ -n "$terminfo[kf16]" ]] && key[F16]=$terminfo[kf16]
|
||||
[[ -n "$terminfo[kf17]" ]] && key[F17]=$terminfo[kf17]
|
||||
[[ -n "$terminfo[kf18]" ]] && key[F18]=$terminfo[kf18]
|
||||
[[ -n "$terminfo[kf19]" ]] && key[F19]=$terminfo[kf19]
|
||||
[[ -n "$terminfo[kf20]" ]] && key[F20]=$terminfo[kf20]
|
||||
[[ -n "$terminfo[kbs]" ]] && key[Backspace]=$terminfo[kbs]
|
||||
[[ -n "$terminfo[kich1]" ]] && key[Insert]=$terminfo[kich1]
|
||||
[[ -n "$terminfo[kdch1]" ]] && key[Delete]=$terminfo[kdch1]
|
||||
[[ -n "$terminfo[khome]" ]] && key[Home]=$terminfo[khome]
|
||||
[[ -n "$terminfo[kend]" ]] && key[End]=$terminfo[kend]
|
||||
[[ -n "$terminfo[kpp]" ]] && key[PageUp]=$terminfo[kpp]
|
||||
[[ -n "$terminfo[knp]" ]] && key[PageDown]=$terminfo[knp]
|
||||
[[ -n "$terminfo[kcuu1]" ]] && key[Up]=$terminfo[kcuu1]
|
||||
[[ -n "$terminfo[kcub1]" ]] && key[Left]=$terminfo[kcub1]
|
||||
[[ -n "$terminfo[kcud1]" ]] && key[Down]=$terminfo[kcud1]
|
||||
[[ -n "$terminfo[kcuf1]" ]] && key[Right]=$terminfo[kcuf1]
|
||||
fi
|
||||
|
||||
# Default key bindings
|
||||
[[ -n ${key[Delete]} ]] && bindkey "${key[Delete]}" delete-char
|
||||
[[ -n ${key[Home]} ]] && bindkey "${key[Home]}" beginning-of-line
|
||||
[[ -n ${key[End]} ]] && bindkey "${key[End]}" end-of-line
|
||||
[[ -n ${key[Up]} ]] && bindkey "${key[Up]}" up-line-or-search
|
||||
[[ -n ${key[Down]} ]] && bindkey "${key[Down]}" down-line-or-search
|
||||
|
||||
# Default prompt
|
||||
PS1="%n@%m %1~ %# "
|
||||
|
||||
# Useful support for interacting with Terminal.app or other terminal programs
|
||||
[ -r "/etc/zshrc_$TERM_PROGRAM" ] && . "/etc/zshrc_$TERM_PROGRAM"
|
||||
@@ -0,0 +1,81 @@
|
||||
# System-wide profile for interactive zsh(1) shells.
|
||||
|
||||
# Setup user specific overrides for this in ~/.zshrc. See zshbuiltins(1)
|
||||
# and zshoptions(1) for more details.
|
||||
|
||||
# Correctly display UTF-8 with combining characters. We'll assume UTF-8 if the
|
||||
# locale(1) binary is missing entirely.
|
||||
if [[ ! -x /usr/bin/locale ]] || [[ "$(locale LC_CTYPE)" == "UTF-8" ]]; then
|
||||
setopt COMBINING_CHARS
|
||||
fi
|
||||
|
||||
# Disable the log builtin, so we don't conflict with /usr/bin/log
|
||||
disable log
|
||||
|
||||
# Save command history
|
||||
HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history
|
||||
HISTSIZE=2000
|
||||
SAVEHIST=1000
|
||||
|
||||
# Beep on error
|
||||
setopt BEEP
|
||||
|
||||
# Use keycodes (generated via zkbd) if present, otherwise fallback on
|
||||
# values from terminfo
|
||||
if [[ -r ${ZDOTDIR:-$HOME}/.zkbd/${TERM}-${VENDOR} ]] ; then
|
||||
source ${ZDOTDIR:-$HOME}/.zkbd/${TERM}-${VENDOR}
|
||||
else
|
||||
typeset -g -A key
|
||||
|
||||
[[ -n "$terminfo[kf1]" ]] && key[F1]=$terminfo[kf1]
|
||||
[[ -n "$terminfo[kf2]" ]] && key[F2]=$terminfo[kf2]
|
||||
[[ -n "$terminfo[kf3]" ]] && key[F3]=$terminfo[kf3]
|
||||
[[ -n "$terminfo[kf4]" ]] && key[F4]=$terminfo[kf4]
|
||||
[[ -n "$terminfo[kf5]" ]] && key[F5]=$terminfo[kf5]
|
||||
[[ -n "$terminfo[kf6]" ]] && key[F6]=$terminfo[kf6]
|
||||
[[ -n "$terminfo[kf7]" ]] && key[F7]=$terminfo[kf7]
|
||||
[[ -n "$terminfo[kf8]" ]] && key[F8]=$terminfo[kf8]
|
||||
[[ -n "$terminfo[kf9]" ]] && key[F9]=$terminfo[kf9]
|
||||
[[ -n "$terminfo[kf10]" ]] && key[F10]=$terminfo[kf10]
|
||||
[[ -n "$terminfo[kf11]" ]] && key[F11]=$terminfo[kf11]
|
||||
[[ -n "$terminfo[kf12]" ]] && key[F12]=$terminfo[kf12]
|
||||
[[ -n "$terminfo[kf13]" ]] && key[F13]=$terminfo[kf13]
|
||||
[[ -n "$terminfo[kf14]" ]] && key[F14]=$terminfo[kf14]
|
||||
[[ -n "$terminfo[kf15]" ]] && key[F15]=$terminfo[kf15]
|
||||
[[ -n "$terminfo[kf16]" ]] && key[F16]=$terminfo[kf16]
|
||||
[[ -n "$terminfo[kf17]" ]] && key[F17]=$terminfo[kf17]
|
||||
[[ -n "$terminfo[kf18]" ]] && key[F18]=$terminfo[kf18]
|
||||
[[ -n "$terminfo[kf19]" ]] && key[F19]=$terminfo[kf19]
|
||||
[[ -n "$terminfo[kf20]" ]] && key[F20]=$terminfo[kf20]
|
||||
[[ -n "$terminfo[kbs]" ]] && key[Backspace]=$terminfo[kbs]
|
||||
[[ -n "$terminfo[kich1]" ]] && key[Insert]=$terminfo[kich1]
|
||||
[[ -n "$terminfo[kdch1]" ]] && key[Delete]=$terminfo[kdch1]
|
||||
[[ -n "$terminfo[khome]" ]] && key[Home]=$terminfo[khome]
|
||||
[[ -n "$terminfo[kend]" ]] && key[End]=$terminfo[kend]
|
||||
[[ -n "$terminfo[kpp]" ]] && key[PageUp]=$terminfo[kpp]
|
||||
[[ -n "$terminfo[knp]" ]] && key[PageDown]=$terminfo[knp]
|
||||
[[ -n "$terminfo[kcuu1]" ]] && key[Up]=$terminfo[kcuu1]
|
||||
[[ -n "$terminfo[kcub1]" ]] && key[Left]=$terminfo[kcub1]
|
||||
[[ -n "$terminfo[kcud1]" ]] && key[Down]=$terminfo[kcud1]
|
||||
[[ -n "$terminfo[kcuf1]" ]] && key[Right]=$terminfo[kcuf1]
|
||||
fi
|
||||
|
||||
# Default key bindings
|
||||
[[ -n ${key[Delete]} ]] && bindkey "${key[Delete]}" delete-char
|
||||
[[ -n ${key[Home]} ]] && bindkey "${key[Home]}" beginning-of-line
|
||||
[[ -n ${key[End]} ]] && bindkey "${key[End]}" end-of-line
|
||||
[[ -n ${key[Up]} ]] && bindkey "${key[Up]}" up-line-or-search
|
||||
[[ -n ${key[Down]} ]] && bindkey "${key[Down]}" down-line-or-search
|
||||
|
||||
# Default prompt
|
||||
PS1="%n@%m %1~ %# "
|
||||
|
||||
# Useful support for interacting with Terminal.app or other terminal programs
|
||||
[ -r "/etc/zshrc_$TERM_PROGRAM" ] && . "/etc/zshrc_$TERM_PROGRAM"
|
||||
|
||||
# Nix
|
||||
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
|
||||
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
|
||||
fi
|
||||
# End Nix
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
# System-wide profile for interactive zsh(1) login shells.
|
||||
|
||||
# Setup user specific overrides for this in ~/.zprofile. See zshbuiltins(1)
|
||||
# and zshoptions(1) for more details.
|
||||
|
||||
if [ -z "$LANG" ]; then
|
||||
export LANG=C.UTF-8
|
||||
fi
|
||||
|
||||
if [ -x /usr/libexec/path_helper ]; then
|
||||
eval `/usr/libexec/path_helper -s`
|
||||
fi
|
||||
Generated
+4
-4
@@ -2,16 +2,16 @@
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1746061036,
|
||||
"narHash": "sha256-OxYwCGJf9VJ2KnUO+w/hVJVTjOgscdDg/lPv8Eus07Y=",
|
||||
"lastModified": 1747953325,
|
||||
"narHash": "sha256-y2ZtlIlNTuVJUZCqzZAhIw5rrKP4DOSklev6c8PyCkQ=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "3afd19146cac33ed242fc0fc87481c67c758a59e",
|
||||
"rev": "55d1f923c480dadce40f5231feb472e81b0bab48",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixpkgs-unstable",
|
||||
"ref": "nixpkgs-25.05-darwin",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
description = "A collection of darwin modules";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-25.05-darwin";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs }: let
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
description = "Example nix-darwin system flake";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
nix-darwin.url = "github:nix-darwin/nix-darwin/master";
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-25.05-darwin";
|
||||
nix-darwin.url = "github:nix-darwin/nix-darwin/nix-darwin-25.05";
|
||||
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ let
|
||||
|
||||
mkBrewfileSectionString = heading: entries: optionalString (entries != [ ]) ''
|
||||
# ${heading}
|
||||
${concatMapStringsSep "\n" (v: v.brewfileLine or v) entries}
|
||||
${concatStringsSep "\n" (unique (map (v: v.brewfileLine or v) entries))}
|
||||
|
||||
'';
|
||||
|
||||
|
||||
+49
-20
@@ -5,12 +5,12 @@
|
||||
...
|
||||
}: let
|
||||
cfg = config.programs.direnv;
|
||||
format = pkgs.formats.toml {};
|
||||
in {
|
||||
meta.maintainers = [
|
||||
lib.maintainers.mattpolzin or "mattpolzin"
|
||||
];
|
||||
options.programs.direnv = {
|
||||
|
||||
enable = lib.mkEnableOption ''
|
||||
direnv integration. Takes care of both installation and
|
||||
setting up the sourcing of the shell. Additionally enables nix-direnv
|
||||
@@ -19,6 +19,12 @@ in {
|
||||
|
||||
package = lib.mkPackageOption pkgs "direnv" {};
|
||||
|
||||
finalPackage = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
readOnly = true;
|
||||
description = "The wrapped direnv package.";
|
||||
};
|
||||
|
||||
direnvrcExtra = lib.mkOption {
|
||||
type = lib.types.lines;
|
||||
default = "";
|
||||
@@ -54,14 +60,46 @@ in {
|
||||
|
||||
package = lib.mkPackageOption pkgs "nix-direnv" {};
|
||||
};
|
||||
|
||||
settings = lib.mkOption {
|
||||
inherit (format) type;
|
||||
default = {};
|
||||
example = lib.literalExpression ''
|
||||
{
|
||||
global = {
|
||||
log_format = "-";
|
||||
log_filter = "^$";
|
||||
};
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
Direnv configuration. Refer to {manpage}`direnv.toml(1)`.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
programs = {
|
||||
direnv = {
|
||||
finalPackage = pkgs.symlinkJoin {
|
||||
inherit (cfg.package) name;
|
||||
paths = [cfg.package];
|
||||
# direnv has a fish library which automatically sources direnv for some reason
|
||||
postBuild = ''
|
||||
rm -rf "$out/share/fish"
|
||||
'';
|
||||
meta.mainProgram = "direnv";
|
||||
};
|
||||
settings = lib.mkIf cfg.silent {
|
||||
global = {
|
||||
log_format = lib.mkDefault "-";
|
||||
log_filter = lib.mkDefault "^$";
|
||||
};
|
||||
};
|
||||
};
|
||||
zsh.interactiveShellInit = ''
|
||||
if ${lib.boolToString cfg.loadInNixShell} || printenv PATH | grep -vqc '/nix/store'; then
|
||||
eval "$(${lib.getExe cfg.package} hook zsh)"
|
||||
eval "$(${lib.getExe cfg.finalPackage} hook zsh)"
|
||||
fi
|
||||
'';
|
||||
|
||||
@@ -69,38 +107,29 @@ in {
|
||||
#$IN_NIX_SHELL for "nix-shell"
|
||||
bash.interactiveShellInit = ''
|
||||
if ${lib.boolToString cfg.loadInNixShell} || [ -z "$IN_NIX_SHELL$NIX_GCROOT$(printenv PATH | grep '/nix/store')" ] ; then
|
||||
eval "$(${lib.getExe cfg.package} hook bash)"
|
||||
eval "$(${lib.getExe cfg.finalPackage} hook bash)"
|
||||
fi
|
||||
'';
|
||||
|
||||
fish.interactiveShellInit = ''
|
||||
if ${lib.boolToString cfg.loadInNixShell};
|
||||
or printenv PATH | grep -vqc '/nix/store';
|
||||
${lib.getExe cfg.package} hook fish | source
|
||||
${lib.getExe cfg.finalPackage} hook fish | source
|
||||
end
|
||||
'';
|
||||
};
|
||||
|
||||
environment = {
|
||||
systemPackages =
|
||||
if cfg.loadInNixShell then [cfg.package]
|
||||
else [
|
||||
#direnv has a fish library which sources direnv for some reason
|
||||
(cfg.package.overrideAttrs (old: {
|
||||
installPhase =
|
||||
(old.installPhase or "")
|
||||
+ ''
|
||||
rm -rf $out/share/fish
|
||||
'';
|
||||
}))
|
||||
];
|
||||
|
||||
systemPackages = [
|
||||
cfg.finalPackage
|
||||
];
|
||||
variables = {
|
||||
DIRENV_CONFIG = "/etc/direnv";
|
||||
DIRENV_LOG_FORMAT = lib.mkIf cfg.silent "";
|
||||
};
|
||||
|
||||
etc = {
|
||||
"direnv/direnv.toml".source = lib.mkIf (cfg.settings != {}) (
|
||||
format.generate "direnv.toml" cfg.settings
|
||||
);
|
||||
"direnv/direnvrc".text = ''
|
||||
${lib.optionalString cfg.nix-direnv.enable ''
|
||||
#Load nix-direnv
|
||||
|
||||
@@ -220,14 +220,18 @@ in
|
||||
environment.etc."zprofile".knownSha256Hashes = [
|
||||
"db8422f92d8cff684e418f2dcffbb98c10fe544b5e8cd588b2009c7fa89559c5"
|
||||
"0235d3c1b6cf21e7043fbc98e239ee4bc648048aafaf6be1a94a576300584ef2" # macOS
|
||||
"f320016e2cf13573731fbee34f9fe97ba867dd2a31f24893d3120154e9306e92" # macOS 26b1 and higher
|
||||
];
|
||||
|
||||
environment.etc."zshrc".knownSha256Hashes = [
|
||||
"19a2d673ffd47b8bed71c5218ff6617dfc5e8533b240b9ba79142a45f8823c23"
|
||||
"fb5827cb4712b7e7932d438067ec4852c8955a9ff0f55e282473684623ebdfa1" # macOS
|
||||
"4d1ab5704f9d167a042fecac0d056c8a79a8ebd71e032d3489536c8db9ffe3e0" # macOS 26b1 and higher
|
||||
"c5a00c072c920f46216454978c44df044b2ec6d03409dc492c7bdcd92c94a110" # official Nix installer
|
||||
"40b0d8751adae5b0100a4f863be5b75613a49f62706427e92604f7e04d2e2261" # official Nix installer
|
||||
"bf76c5ed8e65e616f4329eccf662ee91be33b8bfd33713ce9946f2fe94fea7fa" # official Nix installer (macOS 26b1 and higher)
|
||||
"2af1b563e389d11b76a651b446e858116d7a20370d9120a7e9f78991f3e5f336" # DeterminateSystems installer
|
||||
"27274e44b88a1174787f9a3d437d3387edc4f9aaaf40356054130797f5dc7912" # DeterminateSystems installer (macOS 26b1 and higher)
|
||||
];
|
||||
|
||||
environment.etc."zshenv".knownSha256Hashes = [
|
||||
|
||||
@@ -262,8 +262,8 @@ in
|
||||
};
|
||||
|
||||
nodeRuntimes = mkOption {
|
||||
type = with types; nonEmptyListOf (enum [ "node20" ]);
|
||||
default = [ "node20" ];
|
||||
type = with types; nonEmptyListOf (enum [ "node20" "node24" ]);
|
||||
default = [ "node20" "node24" ];
|
||||
description = ''
|
||||
List of Node.js runtimes the runner should support.
|
||||
'';
|
||||
|
||||
@@ -76,7 +76,7 @@ in
|
||||
|
||||
config.launchd.daemons = flip mapAttrs' config.services.github-runners (name: cfg:
|
||||
let
|
||||
package = cfg.package.override (old: optionalAttrs (hasAttr "nodeRuntimes" old) { inherit (cfg) nodeRuntimes; });
|
||||
package = cfg.package.override { inherit (cfg) nodeRuntimes; };
|
||||
stateDir = mkStateDir cfg;
|
||||
logDir = mkLogDir cfg;
|
||||
workDir = mkWorkDir cfg;
|
||||
|
||||
@@ -20,7 +20,7 @@ in
|
||||
|
||||
system.build = mkOption {
|
||||
internal = true;
|
||||
type = types.attrsOf types.unspecified;
|
||||
type = types.lazyAttrsOf types.unspecified;
|
||||
default = {};
|
||||
description = ''
|
||||
Attribute set of derivation used to setup the system.
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
lib,
|
||||
options,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
@@ -51,11 +50,7 @@
|
||||
)}
|
||||
|
||||
To continue using these options, set `system.primaryUser` to the name
|
||||
of the user you have been using to run `darwin-rebuild`. In the long
|
||||
run, this setting will be deprecated and removed after all the
|
||||
functionality it is relevant for has been adjusted to allow
|
||||
specifying the relevant user separately, moved under the
|
||||
`users.users.*` namespace, or migrated to Home Manager.
|
||||
of the user you have been using to run `darwin-rebuild`.
|
||||
|
||||
If you run into any unexpected issues with the migration, please
|
||||
open an issue at <https://github.com/nix-darwin/nix-darwin/issues/new>
|
||||
|
||||
@@ -11,6 +11,10 @@ fi
|
||||
export PATH=@path@
|
||||
export NIX_PATH=${NIX_PATH:-@nixPath@}
|
||||
|
||||
# Use the daemon even as `root` so that resource limits, TLS and proxy
|
||||
# configuration, etc. work as expected.
|
||||
export NIX_REMOTE=${NIX_REMOTE:-daemon}
|
||||
|
||||
showSyntax() {
|
||||
echo "darwin-rebuild [--help] {edit | switch | activate | build | check | changelog}" >&2
|
||||
echo " [--list-generations] [{--profile-name | -p} name] [--rollback]" >&2
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
enable = true;
|
||||
url = "https://github.com/nixos/nixpkgs";
|
||||
tokenFile = "/secret/path/to/a/github/token";
|
||||
# We need an overridable derivation but cannot use the actual github-runner package
|
||||
# since it still relies on Node.js 16 which is marked as insecure.
|
||||
package = pkgs.hello;
|
||||
};
|
||||
|
||||
test = ''
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"release": "25.05",
|
||||
"isReleaseBranch": false
|
||||
"isReleaseBranch": true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user