-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
149 lines (145 loc) · 4.06 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
{
description = "A basic flake with a shell";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
devshell.url = "github:numtide/devshell";
home-manager = {
url = "github:nix-community/home-manager/master";
inputs.nixpkgs.follows = "nixpkgs";
};
doom-emacs.url = "github:doomemacs/doomemacs/master";
doom-emacs.flake = false;
emacs-overlay.url = "github:nix-community/emacs-overlay";
};
outputs = {
self,
nixpkgs,
flake-utils,
doom-emacs,
emacs-overlay,
home-manager,
devshell,
}: let
inherit (home-manager.lib) homeManagerConfiguration;
isDarwin = system: (builtins.elem system nixpkgs.lib.platforms.darwin);
M1Overlay = (
final: prev: let
pkgs_x86_64 = import nixpkgs {localSystem = "x86_64-darwin";};
in {
emacsMacport = pkgs_x86_64.emacsMacport;
}
);
homePrefix = system:
if isDarwin system
then "/Users"
else "/home";
mkOverlays = system:
[
emacs-overlay.overlay
(final: prev: {doomEmacsRevision = doom-emacs.rev;})
(final: prev: {home-manager = home-manager.packages.${system}.home-manager;})
(import ./nixpkgs/overlays/bins.nix)
]
++ (
if system == "aarch64-darwin"
then [M1Overlay]
else []
);
mkHomeConfig = {
username,
system ? "x86_64-linux",
baseModules ? [],
extraModules ? [],
}:
homeManagerConfiguration rec {
pkgs = nixpkgs.legacyPackages.${system};
modules =
[
{
home = {
inherit username;
homeDirectory = "${homePrefix system}/${username}";
stateVersion = "22.05";
};
}
]
++ baseModules
++ extraModules
++ (
if isDarwin system
then [./nixpkgs/mac.nix]
else [./nixpkgs/linux.nix]
)
++ [{nixpkgs.overlays = mkOverlays system;}];
};
in
{
checks = builtins.listToAttrs (
(map
(system: {
name = system;
value = {
linux = self.homeConfigurations.chris-3900x.activationPackage;
};
})
["x86_64-linux"])
++ (map
(system: {
name = system;
value = {
mac = self.homeConfigurations.Yuris-MacBook-Airlocal.activationPackage;
};
})
nixpkgs.lib.platforms.darwin)
);
homeConfigurations = {
chris-3900x = mkHomeConfig {
username = "chris";
baseModules = [
./nixpkgs/emacs.nix
./nixpkgs/profiles/personal.nix
];
};
FVFG608QQ05Qlocal = mkHomeConfig {
# workm1
system = "aarch64-darwin";
username = "chris.mcdevitt";
baseModules = [
./nixpkgs/emacs.nix
./nixpkgs/fonts.nix
./nixpkgs/profiles/work.nix
];
};
Yuris-MacBook-Airlocal = mkHomeConfig {
system = "aarch64-darwin";
username = "chris";
baseModules = [
./nixpkgs/fonts.nix
./nixpkgs/profiles/personal.nix
];
};
};
}
// flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
overlays = (mkOverlays system) ++ [devshell.overlay];
};
nixBin = pkgs.writeShellScriptBin "nix" ''
${pkgs.nixFlakes}/bin/nix --option experimental-features "nix-command flakes" "$@"
'';
devShellOld = pkgs.mkShell {
nativeBuildInputs = [pkgs.bashInteractive];
packages = with pkgs; [nixUnstable];
buildInputs = with pkgs; [pkgs.home-manager];
shellHook = ''
export NIX_PATH="nixpkgs=${nixpkgs}:home-manager=${home-manager}"
'';
};
in {
devShell = pkgs.devshell.mkShell {
packages = with pkgs; [pkgs.home-manager];
};
});
}