-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
117 lines (107 loc) · 3.18 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
{
inputs = {
nixpkgs = {
url = "github:NixOS/nixpkgs";
};
nix-darwin = {
url = "github:LnL7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-homebrew = {
url = "github:zhaofengli-wip/nix-homebrew";
inputs.nixpkgs.follows = "nixpkgs";
};
nixvim = {
url = "github:nix-community/nixvim";
inputs.nixpkgs.follows = "nixpkgs";
};
hardware = {
url = "github:nixos/nixos-hardware";
};
vscode-server = {
url = "github:nix-community/nixos-vscode-server";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs@{ self, nixpkgs, nix-darwin, home-manager, nix-homebrew, nixvim, hardware, vscode-server, ... }:
let
lib = nixpkgs.lib.extend (lib: _:
let hm = inputs.home-manager.lib.hm; in {
inherit hm;
my = import ./lib { inherit inputs lib; };
});
forAllSystems = nixpkgs.lib.genAttrs [
"aarch64-darwin"
"x86_64-linux"
];
overlays = forAllSystems (system: import ./overlays { inherit inputs lib system; });
mkConfigurationModules = lib.concatMap
(module: (import module { inherit inputs lib overlays; }).modules);
mkDarwinConfiguration = host-config:
let
system = "aarch64-darwin";
in
nix-darwin.lib.darwinSystem {
inherit system;
specialArgs = { inherit self inputs lib overlays system vscode-server; };
modules = [ host-config ]
++ mkConfigurationModules [
./modules/common
./modules/darwin
];
};
mkNixosConfiguration = host-config:
let
system = "x86_64-linux";
in
nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = { inherit self inputs lib overlays system hardware; };
modules = [ host-config ]
++ mkConfigurationModules [
./modules/common
./modules/linux
];
};
in
{
inherit lib;
packages = forAllSystems (system:
let pkgs = nixpkgs.legacyPackages.${system};
in import ./pkgs { inherit pkgs lib system; }
);
devShells = forAllSystems (system:
let
pkgs = nixpkgs.legacyPackages.${system};
pre-commit-hooks = import ./pre-commit.nix { inherit pkgs; };
in
{
default = pkgs.mkShell {
buildInputs = with pkgs; [
nixpkgs-fmt
pre-commit
direnv
];
shellHook = ''
if [ -f .envrc ]; then
direnv allow
fi
pre-commit install -f --hook-type pre-commit
'';
};
}
);
darwinConfigurations.mac-italy = mkDarwinConfiguration ./hosts/mac-italy;
nixosConfigurations.nix-germany = mkNixosConfiguration ./hosts/nix-germany;
templates = {
python = {
path = ./templates/python;
description = "A template for a Python project using poetry";
};
};
};
}