Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
96 lines (90 loc) · 2.59 KB
/
Copy pathflake.nix
File metadata and controls
96 lines (90 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
{
description = "Scotty's Darwin system flake.";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nix-darwin.url = "github:nix-darwin/nix-darwin/master";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
nix-homebrew.url = "github:zhaofengli-wip/nix-homebrew";
homebrew-core = {
url = "github:homebrew/homebrew-core";
flake = false;
};
homebrew-cask = {
url = "github:homebrew/homebrew-cask";
flake = false;
};
homebrew-bundle = {
url = "github:homebrew/homebrew-bundle";
flake = false;
};
};
outputs =
{ ... }@inputs:
with inputs;
let
configuration =
{ pkgs, ... }:
{
nix.settings.experimental-features = "nix-command flakes";
system.configurationRevision = self.rev or self.dirtyRev or null;
system.stateVersion = 6;
nixpkgs.hostPlatform = "aarch64-darwin";
};
machines = {
zmbp = {
username = "scta";
};
safmbp = {
username = "scott";
manageHomebrew = false;
};
};
in
{
darwinConfigurations = nixpkgs.lib.mapAttrs
(hostname: { username, manageHomebrew ? true }: nix-darwin.lib.darwinSystem {
modules = [
configuration
./nix/darwin.nix
./nix/homebrew.nix
./nix/pkgs.nix
];
specialArgs = {
inherit
homebrew-bundle
homebrew-core
homebrew-cask
hostname
manageHomebrew
nix-homebrew
username
;
};
})
machines;
}
// flake-utils.lib.eachDefaultSystem (system: {
apps.install = {
type = "app";
program = toString (
nixpkgs.legacyPackages.${system}.writeShellScript "install" ''
# Set defaults from system
HOSTNAME=$(hostname | cut -d. -f1)
# Optionally override with command line arguments
if [[ $# -gt 0 ]]; then
case $1 in
--hostname=*)
HOSTNAME="''${1#*=}"
shift
;;
esac
fi
sudo \
${nix-darwin.packages.${system}.darwin-rebuild}/bin/darwin-rebuild \
switch --flake .#"$HOSTNAME"
''
);
};
});
}