-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
136 lines (124 loc) · 4.56 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 = "My system configurations for macOS, WSL, and NixOS";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
nixpkgs-stable-darwin.url = "nixpkgs/nixpkgs-24.05-darwin";
nixpkgs-stable-nixos.url = "nixpkgs/nixos-24.05";
nur.url = "github:nix-community/NUR";
nixos-wsl.url = "github:nix-community/NixOS-WSL/main";
nixos-wsl.inputs.nixpkgs.follows = "nixpkgs";
nixos-wsl.inputs.flake-utils.follows = "flake-utils";
nix-darwin.url = "github:LnL7/nix-darwin";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
emacs-overlay.url = "github:nix-community/emacs-overlay";
emacs-overlay.inputs.nixpkgs.follows = "nixpkgs";
emacs-overlay.inputs.flake-utils.follows = "flake-utils";
alacritty-theme.url = "github:alexghr/alacritty-theme.nix";
alacritty-theme.inputs.nixpkgs.follows = "nixpkgs";
nix-darwin-firefox.url = "github:bandithedoge/nixpkgs-firefox-darwin";
nix-darwin-firefox.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, nixpkgs-stable-darwin, nixpkgs-stable-nixos, nix-darwin, nixos-wsl, home-manager, ... }@inputs: let
lib = nixpkgs.lib;
users = [ "lukemurray" "murrayle23" ];
darwinHosts = [ "Lukes-Virtual-Machine" "Lukes-MacBook-Air" ];
nixosHosts = [ "wsl-nix" ];
userHostPairSeparator = "_";
hosts = darwinHosts ++ nixosHosts;
userHosts = builtins.foldl' (x: y: x ++ y) [] (lib.lists.forEach users (user: lib.lists.forEach hosts (host: user + userHostPairSeparator + host )));
dotfilesDir = "~/.dotfiles";
nixpkgsConfig = {
config.allowUnfree = true;
overlays = [
inputs.alacritty-theme.overlays.default
inputs.emacs-overlay.overlays.default
inputs.nix-darwin-firefox.overlay
inputs.nur.overlay
(final: prev: {
stable = if prev.stdenv.isDarwin then nixpkgs-stable-darwin.legacyPackages.${prev.system} else nixpkgs-stable-nixos.legacyPackages.${prev.system};
})
# (import ./packages/ghostty.nix)
];
};
getHostArchitecture = system: import ./system/${system}/system.nix;
forAllSystems = lib.genAttrs ["aarch64-darwin" "x86_64-darwin" "aarch64-linux" "x86_64-linux" "i686-linux"];
in {
darwinConfigurations = lib.genAttrs darwinHosts (system:
let
sys = getHostArchitecture system;
in
nix-darwin.lib.darwinSystem {
system = sys.arch;
specialArgs = inputs;
modules = [
{ nixpkgs = nixpkgsConfig; }
./system/${system}
];
}
);
nixosConfigurations = lib.genAttrs nixosHosts (system:
let
sys = getHostArchitecture system;
in
nixpkgs.lib.nixosSystem {
system = sys.arch;
specialArgs = inputs;
modules = [
{ nixpkgs = nixpkgsConfig; }
./system/${system}
] ++ (if sys.wsl then [ nixos-wsl.nixosModules.default ] else [ ]);
}
);
homeConfigurations = lib.genAttrs userHosts (userHost:
let
userHostPair = lib.strings.splitString userHostPairSeparator userHost;
user = builtins.elemAt userHostPair 0;
system = builtins.elemAt userHostPair 1;
sys = import ./system/${system}/system.nix;
in
home-manager.lib.homeManagerConfiguration {
pkgs = import nixpkgs (nixpkgsConfig // { system = sys.arch; });
modules = [
./user/${user}
];
extraSpecialArgs = inputs // {
username = user;
dotfilesDir = dotfilesDir;
hostname = system;
userSettings = import ./user/${user}/settings.nix;
};
}
);
packages = forAllSystems (platform:
let pkgs = import nixpkgs (nixpkgsConfig // {system = platform; });
in {
default = self.packages.${platform}.installer;
emacs = (import ./module/app/emacs/package.nix) pkgs {
opacity = 0.8;
font = import ./module/font/iosevka; # TODO this will need to be fixed
theme = import ./module/theme/generated/gruvbox-dark-medium;
};
installer = pkgs.writeShellApplication {
name = "install";
text = ''${./install.sh} "$@"'';
};
}
);
apps = forAllSystems (platform:
{
default = self.apps.${platform}.installer;
emacs = {
type = "app";
program = "${self.packages.${platform}.emacs}/bin/emacs";
};
installer = {
type = "app";
program = "${self.packages.${platform}.installer}/bin/install";
};
}
);
};
}