-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
136 lines (121 loc) · 4.07 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
{
description = "Arun's Nix Configuration Flake";
inputs = {
nixpkgs-stable.url = "github:nixos/nixpkgs/nixos-23.05";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
#... Declarative configuration of user specific packages and dotfiles
home-manager.url = "github:nix-community/home-manager/master";
home-manager.inputs.nixpkgs.follows = "nixpkgs-unstable";
#... MacOS system level settings
darwin.url = "github:lnl7/nix-darwin";
darwin.inputs.nixpkgs.follows = "nixpkgs-unstable";
lib-aggregate.url = "github:nix-community/lib-aggregate"; #... Aggregate of nix libs that do not depend on nixpkgs
flake-utils.url = "github:numtide/flake-utils";
};
outputs = {
self,
darwin,
home-manager,
...
} @ inputs:
let
isDarwin = system: (builtins.elem system inputs.nixpkgs.lib.platforms.darwin);
homePrefix = system: if isDarwin system then "/Users" else "/home";
defaultSystems = [ "aarch64-linux" "aarch64-darwin" "x86_64-darwin" "x86_64-linux" ];
#... Function to generate a base darwin configuration with the specified hostname, overlays, and any extraModules applied
mkDarwinConfig = {
system ? "aarch64-darwin",
nixpkgs ? inputs.nixpkgs,
baseModules ? [
home-manager.darwinModules.home-manager
./modules/darwin
],
extraModules ? [],
}:
inputs.darwin.lib.darwinSystem {
inherit system;
modules = baseModules ++ extraModules;
specialArgs = {inherit self inputs nixpkgs;};
};
#... Function to generate home manager configuration usable on any unix system
mkHomeConfig = {
username,
system ? "x86_64-linux",
nixpkgs ? inputs.nixpkgs,
baseModules ? [
./modules/home-manager
{
home = {
inherit username;
homeDirectory = "${homePrefix system}/${username}";
sessionVariables = { };
};
}
],
extraModules ? [],
}:
inputs.home-manager.lib.homeManagerConfiguration rec {
pkgs = import nixpkgs { inherit system; };
extraSpecialArgs = {inherit self inputs nixpkgs;};
modules = baseModules ++ extraModules;
};
mkChecks = {
arch,
os,
username ? "arun",
}: {
"${arch}-${os}" = {
"${username}_${os}" =
if os == "darwin"
then
self.darwinConfigurations
."${username}@${arch}-${os}"
.config
.system
.build
.toplevel
else
builtins.derivation { ##... Dummy derivation until we implement a NixOS derivation
name = "NixOS_NotImplemented";
builder = "true";
system = "${arch}-${os}";
};
"${username}_home" =
self.homeConfigurations."${username}@${arch}-${os}".activationPackage;
};
};
in {
#... MacOS Configurations
darwinConfigurations = {
"arun@aarch64-darwin" = mkDarwinConfig {
system = "aarch64-darwin";
extraModules = [
./profiles/personal.nix
./modules/darwin/apps.nix
];
};
};
#... Home Manager Configurations (for non-NixOS Linux installations)
homeConfigurations = {
"audayashankar@x86_64-linux" = mkHomeConfig {
username = "audayashankar";
system = "x86_64-linux";
extraModules = [ ./profiles/home-manager/work.nix ];
};
"arun@x86_64-linux" = mkHomeConfig {
username = "arun";
system = "x86_64-linux";
extraModules = [ ./profiles/home-manager/personal.nix ];
};
"arun@aarch64-darwin" = mkHomeConfig {
username = "arun";
system = "aarch64-darwin";
extraModules = [ ./profiles/home-manager/personal.nix ];
};
};
checks = {}
// (mkChecks { arch = "aarch64"; os = "darwin"; username = "arun"; })
// (mkChecks { arch = "x86_64"; os = "linux"; username = "audayashankar"; });
};
}