forked from notusknot/dotfiles-nix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
78 lines (72 loc) · 3.3 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
{
description = "NixOS configuration";
# All inputs for the system
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
nur = {
url = "github:nix-community/NUR";
inputs.nixpkgs.follows = "nixpkgs";
};
};
# All outputs for the system (configs)
outputs = { home-manager, nixpkgs, nur, ... }@inputs:
let
system = "x86_64-linux"; #current system
pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux;
lib = nixpkgs.lib;
user = "feng";
# This lets us reuse the code to "create" a system
# Credits go to sioodmy on this one!
# https://github.com/sioodmy/dotfiles/blob/main/flake.nix
mkSystem = pkgs: system: hostname: username:
pkgs.lib.nixosSystem {
system = system;
modules = [
{ networking.hostName = hostname; }
# General configuration (users, networking, sound, etc)
./modules/system/configuration.nix
# Hardware config (bootloader, kernel modules, filesystems, etc)
# DO NOT USE MY HARDWARE CONFIG!! USE YOUR OWN!!
#(./. + "/hosts/${hostname}/hardware-configuration.nix")
./hosts/${hostname}/hardware-configuration.nix
./hosts/${hostname}/configuration.nix
home-manager.nixosModules.home-manager
{
home-manager = {
useUserPackages = true;
useGlobalPkgs = true;
extraSpecialArgs = { inherit inputs; };
# Home manager config (configures programs like firefox, zsh, eww, etc)
# users.${username} = (./. + "/hosts/${hostname}/home.nix");
users.${username} = {
imports =
[
./modules/default.nix
./hosts/${hostname}/home.nix
];
};
};
# nixpkgs.overlays = [
# # Add nur overlay for Firefox addons
# nur.overlay
# (import ./overlays)
# ];
}
];
specialArgs = { inherit inputs username; };
};
in {
nixosConfigurations = {
# Now, defining a new system is can be done in one line
# Architecture Hostname Username
laptop = mkSystem inputs.nixpkgs system "laptop" user;
desktop = mkSystem inputs.nixpkgs system "desktop" user;
vm = mkSystem inputs.nixpkgs system "vm" user;
lxc = mkSystem inputs.nixpkgs system "lxc" user;
};
};
}