-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
117 lines (106 loc) · 3.02 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
{
description = "Home Manager configuration of jga";
inputs = {
# Specify the source of Home Manager and Nixpkgs.
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
nixgl.url = "github:nix-community/nixGL";
};
outputs =
inputs@{
self,
nixpkgs,
home-manager,
nixgl,
...
}:
let
pkgs = import nixpkgs;
# Systems to build for
forAllSystems =
function:
nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
] (system: function nixpkgs.legacyPackages.${system});
# Packages for nix shell
generalPackages =
pkgs: with pkgs; [
nodejs
pre-commit
yamllint
gitleaks
nixfmt-rfc-style
];
# Home config generator
mkHomeConfig =
modules: system:
home-manager.lib.homeManagerConfiguration {
pkgs = import nixpkgs { inherit system; };
modules = modules; # Accepts a list of modules
extraSpecialArgs = {
inherit inputs system;
};
};
in
{
# NixOS configuration
nixosConfigurations.ku = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./nixos/configuration.nix
];
};
# General nix configurations
nix.gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 2w";
};
nix.settings.auto-optimise-store = true;
# Home configurations
homeConfigurations."pi@raspberrypi" = mkHomeConfig [
./pi.nix
./services.nix
./programs.nix
] "aarch64-linux";
homeConfigurations."fuzie@Fuzie-pc" = mkHomeConfig [
./wsl.nix
./services.nix
./programs.nix
] "x86_64-linux";
homeConfigurations."jga@yoga" = mkHomeConfig [
./yoga.nix
./services.nix
./programs.nix
] "x86_64-linux";
homeConfigurations."jga@ku" = mkHomeConfig [
./ucph.nix
./services.nix
./programs.nix
] "x86_64-linux";
# DevShell setup for this repo
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
# Specify the packages that are required
packages = (generalPackages pkgs);
# Use the `buildInputs` to include npm and other tools directly
buildInputs = with pkgs; [ pre-commit ];
# Define a `shellHook` that only sets the environment, not installs things
shellHook = ''
export PATH=./node_modules/.bin/:$PATH
export PS1="(dotfiles-shell 🫥) $PS1"
'';
# Use `postBuild` hook to run actions that need to happen after build
postBuild = ''
pre-commit install
pre-commit autoupdate -j $(nproc)
'';
};
});
};
}