-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
161 lines (140 loc) · 3.79 KB
/
flake.nix
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
{
description = "Tris configuration";
inputs = {
utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
nixpkgs-master.url = "github:NixOS/nixpkgs/master";
nix-darwin = {
url = "github:LnL7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager/release-23.11";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager-unstable = {
url = "github:nix-community/home-manager/master";
inputs.nixpkgs.follows = "nixpkgs-unstable";
};
ragenix = {
url = "github:yaxitech/ragenix";
inputs."flake-utils".follows = "utils";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ self
, nixpkgs
, nixpkgs-unstable
, nixpkgs-master
, nix-darwin
, home-manager
, home-manager-unstable
, ragenix
, flake-utils
, ...
} @ flakes:
let
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" "aarch64-linux" ];
system = "aarch64-darwin";
overlays = [
ragenix.overlays.default
];
commonModules = pkgBase: [
ragenix.nixosModules.age
{
nixpkgs = {
inherit overlays;
config.allowUnfree = true;
};
}
{
nix = {
nixPath = [ "nixpkgs=${pkgBase}" ];
};
}
{
system.configurationRevision = self.rev or self.dirtyRev or null;
}
./common
];
pkgs = import nixpkgs { inherit system overlays; };
darwinInputs = (with pkgs; [
libiconv
]);
macBox = machine: pkgBase: homeBase:
pkgBase.lib.darwinSystem {
system = machine.arch;
modules =
(commonModules pkgBase)
++ [
(./. + "/machines/${machine.hostname}")
homeBase.darwinModules.home-manager
];
specialArgs = {
inherit flakes;
inherit machine;
};
};
nixosBox = arch: pkgBase: homeBase: name:
pkgBase.lib.nixosSystem {
system = arch;
modules =
(commonModules pkgBase)
++ [
(./. + "/machines/${name}")
]
++ (
if builtins.isNull homeBase
then [ ]
else [
homeBase.nixosModules.home-manager
./common/home.nix
]
);
specialArgs = {
inherit flakes;
};
};
in
{
nixosConfiguration = {
"thinkie" = nixosBox "x86_64-linux" nixpkgs home-manager "thinkie";
};
darwinConfigurations = {
# $ darwin-rebuild build --flake .#tequila
tequila =
let
machine = {
arch = "aarch64-darwin";
username = "tmn";
hostname = "tequila";
homeDir = /Users/tmn;
};
in
macBox machine nix-darwin home-manager;
dev.wrk =
let
machine = {
arch = "aarch64-darwin";
username = "tri";
hostname = "dev.wrk";
homeDir = /Users/tri;
};
in
macBox machine nix-darwin home-manager;
};
devShell = pkgs.mkShell {
buildInputs = darwinInputs;
shellAliases = {
cargo = "${pkgs.cargo}/bin/cargo";
};
shellHook = ''
export LIBRARY_PATH="${pkgs.libiconv}/lib:$LIBRARY_PATH"
'';
};
# Expose the package set, including overlays, for convenience.
# darwinPackages = self.darwinConfigurations."simple".pkgs;
};
}