-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
99 lines (95 loc) · 2.94 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
{
description = "Declarative macOS configuration with nix-darwin + Home Manager";
# the nixConfig here only affects the flake itself, not the system configuration!
nixConfig = {
substituters = [
"https://cache.nixos.org"
"https://nix-community.cachix.org"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-24.11-darwin";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
# home-manager, used for managing user configuration
home-manager = {
url = "github:nix-community/home-manager/release-24.11";
# The `follows` keyword in inputs is used for inheritance.
# Here, `inputs.nixpkgs` of home-manager is kept consistent with the `inputs.nixpkgs` of the current flake,
# to avoid problems caused by different versions of nixpkgs dependencies.
inputs.nixpkgs.follows = "nixpkgs";
};
nix-darwin = {
url = "github:LnL7/nix-darwin/nix-darwin-24.11";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-darwin-emacs = {
url = "github:lentil32/nix-darwin-emacs";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
nixpkgs-unstable,
nix-darwin,
home-manager,
nix-darwin-emacs,
rust-overlay,
...
}@inputs:
let
username = "starush";
useremail = "[email protected]";
system = "aarch64-darwin"; # aarch64-darwin or x86_64-darwin
hostname = "lentil32-MacBookPro";
uid = 502; # User ID should match existing system user
nixpkgsConfig = {
overlays = with inputs; [
nix-darwin-emacs.overlays.emacs
rust-overlay.overlays.default
];
};
pkgs = nixpkgs.legacyPackages.${system};
pkgs-unstable = nixpkgs-unstable.legacyPackages.${system};
specialArgs = inputs // {
inherit
pkgs-unstable
username
useremail
hostname
uid
system
;
};
in
{
darwinConfigurations."${hostname}" = nix-darwin.lib.darwinSystem {
inherit system specialArgs;
modules = [
./modules/nix-core.nix
./modules/system.nix
./modules/apps.nix
./modules/host-users.nix
home-manager.darwinModules.home-manager
{
nixpkgs = nixpkgsConfig;
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.extraSpecialArgs = specialArgs;
home-manager.users.${username} = import ./home;
}
];
};
# nix code formatter
formatter.${system} = pkgs.nixfmt-rfc-style;
};
}