-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
115 lines (99 loc) · 3 KB
/
flake.nix
File metadata and controls
115 lines (99 loc) · 3 KB
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
{
description = "Nix configuration";
inputs = {
# Use as the main nixpkgs repository (to get the latest packages)
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
nix-index-database = {
url = "github:nix-community/nix-index-database";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager/master";
inputs.nixpkgs.follows = "nixpkgs";
};
darwin = {
url = "github:nix-darwin/nix-darwin/master";
inputs.nixpkgs.follows = "nixpkgs";
};
# Neovim configuration framework
nixvim = {
url = "github:nix-community/nixvim";
inputs.nixpkgs.follows = "nixpkgs";
};
# To encrypt/decrypt secrets
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# To format the repository
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
# To get Rust toolchains
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
# To get Zig toolchains
zig-overlay = {
url = "github:mitchellh/zig-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ nixpkgs, ... }@inputs:
let
mkDarwin = import ./lib/mk-darwin.nix;
mkNixos = import ./lib/mk-nixos.nix;
supportedSystems = [
"aarch64-darwin"
"aarch64-linux"
];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
in
{
checks = forAllSystems (
system:
let
pkgs = import nixpkgs { inherit system; };
treefmtEval = inputs.treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
in
{
formatting = treefmtEval.config.build.check ./.;
deadnix = pkgs.runCommand "deadnix-check" { nativeBuildInputs = [ pkgs.deadnix ]; } ''
deadnix --fail ${./.}
touch $out
'';
statix = pkgs.runCommand "statix-check" { nativeBuildInputs = [ pkgs.statix ]; } ''
statix check ${./.} --config ${./statix.toml}
touch $out
'';
}
);
formatter = forAllSystems (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
treefmtEval = inputs.treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
in
treefmtEval.config.build.wrapper
);
# NixOS configuration entrypoint
# CLI: "nixos-rebuild --flake .#HOST"
nixosConfigurations = {
nixos-aarch64 = mkNixos "nixos-aarch64" {
inherit inputs;
system = "aarch64-linux";
};
};
# First time CLI: "nix --extra-experimental-features 'flakes nix-command' run nix-darwin -- switch --flake .#HOST"
# CLI: "darwin-rebuild switch --flake .#HOST"
darwinConfigurations = {
darwin-aarch64 = mkDarwin "darwin-aarch64" {
inherit inputs;
system = "aarch64-darwin";
};
};
};
}