-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
100 lines (89 loc) · 2.93 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
{
description = "NixOS dotfiles";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
flake-utils.url = "github:numtide/flake-utils";
home-manager = {
url = "github:nix-community/home-manager";
# Use same nixpkgs versions
inputs.nixpkgs.follows = "nixpkgs";
};
# Nix User Repository (similar to Arch Linux AUR)
nur.url = "github:nix-community/NUR";
# Nix index
nix-index-database = {
url = "github:nix-community/nix-index-database";
inputs.nixpkgs.follows = "nixpkgs";
};
# External packages
scratch = {
url = "github:negrel/scratch";
inputs.flake-utils.follows = "flake-utils";
inputs.nixpkgs.follows = "nixpkgs";
};
allelua = {
url = "github:negrel/allelua";
inputs.flake-utils.follows = "flake-utils";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, nur, scratch, allelua, ... }@inputs:
let
# Make system config helper function
mkConfig = system: hostname:
let
pkgs = (lib.recursiveUpdate self.pkgs."${system}"
self.packages."${system}") // {
scratch = scratch.packages.${system}.default;
allelua = allelua.packages.${system}.default;
};
lib = self.lib."${system}";
# nixosSystem is a nixpkgs function that build a configuration.nix
in nixpkgs.lib.nixosSystem {
inherit system;
modules = [
# Hostname
{
networking.hostName = hostname;
}
# General configuration
./hosts/.common/configuration.nix
# Host specific config
(./. + "/hosts/${hostname}/configuration.nix")
];
# Extra args to pass to modules
specialArgs = inputs // { inherit pkgs lib; };
};
outputsWithoutSystem = {
nixosConfigurations = {
frameworkstation = mkConfig "x86_64-linux" "frameworkstation";
};
};
outputsWithSystem = flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
config = { allowUnfree = true; };
overlays = [
nur.overlay
# Add flake-utils.lib as pkgs.lib.flake-utils
(self: super: {
lib = super.lib // { flake-utils = flake-utils.lib; };
})
# Add ./lib to pkgs.lib.my
(self: super: {
lib = super.lib // {
my = import ./lib { inherit (super) lib; };
};
})
];
};
in {
pkgs = pkgs;
lib = pkgs.lib;
packages =
pkgs.lib.my.callPackagesRecursively ./pkgs { inherit pkgs; };
});
in outputsWithSystem // outputsWithoutSystem;
}