-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
106 lines (95 loc) · 2.5 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
{
description = "dotfiles";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
darwin = {
url = "github:LnL7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
home-manager,
darwin,
treefmt-nix,
rust-overlay,
...
}:
let
supportedSystems = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
pkgsFor =
system:
import nixpkgs {
inherit system;
overlays = self.overlays.default;
config.allowUnfree = true;
};
system = "aarch64-darwin";
username = "shuntaka";
homeDirectory =
if system == "aarch64-darwin" then
"/Users/${username}"
else if system == "x86_64-linux" then
"/home/${username}"
else
throw "Unsupported system: ${system}";
pkgs = pkgsFor system;
specialArgs = {
inherit username system homeDirectory;
};
in
{
overlays.default = [
(import ./overlays { inherit self; })
rust-overlay.overlays.default
];
formatter = forAllSystems (
sys:
let
sysPkgs = pkgsFor sys;
in
(treefmt-nix.lib.evalModule sysPkgs ./treefmt.nix).config.build.wrapper
);
darwinConfigurations.${username} = darwin.lib.darwinSystem {
inherit pkgs specialArgs;
modules = [
./nix-darwin/default.nix
home-manager.darwinModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.${username} = import ./home-manager/home.nix;
home-manager.extraSpecialArgs = specialArgs;
}
];
};
homeConfigurations.${username} = home-manager.lib.homeManagerConfiguration {
inherit pkgs;
extraSpecialArgs = specialArgs;
modules = [
{ nix.package = pkgs.nix; }
(import ./home-manager/home.nix)
];
};
};
}