-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
119 lines (105 loc) · 3.22 KB
/
Copy pathflake.nix
File metadata and controls
119 lines (105 loc) · 3.22 KB
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
{
description =
"Kemalmao nix environment: NixOS, Home Manager, Darwin";
inputs = {
# nix derivations
nixpkgs = {
url = "github:nixos/nixpkgs/nixpkgs-unstable"; # unstable channel
};
# home manager
home-manager = {
url = "github:nix-community/home-manager/master";
inputs.nixpkgs.follows = "nixpkgs";
};
# nix darwin
darwin = {
url = "github:lnl7/nix-darwin";
inputs.nixpkgs.follows = "nixpkgs";
};
# tree-sitter-rescript
ts-rescript = {
url = "github:nkrkv/tree-sitter-rescript";
flake = false;
};
};
# TODO: for each system configuration.
outputs =
inputs@{ nixpkgs, home-manager, darwin, ... }:
let
# Define user
user = {
name = "kemalmao";
linux = "x86_64-linux";
darwin = "x86_64-darwin";
};
# Define pkgs
pkgs = system:
import nixpkgs {
inherit system;
config = {
allowUnfree = true;
permittedInsecurePackages =
[ "broadcom-sta-6.30.223.271-59-6.18.1"];
};
};
# Define Func for Home Manager configuration
mkHomeConfig = system: username:
if system != "x86_64-darwin" || "aarch64-darwin" then
home-manager.lib.homeManagerConfiguration {
pkgs = pkgs system;
modules = [
./modules/home-manager
{
home.username = username;
home.homeDirectory = "/home/${username}";
}
];
}
else
home-manager.darwinModules.home-manager {
home-manager = {
useGlobalPkgs = true;
useUserPackages = true;
extraSpecialArgs = { inherit inputs; };
users.${username}.imports =
[
./modules/home-manager];
};
users.users.${username}.home = "/Users/${username}";
};
# Define Func for NixOS configuration
mkNixosConfig = system: username:
nixpkgs.lib.nixosSystem {
pkgs = pkgs system;
specialArgs = { inherit inputs; };
modules = [
./nixos/configuration.nix
home-manager.nixosModules.home-manager
{
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
# home-manager.extraSpecialArgs = { inherit ; };
home-manager.users.${username} = {
imports = [
./modules/home-manager
];
};
}
];
};
# Define Func for Darwin configuration
mkDarwinConfig = system: username:
darwin.lib.darwinSystem {
lib = nixpkgs.lib;
pkgs = pkgs system;
modules = [ ./modules/darwin (mkHomeConfig system username) ];
};
in {
# darwin & darwin home manager
darwinConfigurations.${user.name} = mkDarwinConfig user.darwin user.name;
# standalone linux home manager
homeConfigurations.${user.name} = mkHomeConfig user.linux user.name;
# nixos + home manager
nixosConfigurations.${user.name} = mkNixosConfig user.linux user.name;
};
}