-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
181 lines (151 loc) · 5.31 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
{
description = "My Personal Nix Configs";
outputs = inputs @ {flake-parts, ...}: let
inherit (inputs.nixpkgs.lib) debug;
# Static data about our homelab
homelab = builtins.fromTOML (builtins.readFile ./homelab.toml);
# Load all of our source file
lib = inputs.haumea.lib.load {
src = ./src;
inputs = {
inherit inputs homelab debug;
inherit (inputs.nixpkgs) lib;
};
};
in
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
inputs.treefmt-nix.flakeModule
];
systems = ["x86_64-linux" "aarch64-linux" "aarch64-darwin"];
perSystem = {
pkgs,
inputs',
config,
system,
...
}: let
sys = {inherit pkgs inputs' config system;};
in {
# Allow unfree packages
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
config.allowUnfree = true;
};
# Pass the per system attributes to each package
# Allow either a packge or attrset of packages in each file
# If it is an atterset, each package within has the filename prefixed
packages =
pkgs.lib.attrsets.concatMapAttrs
(
name: pkgFn: let
inherit (pkgs.lib) attrsets;
pkg = pkgFn sys;
in
if (attrsets.isDerivation pkg)
then {"${name}" = pkg;}
else
attrsets.mapAttrs' (
subName: subPkg:
attrsets.nameValuePair "${name}-${subName}" subPkg
)
pkg
)
lib.packages;
devShells.default = pkgs.mkShell {
buildInputs =
[
inputs'.colmena.packages.colmena
inputs'.ragenix.packages.default
config.packages.deploy
pkgs.git
pkgs.nurl
pkgs.nix-init
pkgs.nushell
pkgs.rage
pkgs.pwgen
pkgs.dogdns
pkgs.opentofu
pkgs.little_boxes
pkgs.nil
(lib.packages.agedit {inherit pkgs;})
(lib.packages.neovim {inherit pkgs;})
]
++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isDarwin [
inputs'.morlana.packages.default
];
};
treefmt = {
projectRootFile = ".git/config";
programs = {
alejandra.enable = true;
stylua.enable = true;
};
};
};
flake = {
# Export our modules and configurations
inherit (lib) nixosModules;
inherit (lib) nixosConfigurations;
inherit (lib) darwinConfigurations;
inherit (lib) homeModules;
# Deploy with Colmena
colmena =
{
meta = {
description = "My personal boxes";
# This can be overriden by node nixpkgs
nixpkgs = import inputs.nixpkgs {system = "x86_64-linux";};
nodeNixpkgs = builtins.mapAttrs (_: value: value.pkgs) lib.nixosConfigurations;
nodeSpecialArgs = builtins.mapAttrs (_: value: value._module.specialArgs) lib.nixosConfigurations;
};
}
// builtins.mapAttrs (_: value: {imports = value._module.args.modules;}) lib.nixosConfigurations;
};
};
inputs = {
# Nixpkgs
nixpkgs.url = "flake:nixpkgs/nixpkgs-unstable";
# Configure MacOS via Nix
nix-darwin.url = "github:LnL7/nix-darwin";
nix-darwin.inputs.nixpkgs.follows = "nixpkgs";
# Flake authoring framework
flake-parts.url = "github:hercules-ci/flake-parts";
# Format all the things
treefmt-nix.url = "github:numtide/treefmt-nix";
# Build NixOS images
nixos-generators.url = "github:nix-community/nixos-generators";
# NixOS modules for specific hardware
nixos-hardware.url = "github:NixOS/nixos-hardware/master";
# Stateless NixOS deployment tool written in Rust
colmena.url = "github:zhaofengli/colmena";
colmena.inputs.nixpkgs.follows = "nixpkgs";
# Declarative disk partitioning
disko.url = "github:nix-community/disko";
disko.inputs.nixpkgs.follows = "nixpkgs";
# Use NixOS in WSL2
nixos-wsl.url = "github:nix-community/NixOS-WSL";
nixos-wsl.inputs.nixpkgs.follows = "nixpkgs";
# Filesystem based importing for Nix
haumea.url = "github:nix-community/haumea/v0.2.2";
haumea.inputs.nixpkgs.follows = "nixpkgs";
# Manage user environments with Nix
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
# Encrypted Secrets
ragenix.url = "github:yaxitech/ragenix";
ragenix.inputs.nixpkgs.follows = "nixpkgs";
# Pre built Nixpkgs index
nix-index-database.url = "github:nix-community/nix-index-database";
nix-index-database.inputs.nixpkgs.follows = "nixpkgs";
# Experimental DE from System76
nixos-cosmic.url = "github:lilyinstarlight/nixos-cosmic";
nixos-cosmic.inputs.nixpkgs.follows = "nixpkgs";
# Nix on my phone
nix-on-droid.url = "github:nix-community/nix-on-droid/master";
nix-on-droid.inputs.nixpkgs.follows = "nixpkgs";
# Nice CLI for deploying Nix on Darwin
morlana.url = "github:ryanccn/morlana";
morlana.inputs.nixpkgs.follows = "nixpkgs";
};
}