-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
150 lines (146 loc) · 4.72 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
{
description = "An example NixOS configuration";
inputs = {
home.url = "github:nix-community/home-manager";
home.inputs.nixpkgs.follows = "nixpkgs";
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
nixos-generators = {
url = "github:/nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
nixos-hardware.url = "github:NixOS/nixos-hardware";
deploy-rs = {
url = "github:serokell/deploy-rs";
inputs.nixpkgs.follows = "nixpkgs";
};
nix-filter.url = "github:numtide/nix-filter";
agenix.url = "github:ryantm/agenix";
agenix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = {
self,
home,
nixpkgs,
nixos-generators,
nixos-hardware,
deploy-rs,
nix-filter,
agenix,
}: let
rev =
if self ? rev
then self.rev
else "dirty";
fix-nixpkgs-path = import ./modules/fix-nixpkgs-path.nix {inherit nixpkgs;};
all-overlays =
[
nix-filter.overlays.default
deploy-rs.overlay
]
++ import ./overlays;
aarch64-linuxPkgs = import nixpkgs {
system = "aarch64-linux";
overlays =
all-overlays
++ [
(final: prev: {
makeModulesClosure = x:
prev.makeModulesClosure (x // {allowMissing = true;});
})
];
};
aarch64-darwinPkgs = import nixpkgs {
system = "aarch64-darwin";
overlays = all-overlays;
config.allowUnfree = true;
};
x86_64Pkgs = import nixpkgs {
system = "x86_64-linux";
overlays = all-overlays;
config.allowUnfree = true;
};
makePiFlashSript = pkgs:
with pkgs;
writeScriptBin "write-raspberry-pi-flash" ''
path_to_image=$(cat ${self.packages.aarch64-linux.raspberryPiInstaller}/nix-support/hydra-build-products | cut -d ' ' -f 3)
${zstd}/bin/zstd -d --stdout $path_to_image | ${coreutils}/bin/dd of=$1 bs=4096 conv=fsync status=progress
'';
packages = {
aarch64-linux.raspberryPiInstaller = with ARCTURUS;
nixos-generators.nixosGenerate {
inherit modules;
pkgs = aarch64-linuxPkgs;
format = "sd-aarch64-installer";
};
x86_64-linux.writeRaspberryPiFlash = makePiFlashSript x86_64Pkgs;
aarch64-linux.writeRaspberryPiFlash = makePiFlashSript aarch64-linuxPkgs;
x86_64-linux.toolbox = x86_64Pkgs.toolbox;
# aarch64-linux.play-xmonad = aarch64-linuxPkgs.haskellPackages.play-xmonad;
aarch64-darwin.toolbox = aarch64-darwinPkgs.toolbox;
aarch64-linux.toolbox = aarch64-linuxPkgs.toolbox;
};
MALAK2 = (import ./machines/MALAK2) {
inherit all-overlays home fix-nixpkgs-path rev;
};
YASAB = (import ./machines/YASAB) {
inherit all-overlays home fix-nixpkgs-path rev;
};
EZRA = (import ./machines/EZRA) {
inherit all-overlays fix-nixpkgs-path rev agenix;
};
ARCTURUS = (import ./machines/ARCTURUS) {
inherit all-overlays home fix-nixpkgs-path rev;
hardware-module = nixos-hardware.nixosModules.raspberry-pi-4;
};
in {
inherit packages;
homeConfigurations = {
d4hines = home.lib.homeManagerConfiguration {
pkgs = aarch64-darwinPkgs;
modules = import ./machines/DARESH {
inherit rev;
pkgs = aarch64-darwinPkgs;
};
};
malak = home.lib.homeManagerConfiguration {
pkgs = aarch64-linuxPkgs;
modules = import ./machines/MALAK {
inherit rev;
pkgs = aarch64-linuxPkgs;
};
};
};
nixosConfigurations = {
# My desktop-on-a-thumb-drive
MALAK2 = nixpkgs.lib.nixosSystem MALAK2;
# My other desktop
YASAB = nixpkgs.lib.nixosSystem YASAB;
# My raspberry pi
ARCTURUS = nixpkgs.lib.nixosSystem ARCTURUS;
# Server
EZRA = nixpkgs.lib.nixosSystem EZRA;
};
apps.x86_64-linux.writeRaspberryPiFlash = {
type = "app";
program = "${self.packages.x86_64-linux.writeRaspberryPiFlash}/bin/write-raspberry-pi-flash";
};
deploy.nodes.ARCTURUS = {
hostname = "192.168.0.103";
profiles.system = {
user = "root";
path = deploy-rs.lib.aarch64-linux.activate.nixos self.nixosConfigurations.ARCTURUS;
};
};
deploy.nodes.EZRA = {
hostname = "ezra.hines.house";
profiles.system = {
user = "root";
path = deploy-rs.lib.x86_64-linux.activate.nixos self.nixosConfigurations.EZRA;
remoteBuild = true;
};
};
checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
formatter.x86_64-linux = nixpkgs.legacyPackages.x86_64-linux.alejandra;
formatter.aarch64-darwin = nixpkgs.legacyPackages.aarch64-darwin.alejandra;
};
}