-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathflake.nix
More file actions
85 lines (71 loc) · 2.96 KB
/
Copy pathflake.nix
File metadata and controls
85 lines (71 loc) · 2.96 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
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; # nixpkgs-unstable";
inputs.homeManager.url = "github:nix-community/home-manager";
inputs.homeManager.inputs.nixpkgs.follows = "nixpkgs";
inputs.nixvim.url = "github:nix-community/nixvim";
inputs.nixvim.inputs.nixpkgs.follows = "nixpkgs";
inputs.localConfig.url = "path:./local-default";
inputs.git-hooks.url = "github:cachix/git-hooks.nix";
inputs.git-hooks.inputs.nixpkgs.follows = "nixpkgs";
#inputs.dwarffs.url = "github:edolstra/dwarffs";
#inputs.dwarffs.inputs.nixpkgs.follows = "nixpkgs";
#inputs.dwarffs.inputs.nix.inputs.nixpkgs.follows = "nixpkgs";
outputs = { self, homeManager, nixpkgs, localConfig, git-hooks, ... }@args:
let
lib = nixpkgs.lib;
# Auto-generate homeConfigurations from home/users/*.nix filenames.
# Files are named "user@machine.nix" and produce a "user@machine" entry.
# Additionally, "user@headless.nix" also produces a bare "user" entry
# (used as fallback when home-manager can't match user@hostname).
userFiles = builtins.readDir ./home/users;
homeEntries = lib.concatMapAttrs
(filename: _:
let
stem = lib.removeSuffix ".nix" filename;
parts = lib.splitString "@" stem;
user = builtins.elemAt parts 0;
machine = builtins.elemAt parts 1;
in
{ "${stem}" = import ./home args user machine; }
// lib.optionalAttrs (machine == "headless") { "${user}" = import ./home args user machine; }
)
userFiles;
in
{
overlays.default = lib.composeManyExtensions [
# New packages from pkgs/by-name/<shard>/<name>/package.nix (nixpkgs
# convention).
(final: prev:
let
byNameDir = ./pkgs/by-name;
shards = builtins.readDir byNameDir;
packagesFromShard = shard: _:
lib.mapAttrs'
(name: _: lib.nameValuePair name (final.callPackage (byNameDir + "/${shard}/${name}/package.nix") { }))
(builtins.readDir (byNameDir + "/${shard}"));
in
lib.concatMapAttrs packagesFromShard shards)
# Overrides of existing nixpkgs packages.
(import ./pkgs/overlays/default.nix)
];
packages.x86_64-linux = {
nix = nixpkgs.legacyPackages.x86_64-linux.nix;
};
nixosConfigurations =
lib.attrsets.mapAttrs
(machine: _: import ./nixos args machine)
(builtins.readDir ./nixos/machines)
;
homeConfigurations = homeEntries;
checks.x86_64-linux.pre-commit-check = git-hooks.lib.x86_64-linux.run {
src = self;
hooks = {
nixpkgs-fmt.enable = true;
};
};
devShells.x86_64-linux.default = nixpkgs.legacyPackages.x86_64-linux.mkShell {
inherit (self.checks.x86_64-linux.pre-commit-check) shellHook;
buildInputs = self.checks.x86_64-linux.pre-commit-check.enabledPackages;
};
};
}