-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
48 lines (41 loc) · 1.63 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
{
description = "dependency flake for my system configurations";
inputs = {};
outputs = inputs: {
darwinModules.default = { ... }: {
_module.args.sysDir = ./.;
imports = inputs.self.lib.importDir ./darwin;
};
homeModules.default = { lib, ... }: {
_module.args.sysDir = ./.;
imports = inputs.self.lib.importDir ./hm;
programs.home-manager.enable = true;
home.enableNixpkgsReleaseCheck = true;
};
nixosModules.default = { lib, ... }: {
_module.args.sysDir = ./.;
imports = inputs.self.lib.importDir ./nixos;
boot.loader.grub.configurationLimit = 30;
boot.loader.systemd-boot.configurationLimit = 30;
boot.tmp.cleanOnBoot = true;
environment.shellAliases = {
l = null;
ll = null;
ls = null;
};
systemd.network.wait-online.anyInterface = true;
users.mutableUsers = false;
};
lib = let
inherit (builtins) attrNames concatMap stringLength substring;
concatMapAttrsToList = f: attrs: concatMap (name: f name attrs.${name}) (attrNames attrs); # see lib.mapAttrsToList
hasPrefix = prefix: s: substring 0 (stringLength prefix) s == prefix; # from nixpkgs
hasSuffix = suffix: s: let
length = stringLength s;
suffixLength = stringLength suffix;
in length >= suffixLength && substring (length - suffixLength) length s == suffix; # from nixpkgs
in {
importDir = dir: concatMapAttrsToList (name: value: if (value == "regular" && hasSuffix ".nix" name) || (value == "directory" && !hasPrefix "." name) then [(dir + "/${name}")] else []) (builtins.readDir dir);
};
};
}