forked from ryanb/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
161 lines (146 loc) · 3.96 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 = "dotfiles";
nixConfig = {
extra-substituters = [
"https://nix-community.cachix.org"
];
extra-trusted-public-keys = [
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
darwin = {
url = "github:lnl7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
mkalias = {
url = "github:reckenrode/mkalias";
inputs.nixpkgs.follows = "nixpkgs";
};
nur.url = "github:nix-community/NUR";
nix-index-database = {
url = "github:nix-community/nix-index-database";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
nixpkgs,
nixos-hardware,
home-manager,
darwin,
nur,
nix-index-database,
...
} @ inputs: let
inherit builtins;
username = "sprice";
getHomeDirectory = system:
with nixpkgs.legacyPackages.${system}.stdenv;
if isDarwin
then "/Users/${username}"
else if isLinux
then "/home/${username}"
else "";
getExtraModules = system:
with nixpkgs.legacyPackages.${system}.stdenv;
if isDarwin || isAarch64
then [./nix/home/darwin]
else if isLinux
then [./nix/home/linux]
else [];
mkDarwinConfig = args:
darwin.lib.darwinSystem {
pkgs = import nixpkgs {
inherit (args) system;
config = {
allowUnfree = true;
allowInsecure = false;
allowUnsupportedSystem = true;
allowUnfreePredicate = pkg: true;
allowBroken = false;
};
};
specialArgs = {
inherit (args) machine;
};
modules = [
./nix/darwin
({...}: {
system.stateVersion = 4;
})
];
};
mkHomeConfig = args:
home-manager.lib.homeManagerConfiguration {
pkgs = import nixpkgs {
inherit (args) system;
config = {
allowUnfree = true;
allowInsecure = false;
allowUnsupportedSystem = true;
allowUnfreePredicate = pkg: true;
allowBroken = false;
};
overlays = [
(final: prev: {
mkalias = inputs.mkalias.outputs.apps.${prev.stdenv.system}.default.program;
})
(nur.overlays.default)
(import ./nix/pkgs)
];
};
modules =
[
./nix/home
{
home = {
inherit username;
homeDirectory = getHomeDirectory args.system;
stateVersion = "23.05";
};
}
nix-index-database.hmModules.nix-index
]
++ getExtraModules args.system;
extraSpecialArgs = {
inherit (args) machine;
};
};
in {
# NixOS configuration entrypoint
# Available through 'nixos-rebuild --flake .#nixos'
nixosConfigurations = {
nixos = nixpkgs.lib.nixosSystem {
specialArgs = {inherit inputs;};
# > Our main nixos configuration file <
modules = [
nixos-hardware.nixosModules.lenovo-thinkpad-t440s
./nix/nixos/configuration.nix
];
};
};
darwinConfigurations.sp = mkDarwinConfig {
system = "aarch64-darwin";
machine = "sp";
};
darwinConfigurations.ltm-3914 = mkDarwinConfig {
system = "aarch64-darwin";
machine = "ltm-3914";
};
homeConfigurations."${username}@linux" = mkHomeConfig {
system = "x86_64-linux";
};
homeConfigurations."${username}@ltm-3914" = mkHomeConfig {
system = "aarch64-darwin";
};
homeConfigurations."${username}@sp" = mkHomeConfig {
system = "aarch64-darwin";
};
};
}