File tree Expand file tree Collapse file tree 3 files changed +65
-0
lines changed Expand file tree Collapse file tree 3 files changed +65
-0
lines changed Original file line number Diff line number Diff line change
1
+ <!--
2
+ SPDX-FileCopyrightText: 2023 Serokell <https://serokell.io/>
3
+
4
+ SPDX-License-Identifier: MPL-2.0
5
+ -->
6
+
7
+ # Example nix-darwin system deployment
8
+
9
+ ## Prerequisites
10
+
11
+ 1 ) Install ` nix ` and ` nix-darwin ` (the latter creates ` /run ` sets up ` /etc/nix/nix.conf ` symlink and so on)
12
+ on the target machine.
13
+ 2 ) Enable remote login on the mac to allow ssh access.
14
+ 3 ) ` deploy-rs ` doesn't support password provisioning for ` sudo ` , so the ` sshUser ` should
15
+ have passwordless ` sudo ` access.
16
+
17
+ ## Deploying
18
+
19
+ Run ` nix run github:serokell/deploy-rs -- --ssh-user <user> ` .
Original file line number Diff line number Diff line change
1
+ {
2
+ description = "Deploy simple 'darwinSystem' to a darwin machine" ;
3
+
4
+ inputs . deploy-rs . url = "github:serokell/deploy-rs" ;
5
+ inputs . darwin . url = "github:LnL7/nix-darwin" ;
6
+
7
+ outputs = { self , nixpkgs , deploy-rs , darwin } : {
8
+ darwinConfigurations . example = darwin . lib . darwinSystem {
9
+ system = "x86_64-darwin" ;
10
+ modules = [
11
+ ( { lib , config , pkgs , ...} : {
12
+ services . nix-daemon . enable = true ;
13
+ nix = {
14
+ settings = {
15
+ trusted-users = [ "rvem" ] ;
16
+ } ;
17
+ extraOptions = ''
18
+ experimental-features = flakes nix-command
19
+ '' ;
20
+ } ;
21
+ # nix commands are added to PATH in the zsh config
22
+ programs . zsh . enable = true ;
23
+ } )
24
+ ] ;
25
+ } ;
26
+ deploy = {
27
+ # remoteBuild = true; # Uncomment in case the system you're deploying from is not darwin
28
+ nodes . example = {
29
+ hostname = "localhost" ;
30
+ profiles . system = {
31
+ user = "root" ;
32
+ path = deploy-rs . lib . x86_64-darwin . activate . darwin self . darwinConfigurations . example ;
33
+ } ;
34
+ } ;
35
+ } ;
36
+
37
+ checks = builtins . mapAttrs ( system : deployLib : deployLib . deployChecks self . deploy ) deploy-rs . lib ;
38
+ } ;
39
+ }
Original file line number Diff line number Diff line change 106
106
107
107
home-manager = base : custom base . activationPackage "$PROFILE/activate" ;
108
108
109
+ # Activation script for 'darwinSystem' from nix-darwin.
110
+ # 'HOME=/var/root' is needed because 'sudo' on darwin doesn't change 'HOME' directory,
111
+ # while 'darwin-rebuild' (which is invoked under the hood) performs some nix-channel
112
+ # checks that rely on 'HOME'. As a result, if 'sshUser' is different from root,
113
+ # deployment may fail without explicit 'HOME' redefinition.
114
+ darwin = base : custom base . config . system . build . toplevel "HOME=/var/root $PROFILE/activate" ;
115
+
109
116
noop = base : custom base ":" ;
110
117
} ;
111
118
You can’t perform that action at this time.
0 commit comments