-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
164 lines (162 loc) · 5.76 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
{
description = "spencerjanssen's configs";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
agenix = {
url = "github:ryantm/agenix";
inputs.home-manager.follows = "home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
NixVirt = {
url = "https://flakehub.com/f/AshleyYakeley/NixVirt/*.tar.gz";
inputs.nixpkgs.follows = "nixpkgs";
};
lanzaboote = {
url = "github:nix-community/lanzaboote/v0.4.1";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs@{ self, nixpkgs, home-manager, agenix, NixVirt, lanzaboote }:
let
mkDevShell = system:
nixpkgs.legacyPackages.${system}.mkShell {
buildInputs =
[
nixpkgs.legacyPackages.${system}.nixpkgs-fmt
nixpkgs.legacyPackages.${system}.treefmt
nixpkgs.legacyPackages.${system}.nodePackages.prettier
nixpkgs.legacyPackages.${system}.nil
agenix.packages.${system}.agenix
(nixpkgs.legacyPackages.${system}.writeShellApplication {
name = "watch-check";
runtimeInputs = [
nixpkgs.legacyPackages.${system}.entr
];
text = ''
while git ls-files | entr -d -c sh -c 'nix flake check' ; [ $? -eq 2 ]; do
echo file added or removed, restarting
sleep 0.1s
done
'';
})
];
};
in
{
devShells.aarch64-linux.default = mkDevShell "aarch64-linux";
devShells.x86_64-linux.default = mkDevShell "x86_64-linux";
overlays = {
patch-hydra = (final: prev: {
hydra_unstable = prev.hydra_unstable.overrideAttrs (old: {
patches = (old.patches or [ ]) ++ [
./nixos/patches/hydra-githubstatus-remove-pr.patch
./nixos/patches/hydra-mangle-github.patch
];
doCheck = false;
});
});
};
nixosModules = {
# used for home-manager configurations, on NixOS prefer nixpkgs.flake.setNixPath:
nixpkgsFromFlake = { ... }:
{
nix = {
nixPath = [ "nixpkgs=${nixpkgs}" ];
registry = {
nixpkgs.flake = nixpkgs;
};
};
};
# for either NixOS or home-manager configurations:
registry = { ... }:
{
nix.registry = {
dotfiles = {
to = {
owner = "spencerjanssen";
repo = "dotfiles";
type = "github";
};
};
};
};
personalOverlays = { ... }:
{
nixpkgs.overlays = nixpkgs.lib.attrValues self.outputs.overlays;
};
home-assistant-os = ./nixos/home-assistant-os/module.nix;
};
nixosConfigurations = {
ungoliant = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
home-manager.nixosModules.home-manager
agenix.nixosModules.age
self.nixosModules.registry
self.nixosModules.personalOverlays
./me/secret-ssh-config.nix
./nixos/ungoliant/config.nix
];
specialArgs = { inherit inputs; };
};
mithlond = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
home-manager.nixosModules.home-manager
agenix.nixosModules.age
NixVirt.nixosModules.default
lanzaboote.nixosModules.lanzaboote
self.nixosModules.registry
self.nixosModules.personalOverlays
self.nixosModules.home-assistant-os
./me/secret-ssh-config.nix
./machines/mithlond
];
specialArgs = { inherit inputs; };
};
};
homeConfigurations.work-hm = home-manager.lib.homeManagerConfiguration {
modules = [
./nixos/home-manager/general-shell.nix
./nixos/home-manager/zsh.nix
self.nixosModules.nixpkgsFromFlake
self.nixosModules.registry
self.nixosModules.personalOverlays
{
home = {
file.".ssh/config".text = ''
Include /home/sjanssen/.ssh/extra-config
'';
sessionPath = [ "/home/sjanssen/.local/bin" "/home/sjanssen/.ghcup/bin" ];
homeDirectory = "/home/sjanssen";
username = "sjanssen";
};
programs.zsh.profileExtra = ''
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then
. '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh'
fi
'';
}
];
pkgs = nixpkgs.legacyPackages."x86_64-linux";
};
hydraJobs = {
ungoliant = self.lib.hydraJobsFromSystem self.nixosConfigurations.ungoliant;
mithlond = self.lib.hydraJobsFromSystem self.nixosConfigurations.mithlond;
work-hm = self.homeConfigurations.work-hm.activationPackage;
devShell-aarch64-linux = self.devShells.aarch64-linux.default;
devShell-x86_64-linux = self.devShells.x86_64-linux.default;
};
lib = {
allSystemPackages = system: builtins.listToAttrs (map (p: { name = (builtins.parseDrvName p.name).name; value = p; }) system.config.environment.systemPackages);
hydraJobsFromSystem = system: {
toplevel = system.config.system.build.toplevel;
kernel = system.config.system.build.kernel;
} // self.lib.allSystemPackages system;
};
};
}