-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
138 lines (129 loc) · 4.28 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
{
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
lima.url = "github:kasuboski/nixos-lima";
lima.inputs.nixpkgs.follows = "nixpkgs";
impermanence.url = "github:Nix-community/impermanence";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
darwin.url = "github:LnL7/nix-darwin";
darwin.inputs.nixpkgs.follows = "nixpkgs";
mac-app-util.url = "github:hraban/mac-app-util";
mac-app-util.inputs.nixpkgs.follows = "nixpkgs";
vscode-server.url = "github:nix-community/nixos-vscode-server";
vscode-server.inputs.nixpkgs.follows = "nixpkgs";
nixvim.url = "github:nix-community/nixvim";
nixvim.inputs.nixpkgs.follows = "nixpkgs";
nix2container.url = "github:nlewo/nix2container";
nix2container.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = {
self,
nixpkgs,
lima,
impermanence,
home-manager,
darwin,
mac-app-util,
vscode-server,
nix2container,
...
} @ inputs: let
inherit (self) outputs;
systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
forEachSystem = nixpkgs.lib.genAttrs systems;
forEachPkgs = f: forEachSystem (sys: f nixpkgs.legacyPackages.${sys});
in {
formatter = forEachPkgs (pkgs: pkgs.alejandra);
devShells = forEachPkgs (pkgs: import ./shell.nix {inherit pkgs;});
overlays = import ./overlays;
nixosConfigurations = {
fettig = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {inherit inputs outputs;};
modules = [
./hosts/fettig/configuration.nix
];
};
ziel = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {inherit inputs outputs;};
modules = [
./hosts/ziel/configuration.nix
];
};
nixos = nixpkgs.lib.nixosSystem {
system = "aarch64-linux";
specialArgs = {inherit inputs outputs;};
modules = [
lima.nixosModules.lima
./hosts/lima/user-config.nix
];
};
nixosx86 = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {inherit inputs outputs;};
modules = [
lima.nixosModules.lima
./hosts/lima/user-config.nix
];
};
# nix build .#nixosConfigurations.live.config.system.build.isoImage
live = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
specialArgs = {inherit inputs outputs;};
modules = [
./hosts/live/configuration.nix
{isoImage.squashfsCompression = "gzip -Xcompression-level 1";}
];
};
};
homeConfigurations = let
lib = nixpkgs.lib;
users = ["josh" "root" "ubuntu"];
systemToArch = system: builtins.head (lib.strings.splitString "_" (builtins.head (lib.strings.splitString "-" system)));
userSystems = lib.lists.concatMap (u: lib.lists.concatMap (sys: [(lib.attrsets.nameValuePair u sys)]) systems) users;
mkHomeManagerConfig = {
user,
system,
}:
home-manager.lib.homeManagerConfiguration {
modules = [
{
nixpkgs.overlays = [(import ./overlays)];
}
./users/josh/home.nix
{
home.username = lib.mkForce user;
}
];
pkgs = nixpkgs.legacyPackages.${system};
extraSpecialArgs = {inherit inputs outputs;};
};
configs = builtins.listToAttrs (builtins.map ({
name,
value,
}: (lib.attrsets.nameValuePair (lib.concatStringsSep "@" [name (systemToArch value)]) (mkHomeManagerConfig {
user = name;
system = value;
})))
userSystems);
in
configs;
packages = forEachPkgs (pkgs: {
devContainer = import ./devcontainer.nix {inherit pkgs nix2container;};
});
darwinConfigurations = {
"work-mac" = darwin.lib.darwinSystem {
system = "x86_64-darwin";
specialArgs = {inherit inputs outputs;};
modules = [./hosts/work-mac/configuration.nix];
};
"personal-mac" = darwin.lib.darwinSystem {
system = "aarch64-darwin";
specialArgs = {inherit inputs outputs;};
modules = [./hosts/personal-mac/configuration.nix];
};
};
};
}